TRIQS/triqs_modest 3.3.0
Modular Electronic Structure Toolkit
Loading...
Searching...
No Matches
triqs::modest::embedding

#include <triqs_modest/embedding.hpp>

Detailed Description

The embedding class.

The embedding class encodes the mapping between impurities and the correlated space \( \mathcal{C} \) (cf. ModEST implementation notes). In particular, it maps the individual "blocks" within an impurity self-energy to a block and spin of the embedded self-energy function, which can then be upfolded (downfolded) to obtain the lattice self-energy and the local Green's function.

Definition at line 32 of file embedding.hpp.

Public Member Functions

 embedding (std::vector< long > sigma_embed_decomposition, std::vector< std::vector< long > > imp_decompositions, nda::array< imp_block_t, 2 > psi, std::vector< std::string > sigma_names)
 Construct an embedding object.
template<typename Mesh>
std::vector< std::pair< block_gf< Mesh, matrix_valued >, block_matrix_t > > make_zero_imp_self_energies (Mesh const &mesh)
 Create zero-initialized impurity self-energies.
Accessors
imp_block_t operator[] (long alpha, long sigma) const
 Bracket accessor: \( \psi[\alpha,\sigma] \).
nda::array< imp_block_t, 2 > psi_map () const
 The mapping table \( \psi \).
long n_alpha () const
 Number of blocks in \( \alpha \) for the \( \Sigma_{\text{embed}} \).
long n_sigma () const
 Number of blocks in \( \sigma \) for the \( \Sigma_{\text{embed}} \).
long n_gamma (long imp_idx) const
 Number of blocks in \( \gamma \) for the \( \Sigma_{\text{imp}} \) [imp_idx].
long n_impurities () const
 Number of impurities.
std::vector< std::string > sigma_names () const
 The names of the sigma indices.
std::vector< long > imp_decomposition (long imp_idx) const
 The impurity decomposition.
C2PY_IGNORE gf_struct2_t embed_block_structure () const
 Block structure (names and dimensions) for the embedded self-energy \( \Sigma_{\text{embed}} \).
std::vector< gf_struct_t > imp_block_structure () const
 Block structure (names and dimensions) for each impurity solver.
std::string description (bool verbosity=false) const
 Summarize the embedding object.
Embedding transformations

Methods that return a new embedding with a modified \( \psi \) map.

bool operator== (embedding const &other) const =default
embedding drop_imp (long imp_idx) const
 Remove an impurity from the embedding table \( \psi \).
embedding replace_imp (long imp_idx_old, long imp_idx_new) const
 Redirect all \( \psi \) entries from one impurity to another.
embedding swap_sigma (long alpha) const
 Swap the \( \sigma \) (spin) assignment for \( \alpha \) block alpha.
embedding swap_sigma (std::vector< long > alphas) const
 Swap the \( \sigma \) (spin) assignment for all \( \alpha \) blocks in alphas.
embedding slice_sigma () const
 Slice the embedding to a single \( \sigma \) channel ("ud").
embedding split_imp (long imp_idx, std::function< bool(long)> p) const
 Split impurity imp_idx using a predicate.
embedding split_imp (long imp_idx, std::vector< long > const &block_list) const
 Split impurity imp_idx based on block_list.
embedding split_imp (long imp_idx, std::initializer_list< const char * > x)=delete
embedding split_imp_block (long imp_idx, long gamma, std::vector< long > const &new_dims) const
 Split a single \( \gamma \) block of an impurity into multiple blocks.
embedding merge_embed_block_by_imp () const
 Merge consecutive \( \alpha \) blocks belonging to the same impurity into a single block.
Embed and extract operations

Methods that map data between impurity and embedded representations.

template<int Rank>
std::vector< std::vector< nda::array< dcomplex, Rank > > > extract (std::vector< nda::array< dcomplex, Rank > > const &X) const
 Extract impurity data from embedded arrays.
template<int Rank>
std::vector< nda::array< dcomplex, Rank > > embed (std::vector< std::vector< nda::array< dcomplex, Rank > > > const &imps_blocks) const
 Embed impurity data into the full correlated space.
template<typename Mesh>
block2_gf< Mesh, matrix_valued > embed (std::vector< block_gf< Mesh, matrix_valued > > const &Sigma_imp_vec) const
 Embed Green's function containers.
