TABLE OF CONTENTS


::pwtk::pwi::CELL_PARAMETERS_fromPWO

SYNOPSIS

proc ::pwtk::pwi::CELL_PARAMETERS_fromPWO {pwoFile {index end}} {

PURPOSE

Load new CELL_PARAMETERS cards from pw.x output file. CELL_PARAMETERS are loaded only if the record is present in the pw.x output file.

ARGUMENTS

SIDE EFFECTS

The ibrav is set to 0 if CELL_PARAMETERS are found in $pwoFile and loaded into PWTK.

SOURCE

    set vec [::pwtk::pwo::getPrimVec -k $pwoFile $index]
    
    if { $vec != "" } {
        set ibrav [::pwtk::pwi::ibrav]
        if { $ibrav != 0 } {
            ::pwtk::infoMsg "setting ibrav = 0, while loading CELL_PARAMETERS from PWO file: $pwoFile"
            SYSTEM " ibrav = 0 "
        }

        if { [string match {*alat=*} $vec] } {
            # we have: CELL_PARAMETERS (alat= 21.08089896)
            #          ...

            set old_vec   $vec
            set cell_line [lindex [split $vec \n] 0]
            set alat      [lindex [split $cell_line =\)] 1]
            
            # now we need to rescale cell_parameters wrt iron and new alat
            set iron_alat [::pwtk::pwi::alat]
            
            if { $iron_alat == 0.0 } {
                # problems ...
                ::pwtk::warning "from ::pwtk::pwi::CELL_PARAMETERS_fromPWO:
CELL_PARAMETERS are specified in alat units in $pwoFile, 
but alat is currently not set. This is a recipe for troubles.
Using the alat from CELL_PARAMETERS of $pwoFile"

                ::pwtk::infoMsg "setting celldm(1) = $alat"
                SYSTEM " celldm(1) = $alat "
                set iron_alat $alat
            }
            set vec [::pwtk::scaleVec $alat/$iron_alat [::pwtk::purifyVec $vec]]

            CELL_PARAMETERS (alat) $vec
            
            ::pwtk::infoMsg "from ::pwtk::pwi::CELL_PARAMETERS_fromPWO:
\"$cell_line\" line found in $pwoFile pw.x output;\n
rescaling cell vectors from PWO by a factor $alat/$iron_alat\n
* extracted cell vectors:\n
$old_vec\n
* rescaled cell vectors:\n
CELL_PARAMETERS (alat) 
[::pwtk::pwi::CELL_PARAMETERS_math_parser $vec]"

        } else {
            CELL_PARAMETERS [lindex $vec 1] [::pwtk::purifyVec $vec]
        }
    }
}