TABLE OF CONTENTS
::pwtk::ATOMIC_POSITIONS_math_parser
SYNOPSIS
proc ::pwtk::ATOMIC_POSITIONS_math_parser {content} {
PURPOSE
Specially supplied math-parser for ATOMIC_POSITIONS card to yield nicely formated output.
There can be 4 or 7 columns, but only coordinates (columns 2,3,4) are math-parsed.
RETURN VALUE
Nicely formated ATOMIC_POSITIONS card as, e.g.:
atom1 x1 y1 z1 if_pos1(x) if_pos1(y) if_pos1(z) atom2 x2 y2 z2 ...
If $content correspond to neb.x POSITIONS card, it returns, e.g.:
FIRST_IMAGE ATOMIC_POSITIONS (unit) atom1 x1 y1 z1 if_pos1(x) if_pos1(y) if_pos1(z) atom2 x2 y2 z2 ... ...
SOURCE
variable fmt_atmPos set charge 0 set parsedContent "" foreach line [split [::pwtk::skipEmptyLines $content] \n] { # check if we have path-calculation set word [lindex $line 0] switch -glob -- $word { "#" { # comment append parsedContent [string trim $line]\n } first_image* - intermediate_image* - last_image* { # atomic positions specified using the old pw.x format append parsedContent [string toupper ${line}]\n append parsedContent "ATOMIC_POSITIONS [::pwtk::input::cardGetFlags ATOMIC_POSITIONS]\n" } FIRST_IMAGE - INTERMEDIATE_IMAGE - LAST_IMAGE - ATOMIC_POSITIONS* { # atomic positions specified using the new neb.x format append parsedContent ${line}\n set charge 0 } TOTAL_CHARGE { # neb.x TOTAL_CHARGE card append parsedContent ${line}\n set charge 1 } default { set len [llength $line] if { ! $charge } { if { $len != 4 && $len != 7 } { ::pwtk::error "wrong number of fields, $len, in ATOMIC_POSITIONS card, must be 4 or 7, while reading ATOMIC_POSITIONS\n$content" 1 } lassign $line atmSymb x y z ifx ify ifz set x [::pwtk::mathParser $x] set y [::pwtk::mathParser $y] set z [::pwtk::mathParser $z] if { $len == 7 } { append parsedContent [format $fmt_atmPos(7) $atmSymb $x $y $z $ifx $ify $ifz] } else { append parsedContent [format $fmt_atmPos(4) $atmSymb $x $y $z] } } else { append parsedContent $line\n } } } } return $parsedContent }