TABLE OF CONTENTS


::pwtk::pwi::displaceAtoms

SYNOPSIS

proc ::pwtk::pwi::displaceAtoms {dispVec {whichAtoms all}} {

PURPOSE

Displace atoms in ATOMIC_POSITIONS card.

ARGUMENTS

RETURN VALUE

The new content of the ATOMIC_POSITIONS card.

SOURCE

    # dispVec may be specified as math expression
    set dispVec [::pwtk::vecMathParser $dispVec]
    
    if { [llength $dispVec] != 3 || ![::pwtk::type::numberlist real $dispVec] } {
        ::pwtk::error "expected a 3D numeric vector, but got: $dispVec" 1
    }

    set whichAtoms [lsort -integer [::pwtk::parseRangeString $whichAtoms [getNAtoms]]]
    set atmPosList [split [::pwtk::purifyCoor [::pwtk::input::cardGetContent ATOMIC_POSITIONS]] \n]
    set result ""
    foreach atom $atmPosList {
        incr iat
        set atm [lindex $atom 0]
        set pos [lrange $atom 1 3]
        set ifv [lrange $atom 4 6]
        if { $iat in $whichAtoms } {
            set pos [::math::linearalgebra::add [::pwtk::vecMathParser $pos] $dispVec]
        }
        if { $ifv eq {} } {
            append result [format $::pwtk::fmt_atmPos(4) $atm {*}$pos]
        } else {
            append result [format $::pwtk::fmt_atmPos(7) $atm {*}$pos {*}$ifv]
        }
    }
    return [::pwtk::input::cardContent ATOMIC_POSITIONS $result]
}