Page 1 of 1

How to use py4vasp for DFT-simulated equal-current STM analysis

Posted: Sat Jan 31, 2026 1:55 am
by yhan_vasp

I am trying to use py4vasp for DFT-simulated equal-current STM analysis. Could anyone recommend the INCAR setup and calculation steps for VASP 6.5.0 SCF calculations that are required before generating STM images with py4vasp?

I have read the available documentation and tutorials, but I could not find a clear description of:

which INCAR tags are required or recommended in the SCF step, and

which outputs (e.g. WAVECAR, CHGCAR, vaspout.h5) py4vasp expects for STM post-processing.

Any guidance or example INCARs would be greatly appreciated.

Thank you!


Re: How to use py4vasp for DFT-simulated equal-current STM analysis

Posted: Sun Feb 01, 2026 12:55 am
by yhan_vasp

python check_h5.py
HDF5 file:
input
input/incar
input/incar/AGGAC
input/incar/ALGO
input/incar/DIPOL
input/incar/EDIFF
input/incar/EDIFFG
input/incar/EINT
input/incar/ENCUT
input/incar/GGA
input/incar/IBRION
input/incar/ICHARG
input/incar/IDIPOL
input/incar/ISMEAR
input/incar/ISPIN
input/incar/LCHARG
input/incar/LDIPOL
input/incar/LORBIT
input/incar/LPARD
input/incar/LPARDH5
input/incar/LREAL
input/incar/LUSENCCL
input/incar/LUSE_VDW
input/incar/LWAVE
input/incar/NBMOD
input/incar/NEDOS
input/incar/NELM
input/incar/NSW
input/incar/NWRITE
input/incar/PARAM1
input/incar/PARAM2
input/incar/PREC
input/incar/SIGMA
input/incar/SYSTEM
input/incar/ismear
input/kpoints
input/kpoints/coordinate_space
input/kpoints/mode
input/kpoints/nkpx
input/kpoints/nkpy
input/kpoints/nkpz
input/kpoints/number_kpoints
input/kpoints/shift
input/kpoints/system
input/poscar
input/poscar/direct_coordinates
input/poscar/ion_sha256
input/poscar/ion_types
input/poscar/lattice_vectors
input/poscar/number_ion_types
input/poscar/position_ions
input/poscar/scale
input/poscar/selective_dynamics
input/poscar/selective_dynamics_ions
input/poscar/system
input/potcar
input/potcar/content
input/potcar/potentialtyp
intermediate
intermediate/ion_dynamics
intermediate/ion_dynamics/electronic_step_converged
intermediate/ion_dynamics/electronic_step_converged_dtype
intermediate/ion_dynamics/energies
intermediate/ion_dynamics/energies_tags
intermediate/ion_dynamics/forces
intermediate/ion_dynamics/lattice_vectors
intermediate/ion_dynamics/magnetism
intermediate/ion_dynamics/magnetism/spin_moments
intermediate/ion_dynamics/magnetism/spin_moments/components
intermediate/ion_dynamics/magnetism/spin_moments/orbitals
intermediate/ion_dynamics/magnetism/spin_moments/values
intermediate/ion_dynamics/oszicar
intermediate/ion_dynamics/oszicar_label
intermediate/ion_dynamics/position_ions
intermediate/ion_dynamics/scale
intermediate/ion_dynamics/stress
results
results/electron_dos
results/electron_dos/anorm
results/electron_dos/aomega
results/electron_dos/jobpar
results/electron_dos/nions
results/electron_dos/potim
results/electron_dos/system
results/electron_dos/temperature
results/electron_eigenvalues
results/electron_eigenvalues/anorm
results/electron_eigenvalues/aomega
results/electron_eigenvalues/ispin
results/electron_eigenvalues/kpoints
results/electron_eigenvalues/nb_tot
results/electron_eigenvalues/nblocks
results/electron_eigenvalues/nelectrons
results/electron_eigenvalues/nions
results/electron_eigenvalues/potim
results/electron_eigenvalues/system
results/electron_eigenvalues/temperature
results/partial_charges
results/partial_charges/bands
results/partial_charges/grid
results/partial_charges/kpoints
results/partial_charges/parchg
results/positions
results/positions/direct_coordinates
results/positions/ion_sha256
results/positions/ion_types
results/positions/lattice_vectors
results/positions/number_ion_types
results/positions/position_ions
results/positions/scale
results/positions/selective_dynamics
results/positions/selective_dynamics_ions
results/positions/system
version
version/major
version/minor
version/patch

