-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sumo-optplot failed to plot optical absorption spectra diagrams of VASP GW+BSE computation. #221
Comments
|
I just realised I only responded to your second issue. I will look into the first one. |
This does not solve the problem, as shown below: (datasci) werner@X10DAi:~/Downloads/GW_BSE/Si_BSE$ sumo-optplot -f vasprun.xml
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'?
|
Taking a look at the Pymatgen code: the Vasprun parser has lots of places that assume So if your Vasprun object does not have a
|
The VASP output is for a GW BSE calculation. I guess that includes different outputs than a regular optics calculation. I don't have much experience in them though. |
Ah right. I started a branch to implement some of these other dielectric function calculations a few years ago but didn't have much incentive to work on it after leaving UCL 😆 |
With the increasing number of researchers using GW+BSE method in current and future computational study, this is not an issue that can be casually ignored. For example, there is a dedicated package pyGWBSE developed for this purpose, which also based on pymatgen. So, I must first confirm whether the current issue is in sumo or Pymatgen. If it is the latter, I should submit a bug report there. Otherwise, it should be fixed in this project. |
See the comment given by @shyuep below:
|
Well, the line of code triggering the error here is only responsible for getting the chemical formula anyway. So Sumo could possibly be made more robust against this specific (i.e. optics) situation where the vasprun is not used heavily. As far as I can tell from the code, many attributes of the Pymatgen Vasprun object such CompleteDos, get_computed_entry(), get_band_structure() ... will attempt to access |
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. |
Agreed that using |
Glad to see this progress. This problem also makes pymatgen more robust via the fix added by @shyuep. |
That sounds great, hopefully the upstream fix will prevent the same issue being hit for other properties. |
Is the data for xx, yy, zz different in the file? It looks like it plotted all three but they were identical. |
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 |
Good, good! Then I will close this issue for now. I suppose we should make a note to update the Pymatgen requirements. |
I try to test sumo-optplot using the calculation results of Dielectric_properties_of_Si_using_BSE, but failed as follows:
I attached the vasprun.xml file below.
vasprun.zip
Regards,
Zhao
The text was updated successfully, but these errors were encountered: