Basic usage

Module import

Upon import, the edipy2 python module will try to load the dynamic library libedipack2_cbinding.so , provided by EDIpack2.0 and containing the c-fortran bindings. The module will try the following routes, in order of priority:

  • As a first choice, the user can override the location of the library by exporting an environment variable called EDIPACK_PATH .

  • By default, the module detects the presence of the Fortran libraries via pkg-config. If EDIpack2.0 was loaded as an environment module, the import will automatically work.

  • The EDIpack2.0 library provides a .pc , located by default in the ~/.pkgconfig.d directory. If the environment variable PKG_CONFIG_PATH is set to include the location of the .pc file, loading the library via pkg-config will work as well.

  • As a last resort LD_LIBRARY_PATH and DYLD_LIBRARY_PATH are scanned.

If none of the previous attempts succeeds, the module will not not load correctly and an error message will be printed.

The EDIpack2.0 library offers, as an independent module, an interface for real-space DMFT functions (see relevant documentation). EDIpy2.0 is in principle capable of solving real-space DMFT problems, provided the Fortran libraries were compiled with the real-space DMFT support enabled. If that is not the case, the python module will disable the real-space DMFT functions, and invoking them will result in a RuntimeError. The user can check the availability of the real-space DMFT interface by printing the value of edipy2.global_env.has_ineq.

The edipy2 module consists mainly of a class called global_env. The global variables and the functions of the EDIpack2.0 library that are exposed to the user are properties and methods of this class. The class needs to be imported at the beginning of the python script, along with other useful modules. Numpy is necessary, while mpi4py is strongly recommended.

import numpy as np
import mpi4py
from mpi4py import MPI
from edipy2 import global_env as ed
import os,sys

Minimal DMFT loop

An example driver is provided in the examples folder of the EDIpy2.0 repository. 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.