Skip to content

Commit

Permalink
Doc updates for the new VASP interface in version 6.5.0 (#269)
Browse files Browse the repository at this point in the history
* [doc] update VASP interface doc for new interface features
* [doc] update VASP SVO tutorial for new interface features
* [doc] NiO VASP CSC tutorial updates for new interface
* [fix] fixes for latest dfttools version
* [doc] updates to CSC NiO example with VASP
  • Loading branch information
the-hampel authored Feb 21, 2025
1 parent 7b8b3dd commit 3c2821f
Show file tree
Hide file tree
Showing 16 changed files with 335 additions and 289 deletions.
19 changes: 2 additions & 17 deletions bin/vasp_dmft.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MPIRUN_CMD=mpirun
show_help()
{
echo "
Usage: vasp_dmft [-n <number of cores>] -i <number of iterations> -j <number of VASP iterations with fixed charge density> [-v <VASP version>] [-p <path to VASP directory>] [<dmft_script.py>]
Usage: vasp_dmft [-n <number of cores>] -i <number of iterations> -j <number of VASP iterations with fixed charge density> [-p <path to VASP directory>] [<dmft_script.py>]
If the number of cores is not specified it is set to 1 by default.
Expand All @@ -14,9 +14,6 @@ Usage: vasp_dmft [-n <number of cores>] -i <number of iterations> -j <number of
Set the number of VASP iteration with a fixed charge density update
inbetween the dmft runs with -j <number of VASP iterations with fixed charge density>
Set the version of VASP by -v standard(default)/no_gamma_write to
specify if VASP writes the GAMMA file or not.
If the path to VASP directory is not specified it must be provided by a
variable VASP_DIR.
Expand Down Expand Up @@ -56,12 +53,6 @@ while getopts ":n:i:j:v:p:h" opt; do
VASP_DIR=$OPTARG
fi
;;
v)
if [ -n "$OPTARG" ]; then
VASP_VERSION=$OPTARG
# echo "Version of VASP (writing GAMMA file (standard) or not (no_gamma_write): $VASP_VERSION"
fi
;;
h)
show_help
exit 1
Expand Down Expand Up @@ -99,11 +90,6 @@ if [ -z "$NDFTITER" ]; then
NDFTITER=1
fi

if [ -z "$VASP_VERSION" ]; then
echo " VASP version not specified, setting to standard"
VASP_VERSION="standard"
fi

shift $((OPTIND-1))

if [ -z "$1" ]; then
Expand All @@ -115,13 +101,12 @@ fi
echo " Number of cores: $NPROC"
echo " Number of iterations: $NITER"
echo " Number of iterations with fixed density: $NDFTITER"
echo " VASP version: $VASP_VERSION"
echo " Script name: $DMFT_SCRIPT"

rm -f vasp.lock STOPCAR
# run in serial and use OMP_NUM_THREADS here for vasp >=6.2 in case there are problems
stdbuf -o 0 $MPIRUN_CMD -np $NPROC "$VASP_DIR" &


$MPIRUN_CMD -np $NPROC @TRIQS_PYTHON_EXECUTABLE@ -m triqs_dft_tools.converters.plovasp.sc_dmft $(jobs -p) $NITER $NDFTITER $DMFT_SCRIPT 'plo.cfg' $VASP_VERSION || kill %1
$MPIRUN_CMD -np $NPROC @TRIQS_PYTHON_EXECUTABLE@ -m triqs_dft_tools.converters.plovasp.sc_dmft $(jobs -p) $NITER $NDFTITER $DMFT_SCRIPT 'plo.cfg' || kill %1

