dgamore.local_four_point#
Local (momentum-independent) four-point objects. LocalFourPoint wraps a single array carrying four
orbital indices and a variable number of bosonic/fermionic Matsubara axes, e.g. the generalized susceptibility
\(\chi_{abcd}^{\omega\nu\nu'}\), the vertex \(F\), the irreducible vertex \(\Gamma\), and the
physical susceptibility \(\chi\). It adds channel-/notation-aware arithmetic (+, -, *, @,
inversion, integer powers), orbital and frequency contractions, and conversions to/from the compound-index
matrix layout used for inversion and matrix products. Notation mirrors the thesis (Chapters 3 & 4).
- class dgamore.local_four_point.LocalFourPoint(mat: ndarray, channel: SpinChannel = SpinChannel.NONE, num_wn_dimensions: int = 1, num_vn_dimensions: int = 2, full_niw_range: bool = True, full_niv_range: bool = True, frequency_notation: FrequencyNotation = FrequencyNotation.PH)[source]#
Bases:
LocalNPoint,IHaveChannelThis class is used to represent a local four-point object in a given channel with four orbital dimensions and a variable number of bosonic and fermionic frequency dimensions.
- Parameters:
mat (ndarray)
channel (SpinChannel)
num_wn_dimensions (int)
num_vn_dimensions (int)
full_niw_range (bool)
full_niv_range (bool)
frequency_notation (FrequencyNotation)
- add(other)[source]#
Adds
otherto this object (operator+); see_add()for the accepted operands and the niw-range handling.- Parameters:
other – A
LocalFourPoint,LocalInteraction, numpy array, or number.- Returns:
The sum (a new
LocalFourPoint, or a raw numpy array for a non-localInteraction).
- change_frequency_notation_ph_to_pp_w0()[source]#
Converts the frequency notation from ph to pp at the bosonic frequency \(\omega' = 0\), returning a copy. The frequency map is \((\omega, \nu_1, \nu_2) \to (\omega', \nu_1', \nu_2') = (\nu_1 + \nu_2 - \omega, \nu_1, \nu_2)\). A pp object is returned unchanged.
- Returns:
A new
LocalFourPointin pp notation at \(\omega' = 0\).- Raises:
ValueError – If the object does not have one bosonic and one or two fermionic frequency dimensions.
- contract_legs(beta: float)[source]#
Contracts the outer legs of a four-point vertex: sums over both fermionic frequency axes (with the \(1/\beta^2\) prefactor) and traces the inner two orbitals (
abcd->ad). Used e.g. to obtain the physical susceptibility \(\chi_{ad}^{\omega}\) from a generalized susceptibility.- Parameters:
beta (float) – Inverse temperature \(\beta\).
- Returns:
A new
LocalFourPointwith two orbital indices and no fermionic frequency axes.- Raises:
ValueError – If the object does not have exactly two fermionic frequency dimensions.
- create_wn_dimension()[source]#
Adds a single-point bosonic frequency axis (niw=0) immediately before the fermionic axes, returning a copy.
- Returns:
A new
LocalFourPointwith one bosonic frequency dimension.- Raises:
ValueError – If the object already has a bosonic frequency dimension.
- static from_constant(n_bands: int, niw: int, niv: int, num_wn_dimensions: int = 1, num_vn_dimensions: int = 2, channel: SpinChannel = SpinChannel.NONE, frequency_notation: FrequencyNotation = FrequencyNotation.PH, value: float = 0.0) LocalFourPoint[source]#
Creates a
LocalFourPointfilled with a constant value.- Parameters:
n_bands (int) – Number of orbitals/bands per orbital axis.
niw (int) – Number of positive bosonic frequencies.
niv (int) – Number of positive fermionic frequencies.
num_wn_dimensions (int) – Number of bosonic frequency axes (0–1).
num_vn_dimensions (int) – Number of fermionic frequency axes (0–2).
channel (SpinChannel) – Spin channel of the object (see
SpinChannel).frequency_notation (FrequencyNotation) – Frequency convention (see
FrequencyNotation).value (float) – Constant fill value.
- Returns:
The constant
LocalFourPoint(in the full niw/niv range).- Return type:
- static identity(n_bands: int, niw: int, niv: int, num_vn_dimensions: int = 2, full_niw_range: bool = False, frequency_notation: FrequencyNotation = FrequencyNotation.PH) LocalFourPoint[source]#
Creates a
LocalFourPointthat is the identity in compound-index (matrix) space.- Parameters:
n_bands (int) – Number of orbitals/bands per orbital axis.
niw (int) – Number of positive bosonic frequencies.
niv (int) – Number of positive fermionic frequencies.
num_vn_dimensions (int) – Number of fermionic frequency axes (1 or 2).
full_niw_range (bool) – Whether the object spans the full (signed) bosonic range or only \(\omega \geq 0\).
frequency_notation (FrequencyNotation) – Frequency convention (see
FrequencyNotation).
- Returns:
The identity
LocalFourPoint.- Raises:
ValueError – If
num_vn_dimensionsis not 1 or 2.- Return type:
- static identity_like(other: LocalFourPoint) LocalFourPoint[source]#
Creates a compound-index identity matching the bands, frequency box, fermionic-axis count, niw range and frequency notation of
other(seeidentity()).- Parameters:
other (LocalFourPoint) – The
LocalFourPointwhose shape/attributes the identity should match.- Returns:
The matching identity
LocalFourPoint.- Return type:
- invert(copy: bool = True)[source]#
Inverts the object in compound-index (matrix) space. The result is always returned in the half bosonic frequency range to save memory.
- Parameters:
copy (bool) – If True, operate on and return a deep copy; if False, mutate and return
selfin place.- Returns:
The inverted
LocalFourPointin the half niw range.
- is_orbitally_symmetrized(orbitals: list | ndarray) bool[source]#
Checks whether the object is already symmetric under all permutations of the given orbitals.
- static load(filename: str, channel: SpinChannel = SpinChannel.NONE, num_wn_dimensions: int = 1, num_vn_dimensions: int = 2, full_niw_range: bool = False, full_niv_range: bool = True, frequency_notation: FrequencyNotation = FrequencyNotation.PH) LocalFourPoint[source]#
Loads a
LocalFourPointfrom a.npyfile.- Parameters:
filename (str) – Path to the
.npyfile (loaded withallow_pickle=False).channel (SpinChannel) – Spin channel of the object (see
SpinChannel).num_wn_dimensions (int) – Number of bosonic frequency axes (0–1).
num_vn_dimensions (int) – Number of fermionic frequency axes (0–2).
full_niw_range (bool) – Whether the stored array spans the full (signed) bosonic range or only \(\omega \geq 0\).
full_niv_range (bool) – Whether the stored array spans the full (signed) fermionic range or only \(\nu \geq 0\).
frequency_notation (FrequencyNotation) – Frequency convention (see
FrequencyNotation).
- Returns:
The loaded
LocalFourPoint.- Return type:
- matmul(other, left_hand_side: bool = True) LocalFourPoint[source]#
Helper method that allows for a matrix multiplication between LocalFourPoint and LocalFourPoint and LocalInteraction objects. Depending on the number of frequency and momentum dimensions, the objects have to be multiplied differently. The use of einsum is very crucial for memory efficiency here, as a regular matrix multiplication in compound index space would create large intermediate arrays if one of both partaking objects has less than two fermionic frequency dimensions. Result objects will always be returned in half of their niw range to save memory.
- Parameters:
other – The right/left operand, a
LocalFourPointorLocalInteraction.left_hand_side (bool) – If True, compute
self @ other; if False, computeother @ self.
- Returns:
A new
LocalFourPointin the half bosonic frequency range, carrying the non-NONE channel.- Raises:
ValueError – If
otheris neither aLocalFourPointnor aLocalInteraction.- Return type:
- mul(other)[source]#
Multiplies the object by a scalar/array (element-wise) or by another
LocalFourPoint. Note this is not a matrix product (seematmul()): for two four-point operands, each with a single fermionic frequency, it forms \(A_{abcd}^{\omega\nu} \, B_{dcef}^{\omega\nu'} = C_{abef}^{\omega\nu\nu'}\), contracting the inner orbitals while keeping both fermionic frequencies as separate axes.- Parameters:
other – A number, numpy array, or
LocalFourPoint.- Returns:
A new
LocalFourPoint(in the half niw range for the four-point case).- Raises:
ValueError – If
otherhas an unsupported type, or either four-point operand does not have exactly one fermionic frequency dimension.
- pad_with_u(u: LocalInteraction, niv_pad: int)[source]#
Extends the fermionic frequency range to
niv_padby filling the shell (outside the core region) with the bare interactionu, returning a copy. Mainly used to add the constant asymptotic value \(U\) to the irreducible vertex \(\Gamma\) beyond the core frequency box. A no-op (returns a copy) ifniv_pad <= self.niv.- Parameters:
u (LocalInteraction) – The bare local interaction to fill the frequency shell with.
niv_pad (int) – Target number of positive fermionic frequencies.
- Returns:
A new
LocalFourPointpadded toniv_pad.
- permute_orbitals(permutation: str = 'abcd->abcd', copy: bool = True) LocalFourPoint[source]#
Permutes the four orbital axes according to an einsum-style string. Summing over orbitals is not allowed (both sides must list all four orbitals); the frequency axes are kept fixed.
- Parameters:
- Returns:
The orbital-permuted
LocalFourPoint.- Raises:
ValueError – If the permutation is malformed or does not list all four orbitals on both sides.
- Return type:
- pow(power: int, identity)[source]#
Raises the object to an integer power using exponentiation by squaring (in compound-index matrix space). For \(n < 0\) the inverse is exponentiated, i.e. \(A^{-n} = (A^{-1})^{n}\).
- Parameters:
power (int) – Integer exponent \(n\).
identity – Identity object matching
self(seeidentity_like()), returned for \(n = 0\).
- Returns:
The exponentiated
LocalFourPoint.- Raises:
ValueError – If
poweris not an integer.
- sub(other)[source]#
Helper method that allows for subtraction of LocalFourPoint objects and other LocalFourPoint or LocalInteraction objects. Subtractions with numpy arrays, floats, ints or complex numbers are also supported. Depending on the number of frequency and momentum dimensions, the vertices have to be subtracted slightly different. If the objects have different niw ranges, they will be converted to the half niw range before the subtraction. Objects will always be returned in the half niw range to save memory.
- Parameters:
other – A
LocalFourPoint,LocalInteraction, numpy array, or number.- Returns:
The difference, implemented as
self._add(other, subtract=True)(see_add()).- Raises:
ValueError – Propagated from
_add()for unsupported operands.
- sum_over_all_vn(beta: float)[source]#
Sums over all fermionic frequency axes and applies the prefactor \(1/\beta^{n}\) (with \(n\) the number of fermionic axes). A no-op (returns
self) if there are no fermionic frequency dimensions.- Parameters:
beta (float) – Inverse temperature \(\beta\).
- Returns:
A new
LocalFourPointwithout fermionic frequency axes (orselfif there were none).- Raises:
ValueError – If the object has more than two fermionic frequency dimensions.
- sum_over_orbitals(orbital_contraction: str = 'abcd->ad')[source]#
Sums over orbital indices according to an einsum-style contraction acting on the four orbital axes (the frequency axes are appended automatically). Mutates
selfin place and updates the orbital-dimension count.- Parameters:
orbital_contraction (str) – Contraction of the form
"abcd->..."whose target side is a subset ofabcd, e.g."abcd->ad"to trace over the inner orbitals.- Returns:
self, with the summed orbital axes removed.- Raises:
ValueError – If the left side does not have four orbitals or the right side has more indices than the left.
- sum_over_vn(beta: float, axis: tuple = (-1,))[source]#
Sums over the given fermionic frequency axes and applies the Matsubara prefactor \(1/\beta^{n}\), where \(n\) is the number of summed axes.
- Parameters:
- Returns:
A new
LocalFourPointwith the summed axes removed andnum_vn_dimensionsreduced accordingly.- Raises:
ValueError – If more axes are requested than the object has fermionic frequency dimensions.
- symmetrize_orbitals(orbitals: list | ndarray) LocalFourPoint[source]#
Symmetrizes the object with respect to the given (equivalent) orbitals by averaging over all permutations of those orbitals applied to the four orbital axes. The orbital labels are 1-based, ranging from 1 to the number of bands; e.g. for a 3-band object
orbitals=[1, 3]symmetrizes the first and third orbital.- Parameters:
orbitals (list | ndarray) – 1-based orbital indices to treat as equivalent.
- Returns:
The symmetrized
LocalFourPoint(selfunchanged if already symmetrized).- Return type:
- symmetrize_v_vp()[source]#
Symmetrizes the vertex with respect to \((\nu, \nu')\) via time-reversal symmetry: \(G_{abcd}(\nu, \nu', \omega) = G_{dcba}(\nu', \nu, \omega)\). Valid for TR-symmetric (real-hopping, paramagnetic) systems with SU(2) symmetry. Mutates
selfin place.- Returns:
self, symmetrized in \((\nu, \nu')\).- Raises:
ValueError – If the object does not have exactly two fermionic frequency dimensions.
- take_first_wn()[source]#
Selects the first entry along the bosonic frequency axis, removing that axis, and returns a copy.
- Returns:
A new
LocalFourPointwithout a bosonic frequency dimension.- Raises:
ValueError – If the object does not have exactly one bosonic frequency dimension.
- to_compound_indices() LocalFourPoint[source]#
Converts the indices of the LocalFourPoint object \(F^{wvv'}_{lmm'l'}\) to compound indices \(F^{w}_{c_1, c_2}\) by transposing the object to [w, o1, o2, v, o4, o3, v’] (if the object has any fermionic frequency dimension, otherwise the compound indices are built from orbital dimensions only) and grouping {o1, o2, v} and {o4, o3, v’} to the new compound index. Always returns the object in the same niw range as the original object.
- Returns:
selfwith shape[w, c1, c2](compound indices).- Raises:
NotImplementedError – If the frequency notation is neither ph nor pp.
- Return type:
- to_full_indices(shape: tuple = None) LocalFourPoint[source]#
Converts an object stored with compound indices to an object that has unraveled orbital and frequency axes. This is the inverse transformation of
to_compound_indices(). Will make use of theoriginal_shapethe object was created or last modified with. If theoriginal_shapeis not set or is hard to obtain, theshapeargument can be used to specify the original shape of the object.- Parameters:
shape (tuple) – Optional override for the stored
original_shapeused to unravel the compound axes.- Returns:
selfwith unraveled orbital and frequency axes.- Raises:
NotImplementedError – If the frequency notation is neither ph nor pp.
- Return type: