Struct lattice_model_instance¶
Defined in File lattice_model_instance.hpp
Struct Documentation¶
-
struct lattice_model_instance¶
instance of a model (i.e. with specific values of the parameters in the Hamiltonian)
Public Functions
-
complex<double> TrSigmaG(Complex w, vector3D<double> &k, bool spin_down)¶
computes Tr(Sigma G) at a given frequency and wavevector, for the computation of the potential energy
- Parameters:
w – frequency
k – wavevector
spin_down – true if in spin down sector (mixing = 4)
- Returns:
Tr(Sigma G)
-
double Berry_flux(const vector<vector3D<double>> &k, int orb, bool spin_down)¶
Computes the integral of the Berry connexion along a closed contour, specified as a list of wavevectors.
- Parameters:
k – [in] array of wavevectors
orb – [in] orb=0 means a sum over all lattice orbitals, otherwise the lattice orbital specified
spin_down – [in] true if the spin down sector is considered
-
double Berry_plaquette(Green_function &G, const vector3D<double> &k1, const double deltax, const double deltay, const int opt, int dir, int orb)¶
Computes the flux of the Berry curvature through a square plaquette with a corner at k1 and wavevector increments deltax and deltay.
- Parameters:
G – [in] Green function objet
k1 – [in] wavevector (corner of the plaquette)
deltax – [in] wavevector step in direction 1
deltay – [in] wavevector step in direction 2
opt – [in] option, like in function Green_eigensystem above
dir – [in] direction of perpendicular to plaquette (x=1, y=2, z=3)
orb – [in] orb=0 means a sum over all lattice orbitals, otherwise the orbital specified
-
double CDMFT_distance(const vector<double> &p, int clus)¶
Computes the CDMFT distance function.
- Parameters:
p – values of the variational parameters
- Returns:
the distance function
-
vector<double> CDMFT_residuals(const vector<double> &p, int clus)¶
Computes the CDMFT residual vector (real-valued) used by least_squares optimizers.
The residuals are r_n = sqrt(w_n) * (Gamma(iw_n) + G_host(iw_n)), packed as [Re(.).ravel(), Im(.).ravel()] for each frequency, then stacked over frequencies. If the model has up_down mixing, residuals for both spin components are concatenated.
NOTE: unlike CDMFT_distance, this does NOT multiply by dw nor divide by (dim*dim), because least_squares uses the residuals directly (sum of squares forms the cost). A constant rescaling does not change the optimum.
- Parameters:
p – values of the variational parameters
clus – cluster index
- Returns:
the real residual vector
-
vector<double> CDMFT_gradient(const vector<double> &p, int clus)¶
Computes the finite-difference Jacobian d r / d p of the CDMFT residual vector using central differences: J[:,j] = (r(p+δeⱼ) − r(p−δeⱼ)) / (2δ).
Stored row-major with shape (Nrows, Nparams), where Nrows = 2 * n_spins * Nfreq * dim^2.
Cost: 2*Nparams calls to CDMFT_residuals (no baseline evaluation needed). Accuracy: O(δ²) ≈ 1e-10 versus O(δ) ≈ 1e-7 for forward differences.
Implementation note: the bath parameters -> Gamma(iw) map is evaluated by finite difference because individual operator derivatives are not exposed by the lattice_model_instance interface. This is still substantially cheaper than scipy’s default numerical Jacobian (all computation stays in C++).
- Parameters:
p – values of the variational parameters
clus – cluster index
- Returns:
the Jacobian as a flat row-major vector (shape: Nrows × Nparams, row-major)
-
double monopole_part(vector3D<double> &k, double a, int nk, int orb, bool rec, int dir, bool spin_down)¶
Computes the contribution of a plaque to the Chern number.
- Parameters:
k – [in] node wavevector
a – [in] half side of the cube
nk – [in] number of wavevectors on the side of the Brillouin zone
orb – [in] orbital label (0 means a sum over all lattice orbitals)
rec – [in] if true, refines reursively the grid if needed
dir – [in] direction of perpendicular to plaquette (x=1, y=2, z=3)
-
double monopole(vector3D<double> &k, double a, int nk, int orb, bool rec)¶
Computes the Chern number integral on the surface of a cube.
- Parameters:
k – [in] wavevector at the center of the cube
a – [in] half side of the cube
nk – [in] number of wavevectors on the side of the Brillouin zone
orb – [in] orbital label (0 means a sum over all lattice orbitals)
rec – [in] if true, refines reursively the grid if needed
-
double potential_energy()¶
Calculates the potential energy using $V = Tr(\Sigma G)$ The self-energy cannot be accurately computed when the frequency is too high, because of round off errors when subtracting the frequency from the inverse Green function.
Best to not go beyond half the accuracy of doubles, i.e., 1e-7 (or freq ~ 1e7).
- Returns:
the potential energy
-
double Potthoff_functional()¶
Calculates the self-energy functional (SEF) = Potthoff functional.
- Returns:
the Potthoff functional
-
double spectral_average(const string &name, const complex<double> w)¶
calculates the contribution of a frequency to the average of the operator ‘name’
- Parameters:
name – [in] name of the operator
w – [in] complex frequency
-
Green_function cluster_Green_function(Complex w, bool sig, bool spin_down)¶
computes cluster Green function and puts it in the structure G
- Parameters:
w – [in] complex frequency
sig – [in] if true, computes also the self-energy
spin_down – [in] if true, computes the spin-down part
- Returns:
a Green_function object
default constructor
- Parameters:
_model – [in] : lattice model
_label – [in] : label given to the instance
-
~lattice_model_instance()¶
-
matrix<complex<double>> cluster_Green_function_remix(size_t i, complex<double> w, bool spin_down, bool blocks)¶
returns the remixed cluster Green function for cluster # i at frequency w if the cluster only contains one system, then this is directly that system’s Green function.
Otherwise they are averaged inverse-wise.
- Parameters:
c – [in] index of the cluster (starts at 0)
w – [in] complex frequency
spin_down – [in] true if we are asking for the spin down part (mixing = 4)
- Returns:
a complex-valued matrix containing the cluster Green function
-
matrix<complex<double>> cluster_Green_function(size_t i, complex<double> w, bool spin_down, bool blocks)¶
returns the cluster Green function for cluster # i at frequency w
- Parameters:
c – [in] index of the cluster (0-based)
w – [in] complex frequency
spin_down – [in] true if we are asking for the spin down part (mixing = 4)
- Returns:
a complex-valued matrix containing the cluster Green function
-
matrix<complex<double>> cluster_hopping_matrix(size_t i, bool spin_down)¶
returns the cluster hopping matrix for cluster # i
- Parameters:
c – [in] index of the cluster (starts at 0)
spin_down – [in] true if we are asking for the spin down part (mixing = 4)
- Returns:
a complex-valued matrix containing the cluster non interacting matrix (hopping + pairing)
-
matrix<complex<double>> cluster_self_energy_remix(size_t i, complex<double> w, bool spin_down)¶
returns the remixed cluster Green function for cluster # i at frequency w if the cluster only contains one system, then this is directly that system’s Green function.
Otherwise they are averaged inverse-wise.
- Parameters:
c – [in] index of the cluster (starts at 0)
w – [in] complex frequency
spin_down – [in] true if we are asking for the spin down part (mixing = 4)
- Returns:
a complex-valued matrix containing the cluster Green function
-
matrix<complex<double>> cluster_self_energy(size_t i, complex<double> w, bool spin_down)¶
returns the cluster Green function for cluster # i at frequency w
- Parameters:
c – [in] index of the cluster (0 to the number of clusters)
w – [in] complex frequency
spin_down – [in] true if we are asking for the spin down part (mixing = 4)
- Returns:
a complex-valued matrix containing the cluster self-energy
-
matrix<complex<double>> hybridization_function_remix(size_t i, complex<double> w, bool spin_down)¶
returns the remixed cluster Green function for cluster # i at frequency w if the cluster only contains one system, then this is directly that system’s Green function.
Otherwise they are averaged inverse-wise.
- Parameters:
c – [in] index of the cluster (starts at 0)
w – [in] complex frequency
spin_down – [in] true if we are asking for the spin down part (mixing = 4)
- Returns:
a complex-valued matrix containing the cluster Green function
-
matrix<complex<double>> hybridization_function(size_t i, complex<double> w, bool spin_down)¶
returns the hybridization function for cluster # i at frequency w
- Parameters:
c – [in] index of the cluster (1 to the number of clusters)
w – [in] complex frequency
spin_down – [in] true if we are asking for the spin down part (mixing = 4)
- Returns:
a complex-valued matrix containing the cluster hybridization function
-
matrix<complex<double>> Green_integral(bool spin_down, int clus)¶
calculates the frequency-integral of the local Green function
- Parameters:
spin_down – [in] true if the spin-down sector is desired (mixing = 4 only)
- Returns:
an average complex-valued matrix
-
matrix<Complex> epsilon(Green_function_k &M)¶
calculates the periodized kinetic energy (of dimension nband, or 2*nband in the anomalous case)
- Parameters:
M – [in, out] Green_function_k object
- Returns:
a complex-valued matrix
-
matrix<Complex> projected_Green_function(Complex w, bool spin_down)¶
Calculates the integral of Gcpt over wavevectors, using the grid kgrid.
- Parameters:
w – [in] complex frequency
spin_down – [in] if true, computes the spin-down component (mixing = 4)
-
matrix<Complex> band_Green_function(Green_function_k &M)¶
Produces the periodized Green function, according to possible periodization schemes.
- Parameters:
M – [in, out] Green_function_k object
-
matrix<Complex> upgrade_cluster_matrix_anomalous(int latt_mix, int clus_mix, matrix<Complex> &g, matrix<Complex> &gm)¶
upgrades a cluster Green function g and its Nambu version gm from its native mixing clus_mix to the lattice model’s mixing latt_mix.
- Parameters:
latt_mix – [in] mixing state of the lattice model
clus_mix – [in] mixing state of the cluster
g – [in] the cluster Green function
gm – [in] Nambu version of the cluster Green function
- Returns:
the upgraded Green function
-
matrix<Complex> upgrade_cluster_matrix(int latt_mix, int clus_mix, matrix<Complex> &g)¶
upgrades a cluster Green function g from its native mixing clus_mix to the lattice model mixing latt_mix.
No additional anomalous component required.
- Parameters:
latt_mix – [in] mixing state of the lattice model
clus_mix – [in] mixing state of the cluster
g – [in] the cluster Green function
- Returns:
the upgraded Green function
-
pair<vector<array<double, 9>>, vector<array<complex<double>, 11>>> site_and_bond_profile()¶
This function computes the density and bond profiles for the model instance.
-
vector<double> Berry_curvature(vector3D<double> &k1, vector3D<double> &k2, int nk, int orb, bool recursive = false, int dir = 3)¶
Plots the interacting Berry curvature within the Brillouin zone See: Z.
Wang and S.C. Zhang, Physical Review X 2 (2012), no. 3, 031008. AND Takahiro Fukui, Yasuhiro Hatsugai, and Hiroshi Suzuki, Journal of the Physical Society of Japan 74 (2005), no. 6, 1674– 1677.
- Parameters:
k1 – [in] lower left corner of the wavevector domain
k2 – [in] upper right of the wavevector domain
nk – [in] number of wavevectors on the side of the Brillouin zone (nk x nk grid)
orb – [in] orbital label (0 means a sum over all lattice orbitals)
rec – [in] if true, refines reursively the grid if needed
dir – [in] direction of perpendicular to plaquette (x=1, y=2, z=3)
-
vector<double> dispersion(Green_function_k &M)¶
calculates the dispersion relation (of dimension nband, or 2*nband in the anomalous case)
- Parameters:
M – [in, out] Green_function_k object
- Returns:
an array of eigenvalues
-
vector<double> dos(const complex<double> w, bool use_grid = false)¶
calculates the density of states In the anomalous case, this function will compute the DoS at the opposite frequency (-w) for the spin down part.
- Parameters:
w – frequency returns an array of dimension 2*n_band
-
vector<double> momentum_profile_per(const lattice_operator &op, const vector<vector3D<double>> &k)¶
calculates the momentum-dependent average of an operator, from the periodized operator
- Parameters:
op – [in] lattice operator
k_set – [in] array of wavevectors
- Returns:
an array of average values, one for each wavevector
-
vector<double> momentum_profile(const lattice_operator &op, const vector<vector3D<double>> &k)¶
calculates the momentum-dependent average of an operator
- Parameters:
op – [in] lattice operator
k_set – [in] array of wavevectors
- Returns:
an array of average values, one for each wavevector
-
vector<pair<double, string>> ground_state()¶
finds the ground states of all clusters
- Returns:
a vector of (double, string) giving the ground state energy and sector for each cluster
-
vector<pair<string, double>> averages(const vector<string> &_ops)¶
Calculates the lattice expectation value of all operators in the model.
- Parameters:
_ops – list of names of operators to compute the averages of
- Returns:
an array of (string, double) giving the average for each lattice operator
-
vector<pair<vector<double>, vector<double>>> Lehmann_Green_function(vector<vector3D<double>> &k, int orb, bool spin_down)¶
Produces the Lehmann form of an array of Green functions at fixed frequency.
- Parameters:
k – [in] array of wavevectors
orb – [in] lattice orbital label
spin_down – [in] true if the spin-down part is to be produced (mixing = 4)
- Returns:
for each wavevector, a pair of arrays giving the location of the pole and the residue
-
void set_CDMFT_host(const vector<double> &freqs, const int clus, const vector<matrix<Complex>> &H, const bool spin_down)¶
sets the CDMFT host from input data
- Parameters:
freqs – [in] frequency array (along the imaginary axis)
clus – [in] label of the cluster
H – [in] vector of matrices (host)
spin_down – [in] boolean : true if spin-down sector (mixing = 4)
-
void average_integrand_per(Complex w, vector3D<double> &k, const int *nv, double *I)¶
integrands in the calculation of lattice averages
- Parameters:
w – frequency
k – wavevector
nv – number of components
I – values of the components of the integrand
-
void average_integrand(Complex w, vector3D<double> &k, const int *nv, double *I)¶
integrands in the calculation of lattice averages
- Parameters:
w – frequency
k – wavevector
nv – number of components
I – values of the components of the integrand
-
void average_integrand(int iw, int ik, vector<double> &I)¶
integrands in the calculation of lattice averages (using a frequency-momentum grid)
- Parameters:
iw – label of frequency
ik – label of wavevector
nv – number of components
I – values of the components of the integrand
-
void average_integrand_k(Green_function &G_up, Green_function *G_down, vector3D<double> &k, const int *nv, double *I)¶
per-k integrand for averages, given a precomputed cluster Green function (and optionally its spin-down counterpart for up_down mixing)
per-k integrand for averages, with the cluster Green function precomputed.
Used to hoist the frequency-dependent (and k-independent) cluster Green function build out of the parallel k-loop in k_integral_grid: with G_up (and G_down) supplied as read-only inputs, the integrand contains no shared mutable state and is safe to call concurrently.
- Parameters:
G_up – cluster Green function at the current frequency (taken by non-const reference because Green_function_k stores a non-const reference; only read)
G_down – cluster Green function for the spin-down sector when mixing is up_down, otherwise nullptr
k – wavevector
nv – number of components
I – values of the components of the integrand
-
void build_cluster_H()¶
building the cluster one-body matrices
-
void build_H()¶
building the k-independent part of the one-body matrices
-
void CDMFT_host(const vector<double> &freqs, const vector<double> &weights)¶
Computes the CDMFT host.
- Parameters:
freqs – [in] frequency array (along the imaginary axis)
weights – [in] weights of the different frequencies in the distance function
-
void CDMFT_host()¶
Computes the CDMFT host from an external hybridization.
-
void cluster_self_energy(Green_function &G)¶
computes the self-energy for the Green function object G
- Parameters:
G – [in] Green function object
-
void Green_eigensystem(Green_function &G, const vector3D<double> &k, vector<double> &e, matrix<Complex> &U, int opt)¶
Computes the eigenvalues and eigenvectors of a Green function at zero frequency.
- Parameters:
G – [in] Green function object
k0 – [in] wave vector
e – [out] eigenvalues
U – [out] matrix whose columns are the eigenvectors
opt –
[in] option:
opt = 0 : physical basis (periodized Green function) opt = 1 : dual_basis (periodized Green function) opt = 2 : non periodized Green function
-
void Green_function_solve()¶
calls the Green_function solver for all clusters
finds the Green function representation of all systems
-
void inverse_Gcpt(const block_matrix<Complex> &Ginv, Green_function_k &M)¶
Computes the inverse CPT Green function (in partial real-space representation) Ginv is the inverse cluster Green function At the end M.V contains the inverse CPT Green function, instead of the CPT Green function as in the usual call.
- Parameters:
Ginv – [in] inverse cluster Green function
M – [in, out] Green_function_k object
-
void periodized_Green_function(Green_function_k &M)¶
Produces the periodized Green function, according to possible periodization schemes.
- Parameters:
M – [in, out] Green_function_k object
-
void potential_energy_integrand(Complex w, vector3D<double> &k, const int *nv, double *I)¶
integrand in the computation of the potential energy
- Parameters:
w – frequency
k – wavevector
nv – number of components
I – values of the components of the integrand
-
void potential_energy_integrand_k(Green_function &G_up, Green_function *G_down, vector3D<double> &k, const int *nv, double *I)¶
per-k potential-energy integrand, given a precomputed cluster Green function (with self-energy) and optionally its spin-down counterpart for up_down mixing
per-k integrand in the computation of the potential energy, given a precomputed cluster Green function (with its self-energy already built).
Used by the discrete (omega, k) grid path to hoist the frequency-dependent (and k-independent) cluster Green function and self-energy build out of the parallel k-loop in k_integral_grid: with G_up (and optionally G_down) supplied as read-only inputs, the integrand contains no shared mutable state and is safe to call concurrently.
- Parameters:
G_up – cluster Green function (with self-energy) at the current frequency
G_down – cluster Green function for the spin-down sector when mixing is up_down, otherwise nullptr
k – wavevector
nv – number of components (1)
I – output: Re Tr(Sigma G) at this (omega, k)
-
void print_parameters(ostream &out, print_format format)¶
Prints model_instance parameters to a stream.
- Parameters:
out – [in] output stream
format – [in] print format, as described in the enumeration print_format
-
void SEF_integrand(Complex w, vector3D<double> &k, const int *nv, double *I)¶
Integrand of the SEF integral.
- Parameters:
w – [in] complex frequency
k – [in] wavevector
nv – number of values in the integrand
I – values of these components
-
void SEF_integrand_k(Green_function &G_up, Green_function *G_down, vector3D<double> &k, const int *nv, double *I)¶
per-k SEF integrand, given a precomputed cluster Green function (and optionally its spin-down counterpart for up_down mixing)
Per-k SEF integrand, given a precomputed cluster Green function.
Used by the discrete (omega, k) grid path to hoist the frequency-dependent (and k-independent) cluster Green function build out of the parallel k-loop in k_integral_grid: with G_up (and optionally G_down) supplied as read-only inputs, the integrand contains no shared mutable state and is safe to call concurrently.
- Parameters:
G_up – cluster Green function at the current frequency
G_down – cluster Green function for the spin-down sector when mixing is up_down, otherwise nullptr
k – wavevector
nv – number of components (1)
I – output: log|det(V*G - 1)| at this (omega, k)
-
void self_energy(Green_function_k &M)¶
calculates the lattice self-energy matrix (of dimension nband, or 2*nband in the anomalous case)
- Parameters:
M – [in, out] Green_function_k object
-
void set_Gcpt(Green_function_k &M)¶
Computes the CPT Green function (in partial real-space representation)
\[ G_{\rm cpt}^{-1} = G^{-1} - V\]- Parameters:
M – [in, out] Green_function_k object
-
void set_V(Green_function_k &M, bool nohybrid = false)¶
Builds the matrix tk, the momentum-dependent hopping matrix then Calculates V, defined as \( t(k) - t' - \Gamma(\omega)\) if nohybrid is true, then only \( t(k) - t' \).
- Parameters:
M – [in, out] Green_function_k object
nohybrid – [in] if true, does not add the hybridization function (used in producing the Lehmann form of the Green function)
Public Members
-
int label¶
label used to distinguish different, concurrent instances stored in memory
-
bool gs_solved¶
true if the ground state has been already solved for that instance
-
bool gf_solved¶
true if the Green function has been already solved for that instance
-
bool average_solved¶
true if the lattice averages have already been computed for that instance
-
bool SEF_solved¶
true if the Potthoff functional (SEF) has already been computed for that instance
-
bool PE_solved¶
true if the potential energy has already been computed for that instance
-
bool complex_HS¶
true if a complex Hilbert space is needed in one of the clusters
-
shared_ptr<lattice_model> model¶
backtrace to the lattice model
-
block_matrix<Complex> Hc¶
one-body matrix of the clusters
-
block_matrix<Complex> Hc_down¶
one-body matrix of the clusters (spin-down part, if mixing=4)
-
map<string, double> params¶
values of the lattice and cluster parameters
-
vector<pair<double, string>> gs¶
ground state energies and sectors of the systems
-
vector<vector<tuple<string, double, double>>> clus_ave¶
cluster averages and variances of all operators
-
vector<pair<string, double>> ave¶
lattice averages of all operators
-
vector<double> GS_energy¶
ground state energies of the clusters + total (component 0)
-
double omega¶
value of the Potthoff functional
-
double E_pot¶
potential energy
-
double E_kin¶
kinetic energy
-
vector<double> G_host_cumul¶
cumulative CDMFT host function along the real frequency axis
-
vector<double> CDMFT_freqs¶
CDMFT frequency grid.
-
vector<double> CDMFT_weights¶
weights of the different frequencies in CDMFT
-
complex<double> TrSigmaG(Complex w, vector3D<double> &k, bool spin_down)¶