template<typename Mesh>
std::vector< block_gf< Mesh, matrix_valued > > extract (block2_gf< Mesh, matrix_valued > const &g_loc) const
 Extract Green's function containers.
template<typename Mesh>
std::pair< block2_gf< Mesh, matrix_valued >, block2_matrix_tembed (std::vector< block_gf< Mesh, matrix_valued > > const &Sigma_imp_vec, std::vector< block_matrix_t > const &Sigma_imp_static_vec) const
 Embed pairs Green's function containers and matrices.
block2_matrix_t embed (std::vector< block_matrix_t > const &Sigma_imp_static_vec) const
 Embed block matrices into the full correlated space.
std::vector< block_matrix_textract (block2_matrix_t const &matrix_C) const
 Extract block matrices from the embedded representation.

Friends

void h5_read (h5::group g, std::string const &name, embedding &x)
void h5_write (h5::group g, std::string const &name, embedding const &x)
 h5 read/write
std::ostream & operator<< (std::ostream &out, embedding const &E)

Constructor & Destructor Documentation

◆ embedding()

triqs::modest::embedding::embedding ( std::vector< long > sigma_embed_decomposition,
std::vector< std::vector< long > > imp_decompositions,
nda::array< imp_block_t, 2 > psi,
std::vector< std::string > sigma_names )

Construct an embedding object.

Parameters
sigma_embed_decompositionDecomposition (list of block sizes) for \( \Sigma_{\text{embed}} \): \([ \alpha ] = \) block size. Note that the decompositions are given for \( \alpha \), \( \gamma \) index, and are independent of \( \sigma \).
imp_decompositionsList of decomposition of solvers: [n_imp][ \( \gamma \)] = block size.
psiThe mapping \( \psi[\alpha,\sigma]\) -> n_imp, \( \gamma \), \( \tau \).
sigma_namesNames for the values of the \( \sigma \) index (e.g., "up", "down").

Definition at line 17 of file embedding.cpp.

Member Function Documentation

◆ description()

std::string triqs::modest::embedding::description ( bool verbosity = false) const

Summarize the embedding object.

Definition at line 101 of file printing.cpp.

◆ drop_imp()

embedding triqs::modest::embedding::drop_imp ( long imp_idx) const

Remove an impurity from the embedding table \( \psi \).

Remove the impurity imp_idx, map the corresponding \( \alpha \) blocks to -1 (i.e. no longer connected to an impurity) and relabel the other impurities with a number > imp_idx.

Parameters
imp_idxIndex of the impurity to remove from the table \( \psi \).
Returns
New embedding with the updated \( \psi \) map.

Definition at line 274 of file embedding.cpp.

◆ embed() [1/4]

template<typename Mesh>
block2_gf< Mesh, matrix_valued > triqs::modest::embedding::embed ( std::vector< block_gf< Mesh, matrix_valued > > const & Sigma_imp_vec) const
inline

Embed Green's function containers.

Embed impurity solver self-energies into an embedded self-energy.

  • \( \Sigma_{\text{embed}}^{ασ} = \Sigma_{\text{imp}}^{ψ(α,σ)} \),
  • \( \psi(\alpha,\sigma) \to \) (n_imp, \( \gamma \), \( \tau \)).
Parameters
Sigma_imp_vecA list of impurity self-energies.
Returns
\( \Sigma_{\text{embed}}[\alpha, \sigma] \) in \( \mathcal{C} \) space using the embed decomposition.

Definition at line 476 of file embedding.hpp.

◆ embed() [2/4]

template<typename Mesh>
std::pair< block2_gf< Mesh, matrix_valued >, block2_matrix_t > triqs::modest::embedding::embed ( std::vector< block_gf< Mesh, matrix_valued > > const & Sigma_imp_vec,
std::vector< block_matrix_t > const & Sigma_imp_static_vec ) const
inline

Embed pairs Green's function containers and matrices.

Embed the impurity self-energy decomposed as a list of dynamic and a list of static parts.

Template Parameters
MeshThe type of mesh.
Parameters
Sigma_imp_vecA list of dynamic impurity self-energies.
Sigma_imp_static_vecA list of static impurity self-energies.
Returns
The self-energy in the \( \mathcal{C} \) space as a pair (dynamic, static).

Definition at line 535 of file embedding.hpp.

◆ embed() [3/4]

block2_matrix_t triqs::modest::embedding::embed ( std::vector< block_matrix_t > const & Sigma_imp_static_vec) const

Embed block matrices into the full correlated space.

