Basic usage
The edipy2 module consists mainly of a class called global_env
. The global variables and the functions of the EDIpack2 library that are exposed to the user are methods of this class. The class needs to be imported at the beginning of the script, along with other useful modules. Numpy is necessary, while mpi4py is strongly recommended.
import numpy as np
import scipy as sp
from edipy2 import global_env as ed
import mpi4py
from mpi4py import MPI
import os,sys
An example driver is provided in the folder tests/python
of the EDIpack2 repo. The basic steps to follow to run a single loop of DMFT-ED with edipy2 are the following:
Read the input file
ed.read_input("inputED.conf")
This will read an input file or generate a template one if no such file is found. The template will have the used.
prefix, which will need to be removed. An example of input file with a brief description of the relevant global variables is provided in the EDIpack2 repo.
Set the local Hamiltonian
ed.set_hloc(hloc=Hloc)
If bath_type
is REPLICA
or GENERAL
, the replica matrix has to be initialized via
ed.set_hreplica(hvec, lambdavec)
ed.set_general(hvec, lambdavec)
where hvec
and lambdavec
are arrays of the proper size (see function documentation).
The solver needs to be initialized via
bath = ed.init_solver()
Optionally, such as when real-space DMFT is used, the bath can be already allocated as an array, the dimension of which has to be given by the output of Nb
= ed.get_bath_dimension()
for single-impurity DMFT and [Nlat,Nb]
for real-space DMFT, where Nlat
is the number of inequivalent impurities
The impurity problem is then solved via
ed.solve(bath)
The self-energy needs to be retrieved in order to calculate the local lattice Green’s function, via
Sigma = ed.get_sigma(axis="m")
The local Green’s function calculation is left to the user, as well as that of the Weiss field or the Delta function, to be fitted by the new bath. This latter step happens via
bath = ed.chi2_fitgf(Delta,bath,ispin=0,iorb=0)
(check the function documentation for more details), but alternatively a fitting routine of the user’s choice can be employed. Convergence can be checked via
err,converged=ed.check_convergence(Delta[0,0,0,0,:],ed.dmft_error,1,ed.Nloop)
and, finally, the solution environment can be cleaned up via
ed.finalize_solver()
some or all of the steps above can be inserted in the DMFT convergence loop.