dgamore.local_n_point#

Base class for all local (momentum-independent) N-point quantities. LocalNPoint adds the orbital and frequency-axis bookkeeping (number of orbital/bosonic/fermionic axes, full vs. half frequency ranges) and the shared frequency transformations (cut, diagonal extension, full/half range conversion, orbital symmetrization) on top of IHaveMat.

class dgamore.local_n_point.LocalNPoint(mat: ndarray, num_orbital_dimensions: int, num_wn_dimensions: int, num_vn_dimensions: int, full_niw_range: bool = True, full_niv_range: bool = True)[source]#

Bases: IHaveMat

Base class for all (Local)NPoint objects, such as the (Full/Irreducible) Vertex functions, Susceptibilities, Fermi-Bose Vertices, Green’s Function, Self-Energy and the like. Removes redundancy of a lot of methods to make the implementation more efficient.

Parameters:
  • mat (ndarray)

  • num_orbital_dimensions (int)

  • num_wn_dimensions (int)

  • num_vn_dimensions (int)

  • full_niw_range (bool)

  • full_niv_range (bool)

cut_niv(niv_cut: int, copy: bool = True)[source]#

Allows to place a cutoff on the number of fermionic frequencies of the object. Returns a copy if copy is True, otherwise modifies and returns self in place. If the requested cutoff is not smaller than the available range this is a no-op and returns self (not a copy) regardless of copy – do not mutate the result expecting the original to be unaffected.

Parameters:
  • niv_cut (int) – Number of fermionic frequencies to keep (per sign).

  • copy (bool) – If True, operate on and return a deep copy; if False, mutate and return self in place.

Returns:

The cut object (a copy, self, or self unchanged for the no-op case).

Raises:

ValueError – If the object has no fermionic frequency dimension.

cut_niw(niw_cut: int, copy: bool = True)[source]#

Allows to place a cutoff on the number of bosonic frequencies of the object. Returns a copy if copy is True, otherwise modifies and returns self in place. If the requested cutoff is not smaller than the available range this is a no-op and returns self (not a copy) regardless of copy – do not mutate the result expecting the original to be unaffected.

Parameters:
  • niw_cut (int) – Number of bosonic frequencies to keep (per sign).

  • copy (bool) – If True, operate on and return a deep copy; if False, mutate and return self in place.

Returns:

The cut object (a copy, self, or self unchanged for the no-op case).

Raises:

ValueError – If the object has no bosonic frequency dimension.

cut_niw_and_niv(niw_cut: int, niv_cut: int, copy: bool = True)[source]#

Allows to place a cutoff on the number of bosonic and fermionic frequencies of the object. Returns a copy if copy is True, otherwise modifies and returns self in place. Fuses the bosonic and fermionic cut into a single slice (one allocation) instead of chaining cut_niw() and cut_niv() (which copies twice). As with those methods, a cutoff not smaller than the available range is a no-op for that axis, and if neither axis is cut self is returned unchanged (not a copy) regardless of copy.

Parameters:
  • niw_cut (int) – Number of bosonic frequencies to keep (per sign).

  • niv_cut (int) – Number of fermionic frequencies to keep (per sign).

  • copy (bool) – If True, operate on and return a deep copy; if False, mutate and return self in place.

Returns:

The cut object; see cut_niw() and cut_niv().

Raises:

ValueError – If the object has no bosonic or no fermionic frequency dimension.

extend_vn_to_diagonal()[source]#

Extends an object […,w,v] to […,w,v,v] by making a diagonal from the last dimension if the number of fermionic frequency dimensions is one. Returns the original object.

Returns:

self with two fermionic frequency axes (a no-op if it already has two).

Raises:

ValueError – If the object has no fermionic frequency dimension.

flip_frequency_axis(axis: tuple | int, copy: bool = True)[source]#

Flips the matrix along the specified frequency axis and returns a copy if specified.

Parameters:
  • axis (tuple | int) – The frequency axis or axes to flip (negative indices into the trailing frequency axes).

  • copy (bool) – If True, operate on and return a deep copy; if False, mutate and return self in place.

Returns:

The flipped object.

Raises:

ValueError – If the object has no frequency axes, or axis is not a valid frequency axis.

property full_niv_range: bool#

Specifies whether the object is stored in the full fermionic frequency range or only a subset of it (only \(\nu\geq0\)). Same reasoning as already discussed in full_niw_range.

Returns:

True if the fermionic axes span the full (signed) range.

property full_niw_range: bool#