Embeds static (frequency-independent) impurity data stored as block matrices into the \( (\alpha, \sigma) \)-indexed embedded representation. This is the matrix analogue of the frequency-dependent embed operation.

Parameters
Sigma_imp_static_vecList of block matrices, one per impurity.
Returns
Embedded block2 matrix in \( \mathcal{C} \) space.

Definition at line 418 of file embedding.cpp.

◆ embed() [4/4]

template<int Rank>
std::vector< nda::array< dcomplex, Rank > > triqs::modest::embedding::embed ( std::vector< std::vector< nda::array< dcomplex, Rank > > > const & imps_blocks) const
inline

Embed impurity data into the full correlated space.

This method maps impurity solver data into the embedded representation using the \( \psi \) mapping table. Given data from each impurity solver organized by blocks \( (\gamma, \tau) \), the method constructs the full embedded arrays indexed by \( (\alpha, \sigma) \).

The algorithm proceeds as follows:

  1. Initialize zero arrays for each \( (\alpha, \sigma) \) block with dimensions from sigma_embed_decomp.
  2. For each \( (\alpha, \sigma) \), look up \( \psi(\alpha, \sigma) = (n\_imp, \gamma, \tau) \) and copy the corresponding impurity block data.
  3. Assemble the blocks into full diagonal tensors for each spin channel \( \sigma \).

Blocks with imp_idx == -1 (disconnected from any impurity) remain zero.

The template parameter Rank determines the dimensionality of the data arrays. For frequency-dependent quantities (Rank ∈ {3,5}), the first dimension is the frequency index.

Template Parameters
RankThe rank of the underlying nda arrays (e.g., 2 for static, 3 for frequency-dependent).
Parameters
imps_blocksNested vector [n_imp][block] of impurity data arrays.
Returns
Vector of embedded arrays, one per spin channel \( \sigma \).

Definition at line 408 of file embedding.hpp.

◆ embed_block_structure()

gf_struct2_t triqs::modest::embedding::embed_block_structure ( ) const

Block structure (names and dimensions) for the embedded self-energy \( \Sigma_{\text{embed}} \).

Definition at line 153 of file embedding.cpp.

◆ extract() [1/3]

template<typename Mesh>
std::vector< block_gf< Mesh, matrix_valued > > triqs::modest::embedding::extract ( block2_gf< Mesh, matrix_valued > const & g_loc) const
inline

Extract Green's function containers.

Template Parameters
MeshThe mesh type triqs::mesh::{dlr_imfreq, imfreq}.
Parameters
g_locBlock2Gf of gloc in \( M \times M \) space.
Returns
Local impurity Green's function.

Definition at line 502 of file embedding.hpp.

◆ extract() [2/3]

std::vector< block_matrix_t > triqs::modest::embedding::extract ( block2_matrix_t const & matrix_C) const

Extract block matrices from the embedded representation.

Extracts static (frequency-independent) impurity data from the embedded \( (\alpha, \sigma) \)-indexed representation back into per-impurity block matrices. This is the inverse of the block matrix embed operation.

Parameters
matrix_CEmbedded block2 matrix in \( \mathcal{C} \) space.
Returns
List of block matrices, one per impurity.

Definition at line 426 of file embedding.cpp.

◆ extract() [3/3]

template<int Rank>
std::vector< std::vector< nda::array< dcomplex, Rank > > > triqs::modest::embedding::extract ( std::vector< nda::array< dcomplex, Rank > > const & X) const
inline

Extract impurity data from embedded arrays.

This method performs the inverse of the embed operation: it takes data in the full correlated space and extracts the individual impurity blocks using the reverse mapping \( \psi^{-1} \).

The algorithm proceeds in two steps:

  1. For each \( (\alpha, \sigma) \) pair, extract the diagonal block from the input array X using the sigma_embed_decomp decomposition.
  2. For each impurity, use the reverse_psi mapping to gather the appropriate blocks into the impurity's block structure, indexed by \( (\gamma, \tau) \).

The template parameter Rank determines the dimensionality of the underlying data arrays. For frequency-dependent quantities (Rank ∈ {3,5}), the first dimension is interpreted as the frequency index.

Template Parameters
RankThe rank of the underlying nda arrays (e.g., 2, 4 for static, 3, 5 for frequency-dependent).
Parameters
XVector of arrays in the embedded space, one per spin channel \( \sigma \).
Returns
Nested vector [n_imp][block] of extracted impurity data arrays.

