TABLE OF CONTENTS


::pwtk::nebi::POSITIONS_fromPATH

SYNOPSIS

proc ::pwtk::nebi::POSITIONS_fromPATH {pathFile} {

PURPOSE

Load POSITIONS from neb.x PATH file.

SOURCE

    ::pwtk::fileMustExist $pathFile "neb.x path file"

    set pathL [split [::pwtk::readFile $pathFile] \n]
    # trim the empty elements at the end
    while { [lindex $pathL end] eq "" } {
        set pathL [lrange $pathL 0 end-1]
    }
    set ims   [lsearch -all $pathL Image:*]
    set nImage [llength $ims]

    for {set i 1} {$i <= $nImage} {incr i} {
        set i1($i) [expr [lindex $ims $i-1] + 2]
        set i2($i) [expr [lindex $ims $i] - 1]
    }
    # the above fails for i2($nImage), hence recalculate it:
    set ii [expr $nImage - 1]
    set i2($nImage) [expr $i1($nImage) + $i2($ii) - $i1($ii)]

    set natp [expr $i2(1) - $i1(1) + 1]
    set nati [::pwtk::nebi::getNAtoms]

    if { $natp != $nati } {
        ::pwtk::error "the number of input atoms ($nati) differ from the number of atoms in the path file ($natp);
cannot assign atomic symbols to atomic positions from the '$pathFile' path file" 1
    }
    
    set symbols [::pwtk::nebi::getAtmSymbList]    

    # 1st image
    
    set image   [join [lmap s $symbols xyz [lrange $pathL $i1(1) $i2(1)] {
        format $::pwtk::fmt_atmPos(7) {*}[concat $s [lrange $xyz 0 2] [lrange $xyz 6 8]]
    }] \n]     
    set positions "
FIRST_IMAGE
ATOMIC_POSITIONS (bohr)
$image
"
    # intermediate images
    
    for {set i 2} {$i < $nImage} {incr i} {
        set image [join [lmap s $symbols xyz [lrange $pathL $i1($i) $i2($i)] {            
            format $::pwtk::fmt_atmPos(4) {*}[concat $s [lrange $xyz 0 2]]
        }] \n]     
        append positions "
INTERMEDIATE_IMAGE
ATOMIC_POSITIONS (bohr)
$image
"
    }
    
    # last image
    
    set image [join [lmap s $symbols xyz [lrange $pathL $i1($nImage) $i2($nImage)] {
        format $::pwtk::fmt_atmPos(4) {*}[concat $s [lrange $xyz 0 2]]
    }] \n]     
    append positions "
LAST_IMAGE
ATOMIC_POSITIONS (bohr)
$image
"
    # input positions
    
    POSITIONS $positions
}