TABLE OF CONTENTS


::pwtk::nebi::setImage

SYNOPSIS

proc ::pwtk::nebi::setImage {index atmPos} {

PURPOSE

Set the atomic positions for the requested image, i.e., insert the corresponding ATOMIC_POSITIONS in the neb.x input.

BEWARE that setImage is not related to num_of_images variable, but to BEGIN_POSITIONS / END_POSITIONS specs.

Note that if index != 1 then "atmPos" will be tranformed to "coor" (the difference is that "atmPos" may contain the if_pos(:) field but "coor" does not).

ARGUMENTS

SOURCE

    set atmPos  [::pwtk::purifyCoor $atmPos]    
    set nimages [getNImages]

    switch -nocase -- $index {
        first - begin - 1st { set index 1 }
        last - end { set index $nimages }
    }
    if { $index < 1 || $index > $nimages } {
        ::pwtk::error "image index $index is out of range, should be within \[1, $nimages\]" 1
    }
    if { $index != 1 } {
        set atmPos [::pwtk::atmPosToCoor $atmPos]
    }

    set nimages 0
    set positions {}
    set skip    0

    foreach line [split [::pwtk::input::cardGetContent POSITIONS] \n] {        
        if { [regexp {IMAGE} $line] } {
            set skip 0
        }
        if { [regexp {ATOMIC_POSITIONS} $line] } {
            incr nimages
            if { $nimages == $index } {
                append positions $line\n$atmPos\n
                set skip 1
                continue
            } else {
                set skip 0
            }
        }
        if { ! $skip } {
            append positions $line\n
        }
    }

    POSITIONS $positions

    return $positions
}