proc ::pwtk::flo::run {head {ion_dynamics bfgs}} {


Perform the FLO (first_last_opt) type PATH calculations, which consists of the following:

     1. pw.x relax calculation to optimize the 1st image
     2. pw.x relax calculation to optimize the last image
     3. neb.x path calculation with optimized 1st and last image

See also ::pwtk::flo for more information on FLO.



    printTitle_ "Performing the FLO-type calculation."

    set restart_mode [::pwtk::input::namelistGetVarValue PATH restart_mode trim]
    set name         [regsub {^neb.} $head {}]

    # do some checks ...

    if { ${restart_mode} == "restart" } {
        ::pwtk::error "PATH { restart_mode = 'restart' } is not supported by FLO" 1
    # first create the input files (look into ::pwtk::flo::input_files proc for the input file names)

    ::pwtk::input::pushpop {        

        ::pwtk::pwi::loadDefaults_ CONTROL        
        set outdir [::pwtk::outdir_query -hard]
        set ion_dynamics [string trim $ion_dynamics '\"]

        # optimize the first image

        CONTROL " calculation  = 'relax'  
                  restart_mode = 'from_scratch' 
                  outdir       = '[file join $outdir first_image]' "
        IONS    " ion_dynamics = '$ion_dynamics' "
        ATOMIC_POSITIONS [::pwtk::nebi::getImageUnit first] [::pwtk::nebi::getImage first]
        print_ "Optimizing the first image with pw.x using the $ion_dynamics algorithm ...\n"
        runPW first_image.$name

        # optimize the last image
        CONTROL " outdir = '[file join $outdir last_image]' "
        ATOMIC_POSITIONS [::pwtk::nebi::getImageUnit last] [::pwtk::nebi::getImage -if_pos last]

        print_ "Optimizing the last image with pw.x using the $ion_dynamics algorithm ...\n"
        runPW last_image.$name

    # fill-in the optimized coordinates
    print_ "Extracting the optimized coordinates for the first and the last image ..."
    ::pwtk::input::pushpop {
        CONTROL { calculation  = }
        input_clear IONS

        ::pwtk::nebi::setImage first [::pwtk::pwo::getAtmPos first_image.$name.out]
        ::pwtk::nebi::setImage last  [::pwtk::pwo::getAtmPos  last_image.$name.out]
        print_ "Running the neb.x calculation ...\n"
        runNEB $

    print_ "FLO calculation completed."