TABLE OF CONTENTS
::pwtk::replaceAtom
SYNOPSIS
proc ::pwtk::replaceAtom {atomIndex atomSpecs atmPos} {
PURPOSE
Replace the atom with index "atomIndex" in "atmPos" with the new atom (i.e. atomic-symbol + coordinates) specified by "atomSpecs".
ARGUMENTS
- atomIndex -- index of atom to replace
- atomSpecs -- specs for new atom, i.e., atmSymbol x y z ?if_pos(x) if_pos(y) if_pos(z)?)
- atmPos -- atomic positions data
RETURN VALUE
new "atmPos" with the atom "atomIndex" replaced with new specs
SOURCE
set nat [getNAtoms $atmPos] if { $atomIndex < 1 || $atomIndex > $nat } { ::pwtk::error "atom index $atom out of range, should be within \[1, $nat\]" 1 } if { ! ([llength $atomSpecs] == 4 || [llength $atomSpecs] == 7) } { ::pwtk::error "wrong atom specs \"$atomSpecs\", must consist of 4 or 7 fields" 1 } set newAtmPos "" set nl "" set ind 1 foreach atom [split [purifyCoor $atmPos] \n] { if { $atomIndex == $ind } { set atom $atomSpecs } append newAtmPos ${nl}$atom set nl \n incr ind } return $newAtmPos }