Specifies whether the object is stored in the full bosonic frequency range or only a subset of it (only \(\omega \geq 0\)). All vertices fulfill a certain symmetry against the sign change of \(\omega\to-\omega\), which can be taken advantage of. By exploiting this symmetry it allows us to almost half their memory usage.

Returns:

True if the bosonic axis spans the full (signed) range.

property n_bands: int#

Returns the number of bands. Since these objects are momentum-independent, the orbital dimension is always in the first dimension.

Returns:

The number of bands (orbitals).

property niv: int#

Returns the number of fermionic frequencies in the object.

Returns:

The half-width of the fermionic frequency box (0 if there is no fermionic axis).

property niw: int#

Returns the number of bosonic frequencies in the object.

Returns:

The half-width of the bosonic frequency box (0 if there is no bosonic axis).

property num_orbital_dimensions: int#

Returns the number of orbital dimensions; two (for a two-point object) or four (for a three-leg or four-leg vertex) are allowed.

Returns:

The number of orbital axes (2 or 4).

property num_vn_dimensions: int#

Returns the number of fermionic frequency dimensions; none, one or two are allowed.

Returns:

The number of fermionic frequency axes (0, 1 or 2).

property num_wn_dimensions: int#

Returns the number of bosonic frequency dimensions; none or one are allowed.

Returns:

The number of bosonic frequency axes (0 or 1).

save(output_dir: str = './', name: str = 'please_give_me_a_name') None[source]#

Saves the content of the matrix to a numpy file. Always saves it in half the niw range to save storage space.

Parameters:
  • output_dir (str) – Directory to write the .npy file to.

  • name (str) – File name (without extension).

Returns:

None.

Return type:

None

swap_fermionic_frequency_axes(copy: bool = True)[source]#

Swaps two frequency axes of the matrix and returns a copy if specified.

Parameters:

copy (bool) – If True, operate on and return a deep copy; if False, mutate and return self in place.

Returns:

The object with its two fermionic frequency axes swapped.

Raises:

ValueError – If the object has fewer than two fermionic frequency dimensions.

take_vn_diagonal()[source]#

Compresses an object […w,v,v] to […,w,v] by taking the diagonal of the last two dimensions and returns the original object.

Returns:

self with one fermionic frequency axis (a no-op if it already has one).

Raises:

ValueError – If the object has no fermionic frequency dimension.

to_full_niw_range()[source]#

Converts the object to the full bosonic frequency range and returns the original object. For details, we refer to Eq. (2.39) and the associated text in Georg Rohringer’s PhD thesis. This corresponds to complex-conjugation symmetry.

Returns:

self over the full (signed) bosonic range (a no-op if there is no bosonic axis or it is already full).

to_half_niv_range()[source]#

Converts the object to the half fermionic frequency range by taking \(F^{\omega\nu\nu'}_{abcd}\to F^{\omega;\nu\geq0,\nu'\geq0}_{abcd}\). Returns the original object.

Returns:

self over the half fermionic range (a no-op if there is no fermionic axis or it is already half).

to_half_niw_range()[source]#

Converts the object to the half bosonic frequency range by taking \(F^{\omega\nu\nu'}_{abcd}\to F^{\omega\geq0;\nu\nu'}_{abcd}\). Returns the original object.

Returns:

self over the half bosonic range (a no-op if there is no bosonic axis or it is already half).

to_negative_niw_range()[source]#

Returns a new object holding the negative bosonic frequency block \(\omega = 0, -1, \ldots, -niw\) (niw + 1 entries, \(\omega = 0\) included for consistency with to_half_niw_range()), derived from a half (positive) niw-range object via the time-reversal symmetry \(F^{-\omega,-\nu,-\nu'}_{abcd} = (F^{\omega\nu\nu'}_{abcd})^{*}\). The bosonic axis order is kept so that index i corresponds to \(\omega = -i\) (index 0 is \(\omega = 0\)); only the fermionic axes are flipped and the whole array is conjugated. This is the negative-frequency counterpart of to_full_niw_range(), and it is its own inverse (applying it twice returns the original object).

Only allowed for an object already in the half (positive) bosonic frequency range (full_niw_range must be False and a bosonic frequency dimension must exist); self is left unchanged. Memory-lean: the result is a single freshly allocated array (np.flip is a view, np.conj allocates only the output) plus the (array-less) metadata clone.

Returns:

A new object holding the negative bosonic frequency block (num_vn/orbital/momentum layout unchanged).

Raises:

ValueError – If the object has no bosonic frequency dimension, or is not in the half (positive) niw range.