3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-22 12:23:41 +01:00

Merge branch 'unstable' into py3

merged unstable into py3

* include the major changes of a94f8ed942
  of blockstructure.py
* adapted all code to python 3
* fixed all tests
This commit is contained in:
Alexander Hampel 2020-06-23 10:53:52 +02:00
commit f27399758e
50 changed files with 6646 additions and 243 deletions

View File

@ -34,6 +34,16 @@ DFT+DMFT
guide/dftdmft_singleshot
guide/dftdmft_selfcons
Advanced Topics
---------------
.. toctree::
:maxdepth: 2
guide/blockstructure
guide/BasisRotation
guide/soc
Postprocessing
--------------

View File

@ -0,0 +1,82 @@
.. _basisrotation:
Automatic basis rotations in DFT+DMFT
=====================================
When performing calculations with off-diagonal terms in the hybridisation function or in the local Hamiltonian, one is
often limited by the fermionic sign-problem slowing down the QMC calculations significantly. This can occur for instance if the crystal shows locally rotated or distorted cages, or when spin-orbit coupling is included. The examples for this are included in the :ref:`tutorials` of this documentation.
However, as the fermonic sign in the QMC calculation is no
physical observable, one can try to improve the calculation by rotating
to another basis. While this basis can in principle be chosen arbitrarily,
two choices which have shown good results; name the basis sets that diagonalize the local Hamiltonian or the local density matrix of the
system.
As outlined in section :ref:`blockstructure`, the :class:`BlockStructure` includes all necessary functionalities. While it is possible to manually transform each Green's functions and self energies between the *sumk* and the *solver* basis, this leads to cumbersum code and is discouraged. Instead, in order to facilitate the block-structure manipulations for an actual DFT+DMFT calculation, some of the necessary steps are automatically included automatically. As soon as the
transformation matrix is stored in the :class:`BlockStructure`, the
transformation is automatically performed when using :class:`SumkDFT`'s :meth:`extract_G_loc`,
:meth:`put_Sigma`, and :meth:`calc_dc` (see below).
Setting up the initial solver structure from DFT
------------------------------------------------
Before the actual calculation one has to specify the *solver* basis structure, in which the impurity problem will be tackled. The different available approximation were introduced in section :ref:`blockstructure`. An important feature of DFTTools is that there is an automatic way to determine the entries of the Green's function matrix that are zero by symmetry, when initialising the class::
from triqs_dft_tools.sumk_dft import *
SK = SumkDFT(hdf_file,use_dft_blocks='True')
The flag *use_dft_blocks=True* analysis the local density matrix, determines the zero entries, and sets up a minimal *solver* structure. Alternatively, this step can be achieved by (see the reference manual for options)::
SK.analyse_block_structure()
Finding the transformation matrix
---------------------------------
The SumkDFT class offers a method that can determine transformation matrices to certain new basis. It is called as follows::
SK.calculate_diagonalization_matrix(prop_to_be_diagonal='eal')
Possible option for *prop_to_be_diagonal* are *eal* (diagonalises the local hamiltonian) or *dm* (diagonalises the local density matrix). This routine stores the transformation matrix in the :class:`SK.block_structure` class, such that it can be used to rotate the basis.
Automatic transformation during the DMFT loop
---------------------------------------------
During a DMFT loop one is often switching back and forth between the unrotated basis (Sumk-Space) and the rotated basis that is used by the QMC Solver.
Once the SK.block_structure.transformation property is set as shown above, this is
done automatically, meaning that :class:`SumkDFT`'s :meth:`extract_G_loc`, :meth:`put_Sigma`, and :meth:`calc_dc` are doing the transformations by default::
for it in range(iteration_offset, iteration_offset + n_iterations):
# every GF is in solver space here
S.G0_iw << inverse(S.Sigma_iw + inverse(S.G_iw))
# solve the impurity in solver space -> hopefully better sign
S.solve(h_int = H, **p)
# calc_dc(..., transform = True) by default
SK.calc_dc(S.G_iw.density(), U_interact=U, J_hund=J, orb=0, use_dc_formula=DC_type)
# put_Sigma(..., transform_to_sumk_blocks = True) by default
SK.put_Sigma([S.Sigma_iw])
SK.calc_mu()
# extract_G_loc(..., transform_to_solver_blocks = True) by default
S.G_iw << SK.extract_G_loc()[0]
.. warning::
Before doing the DMFT self-consistency loop, one must not forget to also transform the
interaction Hamiltonian to the diagonal basis!
This can be also be done with a method of the :class:`BlockStructure` class,
namely the :meth:`convert_operator` method. Having set up a Hamiltonian in the *sumk* structure, it can easily
be transformed to the *solver* structure (including rotations of basis, picking of orbitals,
making matrices diagonal, etc) by::
H_solver = SK.block_structure.convert_operator(H_sumk)
We refer to the tutorials on how to set up the Hamiltonian H_sumk in selected cases.
Note that this transformation might generally lead to complex values in the
interaction Hamiltonian. Unless you know better and can make everything real,
you should take care of using the correct version of the TRIQS CTQMC solver.

View File

@ -0,0 +1,21 @@
5 ! Nsort
2 1 1 4 2 ! Mult(Nsort)
3 ! lmax
complex ! choice of angular harmonics
0 0 0 0 ! l included for each sort
0 0 0 0 ! If split into ireps, gives number of ireps. for a given orbital (otherwise 0)
cubic ! choice of angular harmonics
0 0 2 0 ! l included for each sort
0 0 0 0 ! If split into ireps, gives number of ireps. for a given orbital (otherwise 0)
0 ! SO flag
complex ! choice of angular harmonics
0 0 0 0 ! l included for each sort
0 0 0 0 ! If split into ireps, gives number of ireps. for a given orbital (otherwise 0)
complex ! choice of angular harmonics
0 0 0 0 ! l included for each sort
0 0 0 0 ! If split into ireps, gives number of ireps. for a given orbital (otherwise 0)
complex
0 0 0 0
0 0 0 0
-0.088 0.43 ! 0.40 gives warnings, 0.043 gives occ 1.996
0.04301

View File

@ -0,0 +1,72 @@
Sr2MgOsO6 s-o calc. M|| 0.00 0.00 1.00
B 5 87
RELA
10.507954 10.507954 14.968880 90.000000 90.000000 90.000000
ATOM -1: X=0.00000000 Y=0.50000000 Z=0.75000000
MULT= 2 ISPLIT=-2
-1: X=0.50000000 Y=0.00000000 Z=0.75000000
Sr 2+ NPT= 781 R0=.000010000 RMT= 2.50000 Z: 38.00000
LOCAL ROT MATRIX: 1.0000000 0.0000000 0.0000000
0.0000000 1.0000000 0.0000000
0.0000000 0.0000000 1.0000000
ATOM -2: X=0.00000000 Y=0.00000000 Z=0.00000000
MULT= 1 ISPLIT=-2
Os 6+ NPT= 781 R0=.000005000 RMT= 1.94 Z: 76.00000
LOCAL ROT MATRIX: 1.0000000 0.0000000 0.0000000
0.0000000 1.0000000 0.0000000
0.0000000 0.0000000 1.0000000
ATOM -3: X=0.00000000 Y=0.00000000 Z=0.50000000
MULT= 1 ISPLIT=-2
Mg 2+ NPT= 781 R0=.000100000 RMT= 1.89 Z: 12.00000
LOCAL ROT MATRIX: 1.0000000 0.0000000 0.0000000
0.0000000 1.0000000 0.0000000
0.0000000 0.0000000 1.0000000
ATOM -4: X=0.74270000 Y=0.21790000 Z=0.00000000
MULT= 4 ISPLIT= 8
-4: X=0.25730000 Y=0.78210000 Z=0.00000000
-4: X=0.21790000 Y=0.25730000 Z=0.00000000
-4: X=0.78210000 Y=0.74270000 Z=0.00000000
O 2- NPT= 781 R0=.000100000 RMT= 1.58 Z: 8.00000
LOCAL ROT MATRIX: 1.0000000 0.0000000 0.0000000
0.0000000 1.0000000 0.0000000
0.0000000 0.0000000 1.0000000
ATOM -5: X=0.00000000 Y=0.00000000 Z=0.75390000
MULT= 2 ISPLIT=-2
-5: X=0.00000000 Y=0.00000000 Z=0.24610000
O 2- NPT= 781 R0=.000100000 RMT= 1.58 Z: 8.00000
LOCAL ROT MATRIX: 1.0000000 0.0000000 0.0000000
0.0000000 1.0000000 0.0000000
0.0000000 0.0000000 1.0000000
8 NUMBER OF SYMMETRY OPERATIONS
0-1 0 0.00000000
1 0 0 0.00000000
0 0-1 0.00000000
1
-1 0 0 0.00000000
0-1 0 0.00000000
0 0-1 0.00000000
2
1 0 0 0.00000000
0 1 0 0.00000000
0 0-1 0.00000000
3
0-1 0 0.00000000
1 0 0 0.00000000
0 0 1 0.00000000
4
0 1 0 0.00000000
-1 0 0 0.00000000
0 0-1 0.00000000
5
-1 0 0 0.00000000
0-1 0 0.00000000
0 0 1 0.00000000
6
1 0 0 0.00000000
0 1 0 0.00000000
0 0 1 0.00000000
7
0 1 0 0.00000000
-1 0 0 0.00000000
0 0 1 0.00000000
8

View File

@ -0,0 +1,21 @@
5 ! Nsort
2 1 1 4 2 ! Mult(Nsort)
3 ! lmax
complex ! choice of angular harmonics
0 0 0 0 ! l included for each sort
0 0 0 0 ! If split into ireps, gives number of ireps. for a given orbital (otherwise 0)
cubic ! choice of angular harmonics
0 0 2 0 ! l included for each sort
0 0 0 0 ! If split into ireps, gives number of ireps. for a given orbital (otherwise 0)
1 ! SO flag
complex ! choice of angular harmonics
0 0 0 0 ! l included for each sort
0 0 0 0 ! If split into ireps, gives number of ireps. for a given orbital (otherwise 0)
complex ! choice of angular harmonics
0 0 0 0 ! l included for each sort
0 0 0 0 ! If split into ireps, gives number of ireps. for a given orbital (otherwise 0)
complex
0 0 0 0
0 0 0 0
-0.088 0.43 ! 0.40 gives warnings, 0.043 gives occ 1.996
0.04301

View File

@ -0,0 +1,17 @@
4 ! Nsort
2 1 2 2 ! Multiplicities
3 ! lmax
complex ! Sr
0 0 0 0
0 0 0 0
cubic ! Ru
0 0 2 0 ! include d-shell as correlated
0 0 0 0 ! there are no irreps with SO
1 ! SO-flag
complex ! O1
0 0 0 0
0 0 0 0
complex ! O2
0 0 0 0
0 0 0 0
-0.7 1.4 ! energy window (Ry)

View File

@ -0,0 +1,96 @@
Sr2RuO4 s-o calc. M|| 0.00 0.00 1.00
B 4 39_I
RELA
7.300012 7.300012 24.044875 90.000000 90.000000 90.000000
ATOM -1: X=0.00000000 Y=0.00000000 Z=0.35240000
MULT= 2 ISPLIT=-2
-1: X=0.00000000 Y=0.00000000 Z=0.64760000
Sr2+ NPT= 781 R0=.000010000 RMT= 2.26000 Z: 38.00000
LOCAL ROT MATRIX: 1.0000000 0.0000000 0.0000000
0.0000000 1.0000000 0.0000000
0.0000000 0.0000000 1.0000000
ATOM -2: X=0.00000000 Y=0.00000000 Z=0.00000000
MULT= 1 ISPLIT=-2
Ru4+ NPT= 781 R0=.000010000 RMT= 1.95000 Z: 44.00000
LOCAL ROT MATRIX: 1.0000000 0.0000000 0.0000000
0.0000000 1.0000000 0.0000000
0.0000000 0.0000000 1.0000000
ATOM -3: X=0.50000000 Y=0.00000000 Z=0.00000000
MULT= 2 ISPLIT= 8
-3: X=0.00000000 Y=0.50000000 Z=0.00000000
O 2- NPT= 781 R0=.000100000 RMT= 1.68000 Z: 8.00000
LOCAL ROT MATRIX: 1.0000000 0.0000000 0.0000000
0.0000000 1.0000000 0.0000000
0.0000000 0.0000000 1.0000000
ATOM -4: X=0.00000000 Y=0.00000000 Z=0.16350000
MULT= 2 ISPLIT=-2
-4: X=0.00000000 Y=0.00000000 Z=0.83650000
O 2- NPT= 781 R0=.000100000 RMT= 1.68000 Z: 8.00000
LOCAL ROT MATRIX: 1.0000000 0.0000000 0.0000000
0.0000000 1.0000000 0.0000000
0.0000000 0.0000000 1.0000000
16 NUMBER OF SYMMETRY OPERATIONS
0-1 0 0.00000000
1 0 0 0.00000000
0 0-1 0.00000000
1 A 2 so. oper. type orig. index
-1 0 0 0.00000000
0-1 0 0.00000000
0 0-1 0.00000000
2 A 3
1 0 0 0.00000000
0 1 0 0.00000000
0 0-1 0.00000000
3 A 6
0-1 0 0.00000000
1 0 0 0.00000000
0 0 1 0.00000000
4 A 8
0 1 0 0.00000000
-1 0 0 0.00000000
0 0-1 0.00000000
5 A 9
-1 0 0 0.00000000
0-1 0 0.00000000
0 0 1 0.00000000
6 A 11
1 0 0 0.00000000
0 1 0 0.00000000
0 0 1 0.00000000
7 A 14
0 1 0 0.00000000
-1 0 0 0.00000000
0 0 1 0.00000000
8 A 15
1 0 0 0.00000000
0-1 0 0.00000000
0 0-1 0.00000000
9 B 1
0 1 0 0.00000000
1 0 0 0.00000000
0 0-1 0.00000000
10 B 4
0-1 0 0.00000000
-1 0 0 0.00000000
0 0-1 0.00000000
11 B 5
1 0 0 0.00000000
0-1 0 0.00000000
0 0 1 0.00000000
12 B 7
-1 0 0 0.00000000
0 1 0 0.00000000
0 0-1 0.00000000
13 B 10
0 1 0 0.00000000
1 0 0 0.00000000
0 0 1 0.00000000
14 B 12
0-1 0 0.00000000
-1 0 0 0.00000000
0 0 1 0.00000000
15 B 13
-1 0 0 0.00000000
0 1 0 0.00000000
0 0 1 0.00000000
16 B 16

View File

@ -0,0 +1,15 @@
from triqs_dft_tools.converters.wien2k_converter import Wien2kConverter
from triqs_dft_tools import SumkDFTTools
filename = 'Sr2RuO4'
conv = Wien2kConverter(filename = filename,hdf_filename=filename+'.h5')
conv.convert_dft_input()
SK = SumkDFTTools(filename+'.h5')
mesh = (-10.0,10.0,500)
SK.dos_wannier_basis(broadening=(mesh[1]-mesh[0])/float(mesh[2]),
mesh=mesh,
save_to_file=True,
with_Sigma=False,
with_dc=False)

View File