41 changes: 17 additions & 24 deletions doc/guide/conv_vasp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The VASP interface relies on new options introduced since version 5.4.x In
particular, a new INCAR-option `LOCPROJ
<https://cms.mpi.univie.ac.at/wiki/index.php/LOCPROJ>`_, the new `LORBIT` modes
13 and 14 have been added, and the new `ICHARG` mode 5 for charge
self-consistent DFT+DMFT calculations have been added.
self-consistent DFT+DMFT calculations have been added. The VASP interface for charge self-consistent calculations is officially supported as of VASP version 6.5.0 (see `VASP ICHARG=5 documentation <https://www.vasp.at/wiki/index.php/ICHARG>`_). It is highly recommended to compile VASP with hdf5 support enabled (`-DVASP_HDF5`) to enable all features of the interface. This allows to use the interface while symmetries are switched on in VASP, and enables spin-polarized feedback in charge self-consistent calculations to VASP.

The VASP interface methodologically builds on the so called projection on
localized orbitals (PLO) scheme, where the resulting KS states from DFT are
Expand All @@ -18,26 +18,16 @@ The implementation is presented in `M. Schüler et al. 2018 J. Phys.: Condens.
Matter 30 475901 <https://doi.org/10.1088/1361-648X/aae80a>`_.

The interface consists of two parts, :py:mod:`PLOVASP<triqs_dft_tools.converters.plovasp>`, a collection of
python classes and functions converting the raw VASP output to proper projector
python classes and functions converting the VASP output to proper projector
functions, and the python based :py:mod:`VaspConverter<triqs_dft_tools.converters.vasp>`, which
creates a h5 archive from the :py:mod:`PLOVASP<triqs_dft_tools.converters.plovasp>` output readable by
`SumkDFT`. Therefore, the conversion consist always of two steps.

Here, we will present a guide how the interface `can` be used to create input for a DMFT calculation, using SrVO3 as an example. Full examples can be found in the :ref:`tutorial section of DFTTools<tutorials>`.

Limitations of the interface
============================
For VASP version older than 6.5.0 there are a few limitation of the interface as it was not officially supported and only text file based. See `Remarks for VASP older than 6.5.0`_ for details.

* The interface works correctly only if the k-point symmetries
are turned off during the VASP run (ISYM=-1).
* Generation of projectors for k-point lines (option `Lines` in KPOINTS)
needed for Bloch spectral function calculations is not possible at the moment.
* The interface currently supports only collinear-magnetism calculation
(this implies no spin-orbit coupling) and spin-polarized projectors have not
been tested.
* The converter needs the correct Fermi energy from VASP, which is read from
the LOCPROJ file. However, VASP by default does not output this information.
Please see `Remarks on the VASP version`_.
Generation of projectors for k-point lines (option `Lines` in KPOINTS) needed for Bloch spectral function calculations is not possible at the moment.

VASP: generating raw projectors
===============================
Expand Down Expand Up @@ -383,16 +373,20 @@ For two correlated sites, one can define the file as follows:
0.0 1.0 0.0 0.0 0.0
0.0 0.0 0.0 1.0 0.0

Remarks on the VASP version
===============================
Remarks for VASP older than 6.5.0
=================================

The above mentioned interface has some limitations for VASP versions older than 6.5.0:

In the current version of the interface the Fermi energy is extracted from the
DOSCAR. However, if one pursues to do charge self-consistent calculations one
needs to write the Fermi energy to the projectors (`LOCPROJ` file), as the DOSCAR
is only updated after a full SCF/NSCF run. The file should contain the Fermi energy
in the header. One can either copy the Fermi energy manually there after a successful
VASP run, or modify the VASP source code slightly, by replacing the following line in
`locproj.F` (around line 695):
* The interface works correctly only if the k-point symmetries
are turned off during the VASP run (ISYM=-1).
* The interface currently supports only collinear-magnetism calculation
(this implies no spin-orbit coupling) and spin-polarized projectors have not
been tested.
* The converter needs the correct Fermi energy from VASP, which is read from
the LOCPROJ file. However, VASP by default does not output this information.

For VASP older than 6.5.0 the Fermi level cannot be extracted from the `vaspout.h5` file, then interface falls back to extract the Fermi level from the DOSCAR. However, if one pursues to do charge self-consistent calculations one needs to write the Fermi energy to the projectors (`LOCPROJ` file), as the DOSCAR is only updated after a full SCF/NSCF run. The file should contain the Fermi energy in the header. One can either copy the Fermi energy manually there after a successful VASP run, or modify the VASP source code slightly, by replacing the following line in `locproj.F` (around line 695):
::

