TABLE OF CONTENTS


::pwtk::nebi::fixAtoms

SYNOPSIS

proc ::pwtk::nebi::fixAtoms {atomList {fixString "0 0 0"}} {

PURPOSE

Fix the specified atoms in the neb.x POSITIONS card by setting if_pos(:) flags to 'fixString'.

N.B.: according to neb.x syntax, only THE FIRST_IMAGE atoms are fixed

ARGUMENTS

SOURCE

    set unit       [::pwtk::nebi::getImageUnit 1]    
    set im1_atmPos [::pwtk::nebi::getImageAtmPos -if_pos 1]
    if { $im1_atmPos eq {} } {
        ::pwtk::error "POSITIONS card is empty: cannot fix atoms [join $atomList ,]" 1
    }

    # check that indices are in range

    set natoms [::pwtk::nebi::getNAtoms]
    set atomList [lsort -integer -unique [::pwtk::parseRangeString $atomList $natoms]]
    foreach index $atomList { ::pwtk::int_in_range1_ $index $natoms }
    
    # parse im1_atmPos
    
    set nat 0
    foreach line [split $im1_atmPos \n] {
        if { [llength $line] == 4 || [llength $line] == 7 } {     
            incr nat
            set atmPos($nat) $line
        }
    }

    # immobilize atoms
    
    foreach ind $atomList {
        if { $ind > 0 && $ind <= $nat} {
            set coor [lrange $atmPos($ind) 0 3]
            set atmPos($ind) [concat $coor $fixString]
        }
    }
    
    # build new atmPos

    set atmp {}
    for {set ia 1} {$ia <= $nat} {incr ia} {
        append atmp $atmPos($ia)\n
    }

    # load $atmp into the FIRST_IMAGE's ATOMIC_POSITIONS 

    ::pwtk::nebi::replaceImage 1 "ATOMIC_POSITIONS $unit\n$atmp"
}