Documentation
Welcome to the documentation webpage of LibAMI. Please inform the authors of errors or omissions.
-
class AmiBase
The primary class of libami.
Contact: jleblanc@mun.ca
- Author
James P.F. LeBlanc
- Version
Revision: 0.61
- Date
Date: 2022/01/11
Note
Public Types
-
enum stat_type
Indicator for statistics. A future version might use this more frequently. Current version presumes all integration frequencies are Fermionic.
Values:
-
enumerator Bose
-
enumerator Fermi
-
enumerator Bose
-
enum graph_type
Graph types will likely be removed/replaced in a future release. Current support is limited to Sigma and Pi_phuu graph types. set graph_type=0 for Fermionic external line, and =1 for Bosonic.
Values:
-
enumerator Sigma
-
enumerator Pi_phuu
-
enumerator Pi_phud
-
enumerator Hartree
-
enumerator Bare
-
enumerator Greens
-
enumerator density
-
enumerator doubleocc
-
enumerator Pi_ppuu
-
enumerator Pi_ppud
-
enumerator DOS
-
enumerator ENERGY
-
enumerator FORCE
-
enumerator Sigma
-
enum disp_type
To be removed in a future release.
Values:
-
enumerator tb
-
enumerator fp
-
enumerator hf
-
enumerator tb
-
typedef std::vector<std::complex<double>> energy_t
The energy of each denominator will always appear as a linear combination of these initial (pre integration) energies, \(\epsilon_1, \epsilon_2\) ..etc By convention, the energy_t contains the NEGATIVE of the energy of a given Green’s function line, \( 1/(X+E) \) where \( E=-\epsilon \).
-
typedef std::vector<std::complex<double>> frequency_t
This is the list of internal and external frequencies values. Typically only the last elements for external frequencies are non-zero - but one can evaluate intermediate steps where multiple external frequencies are non-zero.
-
typedef std::vector<int> epsilon_t
Vector of type
intwith elements \( a_i\). This is the symbolic representation of the energy \(E=-\sum\limits_{i}a_i\epsilon_i\) described in AMI paper (https://doi.org/10.1103/PhysRevB.99.035120). We use the convention \(G=\frac{1}{X+E}\). It is the coefficients for a linear combination of a set of possible values.
-
typedef std::vector<int> alpha_t
Vector of type
intwith elements \( \alpha_i\). This is the symbolic representation of the frequency, as a linear combination of possible entries. Typically contains only values of 0, -1 and +1. Other values at intermediate steps typically represent an error. \(X=\sum\limits_{i} i\nu_i \alpha_i\).
-
typedef int species_t
Indicator for multi-species Green’s function or energy dispersions (spin-up vs spin-dn, multiband, etc). This indicator should propagate through the Matsubara sums to the final expression, and might have utility for evaluating energies. Technically this is not necessary for libami, but may be useful.
-
typedef std::vector<double> sign_t
Basic element of the S array in SPR notation.
-
typedef std::vector<pole_struct> pole_array_t
Basic element of the P array in SPR notation.
-
typedef std::vector<pole_array_t> Pi_t
P result after each integration step.
-
typedef std::vector<term> terms
The storage for the term-by-term construction. Each
termstruct is an element of thetermsvector.
-
typedef std::vector<std::vector<std::complex<double>>> SorF_t
Although perhaps strangely named - represents the multiplication of sign and pole arrays defined in Equation (19) (https://doi.org/10.1103/PhysRevB.99.035120).
Public Functions
-
template<typename T>
inline int sgn(T val) Returns the sign of a value - or zero if it is uniquely zero.
-
int factorial(int n)
Simple factorial function. It is rarely called except for multipole problems, and typically for only small arguments.
-
void construct(int N_INT, g_prod_t R0, terms &terms_out)
Construction function for term-by-term construction.
This is a simplified AMI symbolic integration function. It takes a starting integrand defined by
g_prod_tR0 andami_parmsobject, and returns the terms for symbolic evaluation in a simpletermsstructure.- Parameters:
parms – [in] :
ami_parmsobject, basic parameters for AMI.R0 – [in] :
g_prod_tintegrand to be processed.terms_out – [out] Resultant
termscontaining separate AMI terms for later evaluation.
-
void construct(ami_parms &parms, g_prod_t R0, terms &terms_out)
For user simplicity this is a wrapper function to make ami_terms and SPR calls similar.
-
std::complex<double> evaluate(ami_parms &parms, terms &ami_terms, ami_vars &external)
Evaluate Terms.
This is the primary AMI evaluation function for the term-by-term construction.
- Parameters:
- Returns:
Result is returned as single value of type
std::complex<double>.
-
std::complex<double> evaluate_term(ami_parms &parms, term &ami_term, ami_vars &external)
Evaluate a single Term. Usage is identical to
evaluatefunction.
-
std::complex<double> eval_fprod(ami_parms &parms, pole_array_t &p_list, ami_vars &external)
Evaluate the numerator of a term - product of fermi/bose functions.
- Parameters:
- Returns:
Single value for product of fermi/bose functions.
-
void integrate_step(int index, terms &in_terms, terms &out_terms)
Integrates a single Matsubara index.
-
void terms_general_residue(term &this_term, pole_struct this_pole, terms &out_terms)
Primary residue function for term construction.
-
void take_term_derivative(term &in_term, pole_struct &pole, terms &out_terms)
Derivative for term construction.
-
void convert_terms_to_ri(terms &ami_terms, Ri_t &Ri)
Convert terms to Ri structure for optimization. This does not create a usable
termsobject. It is purely an intermediate step for the optimization functions.
-
pole_array_t find_poles(int index, g_prod_t &R)
Simple function to scan through
g_prod_tand collect an std::vector of poles with respect to index.
-
g_prod_t simple_residue(g_prod_t G_in, pole_struct pole)
Used in pole multiplicity == 1 - aka, simple pole. Performs residue theorem on G_in and produces a new
g_prod_tas output.- Parameters:
G_in – [in]
g_prod_tto evaluate residues with respect to pole.pole – [in]
pole_structdefining the pole.
- Returns:
is of type
g_prod_t.
-
g_struct update_G_pole(g_struct g_in, pole_struct pole)
Manipulates a Green’s function to replace residue variable ‘z’ with complex pole.
-
pole_struct update_Z_pole(AmiBase::pole_struct p_in, AmiBase::pole_struct pole)
Manipulates a Pole_struct to replace residue variable ‘z’ with complex pole.
-
void update_gprod_simple(int index, R_t &R_array, P_t &P_array, S_t &S_array)
Depricated version of update_gprod for only simple poles. Replaced by update_gprod_general.
-
void update_gprod_general(int int_index, int array_index, R_t &R_array, P_t &P_array, S_t &S_array)
Primary loop. Takes R[n] as input and outputs R[n+1], P[n+1] and S[n+1].
- Parameters:
int_index – [in] indicator for which is the integration variable.
array_index – [in] indicator for which element of
alpha_tcorresponds to that integration variable. Typically the same as int_index, unless you want to perform out of order.R_array – [in] R[n] input.
R_array – [out] updated with R[n+1] on output.
S_array – [out] updated with S[n+1] on output.
P_array – [out] updated with P[n+1] on output.
-
SorF_t fermi(ami_parms &parms, Pi_t pi, ami_vars external)
The fermi/bose operator. Translates a vector of poles, into a vector of Fermi/Bose functions (and their derivatives) with specific numerical values dependent upon input
ami_vars.
-
std::complex<double> fermi_pole(ami_parms &parms, pole_struct pole, ami_vars external)
Evaluation of a single pole in Fermi/Bose functions for a given
ami_vars.
-
SorF_t cross(SorF_t left, SorF_t right)
Evaluation cross operator from AMI paper.
Cross operator ‘ \(\times \)‘ that is defined after equation (20) in the AMI paper (https://doi.org/10.1103/PhysRevB.99.035120).
-
SorF_t dot(Si_t Si, SorF_t fermi)
Evaluation dot-product from AMI paper.
Dot operator ‘ \( \cdot \)‘ that is defined after equation (20) in the AMI paper (https://doi.org/10.1103/PhysRevB.99.035120).
-
std::complex<double> get_energy_from_pole(pole_struct pole, ami_vars external)
Given a set of external energies, beta, and frequencies, will evaluate the energy of a pole_struct.
-
std::complex<double> get_energy_from_g(g_struct g, ami_vars external)
Given a set of external energies, beta, and frequencies, will evaluate the energy of a g_struct.
-
std::complex<double> eval_gprod(ami_parms &parms, g_prod_t g_prod, ami_vars external)
Evaluates a product of Green’s functions.
Numerical evaluation of a product of Green’s functions. Used both in
termsandR_tconstructions.
-
bool pole_equiv(pole_struct pole1, pole_struct pole2)
Checks if two Poles have similar characteristics. These characteristics include
epsilon_tsize andalpha_tsize. Additionally, it checks each value ofepsilon_tvector andalpha_tvector are the same.- Parameters:
pole1 – [in] First pole you want to compare of type
pole_struct.pole2 – [in] Second pole you want to compare of type
pole_struct.
-
bool g_equiv(g_struct g1, g_struct g2)
Checks if two
g_structhave similar characteristics. These characteristics includeepsilon_tsize andalpha_tsize. Additionally, it checks each value ofepsilon_tvector andalpha_tvector are the same.
-
void evaluate_general_residue(g_prod_t G_in, pole_struct pole, Ri_t &Ri_out, pole_array_t &poles, sign_t &signs)
Void function takes a product of Green’s functions - an element of an
Ri_tobject - and obtains the residue for a specific pole. Output is an array of such elements, a fullRi_Tobject, along with the respective poles and signs forPi_tandSi_t. Includes derivative.- Parameters:
G_in – [in] : Product of green’s functions.
pole – [in] : Pole to evaluate residue.
Ri_out – [out] : Resultant
g_prod_t.poles – [out] : Resultant
pole_array_t.signs – [out] : Resultant
sign_t.
-
void take_derivative_gprod(g_prod_t &g_prod, pole_struct pole, double start_sign, Ri_t &r_out, pole_array_t &poles, sign_t &signs)
Take derivative of
g_prod_twith respect to index stored inpole_struct. This is accomplished via multiple applications of chain rule. This is described in PRB 99 035120 - though the notation changed somewhat. The prefactor of -1 is no longer absorbed into a green’s function, but instead is stored in theS_tarray. What is omitted there is discussion of derivatives of the Fermi functions. Here they are simply tracked by defining an integerder_of thepole-structthat gets incremented.
-
double get_starting_sign(g_prod_t G_in, pole_struct pole)
As part of the construction of the
Si_tarrays, the initial sign is extracted prior to taking derivatives. Also is multiplied by \(1/(M-1)!\) where M is themultiplicity_of the respective pole.Obtains the elements of
S_tarrays, modified for poles with multiplicity!=1.
-
g_prod_t reduce_gprod(g_prod_t G_in, pole_struct pole)
Removes green’s functions from
g_prod_tto account for numerator of residue (z-z0)^m
-
double frk(int r, int k)
In order to take arbitrary derivatives of fermi functions - we need to know the prefactor. The fermi/bose function is given in general by the function:
\[ \sum\limits_{k=0}^{m} f_{rk}(m,k) \sigma^k (-1.0)^{k+1} \frac{1}{\sigma e^{\beta E}+1.0} \frac{1}{[\sigma + e^{-\beta E}]^k} \]The frk function itself returns
\[ f_{rk}(m,k)=\sum\limits_{m=0}^{k+1} binomialCoeff(k,m) m^r (-1)^{k-m}. \]Using notation to match https://doi.org/10.1103/PhysRevB.99.035120. They produced coefficients to the fermi functions and put them in a table. We derive a general expression for those coefficients - we believe this to be general but have only checked up to 6th order.
-
std::complex<double> fermi_bose(int m, double sigma, double beta, std::complex<double> E)
Recursive construction of fermi_bose derivatives.
This computes the mth order derivative of the Fermi function or the negative of the Bose distribution functions given by \(\frac{1}{\sigma \exp^{\beta E}+1} \) at \( \beta\), for energy \( E\). \( \sigma=1.0\) for Fermi and -1.0 for Bose.
-
int binomialCoeff(int n, int k)
Returns value of Binomial Coefficient C(n, k).
-
AmiBase()
Default Constructor. Constructor is empty. Currently no initialization is required in most cases.
-
void construct(ami_parms &parms, g_prod_t R0, R_t &R_array, P_t &P_array, S_t &S_array)
This is the primary AMI symbolic integration function. It takes a starting integrand defined by
g_prod_tR0 andami_parmsobject, and returns the S, P and R arrays necessary for symbolic evaluation.- Parameters:
parms – [in] :
ami_parmsobject, basic parameters for AMI.R0 – [in] :
g_prod_tintegrand to be processed.R_array – [out] Resultant
R_t.P_array – [out] : Resultant
P_t.S_array – [out] : Resultant
S_t.
-
std::complex<double> evaluate(ami_parms &parms, R_t &R_array, P_t &P_array, S_t &S_array, ami_vars &external)
This is a primary AMI symbolic evaluation function. It takes a solution defined by S, P, and R arrays and the external parameters and returns a
complex<double>restult.
-
std::complex<double> evaluate(ami_parms &parms, R_t &R_array, P_t &P_array, S_t &S_array, ami_vars &external, g_prod_t &unique_g, R_ref_t &Rref, ref_eval_t &Eval_list)
This is an optimized version of the evaluate function. For simplicity if the additional arguments are empty the evaluate function is called directly.
-
struct ami_parms
Parameters for AMI construction/evaluation.
Public Members
-
int N_INT_
Number of integrations to perform.
-
int N_EXT_ = 1
Hardcoded as (1) in this version - represents number of external variables.
-
double E_REG_ = 0
Possible energy regulator for evaluation of Fermi/Bose functions to control divergences. Should be zero by default and switched on if needed.
-
double tol_ = 1e-12
Tolerence to determine equality.
-
int N_INT_
-
struct ami_vars
The
ami_varsstruct is the basic information required for the evaluation stage of AMI result. It contains the variable internal/external quantities. Specifically it is a list of numerical values for energies of each line and values for each frequency. Also stored is the possibility of an overall prefactor. Also required is a value of \(\beta=\frac{1}{k_B T}\) needed for evaluation of Fermi/Bose distributions.Public Members
-
frequency_t frequency_
Numerical Values of frequencies.
-
double prefactor = 1.0
Overall prefactor - default(1).
-
double BETA_ = 0.0
Required value of inverse temperature, \(\beta\).
-
double gamma_ = 0
Experimental parameter for spectral representation.
-
frequency_t frequency_
-
struct g_struct
A Green’s function structure. This is a symbolic vector of
epsilon_tand vector ofalpha_t. Also needed is what the statistics of the line are. While this could be determined from alpha - it is better to store it. For multistate systems the species_ index might be useful.
-
struct pole_struct
Pole structure. Equivalent to
g_struct, but kept separate. Tracks multiplicity, and which Green’s function it is attached to. Also it tracks how many derivatives to take when evaluated at a fermi function.
-
struct term
Term Structure for term-by-term evaluation. Conceptually simpler than SPR construction. Storage translates to \( \prod{f(p_i)}\prod{G_j}\times sign \).
Public Members
-
double sign = 1
Sign prefactor.
-
pole_array_t p_list
List of poles, \( \prod{f(p_i)}\).
-
double sign = 1