dgamore.symmetrize_new#

Standalone preprocessing script (a second installed console script) that converts a w2dynamics worm-sampled two-particle vertex file into the symmetrized density/magnetic two-particle Green’s function file consumed by the main DGA routine. It provides the band/spin compound-index bookkeeping for the worm components, extracts the required spin combinations, builds \(G^{(2)}_{\mathrm{dens}}\) and \(G^{(2)}_{\mathrm{magn}}\) assuming SU(2) symmetry, and writes them to an HDF5 output file. Running the module interactively prompts for the input and output filenames.

Functions

complete(text, state)

Readline tab-completion callback for filesystem paths (used for the interactive filename prompts).

component2index_band(num_bands, n_dims, b)

Encodes per-leg orbital indices into a compound (orbital-only) index.

component2index_general(num_bands, n_dims, ...)

Encodes per-leg band and spin indices into a compound index for an n_dims-legged object.

component2index_general_2dims(num_bands, ...)

Encodes per-leg band and spin indices into a compound index for a two-legged object (see component2index_general()).

component2index_general_4dims(num_bands, ...)

Encodes per-leg band and spin indices into a compound index for a four-legged object (see component2index_general()).

extract_g2_general(group_string, indices, ...)

Extracts the two-particle Green's function components from the vertex file for given indices and group string.

get_niw_niv(vertex_file, g4iw_groupstring, ...)

Determines the bosonic and fermionic frequency counts from the shape of the first stored vertex element.

get_worm_components_2dims(num_bands, orbs)

Lists the worm component indices for the given two-leg orbital combinations (both equal-spin sectors).

get_worm_components_4dims(num_bands, orbs)

Lists the worm component indices for the given four-leg orbital combinations, over the spin sectors relevant under SU(2) symmetry.

get_worm_components_all_2dims(num_bands)

Lists the worm component indices over all two-orbital combinations, keeping only the spin combinations relevant for the density and magnetic channels under SU(2) symmetry.

get_worm_components_all_4dims(num_bands)

Lists the worm component indices over all four-orbital combinations, keeping only the spin combinations relevant for the density and magnetic channels under SU(2) symmetry.

get_worm_components_partial_2dims(num_bands)

Lists the worm component indices over the orbital-diagonal two-orbital combinations only, keeping the spin combinations relevant for the density and magnetic channels under SU(2) symmetry.

get_worm_components_partial_4dims(num_bands)

Lists the worm component indices over the four-orbital combinations excluding the ijjj/jijj/jjij/ jjji patterns, keeping the spin combinations relevant for the density and magnetic channels under SU(2) symmetry.

index2component_band(num_bands, n_dims, ind)

Decodes a compound (orbital-only) index into its per-leg orbital indices.

index2component_general(num_bands, n_dims, ind)

Decodes a compound index into its per-leg band and spin components for an n_dims-legged object.

index2component_general_2dims(num_bands, ind)

Decodes a compound index into band and spin components for a two-legged object (see index2component_general()).

index2component_general_4dims(num_bands, ind)

Decodes a compound index into band and spin components for a four-legged object (see index2component_general()).

save_to_file(g2_list, names, niw, nb, ineq)

Writes the given two-particle Green's functions to the (module-level) output HDF5 file in the per-bosonic- frequency, per-orbital-component layout expected by the DGA input reader.

dgamore.symmetrize_new.complete(text, state)[source]#

Readline tab-completion callback for filesystem paths (used for the interactive filename prompts).

Parameters:
  • text – The current text being completed.

  • state – The index of the match requested by readline.

Returns:

The state-th matching path (directories suffixed with /), or None if there are no more matches.

dgamore.symmetrize_new.component2index_band(num_bands: int, n_dims: int, b: list) int[source]#

Encodes per-leg orbital indices into a compound (orbital-only) index.

Parameters:
  • num_bands (int) – Number of bands.

  • n_dims (int) – Number of legs.

  • b (list) – The per-leg orbital indices.

Returns:

The 1-based compound orbital index.

Return type:

int

