TABLE OF CONTENTS


::pwtk::nebi::path2xsf

SYNOPSIS

proc ::pwtk::nebi::path2xsf {pathFile} {

PURPOSE

Transform "pathFile" into the XSF formatted data.

BEWARE

In the path-to-xsf conversion, the current neb.x input data are used for the Bravais lattice vectors and atomic symbols (hence 'pathFile' should be compatible with the current neb.x input data). For this reason, the command is implemented within the ::pwtk::nebi namespace.

ARGUMENTS

RETURN VALUE

The XSF formatted data corresponding to pathFile.

SOURCE

    set primVecs [::pwtk::pwi::getPrimVec angstrom]
    set nat      [::pwtk::input::namelistGetVarValue SYSTEM nat]
    set path_nat [::pwtk::path::getNAtoms $pathFile]

    if { $nat != $path_nat } {
        ::pwtk::error "cannot transform the neb.x '$pathFile path file into AXSF
because the current number of atoms ($nat) differ from the number of
atoms in the path file ($path_nat)" 1
    }
    
    foreach atm [::pwtk::nebi::getAtmSymbList] {
        set symb([incr ia]) $atm
    }

    #
    # convert the PATH file to the XSF file
    #
    set pd [open $pathFile r]
    
    while { ! [eof $pd] } {

        gets $pd line

        if { [regexp {NUMBER OF IMAGES} $line] } {

            gets $pd line
            set nimages [lindex $line 0]
        
            append result "ANIMSTEPS $nimages\n"
            append result "CRYSTAL\n"
            append result "PRIMVEC\n"
            append result $primVecs\n

        } elseif { [regexp {ENERGIES, POSITIONS AND GRADIENTS} $line] } {
            
            for {set ii 1} {$ii <= $nimages} {incr ii} {
                gets $pd line; # Image string
                gets $pd line; # energy

                append result "PRIMCOORD $ii\n"
                append result "$nat\n"

                for {set ia 1} {$ia <= $nat} {incr ia} {
                    gets $pd line

                    set x [expr {[lindex $line 0] * $::pwtk::bohr2angs}]
                    set y [expr {[lindex $line 1] * $::pwtk::bohr2angs}]
                    set z [expr {[lindex $line 2] * $::pwtk::bohr2angs}]
                    # make forces compatible with the neb.x AXSF files
                    set fx [expr {[lindex $line 3] / $::pwtk::bohr2angs}]
                    set fy [expr {[lindex $line 4] / $::pwtk::bohr2angs}]
                    set fz [expr {[lindex $line 5] / $::pwtk::bohr2angs}]
                    
                    append result [format $::pwtk::fmt_coor(7) $symb($ia) $x $y $z $fx $fy $fz]
                }
            }            
            # we are done
            close $pd
            return $result
        }
    }
    close $pd
    return ""
}