Skip to content

Commit

Permalink
deploy: 1d025bf
Browse files Browse the repository at this point in the history
  • Loading branch information
lcrippa committed Oct 13, 2024
0 parents commit 1e68ce2
Show file tree
Hide file tree
Showing 96 changed files with 9,258 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
config: ded57ba0f26af3573bb9b0048aa49a45
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file added .doctrees/basicusage.doctree
Binary file not shown.
Binary file added .doctrees/environment.pickle
Binary file not shown.
Binary file added .doctrees/funcs/0_readinput.doctree
Binary file not shown.
Binary file added .doctrees/funcs/1_solver.doctree
Binary file not shown.
Binary file added .doctrees/funcs/2_bath.doctree
Binary file not shown.
Binary file added .doctrees/funcs/3_inputoutput.doctree
Binary file not shown.
Binary file added .doctrees/funcs/4_auxiliary.doctree
Binary file not shown.
Binary file added .doctrees/functions.doctree
Binary file not shown.
Binary file added .doctrees/globvars.doctree
Binary file not shown.
Binary file added .doctrees/index.doctree
Binary file not shown.
Binary file added .doctrees/installation.doctree
Binary file not shown.
Empty file added .nojekyll
Empty file.
80 changes: 80 additions & 0 deletions _sources/basicusage.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
Basic usage
==============

The edipy2 module consists mainly of a class called :code:`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.

.. code-block:: python
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 :code:`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

.. code-block:: python
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 :code:`used.` prefix, which will need to be removed. An `example <https://raw.githubusercontent.com/aamaricci/EDIpack2.0/refs/heads/master/test/python/inputED.conf>`_ of input file with a brief description of the relevant global variables is provided in the EDIpack2 repo.

Set the local Hamiltonian

.. code-block:: python
ed.set_hloc(hloc=Hloc)
If :code:`BATH_TYPE` is :code:`REPLICA` or :code:`GENERAL`, the replica matrix has to be initialized via

.. code-block:: python
ed.set_hreplica(hvec, lambdavec)
ed.set_general(hvec, lambdavec)
where :code:`hvec` and :code:`lambdavec` are arrays of the proper size (see function documentation).

The solver needs to be initialized via

.. code-block:: python
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 :code:`Nb` = :func:`ed.get_bath_dimension` for single-impurity DMFT and :code:`[Nlat,Nb]` for real-space DMFT, where :code:`Nlat` is the number of inequivalent impurities

The impurity problem is then solved via

.. code-block:: python
ed.solve(bath)
The self-energy needs to be retrieved in order to calculate the local lattice Green's function, via

.. code-block:: python
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

.. code-block:: python
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

.. code-block:: python
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

.. code-block:: python
ed.finalize_solver()
some or all of the steps above can be inserted in the DMFT convergence loop.
17 changes: 17 additions & 0 deletions _sources/funcs/0_readinput.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Input file manipulation
========================

.. function:: read_input(input_string)

This function reads from the input file of EDIpack2. If the file does not exist, a template file is generated with default parameters.
This is generated with the prefix "used." which will need to be removed for it to be read. "used.${input_string}" will be updated within
the DMFT loop with the current value of the input variables.

:param input_string: The name of the input file to be read, including the extension
:type input_string: str
:return: Nothing
:rtype: None




87 changes: 87 additions & 0 deletions _sources/funcs/1_solver.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
.. _solver:

Impurity Problem Initialization, Solution and Finalization
================================================================

These functions initialize, solve and finalize the impurity problem. They can be invoked inside or outside the DMFT loop. The solution environment can be completely reconstructed from the bath parameters array and the global variables.

.. function:: init_solver(bath=None, Nb=None, Nlat=None)

This function initializes the ED environment for the impurity problem solution, and sets the bath reading it from the ``hamiltonian.restart`` file or initializing it in a symmetric way.
The function can take different argument combinations.

If no input is provided, a single-impurity bath is allocated, with dimension given by :func:`get_bath_dimension`.