< WRITE(99,'(4I6," # of spin, # of k-points, # of bands, # of proj" )') NS,NK,NB,NF
Expand All @@ -417,7 +411,6 @@ Next, we need to pass this option when calling from `electron.F` and `main.F`

Now Vasp should print in the header of the `LOCPROJ` file additionally the Fermi energy.


Another critical point for CSC calculations is the function call of
`LPRJ_LDApU` in VASP. This function is not needed, and was left there for debug
purposes, but is called every iteration. Removing the call to this function in `electron.F` in line 644 speeds up the calculation significantly in the `ICHARG=5` mode. Moreover, this prevents VASP from generating the `GAMMA` file, which should ideally only be done by the DMFT code after a successful DMFT step, and then be read by VASP.
Expand Down
11 changes: 7 additions & 4 deletions doc/guide/dftdmft_selfcons.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ Once VASP reaches the point where the projectors are generated
it creates a lock file `vasp.lock` and waits until the lock file is
removed. The shell script, in turn, waits for the VASP process and once
the lock file is created it starts a DMFT iteration. The DMFT iteration
must finish by generating a Kohn-Sham (KS) density matrix (file `GAMMA`)
and removing the lock file. The VASP process then reads in `GAMMA`
must finish by generating a Kohn-Sham (KS) density matrix (file `GAMMA` or `vaspgamma.h5`)
and removing the lock file. The VASP process then reads in `GAMMA`/`vaspgamma.h5`
and proceeds with the next iteration. PLOVasp interface provides a shell-script :program:`vasp_dmft` (in the triqs bin directory)::

vasp_dmft [-n <number of cores>] -i <number of iterations> -j <number of VASP iterations with fixed charge density> [-v <VASP version>] [-p <path to VASP directory>] [<dmft_script.py>]
Expand Down Expand Up @@ -162,14 +162,15 @@ calculations with the main difference that its functionality (apart from the
lines importing other modules) should be placed inside a function `dmft_cycle()`
which will be called every DMFT cycle and returns both the correlation energy and the SumK object.

VASP has a special INCAR `ICHARG=5` mode, that has to be switched on to make VASP wait for the `vasp.lock` file, and read the updated charge density after each step. One should add the following lines to the `INCAR` file::
VASP has a special INCAR `ICHARG=5 <https://www.vasp.at/wiki/index.php/ICHARG>`_ mode, that has to be switched on to make VASP wait for the `vasp.lock` file, and read the updated charge density after each step. One should add the following lines to the `INCAR` file::

ICHARG = 5
NELM = 1000
NELMIN = 1000
IMIX=1
BMIX=0.5
AMIX=0.02
LSYNCH5=True

Technically, VASP runs with `ICHARG=5` in a SCF mode, and adding the DMFT
changes to the DFT density in each step, so that the full DFT+DMFT charge
Expand All @@ -187,7 +188,9 @@ To understand the difference please make sure to read `ISTART flag VASP wiki
`NELMIN` ensure that VASP does not terminate after the default number of
iterations of 60.

For more detailed and fine grained methods to run Vasp in CSC also on clusters see the methods implemented in `solid dmft <https://triqs.github.io/solid_dmft/_ref/dft_managers.html>`_.
The `LSYNCH5 <https://www.vasp.at/wiki/index.php/LSYNCH5>`_ flag is set to `True` to ensure that the `vaspout.h5 <https://www.vasp.at/wiki/index.php/Vaspout.h5>`_ file can be read while VASP is running. Starting from VASP 6.5.0 all communication between VASP and TRIQS is performed through two hdf5 files: `vaspout.h5 <https://www.vasp.at/wiki/index.php/Vaspout.h5>`_ and `vaspgamma.h5 <https://www.vasp.at/wiki/index.php/Vaspgamma.h5>`_ when VASP is compiled with hdf5 support.

For more detailed and fine grained methods to run VASP in CSC also on clusters see the methods implemented in `solid dmft <https://triqs.github.io/solid_dmft/_ref/dft_managers.html>`_.


Elk
Expand Down
9 changes: 2 additions & 7 deletions doc/tutorials/nio_csc_vasp/INCAR
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
System = NiO

# for PLOT DOS
# ISMEAR = -5
# better convergence for small kpt grids
ISMEAR = 2
SIGMA = 0.05
SIGMA = 0.04

# converge wave functions
EDIFF = 1.E-7
NELMIN = 35

# the energy window to optimize projector channels (absolute)
EMIN = -3
EMAX = 10
EMAX = 12

LMAXMIX = 6

# switch off all symmetries
ISYM = -1

# project to Ni d and O p states
LORBIT = 14
LOCPROJ = "1 : d : Pr
Expand Down
29 changes: 29 additions & 0 deletions doc/tutorials/nio_csc_vasp/INCAR.CSC
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
System = NiO

# better convergence for small kpt grids
ISMEAR = 2
SIGMA = 0.05

# converge wave functions
EDIFF = 1.E-7

# the energy window to optimize projector channels (absolute)
EMIN = -3
EMAX = 10

LMAXMIX = 6

# project to Ni d and O p states
LORBIT = 14
LOCPROJ = "1 : d : Pr
2 : p : Pr"

# CSC flags
ICHARG = 5
NELM = 1000
NELMIN = 1000
NELMDL = -2
IMIX=1
BMIX=0.5
AMIX=0.02
LSYNCH5=True
7 changes: 7 additions & 0 deletions doc/tutorials/nio_csc_vasp/INCAR.CSC.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. _INCAR.CSC:

INCAR.CSC
-----------

.. literalinclude:: INCAR.CSC
:language: bash
2 changes: 1 addition & 1 deletion doc/tutorials/nio_csc_vasp/KPOINTS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Automatically generated mesh
0
Gamma
6 6 6
11 11 11
10 changes: 2 additions & 8 deletions doc/tutorials/nio_csc_vasp/NiO_local_lattice_GF.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,11 @@

filename = 'vasp'
beta = 5.0
mesh = MeshImFreq(beta=beta, S='Fermion', n_iw=1000)
mesh = MeshImFreq(beta=beta, S='Fermion', n_iw=500)

SK = SumkDFT(hdf_file = filename+'.h5', use_dft_blocks = False, mesh=mesh)


# We analyze the block structure of the Hamiltonian
Sigma = SK.block_structure.create_gf(mesh=mesh)

SK.put_Sigma([Sigma])


# Setup CTQMC Solver
n_orb = SK.corr_shells[0]['dim']
spin_names = ['up','down']
Expand Down Expand Up @@ -56,7 +50,7 @@
if block_structure:
SK.block_structure = block_structure
else:
G = SK.extract_G_loc()
G = SK.extract_G_loc(transform_to_solver_blocks=False, with_Sigma=False)
SK.analyse_block_structure_from_gf(G, threshold = 1e-3)

SK.put_Sigma(Sigma_imp = [Sigma_iw])
Expand Down
4 changes: 2 additions & 2 deletions doc/tutorials/nio_csc_vasp/maxent.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
gf = gf + G_latt['up'][iO,iO]
tm.set_G_iw(gf)
tm.omega =LinearOmegaMesh(omega_min=-20, omega_max=20, n_points=201)
tm.alpha_mesh = LogAlphaMesh(alpha_min=0.01, alpha_max=20000, n_points=60)
tm.alpha_mesh = LogAlphaMesh(alpha_min=0.01, alpha_max=20000, n_points=30)

tm.set_error(1.e-3)
result=tm.run()
result.get_A_out('LineFitAnalyzer')

if 'iteration_count' in ar['DMFT_results']:
iteration_offset = ar['DMFT_results']['iteration_count']+1
for oo in orb:
Expand Down
Loading

0 comments on commit 3c2821f

Please sign in to comment.