TABLE OF CONTENTS


::pwtk::eos::init_

SYNOPSIS

proc ::pwtk::eos::init_ {} { 

PURPOSE

Initialize the EOS calculation, and perform some checks on the input variables.

SOURCE

    variable eos

    if { ! [info exists eos(mode)] } {
        ::pwtk::warning "EOS mode not set, setting it to \"auto\""
        set eos(mode) auto
    }

    set ibrav [::pwtk::pwi::ibrav]
    
    printTitle_ "Search for an optimum A-lattice parameter"
    print_ "  ibrav                =  $ibrav (lattice type: [::pwtk::eos::ibrav2lattice $ibrav])"
    print_ "  mode                 =  $eos(mode)"
    print_ "  number of points     =  $eos(npoints)"   
    print_ "  use estimator points =  $eos(use_estimator_points)"
    print_ "  use stress           =  $eos(use_stress)"
    if { $eos(mode) == "auto" && !$eos(use_stress) } {
        # N.B. ::pwtk::eos::run_auto_ cmd uses hardcoded "tstress = .true."
        print_ "  WARNING: mode == auto and use_stress == false; using stress anyway"
    }
    
    # switch to celldm()
    ::pwtk::pwi::abc2celldm
    
    # which EOS mode ?
    
    switch -- $eos(mode) {
        auto {
            if { ! [info exists eos(a0)] } {
                set eos(a0) -1.0
            }
            if { $eos(a0) < 0.0 } {
                # set the initial a0 to celldm(1) or A from input
                set a0 [::pwtk::pwi::alat]
                if { $a0 > 0.5 } {
                    set eos(a0) $a0
                } else {
                    ::pwtk::error "unreasonable value for the initial lattice parameter a0: $a0" 1
                }
            }

            if { $eos(da0) > 0.4 } {
                ::pwtk::error "da0 is too big: typical value should be about 10%"
            }
            if { $eos(da0) < 0.03 } {
                ::pwtk::error "da0 is too small: typical value should be about 10%"
            }

            print_ "  initial a0           =  $eos(a0) bohr"
            print_ "  initial B0           =  $eos(B0) kbar"
            print_ "  scale_min            =  $eos(scale_min)"
            print_ "  scale_max            =  $eos(scale_max)"
        }
        range {
            if { ![info exists eos(amin)] || ![info exists eos(amax)] } {
                ::pwtk::error "input parameter \"amin\" or \"amax\" is not defined" 1
            }
            if { $eos(amin) > $eos(amax) } {
                ::pwtk::error "amin is larger than amax, $eos(amin) and $eos(amax), respectively" 1
            }
            print_ "  lattice parameter search-range: \[$eos(amin), $eos(amax)\] bohr"
        }
        stepwise {
            if { ![info exists eos(amin)] || ![info exists eos(da)] } {
                ::pwtk::error "input parameter \"amin\" or \"da\" is not defined" 1
            }
            if { $eos(da) > 0.5*$eos(amin) } {
                ::pwtk::error "da is too big: typical value should be a few percents of a0"
            }
            print_ "  amin                 =  $eos(amin) bohr"
            print_ "  da                   =  $eos(da) bohr"
        }

        default {
            ::pwtk::error "wrong EOS mode \"$eos(mode)\", must be one of auto, range, stepwise"
        }
    }    
}