sumo: sumo-optplot failed to plot optical absorption spectra diagrams of VASP GW+BSE computation.

I try to test sumo-optplot using the calculation results of Dielectric_properties_of_Si_using_BSE, but failed as follows:

(datasci) werner@X10DAi:~/Downloads/GW_BSE/Si_BSE$ sumo-optplot 
Traceback (most recent call last):
  File "/home/werner/.pyenv/versions/datasci/bin/sumo-optplot", line 33, in <module>
    sys.exit(load_entry_point('sumo', 'console_scripts', 'sumo-optplot')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/werner/Public/repo/github.com/SMTG-UCL/sumo.git/sumo/cli/optplot.py", line 455, in main
    optplot(
  File "/home/werner/Public/repo/github.com/SMTG-UCL/sumo.git/sumo/cli/optplot.py", line 170, in optplot
    latexify(vr.final_structure.composition.reduced_formula).replace(
             ^^^^^^^^^^^^^^^^^^
AttributeError: 'Vasprun' object has no attribute 'final_structure'. Did you mean: 'initial_structure'?


(datasci) werner@X10DAi:~/Downloads/GW_BSE/Si_BSE$ sumo-optplot ./vasprun.xml
usage: sumo-optplot [-h] [-f F [F ...]] [-p P] [-d D] [-c C [C ...]] [-g G] [-b [E ...]]
                    [-l L [L ...]] [-a] [--height HEIGHT] [--width WIDTH] [--xmin XMIN] [--xmax XMAX]
                    [--ymin YMIN [YMIN ...]] [--ymax YMAX [YMAX ...]] [--style STYLE [STYLE ...]]
                    [--no-base-style] [--format FORMAT] [--dpi DPI] [--font FONT] [--units UNITS]
                    [M ...]
sumo-optplot: error: argument M: invalid choice: './vasprun.xml' (choose from 'eps_real', 'absorption', 'n_real', 'n_imag', 'loss', 'eps_imag')

I attached the vasprun.xml file below.

vasprun.zip

Regards, Zhao

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (10 by maintainers)

Most upvoted comments

In any case, I have just pushed a fix that makes sure Vasprun.final_structure == Vasprun.initial_structure if there is no relaxation. For getting the chemical formula only, the initial structure (which is always set) is as good as the final structure.

It seems that your conjecture is correct:

In [6]: import pymatgen.io.vasp as vasp
   ...: import numpy as np
   ...: 
   ...: # Read the vasprun.xml file
   ...: vr = vasp.Vasprun("sumo/vasprun.xml")
   ...: e2 = np.array(vr.dielectric[2])
   ...: e2x = e2[:, 0]
   ...: e2y = e2[:, 1]
   ...: e2z = e2[:, 2]
   ...: 
   ...: # Calculate absolute differences and store them in new lists
   ...: differences_x_y = [abs(a - b) for a, b in zip(e2x, e2y)]
   ...: differences_y_z = [abs(a - b) for a, b in zip(e2y, e2z)]
   ...: differences_z_x = [abs(a - b) for a, b in zip(e2z, e2x)]
   ...: 
   ...: # Calculate the maximum and minimum absolute differences
   ...: max_difference = max(max(differences_x_y), max(differences_y_z), max(differences_z_x))
   ...: min_difference = min(min(differences_x_y), min(differences_y_z), min(differences_z_x))
   ...: 
   ...: # Print the maximum and minimum values
   ...: print(f"Maximum absolute difference: {max_difference}")
   ...: print(f"Minimum absolute difference: {min_difference}")
   ...: 
/home/werner/Public/hpc/tools/materialsproject/pymatgen.git/pymatgen/io/vasp/outputs.py:1084: UserWarning: No POTCAR file with matching TITEL fields was found in /home/werner/Public/hpc/vasp/learning-by-doing/optical-absorption-spectra/sumo
  warnings.warn(f"No POTCAR file with matching TITEL fields was found in {os.path.abspath(p)}")
Maximum absolute difference: 0.18339999999999979
Minimum absolute difference: 0.0

Agreed that using initial_structure is the better way to go, and we should probably update sumo to use that. But thanks for the fix @shyuep.