TABLE OF CONTENTS


::pwtk::neb_refine_exe_

SYNOPSIS

proc ::pwtk::neb_refine_exe_ {} {

    # mandatory variables: firstImage lastImage new_prefix num_of_images
    
    uplevel 1 {
        # previous-NEB: E*(->) and E*(<-) in eV
    
        set Eact_fwd [expr $::pwtk::ha2ev*($E($iTS) - $E(1))]
        set Eact_bck [expr $::pwtk::ha2ev*($E($iTS) - $E($nImages))]

        ifset nebi -
        print "Data from the previous neb.x calculation:

  previous-NEB input file:  $nebi
  previous-NEB path file :  $pathFile
  previous-NEB crd file  :  $crdFile

image        energy (eV)
"
        for {set i 1} {$i <= $nImages} {incr i} {
            print [format "%5i    %15.6f" $i [expr $::pwtk::ha2ev*$E($i)]]
        }
        print "
climbing image = $iTS

previous-NEB activation energy (->) = [format %7.3f $Eact_fwd] eV
previous-NEB activation energy (<-) = [format %7.3f $Eact_bck] eV

Data for the refinement neb.x calculation:

  index of the previous-NEB TS image:  $iTS
  image range of the previous-NEB MEP that will be refined:  \[$firstImage, $lastImage]
  number of images for the new neb.x:  $num_of_images"        
        ifnotempty opt(CI_scheme) { print "  CI_scheme for the new neb.x:         $opt(CI_scheme)" }
        ifnotempty opt(CI_thr)    { print "  path_thr  for the new neb.x:         $opt(CI_thr)" }        
        puts ""
        
        # check image indices
        if { ! [::pwtk::type::number posint -strict $firstImage] } { ::pwtk::error "expected positive integer for 'firstImage', but got $firstImage" 1 }
        if { ! [::pwtk::type::number posint -strict $lastImage] } { ::pwtk::error "expected positive integer for 'lastImage', but got $lastImage" 1 }
        if { ! [::pwtk::type::number posint -strict $num_of_images] } { ::pwtk::error "expected positive integer for 'num_of_images', but got $num_of_images" 1 }        
        if { ($lastImage < 2 || $lastImage > $nImages) } { ::pwtk "wrong index for the last image ($lastImage)" 1 }
        if { ($lastImage - $firstImage < 1) || ($firstImage < 1) } { ::pwtk::error "wrong index for the first image (firstImage=$firstImage, lastImage=$lastImage)" 1 }
        if { $num_of_images - ($lastImage - $firstImage) < 1 } { :
            :pwtk::error "specified 'num_of_images = $num_of_images' is too small, must be > [expr $lastImage - $firstImage]" 1
        }

        #
        # get positions of images
        #

        # first l treatment because it has if_pos(:) records
        
        set positions "
FIRST_IMAGE
[::pwtk::nebi::getImageAtmPos -k -if_pos $firstImage]
[::pwtk::nebi::getImageCharge -k $firstImage]
"

        # intermediate images

        for {set i [expr $firstImage+1]} {$i<$lastImage} {incr i} {
            append positions "
INTERMEDIATE_IMAGE    
[::pwtk::nebi::getImage $i]
"
        }

        # last image
        
        append positions "
LAST_IMAGE
[::pwtk::nebi::getImage $lastImage]
"

        # load positions
    
        POSITIONS $positions

        # adapt the input variables

        outdir_prefix [outdir]
        outdir_postfix $new_prefix
    
        PATH [subst {
            num_of_images = $num_of_images
            first_last_opt = .false.
        }]
        if { $opt(CI_thr) ne {} } {
            PATH " path_thr = $opt(CI_thr) "
        }
        CONTROL " prefix = '$new_prefix' "

        if { $opt(CI_scheme) ne {} } {
            PATH " CI_scheme = [squote $opt(CI_scheme)] "
        }

        print "NEB input for the new neb.x:\n\n[::pwtk::input::namelistGet PATH]"
        
        if { $opt(CI) ne {} } {
            CLIMBING_IMAGES $opt(CI)
            print [::pwtk::input::namelistPrint CLIMBING_IMAGES]
        }

        

        
        # run the neb.x calculation

        set CI_scheme [::pwtk::input::namelistGetVarValue PATH CI_scheme trim]
        ifset CI_scheme no-CI
        runNEB neb.$new_prefix.$CI_scheme

        neb_plot $new_prefix

        # final printout of energies
        
        array set new [::pwtk::path::energies $new_prefix.path]
        set newE(TS) $new(Emax)
         # BEWARE: energies in the path file are in Hartrees
        set Eact_fwd [expr $::pwtk::ha2ev*($newE(TS) - $E(1))]
        set Eact_bck [expr $::pwtk::ha2ev*($newE(TS) - $E($nImages))]
        
        print "Data from the new refined neb.x calculation:

  new neb.x input  file:  neb.$new_prefix.$CI_scheme.in
  new neb.x output file:  neb.$new_prefix.$CI_scheme.out

image        energy (eV)
"
        for {set i 1} {$i <= $num_of_images} {incr i} {
            set key E($i)
            print [format "%5i    %15.6f" $i [expr $::pwtk::ha2ev*$new($key)]]
        }
        print "
climbing image = $new(iTS)

  previous_E(IS) = [format %7.3f [expr $::pwtk::ha2ev*$E(1)]] eV
  new_E(TS)      = [format %7.3f [expr $::pwtk::ha2ev*$new(Emax)]] eV
  previous_E(FS) = [format %7.3f [expr $::pwtk::ha2ev*$E($nImages)]] eV

new activation energy (->) = new_E(TS) - previous_E(IS) = [format %7.3f $Eact_fwd] eV
new activation energy (<-) = new_E(TS) - previous_E(FS) = [format %7.3f $Eact_bck] eV

merging previous and new NEB files...
"
        # merge src & new NEB dat, int, crd, and axsf files
        
        foreach {type name} [::pwtk::neb_refine_merge $src_prefix $new_prefix $firstImage $lastImage] {
            ::pwtk::print "  merged [format %-4s [string toupper $type]] file written to:  $name"
        }
        puts ""
        
        return neb.$new_prefix.$CI_scheme.out
    }
}