TABLE OF CONTENTS


::pwtk::nebi::getPositions

SYNOPSIS

proc ::pwtk::nebi::getPositions {{index ""} {positions_only 0}} {

PURPOSE

Get POSITIONS from the neb.x input data, i.e.:

      FIRST_IMAGE
        ATOMIC_POSITIONS
        AtmSy1  x1 y1 z1  [if_pos(1) if_pos(2) if_pos(3)]
        AtmSy2  x2 y2 z2  [if_pos(1) if_pos(2) if_pos(3)]
        ...
      INTERMEDIATE_IMAGE
        ...
      LAST_IMAGE
        ...

If index is specified, then only atomic-positions of the index-th image are returned.

ARGUMENTS

SOURCE

    set pos  [::pwtk::skipEmptyLines [::pwtk::input::cardGetContent POSITIONS]]
    set posL [split $pos \n]
    
    if { $index != "" } {
        set indices [lsearch -all -glob $posL *IMAGE]
        set nimages [llength $indices]
        set index   [image_in_range_ $index $nimages]    
       
        set ind [lindex $indices $index-1]
        if { $index == $nimages } {
            set pos [join [lrange $posL $ind+1 end] \n]
        } else {
            set ind1 [lindex $indices $index]
            set pos [join [lrange $posL $ind+1 $ind1-1] \n]
        }
    }

    if { ! [string is boolean $positions_only] } {
        ::pwtk::warning "expected a boolean 'positions_only' argument, but got $positions_only"
        set positions_only 0
    }
    if { $positions_only } {
        set aux $pos
        set pos {}
        foreach line [split $aux \n] {
            if { [string match *CHARGE* $line] } {
                break
            } else {
                append pos $line\n
            }
        }
    }
    return $pos
}