TABLE OF CONTENTS


::pwtk::pwi::supercell

SYNOPSIS

proc ::pwtk::pwi::supercell {args} {

USAGE

   ::pwtk::pwi::supercell  ?-unit alat|angs|bohr?  ?-unitvec UNITVEC?  ?-kshift "S1 S2 S3"?  supercell  ?unitKmesh?

PURPOSE

Generate CELL_PARAMETERS and, if requested, K_POINTS for a generic supercell.

OPTIONS

ARGUMENTS

SOURCE

    set nargmin 1
    set nargmax 2
    set usage "?-unit alat|angs|bohr?  ?-unitvec unitvec?  supercell  ?unitKmesh?"
    set options {
        {unit.arg     bohr  "alat of the 2D (1x1) unit cell"}
        {unitvec.arg  {}    "unitcell Bravais lattice vectors"}
        {kshift.arg   {}    "a list of k-mesh offsets"}
    }
    ::pwtk::parseOpt_    
    ::pwtk::checkOType_ -kshift $opt(kshift) {numberlist binary} "list of binary numbers"

    lassign $args supercell unitKmesh

    set path_ [namespace path]
    namespace path ::math::linearalgebra
    supercellCommonOpts_

    # generate supercell & k-mesh

    if { $unitKmesh eq {} } {
        set supervec [::pwtk::supercell3D $unitvec $supercell]
    } else {
        lassign [::pwtk::supercell3D $unitvec $supercell $unitKmesh] supervec kp
    }
    set kmesh [list {*}$kp {*}$opt(kshift)]
    
    # rescale the supercell vectors so that norm(v1) = 1.0
    lassign $supervec v1
    set alat [norm $v1]
    set supervec [scale [expr 1.0/$alat] $supervec]
    lassign $supervec v1 v2 v3

    set nb [norm $v2]
    set nc [norm $v3]

    # set the pw.x input
    
    SYSTEM "ibrav = 0, celldm(1) = $alat, A = "
    CELL_PARAMETERS (alat) [::pwtk::m2cell $supervec]
    if { $unitKmesh != {} } {
        K_POINTS (automatic) $kmesh
    }

    # print the basic info to stdout

    set sv [::pwtk::matricize $supercell]
    set area [expr abs([det $sv])]
    
    ::pwtk::print ++++ "Auto-generation of the supercell..."
    if { $unitKmesh ne {} } {
        ::pwtk::print "\nUnitcell k-mesh:  [::pwtk::Kmeshize $unitKmesh 3]"
    }
    ::pwtk::print "
Unitcell lattice vectors (in Bohr):

[show $unitvec  %15.10f]
Supercell expansion matrix:  
                             
[show $sv %3.0f]
Supercell:
   alat = [format %10.6f $alat] Bohr = [format %10.6f [expr $alat/$unitalat]] unitcell-alat
   
   Size of vector A  = [format %8.4f 1.0] alat
   Size of vector B  = [format %8.4f $nb] alat
   Size of vector C  = [format %8.4f $nc] alat
   
   Area of supercell = [format %8.4f $area] of the unitcell area
"    
    if { $unitKmesh != {} } {
        ::pwtk::print "The following cell parameters and k-points cards were generated:\n"    
        ::pwtk::input::cardPrint CELL_PARAMETERS
        ::pwtk::input::cardPrint K_POINTS
    } else {
        ::pwtk::print "The following cell parameters were generated:\n"    
        ::pwtk::input::cardPrint CELL_PARAMETERS
    }

    namespace path $path_
}