TABLE OF CONTENTS
::pwtk::nebi::getImage
SYNOPSIS
proc ::pwtk::nebi::getImage {args} {
USAGE
::pwtk::nebi::getImage [-k -if_pos] index
OPTIONS
-k ... prepend the coordinates with the "ATOMIC_POSITIONS (unit)" line -if_pos ... add "if_pos(1) if_pos(2) if_pos(3)" fields of the 1st image to the coordinates
PURPOSE
Return the atomic positions of the requested explicitly specified image with ATOMIC_POSITIONS in the neb.x input.
BEWARE that genImage is not related to num_of_images variable!
ARGUMENTS
- index -- index of image to return (index can be also "first" and "last"; the 1st image has index of 1)
RETURN VALUE
If -k option is specified then it returns atomic positions with the keyword line:
ATOMIC_POSITIONS (unit) AtmPos1 x1 y1 z1 [if_pos(1) if_pos(2) if_pos(3)] AtmPos2 x2 y2 z2 [if_pos(1) if_pos(2) if_pos(3)] AtmPos3 x3 y3 z3 [if_pos(1) if_pos(2) if_pos(3)] ....
otherwise it returns:
AtmPos1 x1 y1 z1 [if_pos(1) if_pos(2) if_pos(3)] AtmPos2 x2 y2 z2 [if_pos(1) if_pos(2) if_pos(3)] AtmPos3 x3 y3 z3 [if_pos(1) if_pos(2) if_pos(3)] ....
SOURCE
set options { {k "include the ATOMIC_POSITIONS keyword line in the result"} {if_pos "supplement image atomic coordinates with the if_pos(:) fields from the 1st image"} } set usage ": ::pwtk::nebi::getImage \[-k] index" array set opt [::cmdline::getoptions args $options $usage] if { [llength $args] != 1 } { ::pwtk::error "Usage $usage" 1 } set index [lindex $args 0] 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 } set nimages 0 set record 0 set image {} foreach line [split [::pwtk::input::cardGetContent POSITIONS] \n] { if { [regexp {IMAGE} $line] } { set record 0 continue } if { [regexp {ATOMIC_POSITIONS} $line] } { incr nimages if { $nimages == $index } { set record 1 if { $opt(k) } { append image $line\n } continue } } if { $record } { append image $line\n } } if { $opt(if_pos) } { # we need the reference atomic-positions of the 1st image to supplement the if_pos(:) fields to the atomic-coordinates set image [::pwtk::coorToAtmPos $image [::pwtk::nebi::getImage first]] } return $image }