Electronic density plots In py4vasp

Question on input files/tags, interpreting output, etc.

Please check whether the answer to your question is given in the VASP online manual or has been discussed in this forum previously!

Moderators: Global Moderator, Moderator

Locked
Message
Author
cameron_scott
Newbie
Newbie
Posts: 2
Joined: Thu Oct 07, 2021 12:23 pm

Electronic density plots In py4vasp

#1 Post by cameron_scott » Wed Jun 01, 2022 3:59 pm

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.

martin.schlipf
Global Moderator
Global Moderator
Posts: 495
Joined: Fri Nov 08, 2019 7:18 am

Re: Electronic density plots In py4vasp

#2 Post by martin.schlipf » Thu Jun 02, 2022 7:01 am

I noticed that is not documented in the wiki yet. The relevant tag is LCHARGH5 = T.

cameron_scott
Newbie
Newbie
Posts: 2
Joined: Thu Oct 07, 2021 12:23 pm

Re: Electronic density plots In py4vasp

#3 Post by cameron_scott » Mon Jun 06, 2022 10:08 am

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?

martin.schlipf
Global Moderator
Global Moderator
Posts: 495
Joined: Fri Nov 08, 2019 7:18 am

Re: Electronic density plots In py4vasp

#4 Post by martin.schlipf » Tue Jun 07, 2022 6:51 am

I will look into that.

martin.schlipf
Global Moderator
Global Moderator
Posts: 495
Joined: Fri Nov 08, 2019 7:18 am

Re: Electronic density plots In py4vasp

#5 Post by martin.schlipf » Tue Jun 07, 2022 12:40 pm

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

Locked