TABLE OF CONTENTS


::pwtk::pwo::tabulateStructs

SYNOPSIS

proc ::pwtk::pwo::tabulateStructs {args} {

USAGE

 ::pwtk::pwo::tabulateStructs  [options]  latexFile  pwoFileList  xcrysdenScriptList

 Options are:
    -ic
    -lc
    -ilc
    -xcd 0|1|2
    -reduce 2|1|0
    -ncol  <value>
    -npage <value>
    -E0  <value>
    -E0fmt <value>
    -Elabel <value>
    -landscape
    -composite
    -noinfo

PURPOSE

Plot with xcrysden the structures from the supplied list of pw.x output files ($pwoFileList) and arrange them into a table in LaTeX document ($latexFile).

To instruct xcrysden how to plot each structure, user has to provide at least one xcrysden script (i.e., the state-part of *.xcrysden file). If user supllies more then one xcrysden script ($xcrysdenScriptList), each structure will be plotted several times, i.e., once with each supplied xcrysden script file.

OPTIONS

ARGUMENTS

SOURCE

    # parse args

    ::pwtk::printTitle TABULATE "tabulation of pw.x output files (::pwtk::pwo::tabulateStructs)"

    set options {
        {ic                     "extract initial structure"}
        {lc                     "extract the latest structure"}
        {ilc                    "extraxt initial and the latest structure"}
        {xcd.arg      1         "do we run xcrysden to make figures"}
        {reduce.arg   3         "reduce the dimensionality of structure"}
        {ncol.arg    -1         "number of columns (-1 means automatically determined)"}
        {npage.arg    1         "number of pages the table will span (estimate only)"}
        {E0.arg       0.0       "reference-energy for \Delta E calculation"}
        {E0fmt.arg    %.4f      "format specified for \Delta E printout (default = %.4f)"}
        {Elabel.arg  {\Delta E} "energy label of for \Delta E calculation"}
        {landscape              "landscape paper orientation"}
        {composite              "composite mode:  do not dump the latex file, because tabulateStructs will be called again for this latex file"}
        {noinfo                 "do not print the status info & total energy"}
    }
    array set opt [::cmdline::getoptions args $options [list [lindex [info level 0] 0] options:]]    

    lassign $args latexFile pwoFileList xcrysScriptList

    ::pwtk::xcd::runScript $opt(xcd)
    
    if { $opt(landscape) } {
        ::pwtk::latex::landscape
    }

    # make structure figures

    if { $opt(ilc) } {
        set which ilc
    } elseif { $opt(lc) } {
        set which lc
        set type  latest
    } elseif { $opt(ic) } {
        set which ic
        set type  initial
    } else {
        set which lc
        set type  latest
    }

    switch -exact $which {
        ic - lc {
            pwtk::xcd::scriptHead "scripting::filter::pwscfOutput -$which \$structureFile \$reduce"
            set figList [::pwtk::xcd::makeFigs $pwoFileList $xcrysScriptList $which $opt(reduce)]
            foreach fig $figList {
                if { $opt(noinfo) } {
                    lappend infoList {}
                } else {
                    lappend infoList [list [list $type structure]]
                }
            }
        }

        ilc {
            # initial structures

            pwtk::xcd::scriptHead { 
                scripting::filter::pwscfOutput -ic $structureFile $reduce 
            }
            set figList1 [::pwtk::xcd::makeFigs $pwoFileList $xcrysScriptList ic $opt(reduce)]

            # latest structures

            pwtk::xcd::scriptHead { 
                scripting::filter::pwscfOutput -lc $structureFile $reduce 
            }
            set figList2 [::pwtk::xcd::makeFigs $pwoFileList $xcrysScriptList lc $opt(reduce)]
            
            # make a proper figList

            foreach figG1 $figList1 figG2 $figList2 {
                lappend figList  [concat $figG1 $figG2]
                lappend infoList [ilc_infoText_ "initial structure" $figG1 "latest structure" $figG2]
            }
        }
    }

    # make titles and calculated energies ...

    foreach file $pwoFileList {

        # title
        set prefix [file rootname [file tail $file]]
        if { $opt(noinfo) } {
            lappend titleList {}
        } else {
            lappend titleList $prefix
        }
        
        # calculate energies

        set Etot [format %.6f [::pwtk::pwo::totene $file end]]

        # is job already converged

        if { [::pwtk::job_done $file] } {
            set status "Status: job done"
        } else {
            set status "Status: unfinished"
        }

        if { $opt(E0) != 0.0 } {

            set deltaE [format $opt(E0fmt) [expr ($Etot - $opt(E0)) * $::pwtk::ry2ev]]

            if { $opt(noinfo) } {
                lappend textList [subst -nocommands -nobackslashes {
                    \ensuremath{$opt(Elabel)}=\ensuremath{$deltaE} eV
                    \vspace{0.5em}
                }]
            } else {
                lappend textList [subst -nocommands -nobackslashes {
                    \ensuremath{E_{\rm tot}}=\ensuremath{$Etot} ryd\\
                        \ensuremath{$opt(Elabel)}=\ensuremath{$deltaE} eV\\
                        {\footnotesize $status}\\
                    }]
            }
        } else {
            if { $opt(noinfo) } {
                lappend textList [subst -nocommands -nobackslashes {
                    \vspace{0.5em}
                }]
            } else {
                lappend textList [subst -nocommands -nobackslashes {
                    \ensuremath{E_{\rm tot}}=\ensuremath{$Etot} ryd\\
                        {\footnotesize $status}\\
                    }]
            }
        }
    }

    # puts all figures into latex longtable and write corresponding LaTeX file

    ::pwtk::latex::tabulateFigs $latexFile $figList $titleList $infoList $textList $opt(npage) $opt(ncol) $opt(composite)
        
    if { ! $opt(composite) } {
        ::pwtk::print "
LaTeX file written to: $latexFile
To compile the generated LaTeX file, execute:   

      pdflatex $latexFile
"
    }
}