dgamore.symmetrize_new.component2index_general(num_bands: int, n_dims: int, bands: list, spins: list) int[source]#

Encodes per-leg band and spin indices into a compound index for an n_dims-legged object.

Parameters:
  • num_bands (int) – Number of bands.

  • n_dims (int) – Number of legs (orbital/spin index positions).

  • bands (list) – The per-leg band indices.

  • spins (list) – The per-leg spin indices.

Returns:

The 1-based compound index.

Raises:

AssertionError – If num_bands is not a positive integer.

Return type:

int

dgamore.symmetrize_new.component2index_general_2dims(num_bands: int, bands: list, spins: list) int[source]#

Encodes per-leg band and spin indices into a compound index for a two-legged object (see component2index_general()).

Parameters:
  • num_bands (int) – Number of bands.

  • bands (list) – The per-leg band indices.

  • spins (list) – The per-leg spin indices.

Returns:

The 1-based compound index.

Return type:

int

dgamore.symmetrize_new.component2index_general_4dims(num_bands: int, bands: list, spins: list) int[source]#

Encodes per-leg band and spin indices into a compound index for a four-legged object (see component2index_general()).

Parameters:
  • num_bands (int) – Number of bands.

  • bands (list) – The per-leg band indices.

  • spins (list) – The per-leg spin indices.

Returns:

The 1-based compound index.

Return type:

int

dgamore.symmetrize_new.extract_g2_general(group_string: str, indices: list, file: File, niw: int, niv: int) tuple[source]#

Extracts the two-particle Green’s function components from the vertex file for given indices and group string. Returns the components \(G2_{\uparrow\uparrow\uparrow\uparrow}, G2_{\downarrow\downarrow\downarrow\downarrow}\), \(G2_{\downarrow\downarrow\uparrow\uparrow}, G2_{\uparrow\uparrow\downarrow\downarrow}\), \(G2_{\uparrow\downarrow\downarrow\uparrow}\) and \(G2_{\downarrow\uparrow\uparrow\downarrow}\).

Parameters:
  • group_string (str) – The HDF5 group path holding the worm components.

  • indices (list) – The component indices to read.

  • file (File) – The open input vertex h5py.File.

  • niw (int) – Number of positive bosonic frequencies.

  • niv (int) – Number of positive fermionic frequencies.

Returns:

The six spin-component arrays (g2_uuuu, g2_dddd, g2_dduu, g2_uudd, g2_uddu, g2_duud).

Return type:

tuple

dgamore.symmetrize_new.get_niw_niv(vertex_file, g4iw_groupstring, indices)[source]#

Determines the bosonic and fermionic frequency counts from the shape of the first stored vertex element.

Parameters:
  • vertex_file – The open input vertex h5py.File.

  • g4iw_groupstring – The HDF5 group path of the worm-sampled vertex.

  • indices – The component indices (the first is used to read the shape).

Returns:

The tuple (niw, niv) of positive bosonic and fermionic frequency counts.

Raises:

AssertionError – If the stored shape has an odd fermionic or even bosonic frequency count.

dgamore.symmetrize_new.get_worm_components_2dims(num_bands: int, orbs: list[list[int]]) list[int][source]#

Lists the worm component indices for the given two-leg orbital combinations (both equal-spin sectors).

Parameters:
  • num_bands (int) – Number of bands.

  • orbs (list[list[int]]) – The list of two-orbital combinations to include.

Returns:

The sorted list of worm component indices.

Return type:

list[int]

dgamore.symmetrize_new.get_worm_components_4dims(num_bands: int, orbs: list[list[int]]) list[int][source]#

Lists the worm component indices for the given four-leg orbital combinations, over the spin sectors relevant under SU(2) symmetry.

Parameters:
  • num_bands (int) – Number of bands.

  • orbs (list[list[int]]) – The list of four-orbital combinations to include.

Returns:

The sorted list of worm component indices.

Return type:

list[int]

dgamore.symmetrize_new.get_worm_components_all_2dims(num_bands: int) list[int][source]#

Lists the worm component indices over all two-orbital combinations, keeping only the spin combinations relevant for the density and magnetic channels under SU(2) symmetry.

