Electronic density plots In py4vasp
Moderators: Global Moderator, Moderator
-
- Newbie
- Posts: 2
- Joined: Thu Oct 07, 2021 12:23 pm
Electronic density plots In py4vasp
Hi all,
I am trying to plot the electronic density using py4vasp with the method:
calc = py4vasp.Calculation.from_path(".")
calc.density.plot()
as the gas-out.h5 file is in the same directory as my python script and I get
FileAccessError: path/vaspwave.h5 Please check that you already completed the Vasp calculation and that the file is indeed in the directory. Please also check whether you are running the Python script in the same directory or pass the appropriate filename including the path.
As far as I am aware, VASP doesn't produce a vaspwave.h5 file. Is there a tag I need to include in the INCAR to produce this file?
Thanks for any help you can give.
I am trying to plot the electronic density using py4vasp with the method:
calc = py4vasp.Calculation.from_path(".")
calc.density.plot()
as the gas-out.h5 file is in the same directory as my python script and I get
FileAccessError: path/vaspwave.h5 Please check that you already completed the Vasp calculation and that the file is indeed in the directory. Please also check whether you are running the Python script in the same directory or pass the appropriate filename including the path.
As far as I am aware, VASP doesn't produce a vaspwave.h5 file. Is there a tag I need to include in the INCAR to produce this file?
Thanks for any help you can give.
-
- Global Moderator
- Posts: 542
- Joined: Fri Nov 08, 2019 7:18 am
Re: Electronic density plots In py4vasp
I noticed that is not documented in the wiki yet. The relevant tag is LCHARGH5 = T.
Martin Schlipf
VASP developer
-
- Newbie
- Posts: 2
- Joined: Thu Oct 07, 2021 12:23 pm
Re: Electronic density plots In py4vasp
Thank you very much, that has produced the correct file. The issue now is that attempting to plot, read or print the density produces:
KeyError: 'Unable to open object (component not found)'
I have tried to load the density directly using the from_file method but this produces the same error. Is there another tag that I need to include within INCAR?
KeyError: 'Unable to open object (component not found)'
I have tried to load the density directly using the from_file method but this produces the same error. Is there another tag that I need to include within INCAR?
-
- Global Moderator
- Posts: 542
- Joined: Fri Nov 08, 2019 7:18 am
-
- Global Moderator
- Posts: 542
- Joined: Fri Nov 08, 2019 7:18 am
Re: Electronic density plots In py4vasp
Okay there is a bug in the implementation of the density, because the density and the structure are written to different files. The KeyError pops up when the code looks for the structure in the file of the density. Here is a workaround until the next release of py4vasp
Code: Select all
from py4vasp import Calculation
import h5py
calc = Calculation.from_path("path_to_your_VASP_calculation")
fig = calc.structure.plot()
with h5py.File(calc.path() / "vaspwave.h5", "r") as h5f:
fig.show_isosurface(h5f["charge/charge"][0], isolevel=0.2)
fig
Martin Schlipf
VASP developer