:type bath: np.array(dtype=float) **or** [float]
:param bath: If a bath array is provided, it has to be a numpy array or a tuple of floats. It has to have one or two dimensions. If it has one dimension, that must be the same as specified by :func:`get_bath_dimension`. If it has two dimensions, the first has to be the number of inequivalent sites for real-space DMFT, the second must be in agreement with :func:`get_bath_dimension`. If ``Nlat`` or ``Nb`` are provided, this overrides them. If the provided vector is not in agreement with the global system parameters, EDIpack2 will exit with an error.
The array is ordered in F convention inside the function.

:type Nb: int
:param Nb: This sets the bath vector length for each single impurity problem. It has to be in agreement with :func:`get_bath_dimension`. When this parameter alone is provided, a numpy array of this length will be initialized.

:type Nlat: int
:param Nlat: This sets the number of inequivalent sites for real-space DMFT. If this parameter alone is provided, :func:`get_bath_dimension` is invoked to determine the bath vector length Nb for each impurity. A ``[Nlat,Nb]`` vector is then allocated.


:return: An array of floats that contains the bath parameters for the impurity problem. This is a required input of :func:`solve` and :func:`chi2_fitgf`. Its elements are ordered differently depending on the bath geometry. They are (de)compactified for user interaction via :func:`bath_packaging`. Specific symmetrization operations are implemented and listed in the :ref:`bath` section.
:rtype: np.array(dtype=float)

.. function:: finalize_solver()

This function cleans up the ED environment, deallocates the relevant arrays and makes a second call to :command:`init_solver` possible

:return: Nothing
:rtype: None


.. function:: set_hloc(hloc,Nlat=None)

This function sets the local Hamiltonian of the impurity problem.

:type hloc: np.array(dtype=complex)
:param hloc: Local Hamiltonian matrix. This can have the following shapes:

* :code:`[ed.Nspin*ed.Norb,ed.Nspin*ed.Norb]`: single-impurity case, 2-dimensional array
* :code:`[ed.Nspin,ed.Nspin,ed.Norb,ed.Norb]`: single-impurity case, 4-dimensional array
* :code:`[Nlat*ed.Nspin*ed.Norb,Nlat*ed.Nspin*ed.Norb]`: real-space DMFT case, 2-dimensional array.
* :code:`[Nlat,Nspin*ed.Norb,ed.Nspin*ed.Norb]`: single-impurity case, 3-dimensional array.
* :code:`[Nlat,ed.Nspin,ed.Nspin,ed.Norb,ed.Norb]`: single-impurity case, 5-dimensional array.

The array is ordered in F convention inside the function.

**Note**: the way the EDIpack2 library passes from 1 comulative to 2 or 3 running indices is, from slower to faster: ``lat``, ``spin``, ``orb``

:type Nlat: int
:param Nlat: Number of inequivalent sites for real-space DMFT. The function will raise a ValueError if the dimensions of ``hloc`` are inconsistent with the presence or absence of Nlat.
The EDIpack2 library will check the correctness of the dimensions of ``hloc`` and terminate execution if inconsistent.

:raise ValueError: If hloc is not provided or has the wrong shape

:return: Nothing
:rtype: None


.. function:: solve(bath, sflag=True, iflag=True, fmpi=True, mpi_lanc=False)

This function solves the impurity problem and calculates the observables, Green's function and self-energy.

:type bath: np.array(dtype=float)
:param bath: The bath array returned by :func:`init_solver`. If the bath dimensions are inconsistent with the global properties of the problem, EDIpack2 will exit with an error.

:type sflag: bool
:param sflag: for single-impurity DMFT, if :code:`False`, it disables the calculation of the Green's function and susceptibilities

:type iflag: bool
:param iflag: for real-space DMFT, if :code:`False`, it disables the calculation of the Green's function and susceptibilities

:type fmpi: bool
:param fmpi: if :code:`False`, for single-impurity DMFT, it disables MPI for the ED routine, if the communicator is used elsewhere

:type mpi_lanc: bool
:param mpi_lanc: if :code:`True`, for real-space DMFT sets the MPI parallelization for the ED routine. By default it is :code:`False`, and each inequivalent site is solved serially by a different core.

:return: Nothing
:rtype: None


Loading

0 comments on commit 1e68ce2

Please sign in to comment.