TABLE OF CONTENTS
::pwtk::nebi::addImage
SYNOPSIS
proc ::pwtk::nebi::addImage {args} {
USAGE
::pwtk::nebi::addImage ?-before | -after? index imageData
PURPOSE
Add a new image to the POSITIONS card. If the first image is being added, the if-pos fields of the incoming first image will be used.
OPTIONS
- -before ... add a new image before the index-th image (this is default)
- -after ... add a new image after the index-th image
ARGUMENTS
- index --- the index of the reference image
- imageData -- image-data specs for the new image consisting of ATOMIC_POSITIONS and, optionally, TOTAL_CHARGE cards.
EXAMPLE
::pwtk::nebi::addImage -before 1 { ATOMIC_POSITIONS H 0.0 0.0 0.0 0 0 0 H 0.0 0.0 0.7 0 0 1 TOTAL_CHARGE 0.0 }
SOURCE
set narg 2 set usage "?-before | -after? index imageData" set options { {before "add image before the index-th image"} {after "add image after the index-th image"} } ::pwtk::parseOpt_ if { $opt(before) && $opt(after) } { ::pwtk::error "exclusive -before & -after options specified" 1 } if { $opt(before) + $opt(after) == 0 } { # -before is default set opt(before) 1 } lassign $args index imageData set nimage [::pwtk::nebi::getNImages] set index [::pwtk::parseIndex1 $index $nimage] # transform -after to -before if { $opt(after) } { set index [expr max(1,$index+1)] } # for -before, index must be within [1,nimage+1] set index [expr max(1,min($index,$nimage+1))] # store POSITIONS to data array ::pwtk::nebi::positions2data_ data # shift im to im+1 for {set im $nimage} {$im >= $index} {incr im -1} { set im1 [expr $im + 1] set data(unit,$im1) $data(unit,$im) if { [info exist data(charge,$im)] } { set data(charge,$im1) $data(charge,$im) } for {set ia 1} {$ia <= $data(nat)} {incr ia} { foreach e {sy x y z ix iy iz} { set data($e,$im1,$ia) $data($e,$im,$ia) } } } # insert image set nat [::pwtk::nebi::image2data_ $imageData image] if { $nimage } { if { $nat != $data(nat) } { ::pwtk::error "wrong number of atoms in imageData ($nat), but should be $data(nat)" 1 } } else { # only this image exist; set data(nat) set data(nat) $nat } set data(unit,$index) $image(unit) for {set ia 1} {$ia <= $data(nat)} {incr ia} { foreach e {sy x y z ix iy iz} { set data($e,$index,$ia) $image($e,$ia) } } if { [info exist image(charge)] } { set data(charge,$index) $image(charge) } incr data(nimages) # load new data into the POSITIONS card POSITIONS [::pwtk::nebi::data2positions_ data] }