TABLE OF CONTENTS
::pwtk::nebi::getImageAtmPos
SYNOPSIS
proc ::pwtk::nebi::getImageAtmPos {args} {
USAGE
::pwtk::nebi::getImageAtmPos [-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.
REMARK
::pwtk::nebi::getImageAtmPos is not related to the "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 getImageAtmPos 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::getImageAtmPos \[-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] if { $nimages == 0 } { # no image specified ::pwtk::error "cannot get any image AtmPos because POSITIONS/ATOMIC_POSITIONS card is undefined" 1 } set index [image_in_range_ $index $nimages] set iimage 0 set record 0 set image {} foreach line [split [::pwtk::input::cardGetContent POSITIONS] \n] { if { [regexp {IMAGE|CHARGE} $line] } { if { [regexp IMAGE $line] } { incr iimage } set record 0 continue } if { [regexp {ATOMIC_POSITIONS} $line] } { if { $iimage == $index } { set record 1 if { $opt(k) } { append image $line\n } continue } } if { $record } { append image $line\n } } if { $opt(if_pos) && $index != 1 } { # 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::getImageAtmPos first]] } return $image }