From the above check for vaspout.h5, we see: results/partial_charges

However, when I use:
------------------------------------------------
#!/usr/bin/env python3
import py4vasp
import matplotlib.pyplot as plt
import sys

calc_path = "."
current = 0.1
supercell = [1, 1]
save_png = "STM_0.1nA.png"
cmap = "viridis"

try:
calc = py4vasp.Calculation.from_path(calc_path)

stm_graph = calc.partial_density.to_stm(selection="constant_current",current=current,supercell=supercell
)

..................

I got:
python plot_stm.py
Error: no partial_charges is found.


Re: How to use py4vasp for DFT-simulated equal-current STM analysis

Posted: Mon Feb 02, 2026 11:13 am
by andreas.singraber

Hello!

Just for reference, here is the available documentation and a tutorial:

https://vasp.at/wiki/Partial_charge_den ... imulations (here is also a detailed list of relevant INCAR tags)
https://vasp.at/tutorials/latest/surface/part3/

You mentioned that you already studied this and it seems that everything is well-prepared for creating an STM image with py4vasp. The python code you wrote also follows the examples given in the documentation and tutorials. The only possible issue I found so far is that the py4vasp documentation here suggests that there would be a partial_charge "calculation" instead of one named partial_density. Maybe this was renamed recently.. anyway, this is just speculation. Since I have not written this part of VASP/py4vasp myself I will get in touch with my colleagues about this issue.

In the meantime, may I ask you to upload the relevant input and output files according to the forum posting guidelines? Also, could you please check which version of py4vasp you are using via

Code: Select all

import py4vasp
print(py4vasp.__version__)

Maybe you could also check again with h5ls whether there is actual data inside the HDF5 groups (as suggested in the documentation of the LPARDH5 tag):

Code: Select all

h5ls -r vaspout.h5

All the best,
Andreas Singraber


Re: How to use py4vasp for DFT-simulated equal-current STM analysis

Posted: Mon Feb 02, 2026 4:57 pm
by yhan_vasp

Hi Andreas,

Thank you for your reply. I have checked:

