TABLE OF CONTENTS


::pwtk::run_fromXSF

SYNOPSIS

proc ::pwtk::run_fromXSF {engine args} {

USAGE

   run_fromXSF engine [options] xsfFile

 more specifically:

   run_fromXSF engine ?-fix_first n?  ?-fix_last n?  ?-fix indexList?  ?-fix_string fixString?  \
                      ?-head headName?  ?-noalat?  ?-cell?  xsfFile

PURPOSE

Load the atomic positions and, if the -cell option is specified, also the cell parameters, from the XSF file and make a pw.x or cp.x calculation, depending on the 'engine' specs, i.e.:

OPTIONS

ARGUMENTS

RETURN VALUE

The name of the pw.x output file, i.e., type.head.out, where type is the value of the CONTROL's "calculation" variable (scf, relax, mv-relax...) and head is the rootname of either the xsf-file or the argument of the -head option.

SIDE EFFECTS

"prefix", "outdir_postfix", and "nat" are set to appropriate values.

SOURCE

    # check the engine argument
    engine_

    # parse options

    set narg 1
    set usage "engine ?-fix_first n?  ?-fix_last n?  ?-fix indexList?  ?-fix_string fixString?  ?-head headName?  ?-noalat?  ?-cell? xsfFile"
    set options {
        {fix_first.arg  {}  "fix the first Nfirst atoms, i.e., atoms from 1 to Nfirst"}
        {fix_last.arg   {}  "fix the last Nlast atoms, i.e., atoms from N-Nlast+1 to N"}
        {fix.arg        {}  "list of atoms to fix"}
        {fix_string.arg {0 0 0} "fix string"}
        {head.arg       {} "head-name for the pw.x|cp.x I/O files"}
        {noalat            "prevent using coordinates in alat units"}
        {cell              "load also CELL_PARAMETERS from the XSF file (default = only coordinates)"}
    }
    parseOpt_
    # N.B. do not check $opt(fix), it will be checked latter on by ::pwtk::parseRangeString
    #checkOType_ -fix_last  $opt(fix)       {numberlist posint}  "list of positive integer numbers"
    checkOType_ -fix_first $opt(fix_first) {number posint}      "positive integer"
    checkOType_ -fix_last  $opt(fix_last)  {number posint}      "positive integer"
    checkOType_ -fix_last  $opt(fix_string) {numberlist binary} "list of binary integers (0|1)"
    
    # load XSF file
    
    set xsfFile $args
    ::pwtk::fileMustExist $xsfFile XSF

    # head-name of I/O files
    
    set head [file tail [::pwtk::headname $xsfFile *xsf*]]
    if { $opt(head) != "" } {
        set head $opt(head)
    }

    # -alat || -noalat ?
    
    set optalat -alat
    if { $opt(noalat) } {
        set optalat -noalat
    }
    
    # load the structure from XSF file
        
    if { $opt(cell) } {
        ::pwtk::print [procName] "Loading CELL_PARAMETERS & ATOMIC_POSITIONS from XSF file: $xsfFile\n"
        ::pwtk::pwi::CELL_PARAMETERS_and_ATOMIC_POSITIONS_fromXSF $optalat $xsfFile
    } else {
        ::pwtk::print [procName] "Loading ATOMIC_POSITIONS from XSF file: $xsfFile\n"
        ::pwtk::pwi::ATOMIC_POSITIONS_fromXSF $optalat $xsfFile
    }

    # fix atoms
        
    if { $opt(fix_first) != {} } {
        ::pwtk::pwi::fixAtoms1st $opt(fix_first) $opt(fix_string)
    }
    if { $opt(fix_last) != {} } {
        ::pwtk::pwi::fixAtomsLast $opt(fix_last) $opt(fix_string)
    }
    if { $opt(fix) != {} } {
        ::pwtk::pwi::fixAtoms $opt(fix) $opt(fix_string)
    }

    # determine the rootname for I/O files
    
    set type [::pwtk::input::namelistGetVarValue CONTROL -nocase calculation trim]
    ::pwtk::ifset type scf        
    set prefix [regsub "^$type\." $head {}]; # scf.|relax.|vc-relax. stripped
    set head $type.$prefix

    # run the calculation

    outdir_postfix $prefix
    CONTROL " prefix = '$prefix' "    
    $runCmd $head
    
    return $head.out
}