TABLE OF CONTENTS


::pwtk::eos::parseEOS_

SYNOPSIS

proc ::pwtk::eos::parseEOS_ {} {
    variable eos
    variable eos_default

    ::pwtk::ifexist eos { unset eos }
    
    # some variables simply need to be defined for EOS to work
    array set eos [array get eos_default]
                  
    # parse the input data for EOS calculation and perform some checks

    foreach var [::pwtk::input::namelistVars_ EOS] {

        set value [::pwtk::input::namelistGetVarValue EOS $var trim]
        
        # allow:  EOS { value = }
        if { $value == "" } {
            continue
        }
        
        switch -exact -- [string tolower $var] {
            restart {
                ::pwtk::deprecated "The use of the \"restart\" variable in the EOS namelist is obsolete. 
Using PWTK's restart mechanism instead." 
                ::pwtk::restart [string trim $value .]
            }
            use_stress {
                set value [string trim $value .]
                if { ! [string is boolean $value] } {
                    ::pwtk::error "wrong value for EOS's use_stress variable, must be boolean, but got $value"
                } else {
                    set eos(use_stress) $value
                }
            }
            use_estimator_points {
                set value [string trim $value .]
                if { ! [string is boolean $value] } {
                    ::pwtk::error "wrong value for EOS's use_estimator_points variable, must be boolean, but got $value"
                } else {
                    set eos(use_estimator_points) $value
                }
            }
            mode {
                if { [regexp (auto|range|stepwise) $value] } {
                    set eos(mode) $value
                } else {
                    ::pwtk::error "wrong mode for EOS calculation: ${value}, must be one of auto, range, or stepwise"
                }
            }
            b0 {
                if { [regexp (high|medium|small) $value] } {
                    set eos(B0) $eos(B0_$value)
                } elseif { [::pwtk::is_double $value] } {
                    set value [pwtk::mathParser $value]
                    if { $value < 5 || $value > 5000 } {
                        ::pwtk::error "B0 value, ${value} kbar, out of acceptable range, must be witin \[5,5000\] kbar"
                    }
                    set eos(B0) $value
                } else {
                    ::pwtk::error "wrong value of B0 for EOS calculation: ${value}, must be one of high, medium, small, or real-number in kbar, but got $value" 1
                }
            }
            a0 - scale_min - scale_max - amin - amax - da - da0 {                
                if { [::pwtk::is_double $value] } {
                    set value [pwtk::mathParser $value]
                    set eos($var) $value
                } else {
                    ::pwtk::error "wrong value of $var for EOS calculation: ${value}, must be a real number"
                }
                # additional number checks
                if { [regexp (a0|amin|amax|scale_min) $var] && $value < 0.5 } {
                    ::pwtk::error "increase $var, which is too small, ${value}"
                } elseif { $var == "scale_max" && $value > 2.0 } {
                    ::pwtk::error "scale_max is too big: ${value}, should be lower than 2.0, say, around 1.10"
                }
            }
            npoints {
                if { [::pwtk::is_int $value] } {
                    set value [expr $value]
                    if { $value < 4 } {
                        ::pwtk::error "npoints must be >= 4"
                    }
                    set eos($var) $value
                } else {
                    ::pwtk::error "wrong value of $var for EOS calculation: ${value}, must be an integer number"
                }
            }
            default {
                ::pwtk::error "wrong EOS's variable name: $var"
            }
        }
    }
}