Page 1 of 1

Electronic density plots In py4vasp

Posted: Wed Jun 01, 2022 3:59 pm
by cameron_scott
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.

Re: Electronic density plots In py4vasp

Posted: Thu Jun 02, 2022 7:01 am
by martin.schlipf
I noticed that is not documented in the wiki yet. The relevant tag is LCHARGH5 = T.

Re: Electronic density plots In py4vasp

Posted: Mon Jun 06, 2022 10:08 am
by cameron_scott
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?

Re: Electronic density plots In py4vasp

Posted: Tue Jun 07, 2022 6:51 am
by martin.schlipf
I will look into that.

Re: Electronic density plots In py4vasp

Posted: Tue Jun 07, 2022 12:40 pm
by martin.schlipf
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