TABLE OF CONTENTS


::pwtk::pwi::deleteAtoms

SYNOPSIS

proc ::pwtk::pwi::deleteAtoms {deleteList} {

PURPOSE

Delete requested atoms from ATOMIC_POSITIONS card.

ARGUMENTS

SOURCE

    set natoms [::pwtk::pwi::getNAtoms]

    set sortedList [lsort -integer -decreasing [::pwtk::parseRangeString $deleteList $natoms]]
    set atmPosList [split [::pwtk::purifyCoor [::pwtk::input::cardGetContent ATOMIC_POSITIONS]] \n]
    if { $atmPosList eq {} && $deleteList ne {} } {
        ::pwtk::error "atomic structure is empty: cannot delete atoms [join $sortedList {, }]" 1
    }
    
    # check that indices are in range

    foreach index $sortedList { ::pwtk::int_in_range1_ $index $natoms }

    # delete atoms
    
    foreach del $sortedList {
        set d2 [expr {$del - 2}]
        set atmPosList "[lrange $atmPosList 0 $d2] [lrange $atmPosList $del end]"
    }

    ::pwtk::input::cardContent ATOMIC_POSITIONS [::pwtk::purifyCoor [join $atmPosList \n]]
    ::pwtk::pwi::setNAtoms
}