TABLE OF CONTENTS


::pwtk::pseudo::etot_test_many

SYNOPSIS

proc ::pwtk::pseudo::etot_test_many {args} {

USAGE

   ::pwtk::pseudo::etot_test_many ?OPTIONS? ppFileList

DESCRIPTION

Perform the ::pwtk::pseudo::etot_test pseuo-potential test for many pseudopotentials.

In most case no options are needed, hence use options only if the default setup fails.

For each pseudopotential, the calculations will be performed in a separate subdirectory. The subdirectory name is derived from the name of pseudopotential by stripping the ".UPF" extension and adding the ".d" postfix ("d" standing for directory. For example:

      pseudopotential:  O.pbe-n-kjpaw_psl.1.0.0.UPF
      subdirectory:     O.pbe-n-kjpaw_psl.1.0.0.d/

whereas for old naming:

      pseudopotential:  AgUSPBE.RRKJ3
      subdirectory:     AgUSPBE.RRKJ3.d/    

OPTIONS

Options are the same as for ::pwtk::pseudo::etot_test

ARGUMENT

RETURN VALUE

The hardest ecutwfc and ecutrho values among the tested pseudopotentials, as the "$ecutrho $ecutwfc" list.

SOURCE

    variable gpData
    variable dir

    set options    [lrange $args 1 end-1]
    set ppFileList [lindex $args end]

    #
    # informative printout
    #
    
    ::pwtk::printTitle MULTI-PSEUDO "Search of \"ecutwfc\" & \"ecutrho\" for a set of pseudopotential files"

    ::pwtk::print "List of pseudopotential files to test:\n
   No.   pseudopotential-file                  executed in sub-directory
   ---------------------------------------------------------------------"    
    foreach pp $ppFileList {
        incr ind
        if { [file extension $pp] == ".UPF" } {
            set dir($pp) [file tail [file rootname $pp]].d
        } else {
            set dir($pp) [file tail $pp].d
        }
        ::pwtk::print [format {   %3d.  %-35s   %s}   $ind $pp  $dir($pp)/]
    }
    ::pwtk::print "   ---------------------------------------------------------------------\n"
    if { $ppFileList eq {} } {
        ::pwtk::error "the list of pseudopotentials to test is empty" 1
    }
    
    #
    # create a multiplot object to plot the Etot vs. ecutwfc plots for
    # all tested PPs
    #

    set pdf PP-etot-test-many.pdf
    if { [file exists $pdf] } {
        pwtk::infoMsg "file \"$pdf\" exists; making a backup copy to [::pwtk::file_backup $pdf]"
    }    
    set gp [::pwtk::gp::multiplot new auto $ind $pdf]
    $gp options $gpData(options)
    
    #
    # test each pseudopotential
    #

    foreach pp $ppFileList {
        set str "Processing $pp"
        set lin [string repeat - 72]
        ::pwtk::print "$str\n$lin
   Calculations performed in directory: ./$dir($pp)/
   For details see the log file:        ./$dir($pp)/RESULTS.log\n"
        
        file mkdir $dir($pp)
        cd $dir($pp)
        ::pwtk::redirect_stdout_to RESULTS.log {
            ::pwtk::catch_error {
                set res [::pwtk::pseudo::etot_test {*}$options $pp]
                $gp add  $gpData($pp,param)
                $gp add  $gpData($pp,add)
                $gp plot $gpData($pp,plot)
            } {
                puts "ppFile failed: $pp"
                set res "N/A N/A"
            }
            append results [concat $pp $res]\n
        }
        cd ..
    }

    #
    # print a summary for all pseudopotentials
    #
    
    ::pwtk::print MULTI-PSEUDO "Summary of results\n"

    ::pwtk::print "List of tested pseudopotentials:\n
   No.  pseudopotential-file                    ecutwfc   ecutrho   dual
   ---------------------------------------------------------------------"
    
    set ecutwfcMax -1
    set ecutrhoMax -1
    set rhoPP [set wfcPP [lindex $ppFileList 0]]
    
    unset ind

    foreach {pp ecutwfc ecutrho} $results {
        incr ind
        # BEWARE: we may have N/A
        if { $ecutwfc != "N/A" } {
            if { $ecutwfc > $ecutwfcMax } {
                set ecutwfcMax $ecutwfc
                set wfcPP      $pp
            }
            if { $ecutrho > $ecutrhoMax } {
                set ecutrhoMax $ecutrho
                set rhoPP      $pp
            }
            ::pwtk::print [format {  %3d.  %-35s   %7.0f   %7.0f   %4d}   $ind $pp  $ecutwfc $ecutrho [expr round($ecutrho/$ecutwfc)]]
        } else {
            lappend naList $pp
            ::pwtk::print [format {  %3d.  %-35s   %7s   %7s   %4s}   $ind $pp  $ecutwfc $ecutrho N/A]
        }
    }
    ::pwtk::print "   ---------------------------------------------------------------------\n
Hardest ecutwfc = $ecutwfcMax   (pseudopotential: $wfcPP)
Hardest ecutrho = $ecutrhoMax   (pseudopotential: $rhoPP)\n"

    if { [info exists naList] } {
        ::pwtk::print "BEWARE: testing failed for the following pseudopotentials:\n
        [join $naList "\n   "]\n
        Please check the failed cases.\n"
    }
    
    # make a multiplot of all tested PPs
    
    $gp exec
    $gp destroy
    
    return [list $ecutwfcMax $ecutrhoMax]
}