@ -0,0 +1,131 @@
.. _blockstructure:
Manipulating the Green's functions block structure
==================================================
The DFTTools package includes the general :class:`BlockStructure <dft.block_structure.BlockStructure>` class for manipulating the blocks of Green's functions (see also the TRIQS documentation on BlockGF). In the following, we will introduce its basic and most commonly used functionalities that might show up in an actual DFT+DMFT calculation, and will illustrate them on a very basic fictitious problem.
The main idea is to have two structures for the Greens functions available. The first one is used in the procedures of the :class:`SumkDFT <dft.sumk_dft.SumkDFT>` to calculate Dysons equations, lattice Greens functions, and so on, and is normally a full matrix. For instance, in a calculation using :math:`t_{2g}` orbitals without spin-orbit-coupling, you have an spin-up block of size 3x3 and a spin-down block of the same size. In the following, wee will refer to this structure as *sumk* structure.
The second structure, called *solver* structure, is the one which is used for the solution of the Anderson impurity problem. As a matter of fact, in particular in combination with quantum Monte Carlo techniques, it is advisable to use as small blocks as possible in order to run into numerical problems. In particular, it should contain information about the symmetry of the local problem.
Creating a block structure and Green's function
-----------------------------------------------
For the purpose of this documentation, we focus on an example of a 3x3 Green's function, consisting of a 1x1 block and a 2x2 block (with off-diagonal coupling). This is reminiscent of a :math:`t_{2g}` manifold. Note that this initialisation is normally done automatically by DFTTools, we do it here manually for demonstration purposes only.
We can create a simple :class:`BlockStructure <dft.block_structure.BlockStructure>` object as follows::
from triqs_dft_tools import BlockStructure
BS = BlockStructure.full_structure([{'up':[0,1,2]}], None)
This creates a block structure with one 3x3 block named *up*. Note that we have not created any Green's function yet; this is just the structure of those objects. If you want to create a Green's function with this structure, you can do (we will if with some content also)::
from triqs.gf import *
GF_sumk = BS.create_gf(space='sumk', beta = 40, n_points = 1000)
GF_sumk['up'][0,0] << iOmega_n - 2.0
GF_sumk['up'][1,1] << iOmega_n + 0.5
GF_sumk['up'][2,2] << iOmega_n + 0.5
GF_sumk['up'][1,2] << 0.1
GF_sumk['up'][2,1] << 0.1
GF_sumk['up'] << inverse(GF_sumk['up'])
Technically, we use the *sumk* block structure for this Green's function. However, at this point, sumk and solver structure are still the same.
A plot of this structure looks like this. Note that there are off-diagonal elements which are exactly zero by construction.
.. image:: images_scripts/BS_GFsumk.png
:width: 600
:align: center
The *solver* structure
----------------------
The method:`BlockStructure.full_structure()` method, as we used it above to create our BlockStructure object, yields - as the name suggests - a full structure, where *sumk* and *solver* structure are identical. Now we want to take advantage of the symmetries of the problem to reduce the *solver* block structure to the relevant matrix elements only. In our case the [0,0] matrix element of the Green's function is completely decoupled from the 2x2 matrix of [1:2,1:2] elements. We simplify the *solver* structure by setting the mapping of each orbital to its target block and orbital::
BS.map_gf_struct_solver([{('up',0):('up_0',0), ('up',1):('up_1',0), ('up',2):('up_1',1)}])
This creates a *solver* structure different from the *sumk* structure. To see the result, let us look at the Green's function in the *solver* structure now::
GF_solver = BS.convert_gf(GF_sumk, space_from='sumk', space_to='solver')
This converts the GF_sumk into GF_solver, which looks like this.
.. image:: images_scripts/BS_GF_up_0.png
:width: 200
:align: center
.. image:: images_scripts/BS_GF_up_1.png
:width: 400
:align: center
As you can see, the Green's function in the *solver* structure now consists of two blocks: one 1x1 block (called *up_0*) and one 2x2 block (called *up_1*). This is no approximation, as the off-diagonal elements between these blocks are exactly zero anyway.
Picking orbitals
----------------
In some cases it might happen that for the projection to localised orbitals a full *d* or *f*-shell has to be used. However, for the Anderson impurity problem, just a subset of the orbitals are needed. This is the case, e.g., when the projection leads to completely empty or full orbitals that you don't want to include in the AIM.
For the example here, the local energy of the *up_0* block (2 eV) is higher than that of the *up_1* block (0.4 and 0.6 eV). Assuming that the chemical potential lies somewhere in the range of the *up_1* block, we might restrict our calculation to only this *up_1* block. The :class:`BlockStructure <dft.block_structure.BlockStructure>` class includes methods to pick a subset or orbitals::
BS.pick_gf_struct_solver([{'up_1':[0,1]}])
GF2 = BS.convert_gf(GF_sumk, space_from='sumk', space_to='solver')
Now the Green's function GF2 consists of only one 2x2 block, called *up_1*, as we have left out the *up_0* block.
Basis rotations
---------------
In cases where the Greens function or the local Hamiltonian shows off diagonal entries in the chosen basis, it is often beneficial to rotate to a different basis. This is of particular interest when using a QMC solver, since off-diagonal contributions lead to a famous fermionic sign problem. The :class:`BlockStructure <dft.block_structure.BlockStructure>` class includes methods to perform such basis rotations.
In our example, the local Hamiltonian is given by
.. math::
\varepsilon_{mm'} = \begin{pmatrix} 2.0 & 0.0 & 0.0 \\0.0 & -0.5 & -0.1\\0.0 & -0.1 & -0.5 \end{pmatrix}
It is easy to check that the following matrix diagonalises this local Hamiltonian:
.. math::
T_{mm'} = \begin{pmatrix} 1.0 & 0.0 & 0.0 \\0.0 & 1/\sqrt{2} & -1/\sqrt{2}\\0.0 & 1/\sqrt{2} & 1/\sqrt{2} \end{pmatrix}
With this unitary matrix, we can do a basis rotation to reduce the size of the off-diagonal matrix elements. Note that the transformation matrix has to be given in the *sumk* basis form (a 3x3 matrix in this case)::
import numpy as np
# Unitary transformation matrix
T = np.array([[1,0,0],[0,1./np.sqrt(2),-1./np.sqrt(2)],[0,1./np.sqrt(2),1./np.sqrt(2)]])
BS.transformation = [T]
GF3 = BS.convert_gf(GF_sumk, space_from='sumk', space_to='solver')
.. image:: images_scripts/BS_GF_up_1_rotated.png
:width: 400
:align: center
As you can see, the offdiagonal elements are reduced to 1e-16 in this basis. Please note that our example is not the most generic case. Normally, due to non-local hybridisation, the off-diagonals can be made smaller, but not exactly zero.
Diagonal approximation
----------------------
As said above, off diagonal contributions lead to some troubles. However,
when you are exactly sure that you know what you are doing, there is functionality to take only the diagonal parts into account in the block structure. Be careful, there is no automatic check whether this approximation is justified or not!
Starting from the rotated basis as done above, we can get rid of the off-diagonals as follows::
BS.approximate_as_diagonal()
GF4 = BS.convert_gf(GF_sumk, space_from='sumk', space_to='solver')
The Green's function GF4 consists now only of two 1x1 blocks, where *up_1* was the [0,0] element of the former 2x2 block, and *up_2* was the [1,1] element:
.. image:: images_scripts/BS_GF_up_1_rotated_diag.png
:width: 200
:align: center
.. image:: images_scripts/BS_GF_up_2_rotated_diag.png
:width: 200
:align: center
In summary, we started with a full 3x3 matrix in the very beginning, and ended with two 1x1 blocks containing the relevant matrix elements for the calculation.

View File

@ -84,6 +84,8 @@ In our `Pnma`-LaVO\ :sub:`3` example, for instance, we could use::
where the ``x=-1,1,0`` option indicates that the V--O bonds in the octahedra are
rotated by (approximatively) 45 degrees with respect to the axes of the `Pbnm` cell.
The last line of :file:`seedname.inp` is the DFT Fermi energy (in eV), which is subtracted from the onsite terms in the :file:`seedname_hr.dat` file. This is recommended since some functions in DFTTools implicitly assume a Fermi energy of 0 eV.
The converter will analyse the matrix elements of the local Hamiltonian
to find the symmetry matrices `rot_mat` needed for the global-to-local
transformation of the basis set for correlated orbitals

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -5,3 +5,4 @@
1 0 2 3 0 0 # atom, sort, l, dim, SO, irep
2 0 2 3 0 0 # atom, sort, l, dim, SO, irep
3 0 2 3 0 0 # atom, sort, l, dim, SO, irep
0.0 # DFT Fermi Energy (optional)

43
doc/guide/soc.rst Normal file
View File

@ -0,0 +1,43 @@
.. _soc:
Spin-orbit coupled calculations (single-shot)
=============================================
There are two main ways of including the spin-orbit coupling (SOC) term into
DFT+DMFT calculations:
- by performing a DFT calculation including SOC and then doing a DMFT calculation on top, or
- by performing a DFT calculation without SOC and then adding the SOC term on the model level.
The second variant is a bit more involved and needs quite some expertise, so this guide will cover only the first variant with SOC included in the DFT calculations.
Treatment of SOC in DFT
-----------------------
For now, TRIQS/DFTTools does only work with Wien2k when performing calculations with SO.
The treatment of SOC in the VASP package is fundamentally different to the way Wien2k treats it, and the interface does not handle that at the moment.
Therefore, this guide describes how to do an SOC calculation using the Wien2k DFT package.
First, a Wien2k calculation including SOC has to be performed.
For details, we refer the reader to the `documentation of Wien2k <http://susi.theochem.tuwien.ac.at/reg_user/textbooks/>`_ . As a matter of fact, we need the output for the DFT band structure for both spin directions explicitly. That means that one needs to do a spin-polarised DFT calculation with SOC, but, however, with magnetic moment set to zero. In the Wien2k initialisation procedure, one can choose for the option -nom when ``lstart`` is called. This means that the charge densities are initialised without magnetic splitting. The SOC calculation is then performed in a standard way as described in the Wien2k manual.
Performing the projection
~~~~~~~~~~~~~~~~~~~~~~~~~
Note that the final ``x lapw2 -almd -so -up`` and ``x lapw2 -almd -so -dn`` have to be run *on a single core*, which implies that, before, ``x lapw2 -up``, ``x lapw2 -dn``, and ``x lapwso -up`` have to be run in single-core mode (at least once).
In the ``case.indmftpr`` file, the spin-orbit flag has to be set to ``1`` for the correlated atoms.
For example, for the compound Sr\ :sub:`2`\ MgOsO\ :sub:`6`, with the struct file :download:`Sr2MgOsO6.struct <Sr2MgOsO6/Sr2MgOsO6.struct>`, we would, e.g., use the ``indmftpr`` file :download:`found here <Sr2MgOsO6/Sr2MgOsO6_SOC.indmftpr>`.
Then, ``dmftproj -sp -so`` has to be called.
As usual, it is important to check for warnings (e.g., about eigenvalues of the overlap matrix) in the output of ``dmftproj`` and adapt the window until these warnings disappear.
Note that in presence of SOC, it is not possible to project only onto the :math:`t_{2g}` subshell because it is not an irreducible representation.
We strongly suggest using the :py:meth:`.dos_wannier_basis` functionality of the :py:class:`.SumkDFTTools` class (see :download:`calculate_dos_wannier_basis.py <Sr2RuO4/calculate_dos_wannier_basis.py>`) and compare the Wannier-projected orbitals to the original DFT DOS (they should be more or less equal).
Note that, with SOC, there are usually off-diagonal elements of the spectral function, which can also be imaginary.
The imaginary part can be found in the third column of the files ``DOS_wann_...``.
After the projection, one can proceed with the DMFT calculation. However, two things need to be noted here. First, since the spin is not a good quantum number any more, there are off-diagonal elements in the hybridisation function and the local Hamiltonian coupling the two spin directions. This will eventually lead to a fermonic sign problem when QMC is used as a impurity solver. Second, although the :math:`e_{g}` subshell needs to be included in the projection, it can in many cases be neglected in the solution of the Anderson impurity model, after a transformation to a rotated local basis is done. This basis, diagonalising the local Hamiltonian in the presence of SOC, is often called the numerical j-basis. How rotations are performed is described in :ref:`basisrotation`, and the cutting of the orbitals in :ref:`blockstructure`.
A DMFT calculation including SOC for Sr2MgOsO6 is included in the :ref:`tutorials`.

View File

@ -9,8 +9,8 @@ The block structure can also be written to and read from HDF files.
.. warning::
Do not write the individual elements of this class to a HDF file,
as they belong together and changing one without the other can
result in unexpected results. Always write the BlockStructure
as they belong together and changing one without the other can
result in unexpected results. Always write the BlockStructure
object as a whole.
Writing the sumk_to_solver and solver_to_sumk elements
@ -19,4 +19,3 @@ The block structure can also be written to and read from HDF files.
.. autoclass:: triqs_dft_tools.block_structure.BlockStructure
:members:
:show-inheritance:

View File

@ -14,6 +14,24 @@ A simple example: SrVO3
tutorials/srvo3
Basis rotations: Sr2MgOsO6 without SOC
--------------------------------------
.. toctree::
:maxdepth: 2
tutorials/sr2mgoso6_nosoc
Sr2MgOsO6 with SOC (non-magnetic)
---------------------------------
.. toctree::
:maxdepth: 2
tutorials/sr2mgoso6_soc
Full charge self consistency with Wien2k: :math:`\gamma`-Ce
-----------------------------------------------------------

View File

@ -0,0 +1,20 @@
5 ! Nsort
2 1 1 4 2 ! Mult(Nsort)
3 ! lmax
complex ! choice of angular harmonics
0 0 0 0 ! l included for each sort
0 0 0 0 ! If split into ireps, gives number of ireps. for a given orbital (otherwise 0)
cubic ! choice of angular harmonics
0 0 2 0 ! l included for each sort
0 0 0 0 ! If split into ireps, gives number of ireps. for a given orbital (otherwise 0)
1 ! SO flag
complex ! choice of angular harmonics
0 0 0 0 ! l included for each sort
0 0 0 0 ! If split into ireps, gives number of ireps. for a given orbital (otherwise 0)
complex ! choice of angular harmonics
0 0 0 0 ! l included for each sort
0 0 0 0 ! If split into ireps, gives number of ireps. for a given orbital (otherwise 0)
complex
0 0 0 0
0 0 0 0
-0.09 0.43

View File

@ -0,0 +1,31 @@
Density Matrices for the Correlated States :
Sort = 2 Atom = 3 and Orbital l = 2
Writing the matrix as : [ block up/up | block up/dn ] with
[ block dn/up | block dn/dn ]
# For the Up/Up block :
0.003574 0.000000 0.000000 -0.000000 -0.000000 -0.000000 -0.000000 0.000000 -0.000000 -0.000000
0.000000 0.000000 0.254943 -0.000000 -0.020080 0.048438 -0.000000 -0.000000 -0.000000 -0.000000
-0.000000 0.000000 -0.020080 -0.048438 0.011530 0.000000 0.000000 -0.000000 0.000000 -0.000000
-0.000000 -0.000000 -0.000000 0.000000 0.000000 0.000000 0.363933 -0.000000 0.157594 -0.000000
-0.000000 0.000000 -0.000000 0.000000 0.000000 0.000000 0.157594 -0.000000 0.363933 -0.000000
# For the Down/Down block :
0.003574 0.000000 0.000000 0.000000 0.000000 -0.000000 -0.000000 -0.000000 0.000000 -0.000000
0.000000 -0.000000 0.254943 0.000000 0.020080 0.048438 -0.000000 0.000000 0.000000 -0.000000
0.000000 0.000000 0.020080 -0.048438 0.011530 -0.000000 -0.000000 -0.000000 0.000000 0.000000
-0.000000 0.000000 -0.000000 -0.000000 -0.000000 0.000000 0.363933 0.000000 -0.157594 -0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 -0.000000 -0.157594 -0.000000 0.363933 0.000000
# For the Up/Down block :
-0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 0.028268 0.000554 -0.028268 -0.000554
-0.000000 0.000000 -0.000000 -0.000000 -0.000000 -0.000000 -0.111512 0.018026 -0.111512 0.018026
0.000000 0.000000 -0.000000 -0.000000 -0.000000 0.000000 0.014697 0.018147 0.014697 0.018147
-0.028268 -0.000554 0.111512 -0.018026 0.014697 0.018147 -0.000000 -0.000000 0.000000 0.000000
-0.028268 -0.000554 -0.111512 0.018026 -0.014697 -0.018147 0.000000 0.000000 -0.000000 0.000000
# For the Down/Up block :
-0.000000 -0.000000 -0.000000 -0.000000 0.000000 -0.000000 -0.028268 0.000554 -0.028268 0.000554
0.000000 0.000000 -0.000000 0.000000 -0.000000 0.000000 0.111512 0.018026 -0.111512 -0.018026
0.000000 -0.000000 -0.000000 0.000000 -0.000000 -0.000000 0.014697 -0.018147 -0.014697 0.018147
0.028268 -0.000554 -0.111512 -0.018026 0.014697 -0.018147 -0.000000 0.000000 0.000000 -0.000000
-0.028268 0.000554 -0.111512 -0.018026 0.014697 -0.018147 0.000000 -0.000000 -0.000000 -0.000000
The charge of the orbital is : 1.99583

View File

@ -0,0 +1,112 @@
# Import the modules:
from triqs_dft_tools.sumk_dft import *
from triqs.gf import *
from h5 import HDFArchive
from triqs.operators.util import *
from triqs.operators.util.U_matrix import *
from triqs_cthyb import *
import triqs.utility.mpi as mpi
# Init the SumK class:
filename = 'Sr2MgOsO6_SOC.h5'
SK = SumkDFT(hdf_file=filename,use_dft_blocks=True)
# Find diagonal local basis set:
SK.calculate_diagonalization_matrix(prop_to_be_diagonal='eal',calc_in_solver_blocks=True)
###########################
# Now we pick the orbitals:
# BE CAREFUL: THIS NEEDS TO BE DONE PROPERLY
# AND IS DIFFERENT FORM CASE TO CASE!
SK.block_structure.pick_gf_struct_solver([{'ud_0': [0,1,2],'ud_1': [0,1,2]}])
###########################
# Now we set up the U matrix, first in cubic (Wien2k) convention:
U = 2.0
J = 0.2
U_sph = U_matrix(l=2, U_int=U, J_hund=J)
U_sph = np.kron(np.reshape(np.eye(2),(1,2,1,2)),np.kron(np.reshape(np.eye(2),(2,1,2,1)),U_sph))
U_mat = transform_U_matrix(U_sph, SK.T[0].conjugate())
# Now we set up the interaction Hamiltonian
h_sumk = h_int_slater(['ud'], range(10), U_mat, off_diag=True, complex=True)
# And convert it to the solver structure
h_int = SK.block_structure.convert_operator(h_sumk)
# Solver Init:
beta = 40.0
S = Solver(beta=beta, gf_struct=SK.block_structure.gf_struct_solver_list[0])
# Solver parameters:
p = {}
# solver
p["random_seed"] = 123 * mpi.rank + 567
p["length_cycle"] = 200
p["n_warmup_cycles"] = 100000
p["n_cycles"] = 3000000
# tail fit
p["perform_tail_fit"] = True
p["fit_max_moment"] = 4
p["fit_min_w"] = 4.0
p["fit_max_w"] = 8.0
# double counting correction:
dc_type = 0 # FLL
# DMFT loops:
n_loops = 1
#for first iteration, add the outout group:
if mpi.is_master_node():
with HDFArchive(filename) as ar:
if (not ar.is_group('dmft_output')):
ar.create_group('dmft_output')
for iteration_number in range(1,n_loops+1):
mpi.report("Iteration = %s"%iteration_number)
SK.set_Sigma([ S.Sigma_iw ]) # put Sigma into the SumK class
chemical_potential = SK.calc_mu( precision = 0.01 ) # find the chemical potential for given density
S.G_iw << SK.extract_G_loc()[0]
if (iteration_number==1):
# Put Hartree energy on Re Sigma
dm = S.G_iw.density()
SK.calc_dc(dm, U_interact = U, J_hund = J, orb = 0, use_dc_formula = dc_type)
S.Sigma_iw << SK.block_structure.convert_matrix(SK.dc_imp[0],space_from='sumk',space_to='solver')['ud_0'][0,0]
mpi.report("Orbital densities of local Green function :")
for s,gf in S.G_iw:
mpi.report("Orbital %s: %s"%(s,dm[s].real))
mpi.report("Total charge of Gloc : %.6f"%S.G_iw.total_density().real)
# Calculate new G0_iw to input into the solver:
S.G0_iw << S.Sigma_iw + inverse(S.G_iw)
S.G0_iw << inverse(S.G0_iw)
# Solve the impurity problem:
S.solve(h_int=h_int, **p)
# Solved. Now do post-solution stuff:
dm = S.G_iw.density()
mpi.report("Orbital densities of impurity Green function:")
for s,gf in S.G_iw:
mpi.report("Orbital %s: %s"%(s,dm[s].real))
mpi.report("Total charge of impurity problem : %.6f"%S.G_iw.total_density().real)
# Write the final Sigma and G to the hdf5 archive:
if mpi.is_master_node():
with HDFArchive(filename) as ar:
ar['dmft_output']['iterations'] = iteration_number
ar['dmft_output']['G_0'] = S.G0_iw
ar['dmft_output']['G_tau'] = S.G_tau
ar['dmft_output']['G_iw'] = S.G_iw
ar['dmft_output']['Sigma_iw_%s'%iteration_number] = S.Sigma_iw
# Set the new double counting:
dm = S.G_iw.density() # compute the density matrix of the impurity problem
SK.calc_dc(dm, U_interact = U, J_hund = J, orb = 0, use_dc_formula = dc_type)
# Save stuff into the user_data group of hdf5 archive in case of rerun:
SK.save(['chemical_potential','dc_imp','dc_energ'])

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -0,0 +1,20 @@
5 ! Nsort
2 1 1 4 2 ! Mult(Nsort)
3 ! lmax
complex ! choice of angular harmonics
0 0 0 0 ! l included for each sort
0 0 0 0 ! If split into ireps, gives number of ireps. for a given orbital (otherwise 0)
cubic ! choice of angular harmonics
0 0 2 0 ! l included for each sort
0 0 0 0 ! If split into ireps, gives number of ireps. for a given orbital (otherwise 0)
0 ! SO flag
complex ! choice of angular harmonics
0 0 0 0 ! l included for each sort
0 0 0 0 ! If split into ireps, gives number of ireps. for a given orbital (otherwise 0)
complex ! choice of angular harmonics
0 0 0 0 ! l included for each sort
0 0 0 0 ! If split into ireps, gives number of ireps. for a given orbital (otherwise 0)
complex
0 0 0 0
0 0 0 0
-0.09 0.43

View File

@ -0,0 +1,12 @@
Density Matrices for the Correlated States :
Sort = 2 Atom = 3 and Orbital l = 2
0.000739 0.000000 0.000000 0.000000 0.000000 -0.000000 -0.000000 -0.000000 0.000000 -0.000000
0.000000 -0.000000 0.502746 0.000000 0.000000 0.099298 0.000000 -0.000000 0.000000 -0.000000
0.000000 0.000000 0.000000 -0.099298 0.020434 0.000000 0.000000 -0.000000 0.000000 0.000000
-0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.735763 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000 -0.000000 0.735763 -0.000000
The charge of the orbital is : 1.99544

View File

@ -0,0 +1,117 @@
# Import the modules:
from triqs_dft_tools.sumk_dft import *
from triqs.gf import *
from h5 import HDFArchive
from triqs.operators.util import *
from triqs.operators.util.U_matrix import *
from triqs_cthyb import *
import triqs.utility.mpi as mpi
# Convert the input
from triqs_dft_tools.converters.wien2k_converter import *
Converter = Wien2kConverter(filename = "Sr2MgOsO6_noSOC")
Converter.convert_dft_input()
# Init the SumK class:
filename = 'Sr2MgOsO6_noSOC.h5'
SK = SumkDFT(hdf_file=filename,use_dft_blocks=True)
# Find diagonal local basis set:
SK.calculate_diagonalization_matrix(prop_to_be_diagonal='eal',calc_in_solver_blocks=True)
###########################
# Now we pick the orbitals:
# BE CAREFUL: THIS NEEDS TO BE DONE PROPERLY
# AND IS DIFFERENT FORM CASE TO CASE!
SK.block_structure.pick_gf_struct_solver([{'up_1': [0],'up_2': [0],'up_3': [0],'down_1': [0],'down_2': [0],'down_3': [0]}])
###########################
# Now we set up the U matrix, first in cubic Wien2k convention:
U = 2.0
J = 0.2
U_mat = U_matrix(l=2,U_int=U,J_hund=J,basis='other', T=SK.T[0].conjugate())
# Now we set up the Hamiltonian:
h_sumk = h_int_slater(['up','down'], range(5), U_mat, off_diag=True)
# And now we rotate into solver space:
h_int = SK.block_structure.convert_operator(h_sumk)
# Solver Init:
beta = 40.0
S = Solver(beta=beta, gf_struct=SK.block_structure.gf_struct_solver_list[0])
# Solver parameters:
p = {}
# solver
p["random_seed"] = 123 * mpi.rank + 567
p["length_cycle"] = 200
p["n_warmup_cycles"] = 100000
p["n_cycles"] = 1000000
# tail fit
p["perform_tail_fit"] = True
p["fit_max_moment"] = 4
p["fit_min_n"] = 30
p["fit_max_n"] = 70
# double counting correction:
dc_type = 0 # FLL
# DMFT loops:
n_loops = 1
#for first iteration, add the outout group:
if mpi.is_master_node():
with HDFArchive(filename) as ar:
if (not ar.is_group('dmft_output')):
ar.create_group('dmft_output')
for iteration_number in range(1,n_loops+1):
mpi.report("Iteration = %s"%iteration_number)
SK.symm_deg_gf(S.Sigma_iw) # symmetrizing Sigma
SK.set_Sigma([ S.Sigma_iw ]) # put Sigma into the SumK class
chemical_potential = SK.calc_mu( precision = 0.01 ) # find the chemical potential for given density
S.G_iw << SK.extract_G_loc()[0]
if (iteration_number==1):
# Put Hartree energy on Re Sigma
dm = S.G_iw.density()
SK.calc_dc(dm, U_interact = U, J_hund = J, orb = 0, use_dc_formula = dc_type)
S.Sigma_iw << SK.block_structure.convert_matrix(SK.dc_imp[0],space_from='sumk',space_to='solver')['up_1'][0,0]
mpi.report("Orbital densities of local Green function :")
for s,gf in S.G_iw:
mpi.report("Orbital %s: %s"%(s,dm[s].real))
mpi.report("Total charge of Gloc : %.6f"%S.G_iw.total_density().real)
# Calculate new G0_iw to input into the solver:
S.G0_iw << S.Sigma_iw + inverse(S.G_iw)
S.G0_iw << inverse(S.G0_iw)
# Solve the impurity problem:
S.solve(h_int=h_int, **p)
# Solved. Now do post-solution stuff:
dm = S.G_iw.density()
mpi.report("Orbital densities of impurity Green function:")
for s,gf in S.G_iw:
mpi.report("Orbital %s: %s"%(s,dm[s].real))
mpi.report("Total charge of impurity problem : %.6f"%S.G_iw.total_density().real)
# Write the final Sigma and G to the hdf5 archive:
if mpi.is_master_node():
with HDFArchive(filename) as ar:
ar['dmft_output']['iterations'] = iteration_number
ar['dmft_output']['G_0'] = S.G0_iw
ar['dmft_output']['G_tau'] = S.G_tau
ar['dmft_output']['G_iw'] = S.G_iw
ar['dmft_output']['Sigma_iw_%s'%iteration_number] = S.Sigma_iw
# Set the new double counting:
dm = S.G_iw.density() # compute the density matrix of the impurity problem
SK.calc_dc(dm, U_interact = U, J_hund = J, orb = 0, use_dc_formula = dc_type)
# Save stuff into the user_data group of hdf5 archive in case of rerun:
SK.save(['chemical_potential','dc_imp','dc_energ'])

View File

@ -0,0 +1,40 @@
Sr2MgOsO6
B 5 87
RELA
10.507954 10.507954 14.968880 90.000000 90.000000 90.000000
ATOM -1: X=0.00000000 Y=0.50000000 Z=0.75000000
MULT= 2 ISPLIT=-2
-1: X=0.50000000 Y=0.00000000 Z=0.75000000
Sr 2+ NPT= 781 R0=.000010000 RMT= 2.50000 Z: 38.00000
LOCAL ROT MATRIX: 1.0000000 0.0000000 0.0000000
0.0000000 1.0000000 0.0000000
0.0000000 0.0000000 1.0000000
ATOM -2: X=0.00000000 Y=0.00000000 Z=0.00000000
MULT= 1 ISPLIT=-2
Os 6+ NPT= 781 R0=.000005000 RMT= 1.94 Z: 76.00000
LOCAL ROT MATRIX: 1.0000000 0.0000000 0.0000000
0.0000000 1.0000000 0.0000000
0.0000000 0.0000000 1.0000000
ATOM -3: X=0.00000000 Y=0.00000000 Z=0.50000000
MULT= 1 ISPLIT=-2
Mg 2+ NPT= 781 R0=.000100000 RMT= 1.89 Z: 12.00000
LOCAL ROT MATRIX: 1.0000000 0.0000000 0.0000000
0.0000000 1.0000000 0.0000000
0.0000000 0.0000000 1.0000000
ATOM -4: X=0.74270000 Y=0.21790000 Z=0.00000000
MULT= 4 ISPLIT= 8
-4: X=0.25730000 Y=0.78210000 Z=0.00000000
-4: X=0.21790000 Y=0.25730000 Z=0.00000000
-4: X=0.78210000 Y=0.74270000 Z=0.00000000
O 2- NPT= 781 R0=.000100000 RMT= 1.58 Z: 8.00000
LOCAL ROT MATRIX: 1.0000000 0.0000000 0.0000000
0.0000000 1.0000000 0.0000000
0.0000000 0.0000000 1.0000000
ATOM -5: X=0.00000000 Y=0.00000000 Z=0.75390000
MULT= 2 ISPLIT=-2
-5: X=0.00000000 Y=0.00000000 Z=0.24610000
O 2- NPT= 781 R0=.000100000 RMT= 1.58 Z: 8.00000
LOCAL ROT MATRIX: 1.0000000 0.0000000 0.0000000
0.0000000 1.0000000 0.0000000
0.0000000 0.0000000 1.0000000
0 NUMBER OF SYMMETRY OPERATIONS

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

View File

@ -0,0 +1,213 @@
.. _Sr2MgOsO6_noSOC:
Here we will discuss a calculation where off-diagonal matrix elements show up, and will discuss step-by-step how this calculation can be set up.
The full script for this calculation is also provided here (:download:`Sr2MgOsO6_noSOC.py <images_scripts/Sr2MgOsO6_noSOC.py>`).
Note that we do not include spin-orbit coupling here for pedagogical reasons. For the real material it is necessary to include also SOC.
DFT (Wien2k) and Wannier orbitals
=================================
DFT setup
---------
First, we do a DFT calculation, using the Wien2k package. As main input file we have to provide the so-called struct file :file:`Sr2MgOs6_noSOC.struct`. We use the following:
.. literalinclude:: images_scripts/Sr2MgOsO6_noSOC.struct
The DFT calculation is done as usual, for instance you can use for the initialisation
init -b -vxc 5 -numk 2000
This is setting up a non-magnetic calculation, using the LDA and 2000 k-points in the full Brillouin zone. As usual, we start the DFT self consistent cycle by the Wien2k script ::
run
After the SC cycled finished, you can calculate the DOS. It should look like what you can see in this figure:
.. image:: images_scripts/Sr2MgOsO6_noSOC_DOS.png
:width: 700
:align: center
Wannier orbitals
----------------
As a next step, we calculate localised orbitals for the d orbitals. We use this input file for :program:`dmftproj`:
.. literalinclude:: images_scripts/Sr2MgOsO6_noSOC.indmftpr
Note that, due to the distortions in the crystal structure, we need to include all five d orbitals in the calculation (line 8 in the input file above). The projection window is set such that all d orbitals are included.
To prepare the input data for :program:`dmftproj` we execute lapw2 with the `-almd` option ::
x lapw2 -almd
Then :program:`dmftproj` is executed in its default mode (i.e. without spin-polarization or spin-orbit included) ::
dmftproj
At the end of the run you see the density matrix in Wannier space:
.. literalinclude:: images_scripts/Sr2MgOsO6_noSOC.outdmftpr
As you can see, there are off-diagonal elements between the :math:`d_{x^2-y^2}` and the :math:`d_{xy}` orbital.
We convert the output to the hdf5 archive, using
the python module :class:`Wien2kConverter <dft.converters.wien2k_converter.Wien2kConverter>`. A simple python script doing this is::
from triqs_dft_tools.converters.wien2k_converter import *
Converter = Wien2kConverter(filename = "Sr2MgOsO6_noSOC")
Converter.convert_dft_input()
This reads all the data, and stores everything that is necessary for the DMFT calculation in the file :file:`Sr2MgOsO6_noSOC.h5`.
The DMFT calculation
====================
Rotating the basis
------------------
Before starting the DMFT calculation it is beneficial to look a bit more closely at the block structure of the problem. Eventually, we want to use a basis that is as diagonal as possible, and include only the partially filled orbitals in the correlated problem. All this can be done using the functionalities of the :class:`BlockStructure <dft.block_structure.BlockStructure>` class, see section :ref:`blockstructure`.
We first initialise the SumK class::
from triqs_dft_tools.sumk_dft import *
SK = SumkDFT(hdf_file='Sr2MgOsO6_noSOC.h5',use_dft_blocks=True)
The flag *use_dft_blocks=True* determines, as usual, the smallest possible blocks with non-zero entries, and initialises them as *solver* block structure. In order to disentangle the :math:`d_{x^2-y^2}` and the :math:`d_{xy}` orbitals, and pick out only the partially filled one, we do a transformation into a basis where the local Hamiltonian is diagonal::
mat = SK.calculate_diagonalization_matrix(prop_to_be_diagonal='eal',calc_in_solver_blocks=True)
We can look at the diagonalisation matrix, it is::
>>> print mat[0]['down']
[[ 1. +0.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j ]
[ 0. +0.j -0.985+0.j 0. -0.173j 0. +0.j 0. +0.j ]
[ 0. +0.j 0.173+0.j 0. -0.985j 0. +0.j 0. +0.j ]
[ 0. +0.j 0. +0.j 0. +0.j 1. +0.j 0. +0.j ]
[ 0. +0.j 0. +0.j 0. +0.j 0. +0.j 1. +0.j ]]
>>>
This transformation is already stored in the SK.block_structure class. The next step is actually not needed for a DMFT calculation, but it is good to do this check to see what the transformation does to the local Hamiltonian. We can calculate it before rotation, rotate it, and look at the 2x2 block with and without off-diagonals::
eal = SK.eff_atomic_levels()
eal2 = SK.block_structure.convert_matrix(eal[0],space_from='sumk', space_to='solver')
print eal[0]['up'][1:3,1:3] # prints the 2x2 block with offiagonals
[[ 0.391+0.j -0. -0.815j]
[-0. +0.815j 4.884-0.j ]]
print eal2['up_1'] # prints the 2x2 block after rotation
[[0.247-0.j 0. +0.j]
[0. -0.j 5.028+0.j]]
So the local Hamiltonian has been diagonalised. From the other entries we can see that the *up_0* block and the [1,1] entry of the *up_1* block correspond to :math:`e_g`-like orbitals, and the others are the
:math:`t_{2g}` orbitals that we want to keep. So we pick the according orbitals in the block structure::
SK.block_structure.pick_gf_struct_solver([{'up_1': [0],'up_2': [0],'up_3': [0],'down_1': [0],'down_2': [0],'down_3': [0]}])
We can now look at the final result::
print SK.block_structure.convert_matrix(eal[0],space_from='sumk',space_to='solver')
{'up_2': array([[0.156-0.j]]), 'up_3': array([[0.156-0.j]]), 'up_1': array([[0.247-0.j]]), 'down_3': array([[0.156-0.j]]), 'down_2': array([[0.156-0.j]]), 'down_1': array([[0.247-0.j]])}
We see that we arrived at a structure with 3 orbitals per spin only, and blocks of size 1x1.
The interaction Hamiltonian
---------------------------
We now set up the interaction Hamiltonian. Since we want to rotate the interaction matrix into the local basis, we are using the Slater convention for it::
from triqs.operators.util import *
from triqs.operators.util.U_matrix import *
U = 2.0
J = 0.2
U_mat = U_matrix(l=2,U_int=U,J_hund=J,basis='other', T=SK.T[0].conjugate())
In the last line we use the Wien2k convention to write the U matrix in the cubic harmonics. Next, we want to set up a Hamiltonian and rotate it into the *solver* basis::
h_sumk = h_int_slater(['up','down'], range(5), U_mat, off_diag=True)
h_int = SK.block_structure.convert_operator(h_sumk)
h_int = h_int.real
Note that we needed to set up the interaction Hamiltonian for the full set of five *d* orbitals. The :meth:`convert_operator` method then takes care of rotating and picking the relevant orbitals. In the last line above we made the Hamiltonian real, since we know it this case that there are only real numbers in the interaction Hamiltonian. Note that this is not generally the case!
Now we have the interaction Hamiltonian for the solver, which we set up next::
from triqs_cthyb import *
import triqs.utility.mpi as mpi
beta = 40.0
S = Solver(beta=beta, gf_struct=SK.block_structure.gf_struct_solver_list[0])
# Solver parameters:
p = {}
# solver
p["random_seed"] = 123 * mpi.rank + 567
p["length_cycle"] = 200
p["n_warmup_cycles"] = 100000
p["n_cycles"] = 1000000
# tail fit
p["perform_tail_fit"] = True
p["fit_max_moment"] = 4
p["fit_min_n"] = 40
p["fit_max_n"] = 100
The DMFT loop with automatic basis rotations
--------------------------------------------
After these initialisation steps, the formal DMFT cycle is very similar to a calculation without these basis rotations, since these rotations are done automatically, once the :class:`BlockStructure` property *transformation* is set, see :ref:`basisrotation`.
The DMFT loop itself looks very much the same as in :ref:`SrVO3`::
# double counting correction:
dc_type = 0 # FLL
# DMFT loops:
n_loops = 1
for iteration_number in range(1,n_loops+1):
mpi.report("Iteration = %s"%iteration_number)
SK.symm_deg_gf(S.Sigma_iw) # symmetrizing Sigma
SK.set_Sigma([ S.Sigma_iw ]) # put Sigma into the SumK class
chemical_potential = SK.calc_mu( precision = 0.01 ) # find the chemical potential for given density
S.G_iw << SK.extract_G_loc()[0]
if (iteration_number==1):
# Put Hartree energy on Re Sigma
dm = S.G_iw.density()
SK.calc_dc(dm, U_interact = U, J_hund = J, orb = 0, use_dc_formula = dc_type)
S.Sigma_iw << SK.block_structure.convert_matrix(SK.dc_imp[0],space_from='sumk',space_to='solver')['up_1'][0,0]
# Calculate new G0_iw to input into the solver:
S.G0_iw << S.Sigma_iw + inverse(S.G_iw)
S.G0_iw << inverse(S.G0_iw)
# Solve the impurity problem:
S.solve(h_int=h_int, **p)
# Solved. Now do post-solution stuff:
# Set the new double counting:
dm = S.G_iw.density() # compute the density matrix of the impurity problem
SK.calc_dc(dm, U_interact = U, J_hund = J, orb = 0, use_dc_formula = dc_type)
# Save stuff into the user_data group of hdf5 archive in case of rerun:
SK.save(['chemical_potential','dc_imp','dc_energ'])
The only difference to the other example is in the initialisation of the real part of the self energy. We cannot just take an element of the *dc_imp* array, since this array is stored in the *sumk* structure. Therefore, we first need to transform this matrix into *solver* space, and then take the appropriate matrix element. After the first iteration (here done with 24e6 MC sweeps and using the real version of the CTMQC solver), you should get self energies like this:
.. image:: images_scripts/Sr2MgOsO6_noSOC_Sigmas.png
:width: 600
:align: center
The two :math:`d_{xz}` and :math:`d_{yz}` orbitals are degenerate (blocks *up_2* and *up_3*), whereas the :math:`d_{xy}`-like orbital is different.
A complete python script for this tutorial, including some more input/output, is available (:download:`Sr2MgOsO6_noSOC.py <images_scripts/Sr2MgOsO6_noSOC.py>`). When running the script, you will encounter warnings during the transformation from the *sumk* to the *solver* basis. These warnings just reflect that the off-diagonal elements of the full Greens function are not zero at all frequencies, although the local Hamiltonian is. In that sense, we still do an approximation when restricting ourselves to the :math:`t_{2g}`-like orbitals.

View File

@ -0,0 +1,227 @@
.. _Sr2MgOsO6_SOC:
In this tutorial we will discuss how to set up and perform a calculation including spin-orbit coupling. As an example, we again take Sr2MgOsO6, as we used for the discussion of basis rotations (:ref:`Sr2MgOsO6_noSOC`).
The full script for this calculation is also provided here (:download:`Sr2MgOsO6_SOC.py <images_scripts/Sr2MgOsO6_SOC.py>`).
DFT (Wien2k) and Wannier orbitals
=================================
DFT setup
---------
First, we do the DFT calculation, using the Wien2k package. As main input file we have to provide the struct file :file:`Sr2MgOs6_noSOC.struct`:
.. literalinclude:: images_scripts/Sr2MgOsO6_noSOC.struct
The struct file is the same as for non SOC calculations. However, the DFT calculation is done a bit differently now. First, we need to do a spin-polarised DFT calculation, but with magnetic moment set to zero. In the Wien2k initialisation procedure, one can choose for the option -nom when ``lstart`` is called. This means that the charge densities are initialised without magnetic splitting. After initialisation, do a full SC DFT run::
runsp
After this SC cycled finished, we continue with the spin-orbit calculation. We initialise it with the Wien2k command::
init_so
In this initialisation procedure, be sure to select a spin-polarised calculation. Then the SC cycle including SOC is done by::
runsp -so
After the SC cycled finished, you can calculate the DOS with SOC iuncluded. It should look like what you can see in this figure:
.. image:: images_scripts/Sr2MgOsO6_SOC_DOS.png
:width: 700
:align: center
Wannier orbitals
----------------
As a next step, we calculate localised orbitals for the d orbitals. We use this input file for :program:`dmftproj`:
.. literalinclude:: images_scripts/Sr2MgOsO6_SOC.indmftpr
Note that, due to the distortions in the crystal structure and the SOC, we include all five d orbitals in the calculation (line 8 in the input file above). The projection window is set such that all d orbitals are included.
To prepare the input data for :program:`dmftproj` we execute lapw2 with the following options::
x lapw2 -up -c -so -almd
x lapw2 -dn -c -so -almd
Then :program:`dmftproj` is executed for SOC::
dmftproj -sp -so
At the end of the run you see the density matrix in Wannier space:
.. literalinclude:: images_scripts/Sr2MgOsO6_SOC.outdmftpr
As you can see, there are a lot of off-diagonal elements now, in particular also off-diagonal in spin space. This is just telling us that spin is not a good quantum number any more in the presence of SOC.
We convert the output to the hdf5 archive, using
the python module :class:`Wien2kConverter <dft.converters.wien2k_converter.Wien2kConverter>`. A simple python script doing this is::
from triqs_dft_tools.converters.wien2k_converter import *
Converter = Wien2kConverter(filename = "Sr2MgOsO6_SOC")
Converter.convert_dft_input()
This reads all the data, and stores everything that is necessary for the DMFT calculation in the file :file:`Sr2MgOsO6_SOC.h5`.
The DMFT calculation
====================
Rotating the basis
------------------
Before starting the DMFT calculation it is beneficial to look a bit more closely at the block structure of the problem. Eventually, we want to use a basis that is as diagonal as possible, and include only the partially filled orbitals in the correlated problem. All this can be done using the functionalities of the :class:`BlockStructure <dft.block_structure.BlockStructure>` class, see section :ref:`blockstructure`.
We first initialise the SumK class::
from triqs_dft_tools.sumk_dft import *
SK = SumkDFT(hdf_file='Sr2MgOsO6_SOC.h5',use_dft_blocks=True)
The flag *use_dft_blocks=True* determines, as usual, the smallest possible blocks with non-zero entries, and initialises them as *solver* block structure. We want to work in the basis that diagonalises the local Hamiltonian, which is often referred to as numerical j-basis. The transformation into this basis is calculated by::
mat = SK.calculate_diagonalization_matrix(prop_to_be_diagonal='eal',calc_in_solver_blocks=True)
This transformation is stored in the SK.block_structure class and can be used to transform Greens function or operators. The next step is actually not needed for a DMFT calculation, but it is good to do this check to see what the transformation does to the local Hamiltonian. Note that in case of SOC, although spin is not a good quantum number any more, there are two blocks of size 5x5, each corresponding to negative/positive :math:`m_j` values::
eal = SK.eff_atomic_levels()
eal2 = SK.block_structure.convert_matrix(eal[0],space_from='sumk', space_to='solver')
print eal2['ud_0'].diagonal().real. # diagonal of the first 5x5 block
[0.071 0.131 0.608 4.572 5.128]
print eal2['ud_1'].diagonal().real. # diagonal of the second 5x5 block
[0.071 0.131 0.608 4.572 5.128]
We see that the orbitals are ordered from low to high energy, which makes picking the orbitals around the Fermi level quite easy. We just take indices 0 to 2::
SK.block_structure.pick_gf_struct_solver([{'ud_0': [0,1,2],'ud_1': [0,1,2]}])
We can now look at the final result::
eal3 = SK.block_structure.convert_matrix(eal[0],space_from='sumk', space_to='solver')
print eal3['ud_0']
[[ 0.071+0.j 0. +0.j -0. -0.j]
[-0. -0.j 0.131+0.j -0. -0.j]
[-0. +0.j 0. +0.j 0.608-0.j]]
print eal3['ud_1']
[[ 0.071+0.j -0. -0.j 0. +0.j]
[-0. +0.j 0.131-0.j 0. +0.j]
[ 0. -0.j 0. -0.j 0.608+0.j]]
We see that we arrived at a diagonal structure with two blocks of size 3x3, and we have picked the orbitals around the Fermi level.
The interaction Hamiltonian
---------------------------
We now set up the interaction Hamiltonian. Since we want to rotate the interaction matrix into the local basis, we are using the Slater convention for it. We use *l=2* for *d* orbitals. Also, for SOC calculations, we need to inflate the resulting matrix to size 10x10::
from triqs.operators.util import *
from triqs.operators.util.U_matrix import *
U = 2.0
J = 0.2
U_sph = U_matrix(l=2, U_int=U, J_hund=J)
U_sph = np.kron(np.reshape(np.eye(2),(1,2,1,2)),np.kron(np.reshape(np.eye(2),(2,1,2,1)),U_sph)) # inflating the matrix
U_mat = transform_U_matrix(U_sph, SK.T[0].conjugate())
In the last line we use the Wien2k convention to write the U matrix in the cubic harmonics. Next, we want to set up a Hamiltonian and rotate it into the *solver* basis::
h_sumk = h_int_slater(['ud'], range(2*(2*l+1)), U_mat, off_diag=True, complex=True)
h_int = SK.block_structure.convert_operator(h_sumk)
Note that we needed to set up the interaction Hamiltonian first for the full set of *d* orbitals. The :meth:`convert_operator` method then takes care of rotating and picking the relevant orbitals.
Now we have the interaction Hamiltonian for the solver, which we set up next::
from triqs_cthyb import *
import triqs.utility.mpi as mpi
beta = 40.0
S = Solver(beta=beta, gf_struct=SK.block_structure.gf_struct_solver_list[0])
# Solver parameters:
p = {}
# solver
p["random_seed"] = 123 * mpi.rank + 567
p["length_cycle"] = 200
p["n_warmup_cycles"] = 100000
p["n_cycles"] = 1000000
# tail fit
p["perform_tail_fit"] = True
p["fit_max_moment"] = 4
p["fit_min_w"] = 4.0
p["fit_max_w"] = 8.0
The DMFT loop with automatic basis rotations
--------------------------------------------
After these initialisation steps, the formal DMFT cycle is very similar to a calculation without SOC, since the rotations are done automatically, once the :class:`BlockStructure` property *transformation* is set, see :ref:`basisrotation`.
The DMFT loop itself looks very much the same as in :ref:`SrVO3` or :ref:`Sr2MgOsO6_noSOC`::
# double counting correction:
dc_type = 0 # FLL
# DMFT loops:
n_loops = 1
for iteration_number in range(1,n_loops+1):
mpi.report("Iteration = %s"%iteration_number)
SK.set_Sigma([ S.Sigma_iw ]) # put Sigma into the SumK class
chemical_potential = SK.calc_mu( precision = 0.01 ) # find the chemical potential for given density
S.G_iw << SK.extract_G_loc()[0]
if (iteration_number==1):
# Put Hartree energy on Re Sigma
dm = S.G_iw.density()
SK.calc_dc(dm, U_interact = U, J_hund = J, orb = 0, use_dc_formula = dc_type)
S.Sigma_iw << SK.block_structure.convert_matrix(SK.dc_imp[0],space_from='sumk',space_to='solver')['ud_0'][0,0]
# Calculate new G0_iw to input into the solver:
S.G0_iw << S.Sigma_iw + inverse(S.G_iw)
S.G0_iw << inverse(S.G0_iw)
# Solve the impurity problem:
S.solve(h_int=h_int, **p)
# Solved. Now do post-solution stuff:
# Set the new double counting:
dm = S.G_iw.density() # compute the density matrix of the impurity problem
SK.calc_dc(dm, U_interact = U, J_hund = J, orb = 0, use_dc_formula = dc_type)
# Save stuff into the user_data group of hdf5 archive in case of rerun:
SK.save(['chemical_potential','dc_imp','dc_energ'])
The only difference to the other example is in the initialisation of the real part of the self energy. We cannot just take an element of the *dc_imp* array, since this array is stored in the *sumk* structure. Therefore, we first need to transform this matrix into *solver* space, and then take the appropriate matrix element. After the first iteration (here done with 18e6 MC sweeps), you should get this output at the end of the run::
Total number of measures: 18000000
Average sign: (0.884535,-4.11253e-06)
Orbital densities of impurity Green function:
Orbital ud_0:
[[ 5.20045070e-01 -8.24863778e-10 5.95348202e-12]
[-8.24863778e-10 4.30734642e-01 -1.29359496e-03]
[ 5.95348202e-12 -1.29359496e-03 4.80477133e-02]]
Orbital ud_1:
[[ 5.24181422e-01 2.22991244e-09 -8.16290063e-10]
[ 2.22991244e-09 4.30431196e-01 2.19004569e-03]
[-8.16290063e-10 2.19004569e-03 4.77161009e-02]]
Total charge of impurity problem : 2.001156
We see that there is a small sign problem due to the off-diagonal elements in the hybridisation function. However, this sign problem is treatable, since we have rotated into the local basis where these off-diagonal elements are minimised.
The imaginary part of the self energy matrix of the *ud_0* block looks like this:
.. image:: images_scripts/Sr2MgOsO6_SOC_Sigmas.png
:width: 600
:align: center
Plotted on the same scale, the off-diagonal elements are very small, only the *(1,2)* and *(2,1)* elements are visibly different from zero.
A complete python script for this tutorial, including some more input/output, is available (:download:`Sr2MgOsO6_SOC.py <images_scripts/Sr2MgOsO6_SOC.py>`). When running the script, you will encounter warnings during the transformation from the *sumk* to the *solver* basis. These warnings just reflect that the off-diagonal elements of the full Greens function are not zero at all frequencies, although the local Hamiltonian is. In that sense, we still do an approximation when restricting ourselves to the low-energy subset.

File diff suppressed because it is too large Load Diff

View File

@ -189,9 +189,9 @@ def generate_plo(conf_pars, el_struct):
print(" Shell %i"%(ish + 1))
loc_ham = pshells[pgroup.ishells[ish]].local_hamiltonian(el_struct)
for io in range(loc_ham.shape[1]):
print(" Site %i"%(io + 1))
print(" Site %i (real | complex part)"%(io + 1))
for row in loc_ham[:, io, :, :].sum(0):
print(''.join(map("{0:14.7f}".format, row)))
print(''.join(map("{0:14.7f}".format, row.real))+' |'+''.join(map("{0:14.7f}".format, row.imag)))
# END DEBUG output
if 'dosmesh' in conf_pars.general:
print()

View File

@ -363,7 +363,7 @@ class ProjectorShell:
assert site_diag, "site_diag = False is not implemented"
assert spin_diag, "spin_diag = False is not implemented"
loc_ham = np.zeros((ns, nion, nlm, nlm), dtype=np.float64)
loc_ham = np.zeros((ns, nion, nlm, nlm), dtype=np.complex128)
# self.proj_win = np.zeros((nion, ns, nk, nlm, nb_max), dtype=np.complex128)
kweights = el_struct.kmesh['kweights']
@ -376,7 +376,7 @@ class ProjectorShell:
for io in range(nion):
proj_k = self.proj_win[io, isp, ik, ...]
loc_ham[isp, io, :, :] += np.dot(proj_k * (eigk - el_struct.efermi),
proj_k.conj().T).real * weight
proj_k.conj().T) * weight
# if not symops is None:
# occ_mats = symmetrize_matrix_set(occ_mats, symops, ions, perm_map)

View File

@ -142,6 +142,10 @@ class Wannier90Converter(ConverterTools):
# l, dim, SO flag, irep):
corr_shells = [{name: int(val) for name, val in zip(
corr_shell_entries, R)} for icrsh in range(n_corr_shells)]
try:
self.fermi_energy = R.next()
except:
self.fermi_energy = 0.
except StopIteration: # a more explicit error if the file is corrupted.
mpi.report(self._name + ": reading input file %s failed!" %
self.inp_file)
@ -443,7 +447,10 @@ class Wannier90Converter(ConverterTools):
"Inconsistent indices for R vector n. %s" % ir)
# fill h_of_r with the matrix elements of the Hamiltonian
h_of_r[ir][ii, jj] = complex(float(cline[5]), float(cline[6]))
if not numpy.any(rcurr) and ii == jj:
h_of_r[ir][ii, jj] = complex(float(cline[5]) - self.fermi_energy, float(cline[6]))
else:
h_of_r[ir][ii, jj] = complex(float(cline[5]), float(cline[6]))
except ValueError:
mpi.report("Wrong data or structure in file %s" % hr_filename)

