TABLE OF CONTENTS


::pwtk::pwi::fixAtoms

SYNOPSIS

proc ::pwtk::pwi::fixAtoms {atomList {fixString "0 0 0"}} {

PURPOSE

Fix specified atoms by seting if_pos(:) flags to $fixString

ARGUMENTS

SOURCE

    set nat         0
    set fi          {}
    set oi          {}
    set atmPosList  [getAtmPos]
    set atomList    [lsort -integer -unique [::pwtk::parseRangeString $atomList [::pwtk::pwi::getNAtoms]]]

    # parse atmPosList

    if { [string match -nocase {*first_image*} [lindex $atmPosList 0]] } {
        
        # path calculation
        
        set fi [lindex $atmPosList 0]\n
        foreach line [lrange [split $atmPosList \n] 1 end] {
            if { [string match -nocase *intermediate_image* $line] || [string match -nocase *last_image* $line] } {
                set oi $line\n
            } elseif { $oi != {} } {
                append oi $line\n               
            } elseif { [llength $line] == 4 || [llength $line] == 7 } {     
                incr nat
                set atmPos($nat) $line
            }
        }
    } else {

        # normal calculation

        foreach line [split $atmPosList \n] {
            if { [llength $line] == 4 || [llength $line] == 7 } {     
                incr nat
                set atmPos($nat) $line
            }
        }
    }    

    # immobilize atoms
    
    foreach ind $atomList {
        if { $ind > 0 && $ind <= $nat} {
            set coor [lrange $atmPos($ind) 0 3]
            set atmPos($ind) [concat $coor $fixString]
        }
    }
    
    # build a new atmPos list

    if { $fi != {} } {
        set atmp $fi
    }
    
    for {set ia 1} {$ia <= $nat} {incr ia} {
        append atmp $atmPos($ia)\n
    }

    if { $oi != {} } {
        append $atmp $oi
    }

    # load $atmp into the ATOMIC_POSITIONS card

    ::pwtk::input::cardContent ATOMIC_POSITIONS $atmp
}