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


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

Options are:

    -xcd 0|1|2
    -reduce 2|1|0
    -ncol  <value>
    -npage <value>
    -E0  <value>
    -Elabel <value>


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.




    # 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"}
        {Elabel.arg  {\Delta E} "energy label of for \Delta E calculation"}
        {landscape              "landscape paper orientation"}
    array set opt [::cmdline::getoptions args $options [list [lindex [info level 0] 0] options:]]    

    set latexFile        [lindex $args 0]
    set pwoFileList      [lindex $args 1]
    set xcrysScriptList  [lindex $args 2]

    ::pwtk::xcd::runScript $opt(xcd)
    if { $opt(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 {
                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]]
        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 %.4f [expr ($Etot - $opt(E0)) * $::pwtk::ry2ev]]
            lappend textList [subst -nocommands -nobackslashes {
                \ensuremath{E_{\rm tot}}=\ensuremath{$Etot} ryd\\
                \ensuremath{$opt(Elabel)}=\ensuremath{$deltaE} eV\\
                    {\footnotesize $status}\\

        } 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)
    ::pwtk::print "
LaTeX file written to: $latexFile
To compile the generated LaTeX file, execute:   

      pdflatex $latexFile