Definition at line 338 of file embedding.hpp.

◆ imp_block_structure()

std::vector< gf_struct_t > triqs::modest::embedding::imp_block_structure ( ) const

Block structure (names and dimensions) for each impurity solver.

Definition at line 161 of file embedding.cpp.

◆ imp_decomposition()

std::vector< long > triqs::modest::embedding::imp_decomposition ( long imp_idx) const
inlinenodiscard

The impurity decomposition.

Definition at line 131 of file embedding.hpp.

◆ make_zero_imp_self_energies()

template<typename Mesh>
std::vector< std::pair< block_gf< Mesh, matrix_valued >, block_matrix_t > > triqs::modest::embedding::make_zero_imp_self_energies ( Mesh const & mesh)
inline

Create zero-initialized impurity self-energies.

Constructs a list of zero-initialized self-energy containers for each impurity, with both dynamic (frequency-dependent) and static components. The block structure of each impurity's self-energy is determined by imp_block_structure().

Each impurity receives a pair consisting of:

  • A block_gf initialized to zero on the provided mesh (dynamic part).
  • A block_matrix_t of zero matrices matching the block dimensions (static part).
Template Parameters
MeshThe mesh type (e.g., imfreq, refreq, dlr_imfreq).
Parameters
meshThe frequency mesh for the dynamic self-energy.
Returns
List of (dynamic, static) self-energy pairs, one per impurity.

Definition at line 286 of file embedding.hpp.

◆ merge_embed_block_by_imp()

embedding triqs::modest::embedding::merge_embed_block_by_imp ( ) const

Merge consecutive \( \alpha \) blocks belonging to the same impurity into a single block.

Merges consecutive \( \alpha \) blocks that belong to the same atom into a single block. Atom boundaries are detected by monitoring the \( \gamma \) index: within one atom the \( \gamma \) values are strictly increasing; when \( \gamma \) resets or the impurity index changes a new group is started. Disconnected blocks (imp_idx == -1) are never merged and pass through unchanged.

Returns
New embedding with a coarser block structure suitable for two-particle quantities.

Definition at line 200 of file embedding.cpp.

◆ n_alpha()

long triqs::modest::embedding::n_alpha ( ) const
inlinenodiscard

Number of blocks in \( \alpha \) for the \( \Sigma_{\text{embed}} \).

Definition at line 116 of file embedding.hpp.

◆ n_gamma()

long triqs::modest::embedding::n_gamma ( long imp_idx) const
inlinenodiscard

Number of blocks in \( \gamma \) for the \( \Sigma_{\text{imp}} \) [imp_idx].

Definition at line 122 of file embedding.hpp.

◆ n_impurities()

long triqs::modest::embedding::n_impurities ( ) const
inlinenodiscard

Number of impurities.

Definition at line 125 of file embedding.hpp.

◆ n_sigma()

long triqs::modest::embedding::n_sigma ( ) const
inlinenodiscard

Number of blocks in \( \sigma \) for the \( \Sigma_{\text{embed}} \).

Definition at line 119 of file embedding.hpp.

◆ operator==()

bool triqs::modest::embedding::operator== ( embedding const & other) const
default

◆ operator[]()

imp_block_t triqs::modest::embedding::operator[] ( long alpha,
long sigma ) const
inline

Bracket accessor: \( \psi[\alpha,\sigma] \).

Returns
The corresponding impurity block (n_imp, \( \gamma \), \( \tau \)).

Definition at line 110 of file embedding.hpp.

◆ psi_map()

nda::array< imp_block_t, 2 > triqs::modest::embedding::psi_map ( ) const
inlinenodiscard

The mapping table \( \psi \).

Definition at line 113 of file embedding.hpp.

◆ replace_imp()

embedding triqs::modest::embedding::replace_imp ( long imp_idx_old,
long imp_idx_new ) const

Redirect all \( \psi \) entries from one impurity to another.

Rewires every \( (\alpha, \sigma) \) that currently points to imp_idx_old so that it points to imp_idx_new instead. The impurity at imp_idx_old remains in the embedding but becomes dangling — no \( \alpha \) block maps to it any longer. Call drop_imp(imp_idx_old) afterwards to remove the dangling entry and compact the indices.

Parameters
imp_idx_oldThe impurity whose \( \alpha \) connections are redirected.
imp_idx_newThe impurity that will receive those connections.
Returns
New embedding with the updated \( \psi \) map (dangling impurity retained).

