TABLE OF CONTENTS


::pwtk::pwi::fixAtoms

SYNOPSIS

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

PURPOSE

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

ARGUMENTS

SOURCE

    set atmPosList [getAtmPos]
    if { $atmPosList eq {} } {
        # no atoms
        ::pwtk::error "atomic structure is empty: cannot fix atoms [join $atomList {, }]" 1
    }

    # check that indices are in range
    
    set natoms [::pwtk::pwi::getNAtoms]
    set atomList [lsort -integer -unique [::pwtk::parseRangeString $atomList $natoms]]
    foreach index $atomList { ::pwtk::int_in_range1_ $index $natoms }
    
    # parse atmPosList

    set nat     0
    set fi      {}
    set oi      {}
    
    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

    set atmp {}
    
    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
}