View File

@ -3,6 +3,7 @@
#
# TRIQS: a Toolbox for Research in Interacting Quantum Systems
#
# Copyright (C) 2018 by G. J. Kraberger
# Copyright (C) 2011 by M. Aichhorn, L. Pourovskii, V. Vildosola
#
# TRIQS is free software: you can redistribute it and/or modify it under the
@ -50,11 +51,11 @@ class SumkDFT(object):
hdf_file : string
Name of hdf5 containing the data.
h_field : scalar, optional
The value of magnetic field to add to the DFT Hamiltonian.
The value of magnetic field to add to the DFT Hamiltonian.
The contribution -h_field*sigma is added to diagonal elements of the Hamiltonian.
It cannot be used with the spin-orbit coupling on; namely h_field is set to 0 if self.SO=True.
use_dft_blocks : boolean, optional
If True, the local Green's function matrix for each spin is divided into smaller blocks
If True, the local Green's function matrix for each spin is divided into smaller blocks
with the block structure determined from the DFT density matrix of the corresponding correlated shell.
Alternatively and additionally, the block structure can be analysed using :meth:`analyse_block_structure <dft.sumk_dft.SumkDFT.analyse_block_structure>`
@ -62,7 +63,7 @@ class SumkDFT(object):
dft_data : string, optional
Name of hdf5 subgroup in which DFT data for projector and lattice Green's function construction are stored.
symmcorr_data : string, optional
Name of hdf5 subgroup in which DFT data on symmetries of correlated shells
Name of hdf5 subgroup in which DFT data on symmetries of correlated shells
(symmetry operations, permutaion matrices etc.) are stored.
parproj_data : string, optional
Name of hdf5 subgroup in which DFT data on non-normalized projectors for non-correlated
@ -93,6 +94,8 @@ class SumkDFT(object):
self.misc_data = misc_data
self.h_field = h_field
self.block_structure = BlockStructure()
# Read input from HDF:
things_to_read = ['energy_unit', 'n_k', 'k_dep_projection', 'SP', 'SO', 'charge_below', 'density_required',
'symm_op', 'n_shells', 'shells', 'n_corr_shells', 'corr_shells', 'use_rotations', 'rot_mat',
@ -121,8 +124,6 @@ class SumkDFT(object):
self.spin_names_to_ind[iso][
self.spin_block_names[iso][isp]] = isp * self.SP
self.block_structure = BlockStructure()
# GF structure used for the local things in the k sums
# Most general form allowing for all hybridisation, i.e. largest
# blocks possible
@ -151,14 +152,14 @@ class SumkDFT(object):
self.chemical_potential = 0.0 # initialise mu
self.init_dc() # initialise the double counting
# charge mixing parameters
self.charge_mixing = False
# defaults from PRB 90 235103 ("... slow but stable convergence ...")
self.charge_mixing_alpha = 0.1
self.charge_mixing_gamma = 1.0
self.deltaNOld = None
# Analyse the block structure and determine the smallest gf_struct
# blocks and maps, if desired
if use_dft_blocks:
@ -192,7 +193,7 @@ class SumkDFT(object):
# initialise variables on all nodes to ensure mpi broadcast works at
# the end
for it in things_to_read:
setattr(self, it, 0)
setattr(self, it, None)
subgroup_present = 0
if mpi.is_master_node():
@ -295,10 +296,10 @@ class SumkDFT(object):
bname : string
Block name of the target block of the lattice Green's function.
gf_to_downfold : Gf
gf_to_downfold : Gf
Block of the Green's function that is to be downfolded.
gf_inp : Gf
FIXME
gf_inp : Gf
FIXME
shells : string, optional
- if shells='corr': orthonormalized projectors for correlated shells are used for the downfolding.
@ -350,10 +351,10 @@ class SumkDFT(object):
bname : string
Block name of the target block of the lattice Green's function.
gf_to_upfold : Gf
gf_to_upfold : Gf
Block of the Green's function that is to be upfolded.
gf_inp : Gf
FIXME
gf_inp : Gf
FIXME
shells : string, optional
- if shells='corr': orthonormalized projectors for correlated shells are used for the upfolding.
@ -401,10 +402,10 @@ class SumkDFT(object):
- if shells='corr': ish labels all correlated shells (equivalent or not)
- if shells='all': ish labels only representative (inequivalent) non-correlated shells
gf_to_rotate : Gf
gf_to_rotate : Gf
Block of the Green's function that is to be rotated.
direction : string
The direction of rotation can be either
The direction of rotation can be either
- 'toLocal' : global -> local transformation,
- 'toGlobal' : local -> global transformation.
@ -454,7 +455,7 @@ class SumkDFT(object):
def lattice_gf(self, ik, mu=None, iw_or_w="iw", beta=40, broadening=None, mesh=None, with_Sigma=True, with_dc=True):
r"""
Calculates the lattice Green function for a given k-point from the DFT Hamiltonian and the self energy.
Calculates the lattice Green function for a given k-point from the DFT Hamiltonian and the self energy.
Parameters
----------
@ -477,7 +478,7 @@ class SumkDFT(object):
Data defining mesh on which the real-axis GF will be calculated, given in the form
(om_min,om_max,n_points), where om_min is the minimum omega, om_max is the maximum omega and n_points is the number of points.
with_Sigma : boolean, optional
If True the GF will be calculated with the self-energy stored in self.Sigmaimp_(w/iw), for real/Matsubara GF, respectively.
If True the GF will be calculated with the self-energy stored in self.Sigmaimp_(w/iw), for real/Matsubara GF, respectively.
In this case the mesh is taken from the self.Sigma_imp object.
If with_Sigma=True but self.Sigmaimp_(w/iw) is not present, with_Sigma is reset to False.
with_dc : boolean, optional
@ -568,9 +569,9 @@ class SumkDFT(object):
idmat = [numpy.identity(
self.n_orbitals[ik, ntoi[sp]], numpy.complex_) for sp in spn]
M = copy.deepcopy(idmat)
for ibl in range(self.n_spin_blocks[self.SO]):
ind = ntoi[spn[ibl]]
n_orb = self.n_orbitals[ik, ind]
M[ibl] = self.hopping[ik, ind, 0:n_orb, 0:n_orb] - \
@ -588,86 +589,128 @@ class SumkDFT(object):
return G_latt
def set_Sigma(self, Sigma_imp):
self.put_Sigma(Sigma_imp)
def set_Sigma(self, Sigma_imp, transform_to_sumk_blocks=True):
self.put_Sigma(Sigma_imp, transform_to_sumk_blocks)
def put_Sigma(self, Sigma_imp):
def put_Sigma(self, Sigma_imp, transform_to_sumk_blocks=True):
r"""
Inserts the impurity self-energies into the sumk_dft class.
Insert the impurity self-energies into the sumk_dft class.
Parameters
----------
Sigma_imp : list of BlockGf (Green's function) objects
List containing impurity self-energy for all inequivalent correlated shells.
Self-energies for equivalent shells are then automatically set by this function.
The self-energies can be of the real or imaginary-frequency type.
List containing impurity self-energy for all (inequivalent) correlated shells.
Self-energies for equivalent shells are then automatically set by this function.
The self-energies can be of the real or imaginary-frequency type.
transform_to_sumk_blocks : bool, optional
If True (default), the input Sigma_imp will be transformed to the block structure ``gf_struct_sumk``,
else it has to be given in ``gf_struct_sumk``.
"""
assert isinstance(
Sigma_imp, list), "put_Sigma: Sigma_imp has to be a list of Sigmas for the correlated shells, even if it is of length 1!"
assert len(
Sigma_imp) == self.n_inequiv_shells, "put_Sigma: give exactly one Sigma for each inequivalent corr. shell!"
if transform_to_sumk_blocks:
Sigma_imp = self.transform_to_sumk_blocks(Sigma_imp)
# init self.Sigma_imp_(i)w:
if all( (isinstance(gf, Gf) and isinstance (gf.mesh, MeshImFreq)) for bname, gf in Sigma_imp[0]):
assert isinstance(Sigma_imp, list),\
"put_Sigma: Sigma_imp has to be a list of Sigmas for the correlated shells, even if it is of length 1!"
assert len(Sigma_imp) == self.n_corr_shells,\
"put_Sigma: give exactly one Sigma for each corr. shell!"
if all((isinstance(gf, Gf) and isinstance(gf.mesh, MeshImFreq)) for bname, gf in Sigma_imp[0]):
# Imaginary frequency Sigma:
self.Sigma_imp_iw = [BlockGf(name_block_generator=[(block, GfImFreq(indices=inner, mesh=Sigma_imp[0].mesh))
for block, inner in self.gf_struct_sumk[icrsh]], make_copies=False)
self.Sigma_imp_iw = [self.block_structure.create_gf(ish=icrsh, mesh=Sigma_imp[icrsh].mesh, space='sumk')
for icrsh in range(self.n_corr_shells)]
SK_Sigma_imp = self.Sigma_imp_iw
elif all( isinstance(gf, Gf) and isinstance (gf.mesh, MeshReFreq) for bname, gf in Sigma_imp[0]):
elif all(isinstance(gf, Gf) and isinstance(gf.mesh, MeshReFreq) for bname, gf in Sigma_imp[0]):
# Real frequency Sigma:
self.Sigma_imp_w = [BlockGf(name_block_generator=[(block, GfReFreq(indices=inner, mesh=Sigma_imp[0].mesh))
for block, inner in self.gf_struct_sumk[icrsh]], make_copies=False)
self.Sigma_imp_w = [self.block_structure.create_gf(ish=icrsh, mesh=Sigma_imp[icrsh].mesh, gf_function=GfReFreq, space='sumk')
for icrsh in range(self.n_corr_shells)]
SK_Sigma_imp = self.Sigma_imp_w
else:
raise ValueError("put_Sigma: This type of Sigma is not handled.")
raise ValueError("put_Sigma: This type of Sigma is not handled, give either BlockGf of GfReFreq or GfImFreq.")
# rotation from local to global coordinate system:
for icrsh in range(self.n_corr_shells):
for bname, gf in SK_Sigma_imp[icrsh]:
if self.use_rotations:
gf << self.rotloc(icrsh,
Sigma_imp[icrsh][bname],
direction='toGlobal')
else:
gf << Sigma_imp[icrsh][bname]
def transform_to_sumk_blocks(self, Sigma_imp, Sigma_out=None):
r""" transform Sigma from solver to sumk space
Parameters
----------
Sigma_imp : list of BlockGf (Green's function) objects
List containing impurity self-energy for all inequivalent correlated shells.
The self-energies can be of the real or imaginary-frequency type.
Sigma_out : list of BlockGf
list of one BlockGf per correlated shell with the block structure
according to ``gf_struct_sumk``; if None, it will be created
"""
assert isinstance(Sigma_imp, list),\
"transform_to_sumk_blocks: Sigma_imp has to be a list of Sigmas for the inequivalent correlated shells, even if it is of length 1!"
assert len(Sigma_imp) == self.n_inequiv_shells,\
"transform_to_sumk_blocks: give exactly one Sigma for each inequivalent corr. shell!"
if Sigma_out is None:
Sigma_out = [self.block_structure.create_gf(ish=icrsh, mesh=Sigma_imp[self.corr_to_inequiv[icrsh]].mesh, space='sumk')
for icrsh in range(self.n_corr_shells)]
else:
for icrsh in range(self.n_corr_shells):
self.block_structure.check_gf(Sigma_out,
ish=icrsh,
space='sumk')
# transform the CTQMC blocks to the full matrix:
for icrsh in range(self.n_corr_shells):
# ish is the index of the inequivalent shell corresponding to icrsh
ish = self.corr_to_inequiv[icrsh]
for block, inner in self.gf_struct_solver[ish].items():
for ind1 in inner:
for ind2 in inner:
block_sumk, ind1_sumk = self.solver_to_sumk[
ish][(block, ind1)]
block_sumk, ind2_sumk = self.solver_to_sumk[
ish][(block, ind2)]
SK_Sigma_imp[icrsh][block_sumk][
ind1_sumk, ind2_sumk] << Sigma_imp[ish][block][ind1, ind2]
self.block_structure.convert_gf(
G=Sigma_imp[ish],
G_struct=None,
space_from='solver',
space_to='sumk',
ish_from=ish,
ish_to=icrsh,
G_out=Sigma_out[icrsh])
return Sigma_out
# rotation from local to global coordinate system:
if self.use_rotations:
for icrsh in range(self.n_corr_shells):
for bname, gf in SK_Sigma_imp[icrsh]:
gf << self.rotloc(icrsh, gf, direction='toGlobal')
def extract_G_loc(self, mu=None, iw_or_w='iw', with_Sigma=True, with_dc=True, broadening=None):
def extract_G_loc(self, mu=None, iw_or_w='iw', with_Sigma=True, with_dc=True, broadening=None,
transform_to_solver_blocks=True, show_warnings=True):
r"""
Extracts the local downfolded Green function by the Brillouin-zone integration of the lattice Green's function.
Parameters
----------
mu : real, optional
Input chemical potential. If not provided the value of self.chemical_potential is used as mu.
Input chemical potential. If not provided the value of self.chemical_potential is used as mu.
with_Sigma : boolean, optional
If True then the local GF is calculated with the self-energy self.Sigma_imp.
If True then the local GF is calculated with the self-energy self.Sigma_imp.
with_dc : boolean, optional
If True then the double-counting correction is subtracted from the self-energy in calculating the GF.
If True then the double-counting correction is subtracted from the self-energy in calculating the GF.
broadening : float, optional
Imaginary shift for the axis along which the real-axis GF is calculated.
If not provided, broadening will be set to double of the distance between mesh points in 'mesh'.
Only relevant for real-frequency GF.
Imaginary shift for the axis along which the real-axis GF is calculated.
If not provided, broadening will be set to double of the distance between mesh points in 'mesh'.
Only relevant for real-frequency GF.
transform_to_solver_blocks : bool, optional
If True (default), the returned G_loc will be transformed to the block structure ``gf_struct_solver``,
else it will be in ``gf_struct_sumk``.
show_warnings : bool, optional
Displays warning messages during transformation
(Only effective if transform_to_solver_blocks = True
Returns
-------
G_loc_inequiv : list of BlockGf (Green's function) objects
List of the local Green's functions for all inequivalent correlated shells,
rotated into the corresponding local frames.
G_loc : list of BlockGf (Green's function) objects
List of the local Green's functions for all (inequivalent) correlated shells,
rotated into the corresponding local frames.
If ``transform_to_solver_blocks`` is True, it will be one per correlated shell, else one per
inequivalent correlated shell.
"""
if mu is None:
@ -726,25 +769,58 @@ class SumkDFT(object):
G_loc[icrsh][bname] << self.rotloc(
icrsh, gf, direction='toLocal')
if transform_to_solver_blocks:
return self.transform_to_solver_blocks(G_loc, show_warnings=show_warnings)
return G_loc
def transform_to_solver_blocks(self, G_loc, G_out=None, show_warnings = True):
""" transform G_loc from sumk to solver space
Parameters
----------
G_loc : list of BlockGf
a list of one BlockGf per correlated shell with a structure
according to ``gf_struct_sumk``, e.g. as returned by
:py:meth:`.extract_G_loc` with ``transform_to_solver_blocks=False``.
G_out : list of BlockGf
a list of one BlockGf per *inequivalent* correlated shell
with a structure according to ``gf_struct_solver``.
The output Green's function (if not given, a new one is
created)
Returns
-------
G_out
"""
assert isinstance(G_loc, list), "G_loc must be a list (with elements for each correlated shell)"
if G_out is None:
G_out = [self.block_structure.create_gf(ish=ish, mesh=G_loc[self.inequiv_to_corr[ish]].mesh)
for ish in range(self.n_inequiv_shells)]
else:
for ish in range(self.n_inequiv_shells):
self.block_structure.check_gf(G_out, ish=ish)
# transform to CTQMC blocks:
for ish in range(self.n_inequiv_shells):
for block, inner in self.gf_struct_solver[ish].items():
for ind1 in inner:
for ind2 in inner:
block_sumk, ind1_sumk = self.solver_to_sumk[
ish][(block, ind1)]
block_sumk, ind2_sumk = self.solver_to_sumk[
ish][(block, ind2)]
G_loc_inequiv[ish][block][ind1, ind2] << G_loc[
self.inequiv_to_corr[ish]][block_sumk][ind1_sumk, ind2_sumk]
self.block_structure.convert_gf(
G=G_loc[self.inequiv_to_corr[ish]],
G_struct=None,
ish_from=self.inequiv_to_corr[ish],
ish_to=ish,
space_from='sumk',
G_out=G_out[ish],
show_warnings = show_warnings)
# return only the inequivalent shells:
return G_loc_inequiv
return G_out
def analyse_block_structure(self, threshold=0.00001, include_shells=None, dm=None, hloc=None):
r"""
Determines the block structure of local Green's functions by analysing the structure of
the corresponding density matrices and the local Hamiltonian. The resulting block structures
Determines the block structure of local Green's functions by analysing the structure of
the corresponding density matrices and the local Hamiltonian. The resulting block structures
for correlated shells are stored in the :class:`SumkDFT.block_structure <dft.block_structure.BlockStructure>` attribute.
Parameters
@ -882,7 +958,7 @@ class SumkDFT(object):
the output G(tau) or A(w)
"""
# make a GfImTime from the supplied GfImFreq
if all(isinstance(g_sh._first(), GfImFreq) for g_sh in G):
if all(isinstance(g_sh.mesh, MeshImFreq) for g_sh in G):
gf = [BlockGf(name_block_generator = [(name, GfImTime(beta=block.mesh.beta,
indices=block.indices,n_points=len(block.mesh)+1)) for name, block in g_sh],
make_copies=False) for g_sh in G]
@ -890,15 +966,15 @@ class SumkDFT(object):
for name, g in gf[ish]:
g.set_from_fourier(G[ish][name])
# keep a GfImTime from the supplied GfImTime
elif all(isinstance(g_sh._first(), GfImTime) for g_sh in G):
elif all(isinstance(g_sh.mesh, MeshImTime) for g_sh in G):
gf = G
# make a spectral function from the supplied GfReFreq
elif all(isinstance(g_sh._first(), GfReFreq) for g_sh in G):
elif all(isinstance(g_sh.mesh, MeshReFreq) for g_sh in G):
gf = [g_sh.copy() for g_sh in G]
for ish in range(len(gf)):
for name, g in gf[ish]:
g << 1.0j*(g-g.conjugate().transpose())/2.0/numpy.pi
elif all(isinstance(g_sh._first(), GfReTime) for g_sh in G):
elif all(isinstance(g_sh.mesh, MeshReTime) for g_sh in G):
def get_delta_from_mesh(mesh):
w0 = None
for w in mesh:
@ -907,7 +983,7 @@ class SumkDFT(object):
else:
return w-w0
gf = [BlockGf(name_block_generator = [(name, GfReFreq(
window=(-numpy.pi*(len(block.mesh)-1) / (len(block.mesh)*get_delta_from_mesh(block.mesh)),
window=(-numpy.pi*(len(block.mesh)-1) / (len(block.mesh)*get_delta_from_mesh(block.mesh)),
numpy.pi*(len(block.mesh)-1) / (len(block.mesh)*get_delta_from_mesh(block.mesh))),
n_points=len(block.mesh), indices=block.indices)) for name, block in g_sh], make_copies=False)
for g_sh in G]
@ -954,6 +1030,8 @@ class SumkDFT(object):
the Green's function transformed into the new block structure
"""
assert isinstance(G, list), "G must be a list (with elements for each correlated shell)"
gf = self._get_hermitian_quantity_from_gf(G)
# initialize the variables
@ -1022,11 +1100,11 @@ class SumkDFT(object):
full_structure = BlockStructure.full_structure(
[{sp:list(range(self.corr_shells[self.inequiv_to_corr[ish]]['dim']))
for sp in self.spin_block_names[self.corr_shells[self.inequiv_to_corr[ish]]['SO']]}
for ish in range(self.n_inequiv_shells)],None)
for ish in range(self.n_inequiv_shells)],self.corr_to_inequiv)
G_transformed = [
self.block_structure.convert_gf(G[ish],
full_structure, ish, mesh=G[ish].mesh.copy(), show_warnings=threshold,
gf_function=type(G[ish]._first()))
gf_function=type(G[ish]._first()), space_from='sumk', space_to='solver')
for ish in range(self.n_inequiv_shells)]
if analyse_deg_shells:
@ -1270,6 +1348,82 @@ class SumkDFT(object):
# a block was found, break out of the loop
break
def calculate_diagonalization_matrix(self, prop_to_be_diagonal='eal', calc_in_solver_blocks=True, write_to_blockstructure = True, shells=None):
"""
Calculates the diagonalisation matrix, and (optionally) stores it in the BlockStructure.
Parameters
----------
prop_to_be_diagonal : string, optional
Defines the property to be diagonalized.
- 'eal' : local hamiltonian (i.e. crystal field)
- 'dm' : local density matrix
calc_in_solver_blocks : bool, optional
Whether the property shall be diagonalized in the
full sumk structure, or just in the solver structure.
write_to_blockstructure : bool, optional
Whether the diagonalization matrix shall be written to
the BlockStructure directly.
shells : list of int, optional
Indices of correlated shells to be diagonalized.
None: all shells
Returns
-------
trafo : dict
The transformation matrix for each spin-block in the correlated shell
"""
if self.block_structure.transformation:
mpi.report(
"calculate_diagonalization_matrix: requires block_structure.transformation = None.")
return 0
# Use all shells
if shells is None:
shells = range(self.n_corr_shells)
elif max(shells) >= self.n_corr_shells: # Check if the shell indices are present
mpi.report("calculate_diagonalization_matrix: shells not correct.")
return 0
if prop_to_be_diagonal == 'eal':
prop = [self.eff_atomic_levels()[self.corr_to_inequiv[ish]]
for ish in range(self.n_corr_shells)]
elif prop_to_be_diagonal == 'dm':
prop = self.density_matrix(method='using_point_integration')
else:
mpi.report(
"calculate_diagonalization_matrix: Choices for prop_to_be_diagonal are 'eal' or 'dm'.")
return 0
trans = [{block: numpy.eye(len(indices)) for block, indices in gfs} for gfs in self.gf_struct_sumk]
for ish in shells:
trafo = {}
# Transform to solver basis if desired, blocks of prop change in this step!
if calc_in_solver_blocks:
prop[ish] = self.block_structure.convert_matrix(prop[ish], space_from='sumk', space_to='solver')
# Get diagonalisation matrix, if not already diagonal
for name in prop[ish]:
if numpy.sum(abs(prop[ish][name]-numpy.diag(numpy.diagonal(prop[ish][name])))) > 1e-13:
trafo[name] = numpy.linalg.eigh(prop[ish][name])[1].conj().T
else:
trafo[name] = numpy.identity(numpy.shape(prop[ish][name])[0])
# Transform back to sumk if necessay, blocks change in this step!
if calc_in_solver_blocks:
trafo = self.block_structure.convert_matrix(trafo, space_from='solver', space_to='sumk')
trans[ish] = trafo
# Write to block_structure object
if write_to_blockstructure:
self.block_structure.transformation = trans
return trans
def density_matrix(self, method='using_gf', beta=40.0):
"""Calculate density matrices in one of two ways.
@ -1284,7 +1438,7 @@ class SumkDFT(object):
- if 'using_point_integration': Only works for diagonal hopping matrix (true in wien2k).
beta : float, optional
Inverse temperature.
Inverse temperature.
Returns
-------
@ -1468,21 +1622,22 @@ class SumkDFT(object):
dc_imp : gf_struct_sumk like
Double-counting self-energy term.
dc_energ : list of floats
Double-counting energy corrections for each correlated shell.
Double-counting energy corrections for each correlated shell.
"""
self.dc_imp = dc_imp
self.dc_energ = dc_energ
def calc_dc(self, dens_mat, orb=0, U_interact=None, J_hund=None, use_dc_formula=0, use_dc_value=None):
def calc_dc(self, dens_mat, orb=0, U_interact=None, J_hund=None,
use_dc_formula=0, use_dc_value=None, transform=True):
r"""
Calculates and sets the double counting corrections.
Calculate and set the double counting corrections.
If 'use_dc_value' is provided the double-counting term is uniformly initialized
with this constant and 'U_interact' and 'J_hund' are ignored.
If 'use_dc_value' is None the correction is evaluated according to
If 'use_dc_value' is None the correction is evaluated according to
one of the following formulae:
* use_dc_formula = 0: fully-localised limit (FLL)
@ -1500,19 +1655,21 @@ class SumkDFT(object):
Parameters
----------
dens_mat : gf_struct_solver like
Density matrix for the specified correlated shell.
Density matrix for the specified correlated shell.
orb : int, optional
Index of an inequivalent shell.
Index of an inequivalent shell.
U_interact : float, optional
Value of interaction parameter `U`.
Value of interaction parameter `U`.
J_hund : float, optional
Value of interaction parameter `J`.
Value of interaction parameter `J`.
use_dc_formula : int, optional
Type of double-counting correction (see description).
Type of double-counting correction (see description).
use_dc_value : float, optional
Value of the double-counting correction. If specified
`U_interact`, `J_hund` and `use_dc_formula` are ignored.
Value of the double-counting correction. If specified
`U_interact`, `J_hund` and `use_dc_formula` are ignored.
transform : bool
whether or not to use the transformation in block_structure
to transform the dc
"""
for icrsh in range(self.n_corr_shells):
@ -1593,6 +1750,11 @@ class SumkDFT(object):
mpi.report(
"DC for shell %(icrsh)i = %(use_dc_value)f" % locals())
mpi.report("DC energy = %s" % self.dc_energ[icrsh])
if transform:
for sp in spn:
T = self.block_structure.effective_transformation_sumk[icrsh][sp]
self.dc_imp[icrsh][sp] = numpy.dot(T.conjugate().transpose(),
numpy.dot(self.dc_imp[icrsh][sp], T))
def add_dc(self, iw_or_w="iw"):
r"""
@ -1624,7 +1786,7 @@ class SumkDFT(object):
return sigma_minus_dc
def symm_deg_gf(self, gf_to_symm, orb):
def symm_deg_gf(self, gf_to_symm, ish=0):
r"""
Averages a GF over degenerate shells.
@ -1636,8 +1798,8 @@ class SumkDFT(object):
----------
gf_to_symm : gf_struct_solver like
Input and output GF (i.e., it gets overwritten)
orb : int
Index of an inequivalent shell.
ish : int
Index of an inequivalent shell. (default value 0)
"""
@ -1645,7 +1807,7 @@ class SumkDFT(object):
# an h5 file, self.deg_shells might be None
if self.deg_shells is None: return
for degsh in self.deg_shells[orb]:
for degsh in self.deg_shells[ish]:
# ss will hold the averaged orbitals in the basis where the
# blocks are all equal
# i.e. maybe_conjugate(v^dagger gf v)
@ -1684,7 +1846,7 @@ class SumkDFT(object):
def total_density(self, mu=None, iw_or_w="iw", with_Sigma=True, with_dc=True, broadening=None):
r"""
Calculates the total charge within the energy window for a given chemical potential.
Calculates the total charge within the energy window for a given chemical potential.
The chemical potential is either given by parameter `mu` or, if it is not specified,
taken from `self.chemical_potential`.
@ -1701,7 +1863,7 @@ class SumkDFT(object):
with
.. math:: n(k) = Tr G_{\nu\nu'}(k, i\omega_{n}).
.. math:: n(k) = Tr G_{\nu\nu'}(k, i\omega_{n}).
The calculation is done in the global coordinate system, if distinction is made between local/global.
@ -1868,7 +2030,7 @@ class SumkDFT(object):
ik, 0, bname, G_latt_iw[bname], gf,shells='csc')
G_latt_iw[bname] = G_latt_rot_iw.copy()
for bname, gf in G_latt_iw:
deltaN[bname][ik] = G_latt_iw[bname].density()
@ -1878,7 +2040,7 @@ class SumkDFT(object):
nb = self.n_orbitals[ik, ntoi[bname]]
diag_inds = numpy.diag_indices(nb)
deltaN[bname][ik][diag_inds] -= dens_mat_dft[bname][ik][:nb]
if self.charge_mixing and self.deltaNOld is not None:
G2 = numpy.sum(self.kpts_cart[ik,:]**2)
# Kerker mixing
@ -1900,9 +2062,9 @@ class SumkDFT(object):
mpi.world, dens[bname], lambda x, y: x + y)
self.deltaNOld = copy.copy(deltaN)
mpi.barrier()
band_en_correction = mpi.all_reduce(mpi.world, band_en_correction, lambda x,y : x+y)
# now save to file:
@ -2012,7 +2174,7 @@ class SumkDFT(object):
return dc
def check_projectors(self):
"""Calculated the density matrix from projectors (DM = P Pdagger) to check that it is correct and
"""Calculated the density matrix from projectors (DM = P Pdagger) to check that it is correct and
specifically that it matches DFT."""
dens_mat = [numpy.zeros([self.corr_shells[icrsh]['dim'], self.corr_shells[icrsh]['dim']], numpy.complex_)
for icrsh in range(self.n_corr_shells)]
@ -2091,3 +2253,31 @@ class SumkDFT(object):
def __set_deg_shells(self,value):
self.block_structure.deg_shells = value
deg_shells = property(__get_deg_shells,__set_deg_shells)
@property
def gf_struct_solver_list(self):
return self.block_structure.gf_struct_solver_list
@property
def gf_struct_sumk_list(self):
return self.block_structure.gf_struct_sumk_list
@property
def gf_struct_solver_dict(self):
return self.block_structure.gf_struct_solver_dict
@property
def gf_struct_sumk_dict(self):
return self.block_structure.gf_struct_sumk_dict
def __get_corr_to_inequiv(self):
return self.block_structure.corr_to_inequiv
def __set_corr_to_inequiv(self, value):
self.block_structure.corr_to_inequiv = value
corr_to_inequiv = property(__get_corr_to_inequiv, __set_corr_to_inequiv)
def __get_inequiv_to_corr(self):
return self.block_structure.inequiv_to_corr
def __set_inequiv_to_corr(self, value):
self.block_structure.inequiv_to_corr = value
inequiv_to_corr = property(__get_inequiv_to_corr, __set_inequiv_to_corr)

View File

@ -48,7 +48,7 @@ class TransBasis:
self.T = copy.deepcopy(self.SK.T[0])
self.w = numpy.identity(SK.corr_shells[0]['dim'])
def calculate_diagonalisation_matrix(self, prop_to_be_diagonal='eal'):
def calculate_diagonalisation_matrix(self, prop_to_be_diagonal='eal', calc_in_solver_blocks = False):
"""
Calculates the diagonalisation matrix w, and stores it as member of the class.
@ -60,6 +60,10 @@ class TransBasis:
- 'eal' : local hamiltonian (i.e. crystal field)
- 'dm' : local density matrix
calc_in_solver_blocks : bool, optional
Whether the property shall be diagonalized in the
full sumk structure, or just in the solver structure.
Returns
-------
wsqr : double
@ -76,16 +80,29 @@ class TransBasis:
"trans_basis: not a valid quantitiy to be diagonal. Choices are 'eal' or 'dm'.")
return 0
if self.SK.SO == 0:
self.eig, self.w = numpy.linalg.eigh(prop['up'])
# calculate new Transformation matrix
if calc_in_solver_blocks:
trafo = self.SK.block_structure.transformation
self.SK.block_structure.transformation = None
prop_solver = self.SK.block_structure.convert_matrix(prop, space_from='sumk', space_to='solver')
v= {}
for name in prop_solver:
v[name] = numpy.linalg.eigh(prop_solver[name])[1]
self.w = self.SK.block_structure.convert_matrix(v, space_from='solver', space_to='sumk')['ud' if self.SK.SO else 'up']
self.T = numpy.dot(self.T.transpose().conjugate(),
self.w).conjugate().transpose()
self.SK.block_structure.transformation = trafo
else:
self.eig, self.w = numpy.linalg.eigh(prop['ud'])
# calculate new Transformation matrix
self.T = numpy.dot(self.T.transpose().conjugate(),
self.w).conjugate().transpose()
if self.SK.SO == 0:
self.eig, self.w = numpy.linalg.eigh(prop['up'])
# calculate new Transformation matrix
self.T = numpy.dot(self.T.transpose().conjugate(),
self.w).conjugate().transpose()
else:
self.eig, self.w = numpy.linalg.eigh(prop['ud'])
# calculate new Transformation matrix
self.T = numpy.dot(self.T.transpose().conjugate(),
self.w).conjugate().transpose()
# measure for the 'unity' of the transformation:
wsqr = sum(abs(self.w.diagonal())**2) / self.w.diagonal().size

View File

@ -5,7 +5,7 @@ foreach(file ${all_h5_ref_files})
endforeach()
# Copy other files
FILE(COPY SrVO3.pmat SrVO3.struct SrVO3.outputs SrVO3.oubwin SrVO3.ctqmcout SrVO3.symqmc SrVO3.sympar SrVO3.parproj hk_convert_hamiltonian.hk LaVO3-Pnma_hr.dat LaVO3-Pnma.inp DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
FILE(COPY SrVO3.pmat SrVO3.struct SrVO3.outputs SrVO3.oubwin SrVO3.ctqmcout SrVO3.symqmc SrVO3.sympar SrVO3.parproj hk_convert_hamiltonian.hk LaVO3-Pnma_hr.dat LaVO3-Pnma.inp LaVO3-Pnma_ef_hr.dat LaVO3-Pnma_ef.inp DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
# List of all tests

View File

@ -0,0 +1,8 @@
0 3 2 3
8.0
4
0 0 2 3 0 0
1 0 2 3 0 0
2 0 2 3 0 0
3 0 2 3 0 0
10.3

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,6 @@ G = SK.extract_G_loc()
# the original block structure
block_structure1 = SK.block_structure.copy()
G_new = SK.analyse_block_structure_from_gf(G)
# the new block structure
@ -163,9 +162,9 @@ for conjugate in conjugate_values:
G_new = SK.analyse_block_structure_from_gf(G, 1.e-7)
# transform G_noisy etc. to the new block structure
G_noisy = SK.block_structure.convert_gf(G_noisy, block_structure1, beta = G_noisy.mesh.beta)
G_pre_transform = SK.block_structure.convert_gf(G_pre_transform, block_structure1, beta = G_noisy.mesh.beta)
G_noisy_pre_transform = SK.block_structure.convert_gf(G_noisy_pre_transform, block_structure1, beta = G_noisy.mesh.beta)
G_noisy = SK.block_structure.convert_gf(G_noisy, block_structure1, beta = G_noisy.mesh.beta, space_from='sumk')
G_pre_transform = SK.block_structure.convert_gf(G_pre_transform, block_structure1, beta = G_noisy.mesh.beta, space_from='sumk')
G_noisy_pre_transform = SK.block_structure.convert_gf(G_noisy_pre_transform, block_structure1, beta = G_noisy.mesh.beta, space_from='sumk')
assert len(SK.deg_shells[0]) == 2, "wrong number of equivalent groups found"
assert sorted([len(d) for d in SK.deg_shells[0]]) == [2,3], "wrong number of members in the equivalent groups found"

View File

@ -0,0 +1,99 @@
from triqs.utility.comparison_tests import *
from triqs_dft_tools.sumk_dft import *
import numpy as np
def is_diagonal_matrix(M):
return abs(np.sum(M-np.diag(np.diagonal(M)))) < 1e-10
def call_diagonalize(SK):
SK.block_structure.transformation = None
t_sumk_eal = SK.calculate_diagonalization_matrix(prop_to_be_diagonal='eal', calc_in_solver_blocks=False, write_to_blockstructure = True)
SK.block_structure.transformation = None
t_solver_eal = SK.calculate_diagonalization_matrix(prop_to_be_diagonal='eal', calc_in_solver_blocks=True, write_to_blockstructure = True)
SK.block_structure.transformation = None
t_solver_dm = SK.calculate_diagonalization_matrix(prop_to_be_diagonal='dm', calc_in_solver_blocks=False, write_to_blockstructure = True)
SK.block_structure.transformation = None
t_sumk_dm = SK.calculate_diagonalization_matrix(prop_to_be_diagonal='dm', calc_in_solver_blocks=True, write_to_blockstructure = True)
SK.block_structure.transformation = None
return t_sumk_eal, t_solver_eal, t_sumk_dm, t_solver_dm
SK = SumkDFT(hdf_file = 'SrVO3.h5', use_dft_blocks=True)
# only eal and dm are allowed
SK.block_structure.transformation = None
assert not SK.calculate_diagonalization_matrix(prop_to_be_diagonal='test')
# check for shell index
assert not SK.calculate_diagonalization_matrix(shells = [15])
# calling the function twice leads to block_structure.transformation already being set
SK.calculate_diagonalization_matrix()
assert not SK.calculate_diagonalization_matrix()
SK.block_structure.transformation = None
# Check writing to block_structure
SK.calculate_diagonalization_matrix(write_to_blockstructure=False)
assert SK.block_structure.transformation is None
SK.block_structure.transformation = None
SK.calculate_diagonalization_matrix(write_to_blockstructure=True)
assert SK.block_structure.transformation is not None
SK.block_structure.transformation = None
t_sumk_eal, t_solver_eal, t_sumk_dm, t_solver_dm = call_diagonalize(SK)
# All matrices should be identities
for orb in range(SK.n_corr_shells):
for block in t_solver_eal[orb]:
assert_arrays_are_close(t_sumk_eal[orb][block],np.identity(3), precision=1e-6)
assert_arrays_are_close(t_sumk_dm[orb][block],np.identity(3), precision=1e-6)
assert_arrays_are_close(t_solver_eal[orb][block],np.identity(3), precision=1e-6)
assert_arrays_are_close(t_solver_dm[orb][block],np.identity(3), precision=1e-6)
SK = SumkDFT(hdf_file = 'w90_convert.ref.h5', use_dft_blocks=True)
t_sumk_eal, t_solver_eal, t_sumk_dm, t_solver_dm = call_diagonalize(SK)
# In this example solver and sumk should be the same
for orb in range(SK.n_corr_shells):
for block in t_solver_eal[orb]:
assert_arrays_are_close(t_sumk_eal[orb][block],t_solver_eal[orb][block], precision=1e-6)
assert_arrays_are_close(t_sumk_dm[orb][block],t_solver_dm[orb][block], precision=1e-6)
# Check if transformations make eal and dm really diagonal
eal = SK.eff_atomic_levels()[0]
for e in eal:
assert is_diagonal_matrix(np.dot(np.dot(t_solver_eal[0][e], eal[e].conj().T),t_solver_eal[0][e].conj().T))
dm = SK.density_matrix(method='using_point_integration')
for dmi in dm:
for e in dmi:
assert is_diagonal_matrix(np.dot(np.dot(t_solver_dm[0][e], dmi[e].conj().T),t_solver_dm[0][e].conj().T))
# Test convert_operator
SK = SumkDFT(hdf_file = 'SrVO3.h5', use_dft_blocks=True)
BS = SK.block_structure
from triqs.operators.util import h_int_slater, U_matrix, t2g_submatrix, transform_U_matrix
U3x3 = t2g_submatrix(U_matrix(2, U_int=2, J_hund=0.2, basis='spheric'))
BS.transformation = [{'up':np.eye(3), 'down': np.eye(3)}]
H0 = h_int_slater(spin_names=['up','down'], orb_names=range(3), U_matrix=U3x3, off_diag=False)
H1 = h_int_slater(spin_names=['up','down'], orb_names=range(3), U_matrix=U3x3, off_diag=True)
assert( H0 == BS.convert_operator(H1) )
# Trafo Matrix switching index 1 & 2
BS.transformation = [{'up':np.array([[1,0,0],[0,0,1],[0,1,0]]), 'down': np.array([[1,0,0],[0,0,1],[0,1,0]])}]
H2 = BS.convert_operator(h_int_slater(spin_names=['up','down'], orb_names=[0,2,1], U_matrix=U3x3, off_diag=True))
assert( H0 == H2 )
BS.transformation = [{'up':np.array([[1,0,0],[0,1/np.sqrt(2),1/np.sqrt(2)],[0,1/np.sqrt(2),-1/np.sqrt(2)]]), 'down': np.array([[1,0,0],[0,1/np.sqrt(2),1/np.sqrt(2)],[0,1/np.sqrt(2),-1/np.sqrt(2)]])}]
H3 = BS.convert_operator(h_int_slater(spin_names=['up','down'], orb_names=[0,1,2], U_matrix=U3x3, off_diag=True))
for op in H3:
for c_op in op[0]:
assert(BS.gf_struct_solver_dict[0][c_op[1][0]][c_op[1][1]] is not None) # This crashes with a key error if the operator structure is not the solver structure
U_trafod = transform_U_matrix(U3x3, BS.transformation[0]['up'].conjugate()) # The notorious .conjugate()
H4 = h_int_slater(spin_names=['up','down'], orb_names=range(3), U_matrix=U_trafod, map_operator_structure=BS.sumk_to_solver[0])
assert( H4 == H3 ) # check that convert_operator does the same as transform_U_matrix

Binary file not shown.

View File

@ -1,68 +1,223 @@
from triqs_dft_tools.sumk_dft import *
from triqs.utility.h5diff import h5diff
from triqs.utility.h5diff import h5diff, compare, failures
from triqs.gf import *
from triqs.utility.comparison_tests import assert_block_gfs_are_close
from scipy.linalg import expm
from triqs_dft_tools.block_structure import BlockStructure
import numpy as np
SK = SumkDFT('blockstructure.in.h5',use_dft_blocks=True)
def cmp(a, b, precision=1.e-15):
compare('', a, b, 0, precision)
if failures:
raise AssertionError('\n'.join(failures))
SK = SumkDFT('blockstructure.in.h5', use_dft_blocks=True)
original_bs = SK.block_structure
cmp(original_bs.effective_transformation_sumk,
[{'up': np.array([[1., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]]),
'down': np.array([[1., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]])}])
cmp(original_bs.effective_transformation_solver,
[{'up_0': np.array([[1., 0., 0.],
[0., 1., 0.]]),
'up_1': np.array([[0., 0., 1.]]),
'down_0': np.array([[1., 0., 0.],
[0., 1., 0.]]),
'down_1': np.array([[0., 0., 1.]])}])
created_matrix = original_bs.create_matrix()
cmp(created_matrix,
{'up_0': np.array([[0. + 0.j, 0. + 0.j],
[0. + 0.j, 0. + 0.j]]),
'up_1': np.array([[0. + 0.j]]),
'down_0': np.array([[0. + 0.j, 0. + 0.j],
[0. + 0.j, 0. + 0.j]]),
'down_1': np.array([[0. + 0.j]])})
# check pick_gf_struct_solver
pick1 = original_bs.copy()
pick1.pick_gf_struct_solver([{'up_0': [1], 'up_1': [0], 'down_1': [0]}])
cmp(pick1.effective_transformation_sumk,
[{'up': np.array([[0., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]]),
'down': np.array([[0., 0., 0.],
[0., 0., 0.],
[0., 0., 1.]])}])
cmp(pick1.effective_transformation_solver,
[{'up_0': np.array([[0., 1., 0.]]),
'up_1': np.array([[0., 0., 1.]]),
'down_1': np.array([[0., 0., 1.]])}])
# check loading a block_structure from file
SK.block_structure = SK.load(['block_structure'],'mod')[0]
SK.block_structure = SK.load(['block_structure'], 'mod')[0]
assert SK.block_structure == pick1, 'loading SK block structure from file failed'
# check SumkDFT backward compatibility
sk_pick1 = BlockStructure(gf_struct_sumk = SK.gf_struct_sumk,
gf_struct_solver = SK.gf_struct_solver,
solver_to_sumk = SK.solver_to_sumk,
sumk_to_solver = SK.sumk_to_solver,
solver_to_sumk_block = SK.solver_to_sumk_block,
deg_shells = SK.deg_shells)
sk_pick1 = BlockStructure(gf_struct_sumk=SK.gf_struct_sumk,
gf_struct_solver=SK.gf_struct_solver,
solver_to_sumk=SK.solver_to_sumk,
sumk_to_solver=SK.sumk_to_solver,
solver_to_sumk_block=SK.solver_to_sumk_block,
deg_shells=SK.deg_shells,
corr_to_inequiv=SK.corr_to_inequiv)
assert sk_pick1 == pick1, 'constructing block structure from SumkDFT properties failed'
cmp(pick1.effective_transformation_sumk,
[{'up': np.array([[0., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]]),
'down': np.array([[0., 0., 0.],
[0., 0., 0.],
[0., 0., 1.]])}])
cmp(pick1.effective_transformation_solver,
[{'up_0': np.array([[0., 1., 0.]]),
'up_1': np.array([[0., 0., 1.]]),
'down_1': np.array([[0., 0., 1.]])}])
# check pick_gf_struct_sumk
pick2 = original_bs.copy()
pick2.pick_gf_struct_sumk([{'up': [1, 2], 'down': [0,1]}])
pick2.pick_gf_struct_sumk([{'up': [1, 2], 'down': [0, 1]}])
cmp(pick2.effective_transformation_sumk,
[{'up': np.array([[0., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]]),
'down': np.array([[1., 0., 0.],
[0., 1., 0.],
[0., 0., 0.]])}])
cmp(pick2.effective_transformation_solver,
[{'up_0': np.array([[0., 1., 0.]]),
'up_1': np.array([[0., 0., 1.]]),
'down_0': np.array([[1., 0., 0.],
[0., 1., 0.]])}])
pick3 = pick2.copy()
pick3.transformation = [np.reshape(range(9), (3, 3))]
cmp(pick3.effective_transformation_sumk,
[{'up': np.array([[0, 0, 0],
[3, 4, 5],
[6, 7, 8]]),
'down': np.array([[0, 1, 2],
[3, 4, 5],
[0, 0, 0]])}])
cmp(pick3.effective_transformation_solver,
[{'up_0': np.array([[3, 4, 5]]),
'up_1': np.array([[6, 7, 8]]),
'down_0': np.array([[0, 1, 2],
[3, 4, 5]])}])
pick4 = original_bs.copy()
pick4.transformation = [np.array([[0, 1, 0], [1, 0, 0], [0, 0, 1]])]
pick4.pick_gf_struct_sumk([{'up': [1, 2], 'down': [0, 1]}])
cmp(pick2.gf_struct_sumk, pick4.gf_struct_sumk)
cmp(pick2.gf_struct_solver, pick4.gf_struct_solver)
assert pick4.sumk_to_solver == [{('up', 0): ('up_0', 0),
('up', 1): (None, None),
('up', 2): ('up_1', 0),
('down', 2): (None, None),
('down', 1): ('down_0', 1),
('down', 0): ('down_0', 0)}]
assert pick4.solver_to_sumk == [{('up_1', 0): ('up', 2),
('up_0', 0): ('up', 0),
('down_0', 0): ('down', 0),
('down_0', 1): ('down', 1)}]
# check map_gf_struct_solver
mapping = [{ ('down_0', 0):('down', 0),
('down_0', 1):('down', 2),
('down_1', 0):('down', 1),
('up_0', 0) :('down_1', 0),
('up_0', 1) :('up_0', 0) }]
mapping = [{('down_0', 0): ('down', 0),
('down_0', 1): ('down', 2),
('down_1', 0): ('down', 1),
('up_0', 0): ('down_1', 0),
('up_0', 1): ('up_0', 0)}]
map1 = original_bs.copy()
map1.map_gf_struct_solver(mapping)
# check create_gf
G1 = original_bs.create_gf(beta=40,n_points=3)
i = 1
for block,gf in G1:
gf << SemiCircular(i)
i+=1
G1 = original_bs.create_gf(beta=40, n_points=3)
widths = dict(up_0=1, up_1=2, down_0=4, down_1=3)
for block, gf in G1:
gf << SemiCircular(widths[block])
original_bs.check_gf(G1)
original_bs.check_gf([G1])
# check approximate_as_diagonal
offd = original_bs.copy()
offd.approximate_as_diagonal()
# check map_gf_struct_solver
G2 = map1.convert_gf(G1,original_bs,beta=40,n_points=3,show_warnings=False)
import warnings
with warnings.catch_warnings(record=True) as w:
G2 = map1.convert_gf(G1, original_bs, beta=40, n_points=3,
show_warnings=True)
assert len(w) == 1
assert issubclass(w[-1].category, UserWarning)
assert "Block up_1 maximum difference" in str(w[-1].message)
m2 = map1.convert_matrix(created_matrix, original_bs, show_warnings=True)
cmp(m2,
{'down': np.array([[0. + 0.j, 0. + 0.j, 0. + 0.j],
[0. + 0.j, 0. + 0.j, 0. + 0.j],
[0. + 0.j, 0. + 0.j, 0. + 0.j]]),
'down_1': np.array([[0. + 0.j]]),
'up_0': np.array([[0. + 0.j]])})
# check full_structure
full = BlockStructure.full_structure([{'up_0': [0, 1], 'up_1': [0], 'down_1': [0], 'down_0': [0, 1]}],None)
full = BlockStructure.full_structure(
[{'up_0': [0, 1], 'up_1': [0], 'down_1': [0], 'down_0': [0, 1]}], None)
G_sumk = BlockGf(mesh=G1.mesh, gf_struct=original_bs.gf_struct_sumk[0])
for i in range(3):
G_sumk['up'][i, i] << SemiCircular(1 if i < 2 else 2)
G_sumk['down'][i, i] << SemiCircular(4 if i < 2 else 3)
G3 = original_bs.convert_gf(G_sumk,
None,
space_from='sumk',
beta=40,
n_points=3)
assert_block_gfs_are_close(G1, G3)
# check convert_gf with transformation
# np.random.seed(894892309)
H = np.random.rand(3, 3) + 1.0j * np.random.rand(3, 3)
H = H + H.conjugate().transpose()
T = expm(1.0j * H)
G_T = G_sumk.copy()
for block, gf in G_T:
gf.from_L_G_R(T.conjugate().transpose(), gf, T)
transformed_bs = original_bs.copy()
transformed_bs.transformation = [T]
G_bT = transformed_bs.convert_gf(G_T, None, space_from='sumk',
beta=40, n_points=3)
assert_block_gfs_are_close(G1, G_bT)
assert original_bs.gf_struct_sumk_list ==\
[[('up', [0, 1, 2]), ('down', [0, 1, 2])]]
assert original_bs.gf_struct_solver_dict ==\
[{'up_0': [0, 1], 'up_1': [0], 'down_1': [0], 'down_0': [0, 1]}]
assert original_bs.gf_struct_sumk_dict ==\
[{'down': [0, 1, 2], 'up': [0, 1, 2]}]
assert original_bs.gf_struct_solver_list ==\
[[('down_0', [0, 1]), ('down_1', [0]), ('up_0', [0, 1]), ('up_1', [0])]]
# check __eq__
assert full==full, 'equality not correct (equal structures not equal)'
assert pick1==pick1, 'equality not correct (equal structures not equal)'
assert pick1!=pick2, 'equality not correct (different structures not different)'
assert original_bs!=offd, 'equality not correct (different structures not different)'
assert full == full, 'equality not correct (equal structures not equal)'
assert pick1 == pick1, 'equality not correct (equal structures not equal)'
assert pick1 != pick2, 'equality not correct (different structures not different)'
assert original_bs != offd, 'equality not correct (different structures not different)'
if mpi.is_master_node():
with HDFArchive('blockstructure.out.h5','w') as ar:
with HDFArchive('blockstructure.out.h5', 'w') as ar:
ar['original_bs'] = original_bs
ar['pick1'] = pick1
ar['pick2'] = pick2
@ -75,10 +230,11 @@ if mpi.is_master_node():
# cannot use h5diff because BlockStructure testing is not implemented
# there (and seems difficult to implement because it would mix triqs
# and dft_tools)
with HDFArchive('blockstructure.out.h5','r') as ar,\
HDFArchive('blockstructure.ref.h5','r') as ar2:
for k in ar2:
if isinstance(ar[k],BlockGf):
assert_block_gfs_are_close(ar[k],ar2[k],1.e-6)
else:
assert ar[k]==ar2[k], '{} not equal'.format(k)
with HDFArchive('blockstructure.out.h5', 'r') as ar,\
HDFArchive('blockstructure.ref.h5', 'r') as ar2:
for k in ar2:
print(k)
if isinstance(ar[k], BlockGf):
assert_block_gfs_are_close(ar[k], ar2[k], 1.e-6)
else:
assert ar[k] == ar2[k], '{} not equal'.format(k)

Binary file not shown.

View File

@ -41,7 +41,6 @@ orb_hybridized = False
gf_struct = set_operator_structure(spin_names,orb_names,orb_hybridized)
glist = [ GfImFreq(indices=inner,beta=beta) for block,inner in gf_struct]
print(gf_struct)
Sigma_iw = BlockGf(name_list = [block for block,inner in gf_struct], block_list = glist, make_copies = False)
SK.set_Sigma([Sigma_iw])

View File

@ -0,0 +1,25 @@
import unittest
import numpy as np
import sys
sys.path.insert(1, '../python/converters/')
from triqs_dft_tools.converters.wannier90_converter import Wannier90Converter
from triqs_dft_tools import SumkDFT
class test_w90_conv(unittest.TestCase):
def test_hopping(self):
conv1 = Wannier90Converter(seedname='LaVO3-Pnma')
conv1.convert_dft_input()
SK1 = SumkDFT(hdf_file='LaVO3-Pnma.h5')
conv2 = Wannier90Converter(seedname='LaVO3-Pnma_ef')
conv2.convert_dft_input()
SK2 = SumkDFT(hdf_file='LaVO3-Pnma_ef.h5')
for ik in range(SK1.n_k):
self.assertTrue(np.all(SK1.hopping[ik,0] - conv2.fermi_energy*np.identity(SK1.n_orbitals[ik][0]) - SK2.hopping[ik,0] < 1e-12))
if __name__ == '__main__':
unittest.main()