Parameters:

num_bands (int) – Number of bands.

Returns:

The sorted list of worm component indices.

Return type:

list[int]

dgamore.symmetrize_new.get_worm_components_all_4dims(num_bands: int) list[int][source]#

Lists the worm component indices over all four-orbital combinations, keeping only the spin combinations relevant for the density and magnetic channels under SU(2) symmetry.

Parameters:

num_bands (int) – Number of bands.

Returns:

The sorted list of worm component indices.

Return type:

list[int]

dgamore.symmetrize_new.get_worm_components_partial_2dims(num_bands: int) list[int][source]#

Lists the worm component indices over the orbital-diagonal two-orbital combinations only, keeping the spin combinations relevant for the density and magnetic channels under SU(2) symmetry.

Parameters:

num_bands (int) – Number of bands.

Returns:

The sorted list of orbital-diagonal worm component indices.

Return type:

list[int]

dgamore.symmetrize_new.get_worm_components_partial_4dims(num_bands: int) list[int][source]#

Lists the worm component indices over the four-orbital combinations excluding the ijjj/jijj/jjij/ jjji patterns, keeping the spin combinations relevant for the density and magnetic channels under SU(2) symmetry.

Parameters:

num_bands (int) – Number of bands.

Returns:

The sorted list of worm component indices.

Return type:

list[int]

dgamore.symmetrize_new.index2component_band(num_bands: int, n_dims: int, ind: int) list[source]#

Decodes a compound (orbital-only) index into its per-leg orbital indices.

Parameters:
  • num_bands (int) – Number of bands.

  • n_dims (int) – Number of legs.

  • ind (int) – The 1-based compound orbital index.

Returns:

The list of per-leg orbital indices.

Return type:

list

dgamore.symmetrize_new.index2component_general(num_bands: int, n_dims: int, ind: int) tuple[ndarray, ndarray, ndarray][source]#

Decodes a compound index into its per-leg band and spin components for an n_dims-legged object.

Parameters:
  • num_bands (int) – Number of bands.

  • n_dims (int) – Number of legs (orbital/spin index positions).

  • ind (int) – The 1-based compound index.

Returns:

The tuple (bandspin, band, spin) of per-leg combined, band and spin index arrays.

Return type:

tuple[ndarray, ndarray, ndarray]

dgamore.symmetrize_new.index2component_general_2dims(num_bands: int, ind: int) tuple[ndarray, ndarray, ndarray][source]#

Decodes a compound index into band and spin components for a two-legged object (see index2component_general()).

Parameters:
  • num_bands (int) – Number of bands.

  • ind (int) – The 1-based compound index.

Returns:

The tuple (bandspin, band, spin) of per-leg combined, band and spin index arrays.

Return type:

tuple[ndarray, ndarray, ndarray]

dgamore.symmetrize_new.index2component_general_4dims(num_bands: int, ind: int) tuple[ndarray, ndarray, ndarray][source]#

Decodes a compound index into band and spin components for a four-legged object (see index2component_general()).

Parameters:
  • num_bands (int) – Number of bands.

  • ind (int) – The 1-based compound index.

Returns:

The tuple (bandspin, band, spin) of per-leg combined, band and spin index arrays.

Return type:

tuple[ndarray, ndarray, ndarray]

dgamore.symmetrize_new.save_to_file(g2_list: list[ndarray], names: list[str], niw: int, nb: int, ineq: int)[source]#

Writes the given two-particle Green’s functions to the (module-level) output HDF5 file in the per-bosonic- frequency, per-orbital-component layout expected by the DGA input reader.

Parameters:
  • g2_list (list[ndarray]) – The two-particle Green’s function arrays to write.

  • names (list[str]) – The channel names (one per array, e.g. ["dens", "magn"]).

  • niw (int) – Number of positive bosonic frequencies.

  • nb (int) – Number of bands.

  • ineq (int) – The inequivalent-atom index used in the output group path.

Returns:

None.

Raises:

AssertionError – If g2_list and names have different lengths.