TABLE OF CONTENTS


::pwtk::nebi::addImageCoor_fromXSF

SYNOPSIS

proc ::pwtk::nebi::addImageCoor_fromXSF {args} {

USAGE

   ::pwtk::nebi::addImageCoor_fromXSF ?-before | -after? imageIndex xsfFile ?xsfIndex?

PURPOSE

Add a new image's atomic Coor (aka ATOMIC_POSITIONS) from the XSF file to the POSITIONS card.

OPTIONS

ARGUMENTS

EXAMPLE

   ::pwtk::nebi::addImageCoor_fromXSF -before 1 file.xsf

SOURCE

    set argum   $args
    set nargmin 2
    set nargmax 3
    set usage   "?-before | -after? imageIndex xsfFile ?xsfIndex?"
    set options {
        {before "add image before the index-th image"}
        {after  "add image after the index-th image"}
    }
    ::pwtk::parseOpt_
    lassign $args imageIndex xsfFile xsfIndex

    ::pwtk::fileMustExist $xsfFile xsfFile
    ::pwtk::ifset xsfIndex 1

    set xsfIndex [image_in_range_ $xsfIndex [::pwtk::xsf::getAnimsteps $xsfFile]]

    # if "nat" in the SYSTEM namelist is undefined, define it
    if { [::pwtk::input::namelistGetVarValue SYSTEM nat]  == "" } {
        SYSTEM " nat = [::pwtk::xsf::getNAtoms $xsfFile] "
    }
    set unit [::pwtk::xsf::getPrimCoorUnit $xsfFile]
    set coor [::pwtk::atmPosToCoor [::pwtk::purifyCoor [::pwtk::xsf::getPrimCoor $xsfFile $xsfIndex]]]
    if { $coor eq "" } {
        pwtk::error "no coordinates found in the XSF file: $xsfFile" 1
    }
    set imageData "ATOMIC_POSITIONS $unit\n$coor"
    if { [llength $args] == 2 } {
        addImage {*}[lrange $argum 0 end-1] $imageData
    } else {
        addImage {*}[lrange $argum 0 end-2] $imageData
    }
}