The py4vasp version is 0.10.4.
---------------------------------------------
C:\Users\octav>python
Python 3.14.2 (tags/v3.14.2:df79316, Dec 5 2025, 17:18:21) [MSC v.1944 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import py4vasp
... print(py4vasp.__version__)
...
0.10.4
--------------------------------------------------

Using h5py to inspect vaspout.h5, I see the HDF5 groups as follows:

------------------------------
>>> import h5py
... with h5py.File("vaspout.h5", "r") as f:
... def print_name(name):
... print(name)
... f.visit(print_name)
...
input
input/incar
input/incar/AGGAC
input/incar/ALGO
input/incar/DIPOL
input/incar/EDIFF
input/incar/EDIFFG
input/incar/EINT
input/incar/ENCUT
input/incar/GGA
input/incar/IBRION
input/incar/ICHARG
input/incar/IDIPOL
input/incar/ISMEAR
input/incar/ISPIN
input/incar/LCHARG
input/incar/LDIPOL
input/incar/LORBIT
input/incar/LPARD
input/incar/LPARDH5
input/incar/LREAL
input/incar/LUSENCCL
input/incar/LUSE_VDW
input/incar/LWAVE
input/incar/NBMOD
input/incar/NEDOS
input/incar/NELM
input/incar/NSW
input/incar/NWRITE
input/incar/PARAM1
input/incar/PARAM2
input/incar/PREC
input/incar/SIGMA
input/incar/SYSTEM
input/incar/ismear
input/kpoints
input/kpoints/coordinate_space
input/kpoints/mode
input/kpoints/nkpx
input/kpoints/nkpy
input/kpoints/nkpz
input/kpoints/number_kpoints
input/kpoints/shift
input/kpoints/system
input/poscar
input/poscar/direct_coordinates
input/poscar/ion_sha256
input/poscar/ion_types
input/poscar/lattice_vectors
input/poscar/number_ion_types
input/poscar/position_ions
input/poscar/scale
input/poscar/selective_dynamics
input/poscar/selective_dynamics_ions
input/poscar/system
input/potcar
input/potcar/content
input/potcar/potentialtyp
intermediate
intermediate/ion_dynamics
intermediate/ion_dynamics/electronic_step_converged
intermediate/ion_dynamics/electronic_step_converged_dtype
intermediate/ion_dynamics/energies
intermediate/ion_dynamics/energies_tags
intermediate/ion_dynamics/forces
intermediate/ion_dynamics/lattice_vectors
intermediate/ion_dynamics/magnetism
intermediate/ion_dynamics/magnetism/spin_moments
intermediate/ion_dynamics/magnetism/spin_moments/components
intermediate/ion_dynamics/magnetism/spin_moments/orbitals
intermediate/ion_dynamics/magnetism/spin_moments/values
intermediate/ion_dynamics/oszicar
intermediate/ion_dynamics/oszicar_label
intermediate/ion_dynamics/position_ions
intermediate/ion_dynamics/scale
intermediate/ion_dynamics/stress
results
results/electron_dos
results/electron_dos/anorm
results/electron_dos/aomega
results/electron_dos/jobpar
results/electron_dos/nions
results/electron_dos/potim
results/electron_dos/system
results/electron_dos/temperature
results/electron_eigenvalues
results/electron_eigenvalues/anorm
results/electron_eigenvalues/aomega
results/electron_eigenvalues/ispin
results/electron_eigenvalues/kpoints
results/electron_eigenvalues/nb_tot
results/electron_eigenvalues/nblocks
results/electron_eigenvalues/nelectrons
results/electron_eigenvalues/nions
results/electron_eigenvalues/potim
results/electron_eigenvalues/system
results/electron_eigenvalues/temperature
results/partial_charges
results/partial_charges/bands
results/partial_charges/grid
results/partial_charges/kpoints
results/partial_charges/parchg
results/positions
results/positions/direct_coordinates
results/positions/ion_sha256
results/positions/ion_types
results/positions/lattice_vectors
results/positions/number_ion_types
results/positions/position_ions
results/positions/scale
results/positions/selective_dynamics
results/positions/selective_dynamics_ions
results/positions/system
version
version/major
version/minor
version/patch
>>>
-------------------------------

There is no partial_density group, only partial_charges. It seems that the API changed recently, and what used to be partial_density is now stored under partial_charges. Could you confirm if I should use calc.partial_charges instead of calc.partial_density to generate equal-current STM images?

Thank you for your time!
Yong


Re: How to use py4vasp for DFT-simulated equal-current STM analysis

Posted: Mon Feb 02, 2026 5:24 pm
by yhan_vasp

The calculation was performed with VASP.6.5.0.
The attached archive job_files.tar.gz contains the following input files:
INCAR
KPOINTS
POSCAR
POTCAR
vdw_kernel.bindat

The output files CHGCAR, WAVECAR, and vaspout.h5 are too large to upload. If necessary, these can be shared separately upon request.


Re: How to use py4vasp for DFT-simulated equal-current STM analysis

Posted: Thu Feb 05, 2026 11:15 am
by andreas.singraber

Hello!

Unfortunately, I was not yet able to reproduce the behavior you are describing. The example files you provided seem to contain a rather computationally expensive calculation so I did not try to reproduce exactly this system. Instead I combined the tutorial example with your additional INCAR tags. While this may not be a meaningful setup it should still show any incompatibility issues. However, I did not run into any problems. I was able to get the STM image following the instructions given in the tutorial and using the Python script in the Jupter notebook. As we already discussed, there seems to be an API change in the recent py4vasp version:

Code: Select all

py4vasp 0.10.2:   calc.partial_charge.to_stm(...)
py4vasp 0.10.4:   calc.partial_density.to_stm(...)

Both versions worked for me. Maybe it is easier to find the problem if you try now to reproduce the tutorial example which actually requires only minimal amount of compute time. Could you please download the tutorial (there is a purple "Download this tutorial" button on the tutorial page linked above) and check if you can obtain the STM image? Depending on the answer to this we should proceed:

If the tutorial works for you, then please provide a complete description of how you obtained results for your real-world example. In particular, provide separate input files for each step of your process. Also, include the complete Python script you are using. If possible, upload the output files to some third-party file hosting service.

If the tutorials do not work for you, we have to investigate further how you have set up VASP and py4vasp. Please provide details about the installation process of VASP (makefile.include, toolchain used) and py4vasp (which commands you used for installation).

All the best,
Andreas Singraber