Definition at line 287 of file embedding.cpp.

◆ sigma_names()

std::vector< std::string > triqs::modest::embedding::sigma_names ( ) const
inlinenodiscard

The names of the sigma indices.

Definition at line 128 of file embedding.hpp.

◆ slice_sigma()

embedding triqs::modest::embedding::slice_sigma ( ) const

Slice the embedding to a single \( \sigma \) channel ("ud").

Converts a spinful embedding (with two spin channels, e.g., "up" and "down") into a single-channel embedding labelled "ud". This is useful when working with systems with spin-orbit coupling or spin-averaged quantities, like the density-density susceptibility.

Returns
New embedding with a single spin channel.

Definition at line 190 of file embedding.cpp.

◆ split_imp() [1/3]

embedding triqs::modest::embedding::split_imp ( long imp_idx,
std::function< bool(long)> p ) const

Split impurity imp_idx using a predicate.

Partitions the blocks of impurity imp_idx into two new impurities based on predicate p. Blocks for which p(block_idx) returns true stay with imp_idx; the rest are assigned to a new impurity inserted at imp_idx + 1.

Parameters
imp_idxImpurity number.
pPredicate taking a block index and returning true/false.
Returns
New embedding with the updated \( \psi \) map.

Definition at line 301 of file embedding.cpp.

◆ split_imp() [2/3]

embedding triqs::modest::embedding::split_imp ( long imp_idx,
std::initializer_list< const char * > x )
delete

◆ split_imp() [3/3]

embedding triqs::modest::embedding::split_imp ( long imp_idx,
std::vector< long > const & block_list ) const

Split impurity imp_idx based on block_list.

For impurity imp_idx, split part of its blocks into a new impurity. The blocks that were split off remain mapped to their original alpha blocks with the updated imp_idx.

Parameters
imp_idxImpurity number.
block_listA list of blocks of imp_idx to split off.
Returns
New embedding with the updated \( \psi \) map.

Definition at line 336 of file embedding.cpp.

◆ split_imp_block()

embedding triqs::modest::embedding::split_imp_block ( long imp_idx,
long gamma,
std::vector< long > const & new_dims ) const

Split a single \( \gamma \) block of an impurity into multiple blocks.

Splits block gamma of impurity imp_idx into multiple blocks whose sizes are given by new_dims. The sum of new_dims must equal the original dimension of the block. For example, a block of dimension 5 could be split into blocks of dimensions 2 (e.g.) and 3 (t2g).

Parameters
imp_idxThe index of the impurity to operate on.
gammaThe block index of the impurity to split.
new_dimsNew dimensions of the split blocks; must sum to the original block dimension.
Returns
New embedding with the updated impurity structure and \( \psi \) mapping.

Definition at line 345 of file embedding.cpp.

◆ swap_sigma() [1/2]

embedding triqs::modest::embedding::swap_sigma ( long alpha) const

Swap the \( \sigma \) (spin) assignment for \( \alpha \) block alpha.

For block \( \alpha \) transforms \( (\sigma,\sigma') \to (\tau, \tau') \) to \( (\sigma, \sigma') \to (\tau', \tau)\).

Parameters
alphaThe index of the alpha block whose spin assignment is swapped.
Returns
New embedding with the updated \( \psi \) map.

Definition at line 173 of file embedding.cpp.

◆ swap_sigma() [2/2]

embedding triqs::modest::embedding::swap_sigma ( std::vector< long > alphas) const

Swap the \( \sigma \) (spin) assignment for all \( \alpha \) blocks in alphas.

For each block \( \alpha \) in alphas, transforms \( (\sigma,\sigma') \to (\tau, \tau') \) to \( (\sigma, \sigma') \to (\tau', \tau)\).

Parameters
alphasA list of alpha blocks whose spin assignments are swapped.
Returns
New embedding with the updated \( \psi \) map.

Definition at line 182 of file embedding.cpp.

◆ h5_read

void h5_read ( h5::group g,
std::string const & name,
embedding & x )
friend

Definition at line 96 of file h5.cpp.

◆ h5_write

void h5_write ( h5::group g,
std::string const & name,
embedding const & x )
friend

h5 read/write

Definition at line 104 of file h5.cpp.

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
embedding const & E )
friend

Definition at line 167 of file printing.cpp.


The documentation for this class was generated from the following files: