3
0
mirror of https://github.com/triqs/dft_tools synced 2024-06-29 16:34:53 +02:00

SVO tutorial finalized, added remarks on VASP version in VASP interface guide, added CSC guide, small typo corrections in other files

This commit is contained in:
Alexander Hampel 2019-12-04 19:19:22 -05:00
parent e26444201a
commit 18abc77e33
9 changed files with 1557 additions and 80 deletions

View File

@ -35,6 +35,9 @@ Limitations of the interface
* 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`_.
VASP: generating raw projectors
===============================
@ -58,7 +61,7 @@ for more information. The formalism for this type of projectors is presented in
<https://cms.mpi.univie.ac.at/wiki/index.php/LOCPROJ>`_.
The allowed labels of the local states defined in terms of cubic
harmonics are:
harmonics are (mind the order):
* Entire shells: `s`, `p`, `d`, `f`
@ -373,3 +376,40 @@ For two correlated sites, one can define the file as follows:
1.0 0.0 0.0 0.0 0.0
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
===============================
In the current version of the interface the Fermi energy is extracted from the
`LOCPROJ` file. 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
with:
::
WRITE(99,'(4I6,F12.7," # of spin, # of k-points, # of bands, # of proj, Efermi" )') W%WDES%NCDIJ,NK,NB,NF,EFERMI
Please make sure that mixing in VASP is turned of IMIX=0 for CSC calculations. Otherwise VASP mixes the charge density, which in the worst case removes the effect of CSC completely.
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.
Furthermore, there is an bug in `fileio.F` around line 1710 where the code tries
print out "reading the density matrix from Gamma", but this should be done only
by the master node, and VASP gets stuck sometimes. So I added a `IF (IO%IU0>=0)
THEN ... ENDIF` statement. Also, VASP gets sometimes stuck and does not write
the `OSZICAR` file correctly due to a stuck buffer. I added a flush to the
buffer to have a correctly written `OSZICAR` to extract the DFT energy. To do
so, one can add in `electron.F` around line 580 after
::
CALL STOP_TIMING("G",IO%IU6,"DOS")
two lines:
::
flush(17)
print *, ' '

View File

@ -124,28 +124,55 @@ example how such a self-consistent calculation is performed from scratch.
VASP + PLOVasp
--------------
.. warning::
This is a preliminary documentation valid for the alpha-version of the interface.
Modifications to the implementation might be introduced before the final release.
Unlike Wien2k implementation the charge self-consistent DMFT cycle in the
framework of PLOVasp interface is controlled by an external script. Because of
the specific way the DFT self-consistency is implemented in VASP the latter has
to run parallel to the DMFT script, with the synchronisation being ensured by a
lock file.
Unlike Wien2k implementation the charge self-consistent DMFT cycle
in the framework of PLOVasp interface is controlled by an external script.
Because of the specific way the DFT self-consistency is implemented in VASP
the latter has to run parallel to the DMFT script, with the synchronisation being
ensured by a lock file. PLOVasp interface provides a shell-script :program:`vasp_dmft.sh`
which takes care of the process management. The user must, however, specify a path
to VASP code and provide the DMFT Python-script.
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`
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>]
If the number of cores is not specified it is set to 1 by default.
<dmft_script.py> must provide an importable function 'dmft_cycle()'
which is invoked once per DFT+DMFT iteration. If the script name is
omitted the default name 'csc_dmft.py' is used.
If the path to VASP directory is not specified it must be provided by a
variable VASP_DIR.
Set the version of VASP by -v standard(default)/no_gamma_write to
specify if VASP writes the GAMMA file or not.
which takes care of the process management. The user must, however, specify a path to VASP code and provide the DMFT Python-script. See for an example :ref:`NiO CSC tutorial<nio_csc>`.
The user-provided script is almost the same as for Wien2k charge self-consistent
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. Another difference is the way
function `calc_density_correction()` works.
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.
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::
ICHARG = 5
NELM = 1000
NELMIN = 1000
IMIX=0
Here, the flag `IMIX=0` ensures that VASP does not mix the new charge density with previous iterations. Technically, VASP runs with `ICHARG=5` in a NSCF mode. Therefore, one needs to make sure to start with a converged `WAVECAR` file! To understand the difference please make sure to read `ISTART flag VASP wiki <https://www.vasp.at/wiki/index.php/ISTART>`_. Furthermore, the flags `NELM` and `NELMIN` ensure that VASP does not terminate after the default number of iterations of 60.
Other DFT codes
---------------
The extension to other DFT codes is straight forward. As described
The extension to other DFT codes is straightforward. As described
here, one needs to implement the correlated density matrix to be used
for the calculation of the charge density. This implementation will of
course depend on the DFT package, and might be easy to do or a quite

View File

@ -26,8 +26,8 @@ Full charge self consistency with Wien2k: :math:`\gamma`-Ce
VASP interface examples
-----------------------
Simple example: SrVO3
"""""""""""""""""""""
Simple Converter example: SrVO3
"""""""""""""""""""""""""""""""
.. toctree::
:maxdepth: 2

View File

@ -9,10 +9,10 @@ We will perform DFT+DMFT calcluations for the charge-transfer insulator NiO. We
VASP setup
-------------------------------
We start by running a simple VASP calculation to converge the charge density initially.
Use the :ref:`INCAR`, :ref:`POSCAR`, and :ref:`KPOINTS` provided and use your
Use the :ref:`INCAR`, :ref:`POSCAR`, and :ref:`KPOINTS` provided and use your
own :file:`POTCAR` file.
Let us take a look in the :file:`INCAR`, where we have to specify local orbitals as basis
Let us take a look in the :file:`INCAR`, where we have to specify local orbitals as basis
for our many-body calculation.
.. literalinclude:: images_scripts/INCAR
@ -83,6 +83,7 @@ In this part we will perform charge self-consistent DMFT calculations. To do so
ICHARG = 5
NELM = 1000
NELMIN = 1000
IMIX=0
which makes VASP wait after each step of its iterative diagonalization until the file vasp.lock is created. It then reads the update of the charge density in the file `GAMMA`. It is terminated by an external script after a desired amount of steps, such that we deactivate all automatic stoping criterion by setting the number of steps to a very high number.

View File

@ -1,30 +1,23 @@
SYSTEM = SrVO3
ENCUT = 450
NCORE = 4
LMAXMIX=6
EDIFF = 1.E-10
ICHARG=2 ! 5 for fcsc calculations (communication with python)
# DOS energy window
NEDOS = 2001
! switch off symmetries
ISYM=-1
EDIFF = 1.E-10
!! DOS energy window
NEDOS = 2001
!! Smearing procedure
# Smearing procedure
ISMEAR = -5
!! real/reci projection scheme
LREAL = .FALSE.
NCORE = 4
LMAXMIX=6
LORBIT=14
# the energy window to optimize projector channels
EMIN = 3.9
EMAX = 7.1
LOCPROJ = 2 : d : Pr
!! write WAVECAR, CHGCAR
LWAVE = .FALSE.
LCHARG = .FALSE.
# use the PAW channel optimization
LORBIT=14
# project to V d
LOCPROJ = 2 : d : Pr

View File

@ -0,0 +1,6 @@
Automatic Mesh
0
Gamma
9 9 9
0 0 0

View File

@ -0,0 +1,13 @@
SrVO3
1.0
3.8420900000 0.0000000000 0.0000000000
0.0000000000 3.8420900000 0.0000000000
0.0000000000 0.0000000000 3.8420900000
Sr V O
1 1 3
Direct
0.000000000 0.000000000 0.000000000
0.500000000 0.500000000 0.500000000
0.500000000 0.500000000 0.000000000
0.000000000 0.500000000 0.500000000
0.500000000 0.000000000 0.500000000

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 56 KiB

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 1,
"metadata": {
"nbsphinx": "hidden"
},
@ -31,44 +31,107 @@
"warnings.filterwarnings(\"ignore\") #ignore some matplotlib warnings\n",
"\n",
"# numpy\n",
"import numpy as np\n",
"\n",
"# .. _svonotebook:"
"import numpy as np"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# DFT and projections"
"In this basic example we will perform a VASP calculation for SrVO$_3$, build PLOs for the Vanadium t$_{2g}$ orbitals, and load them as SumK object, which can be then used to perform a DMFT calculation.\n",
"\n",
"## VASP setup\n",
"\n",
"First we setup the VASP [INCAR link](INCAR) file by specifing the LOCPROJ, EMIN, EMAX and LORBIT flags:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": [
"from pytriqs.archive import HDFArchive"
"```\n",
"SYSTEM = SrVO3\n",
"NCORE = 4\n",
"LMAXMIX=6\n",
"EDIFF = 1.E-10\n",
"\n",
"# DOS energy window\n",
"NEDOS = 2001\n",
"\n",
"! switch off symmetries\n",
"ISYM=-1\n",
"\n",
"# Smearing procedure\n",
"ISMEAR = -5\n",
"\n",
"# the energy window to optimize projector channels\n",
"EMIN = 3.9\n",
"EMAX = 7.1\n",
"\n",
"# use the PAW channel optimization\n",
"LORBIT=14\n",
"\n",
"# project to V d\n",
"LOCPROJ = 2 : d : Pr\n",
"```\n",
"Moreover we prepare a [KPOINTS link](KPOINTS), [POSCAR link](POSCAR), and a POTCAR file. For the POTCAR file please use the VASP provided PBE pseudopotentials: `Sr_sv`, `V`, and `O`. \n",
"\n",
"Now VASP is executed, which should converge in roughly 27 iterations. Afterwards you should find the files LOCPROJ and PROJCAR in you directory. \n",
"\n",
"## PLOVASP\n",
"\n",
"First import the PLOVASP module of DFTTools:"
]
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 2,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Starting run with 1 MPI rank(s) at : 2019-12-04 22:26:08.145620\n"
]
}
],
"source": [
"# import plovasp converter\n",
"import triqs_dft_tools.converters.plovasp.converter as plo_converter\n",
"# import VASPconverter\n",
"from triqs_dft_tools.converters.vasp_converter import *\n",
"# SumK\n",
"from triqs_dft_tools.sumk_dft_tools import SumkDFTTools"
"import triqs_dft_tools.converters.plovasp.converter as plo_converter"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Next, create a configuration file for plovasp [plo.cfg link](plo.cfg):\n",
"\n",
"```\n",
"[General]\n",
"DOSMESH = -3.0 3.0 2001\n",
"\n",
"[Shell 1]\n",
"LSHELL = 2\n",
"IONS = 2\n",
"EWINDOW = -1.4 2.0\n",
"\n",
"TRANSFORM = 1.0 0.0 0.0 0.0 0.0\n",
" 0.0 1.0 0.0 0.0 0.0\n",
" 0.0 0.0 0.0 1.0 0.0\n",
"\n",
"```\n",
"where the energy window of the t$_{2g}$ bands is specified by `EWINDOW` and the `TRANSFORM` flag picks the correct three orbitals out of the five Vanadium $d$ orbitals [see the guide for the ordering of orbitals](../../guide/conv_vasp.html). Before running PLOVASP, make sure that the Fermi energy is written in the first line of the `LOCPROJ` file, or copy it there (see the VASP [interface guide](../../guide/conv_vasp.html) for more information). The first line should look like\n",
"```\n",
"1 729 21 5 5.3834262 # of spin, # of k-points, # of bands, # of proj, Efermi\n",
"```\n",
"\n",
"Now run PLOVASP:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 28,
"metadata": {},
"outputs": [
{
@ -90,14 +153,15 @@
" Total number of tetrahedra: 4374\n",
"eigvals from LOCPROJ\n",
"\n",
" Unorthonormalized density matrices and overlaps:\n",
" Spin: 1\n",
" Site: 2\n",
" Density matrix Overlap\n",
" 0.5878638 0.0015655 -0.0003729 0.0016028 -0.0000013 0.9294189 -0.0000079 -0.0000080 -0.0000079 0.0000001\n",
" 0.0015655 0.5878216 -0.0001853 -0.0015606 0.0003205 -0.0000079 0.9294189 -0.0000041 0.0000080 0.0000068\n",
" -0.0003729 -0.0001853 0.5820729 -0.0001876 0.0000001 -0.0000080 -0.0000041 0.9715784 -0.0000036 -0.0000002\n",
" 0.0016028 -0.0015606 -0.0001876 0.5878590 -0.0003219 -0.0000079 0.0000080 -0.0000036 0.9294189 -0.0000070\n",
" -0.0000013 0.0003205 0.0000001 -0.0003219 0.5820728 0.0000001 0.0000068 -0.0000002 -0.0000070 0.9715787\n",
" Density matrix Overlap\n",
" 0.5875772 0.0015679 -0.0003707 0.0015674 0.0000000 0.9294791 -0.0000080 -0.0000078 -0.0000080 -0.0000001\n",
" 0.0015679 0.5876177 -0.0001854 -0.0016078 0.0003240 -0.0000080 0.9294790 -0.0000042 0.0000080 0.0000070\n",
" -0.0003707 -0.0001854 0.5815486 -0.0001854 -0.0000000 -0.0000078 -0.0000042 0.9715751 -0.0000038 0.0000003\n",
" 0.0015674 -0.0016078 -0.0001854 0.5876172 -0.0003240 -0.0000080 0.0000080 -0.0000038 0.9294791 -0.0000066\n",
" 0.0000000 0.0003240 -0.0000000 -0.0003240 0.5815487 -0.0000001 0.0000070 0.0000003 -0.0000066 0.9715748\n",
"\n",
" Generating 1 shell...\n",
"\n",
@ -105,32 +169,37 @@
" Orbital l : 2\n",
" Number of ions: 1\n",
" Dimension : 3\n",
" Correlated : True\n",
" Ion sort : [1]\n",
"Density matrix:\n",
" Site 1\n",
" 0.3333155 0.0021688 0.0022148\n",
" 0.0021688 0.3332635 -0.0021629\n",
" 0.0022148 -0.0021629 0.3333096\n",
" trace: 0.999888560089083\n",
" Shell 1\n",
" Site 1\n",
" 0.3332630 0.0021719 0.0021714\n",
" 0.0021719 0.3333128 -0.0022211\n",
" 0.0021714 -0.0022211 0.3333123\n",
" trace: 0.9998880790966638\n",
"\n",
" Impurity density: 0.999888560089083\n",
" Impurity density: 0.9998880790966638\n",
"\n",
"Overlap:\n",
" Site 1\n",
"[[ 1. 0. -0.]\n",
" [ 0. 1. 0.]\n",
" [-0. 0. 1.]]\n",
"[[ 1. -0. 0.]\n",
" [-0. 1. 0.]\n",
" [ 0. 0. 1.]]\n",
"\n",
"Local Hamiltonian:\n",
" Site 1\n",
" 0.5635031 0.0007530 0.0007528\n",
" 0.0007530 0.5635034 -0.0007530\n",
" 0.0007528 -0.0007530 0.5635032\n",
" Shell 1\n",
" Site 1\n",
" 0.5633806 0.0007563 0.0007563\n",
" 0.0007563 0.5633801 -0.0007559\n",
" 0.0007563 -0.0007559 0.5633801\n",
"\n",
"Evaluating DOS...\n",
" Total number of states: [[[1.99711439 1.99526935 1.99688248]]]\n",
" Shell 1\n",
" Total number of states: [[[1.99490462 0.21151785 0.00581811]]]\n",
" Storing ctrl-file...\n",
" Storing PLO-group file 'vasp.pg1'...\n",
" Density within window: 0.9999735861893001\n"
" Density within window: 0.9999741659673522\n"
]
}
],
@ -139,9 +208,25 @@
"plo_converter.generate_and_output_as_text('plo.cfg', vasp_dir='./')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"PLOVASP created one shell with three orbitals, which are equally filled by 1/3, one electron in total. Additionally we calculated the density of states. Both in VASP and PLOVASP. The later stores the data in the file pdos_x.dat, which can be simply plotted with [matplotlib](https://matplotlib.org/). The result should look similar to:\n",
"\n",
"![](svo_dos.svg)\n",
"\n",
"Here the gray area highlights the energy window for the PLOs. The total DOS of VASP (blue) coincides with the PLO DOS in the window, as we re-orthonormalized the projector functions in the given window, picking up also Oxygen weight. This setting is closed to the result of maximally localized Wannier functions created with [wannier90](http://www.wannier.org/) without running the actual minimization of the spread. Note, for a proper comparison one can use the hydrogen projector in VASP by using the the line `LOCPROJ= 2 : d : Hy`, instead of `Pr`. \n",
"\n",
"\n",
"## Converting to hdf5 file\n",
"\n",
"Finally we can run the VASP converter to create a h5 file:"
]
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 4,
"metadata": {},
"outputs": [
{
@ -161,19 +246,83 @@
}
],
"source": [
"# import VASPconverter\n",
"from triqs_dft_tools.converters.vasp_converter import *\n",
"\n",
"\n",
"# create Converter\n",
"Converter = VaspConverter(filename = 'vasp')\n",
"# run the converter\n",
"Converter.convert_dft_input()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The resulting h5 file `vasp.h5` can now be loaded as sumk object via:"
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
"sk = SumkDFTTools(hdf_file='vasp.h5')"
"# SumK\n",
"from triqs_dft_tools.sumk_dft_tools import SumkDFTTools\n",
"\n",
"SK = SumkDFTTools(hdf_file='vasp.h5', use_dft_blocks = False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here one should carefully determine the block structure manually. This is important to find degenerate orbitals and spin-channels:"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"found 1 blocks of degenerate orbitals in shell 0\n",
"block 0 consists of orbitals:\n",
" up_2\n",
" up_0\n",
" up_1\n",
" down_2\n",
" down_1\n",
" down_0\n"
]
}
],
"source": [
"Sigma = SK.block_structure.create_gf(beta=40)\n",
"SK.put_Sigma([Sigma])\n",
"G = SK.extract_G_loc()\n",
"SK.analyse_block_structure_from_gf(G, threshold = 1e-3)\n",
"for i_sh in range(len(SK.deg_shells)):\n",
" num_block_deg_orbs = len(SK.deg_shells[i_sh])\n",
" mpi.report('found {0:d} blocks of degenerate orbitals in shell {1:d}'.format(num_block_deg_orbs, i_sh))\n",
" for iblock in range(num_block_deg_orbs):\n",
" mpi.report('block {0:d} consists of orbitals:'.format(iblock))\n",
" for keys in SK.deg_shells[i_sh][iblock].keys():\n",
" mpi.report(' '+keys)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This minimal example extracts the block structure by calculating once the local Green's functions and then finds degenerate orbitals with a certain threshold in `Gloc`. Afterwards the result is reported, where 1 block is found with size 6 (3x2 orbitals for spin), where a all 6 orbitals are marked as degenerate. This is indeed correct in cubic SrVO$_3$, as all 3 t$_{2g}$ orbitals are degenerate. Note: for a magnetic calculation one has to break the symmetry between up and down at this point manually. Moreover, one can reduce the threshold for example to `1e-5` and finds that then the degeneracy of the 3 t$_{2g}$ orbitals is not found anymore, resulting in only two degenerate blocks for spin up and down, each with size 3x3.\n",
"\n",
"Afterwards the exact same DMFT script as in the [Wien2k tutorial](../srvo3.html) can be used. For a more elaborate example including charge self-consistency take a look at the [VASP NiO example](../nio_csc.html)."
]
},
{