TABLE OF CONTENTS


::pwtk::coorToAtmPos

SYNOPSIS

proc ::pwtk::coorToAtmPos {coor refAtmPos} {

PURPOSE

Tranform "coor" to "atmPos" according to the reference atmPos, where "coor" are:

       AtmSymb1 x1 y1 z1
       AtmSymb2 x2 y2 z2
       ...

and "atmPos" are:

       AtmSymb1 x1 y1 z1 [if_pos1(1) if_pos1(2) if_pos1(3)]
       AtmSymb2 x2 y2 z2 [if_pos2(1) if_pos2(2) if_pos2(3)]
       ...    

Note that coor can be prepended with the "ATOMIC_POSITIONS (unit)" line and in this case also the resulting "atmPos" will be prepended with the "ATOMIC_POSITIONS (unit)" line

ARGUMENTS

SOURCE

    # parse refAtmPos and store the if_pos records
    
    set N 0
    foreach line [split [::pwtk::purifyCoor $refAtmPos] \n] {
        incr N
        set if_pos($N,1) [lindex $line 4]
        set if_pos($N,2) [lindex $line 5]
        set if_pos($N,3) [lindex $line 6]        
    }

    # parse coor and supplement it with the if_pos fields
    
    set atmPos ""
    set nl ""
    set i 0
    
    foreach line [split $coor \n] {
        if { [regexp ATOMIC_POSITIONS $line] } {
            append atmPos $line
            set nl \n
            continue
        }
        set nf [llength $line]
        if { $nf == 4 || $nf == 7 } {
            incr i
            set ifp {}
            if { $i <= $N } {
                set ifp [concat $if_pos($i,1) $if_pos($i,2) $if_pos($i,3)]
            }            
            append atmPos "${nl}$line   $ifp"
            set nl \n
        }
    }
    return $atmPos
}