MADNESS 0.10.1
madness::DiagnosticMatrix< T, NDIM > Class Template Reference

#include <operator_diagnostics.h>

Collaboration diagram for madness::DiagnosticMatrix< T, NDIM >:

Public Types

using ElementProvider

Public Member Functions

 DiagnosticMatrix (World &world, std::vector< Function< T, LDIM > > ao_basis_in, bool orthonormalize=true)
std::vector< CCPairFunction< T, NDIM > > build_Gab_bra (double energy, double lo, double eps=-1.0) const
std::vector< CCPairFunction< T, NDIM > > build_simple_bra () const
 Single-slot bra for plain.
void compute_errors ()
 Compute error = ||ref - result||_F for every initialized entry.
Tensor< T > & init (const std::string &name)
int nbasis () const
void print_report (const std::string &tag="") const
 Print a compact report: name, ||ref||, ||result||, error.
Tensor< T > project_ab (const Function< T, NDIM > &ket) const
 Returns T(a,b) = <ao_basis[a] ao_basis[b] | ket>.
Tensor< T > project_ab (const std::vector< CCPairFunction< T, NDIM > > &ket) const
Tensor< T > project_Gab (const Function< T, NDIM > &ket, double energy, double lo) const
 Returns T(a,b) ≈ <ao_basis[a] ao_basis[b] | G · ket> via Schwinger BSH quadrature.
Tensor< T > project_Gab (const std::vector< CCPairFunction< T, NDIM > > &ket, double energy, double lo) const
Tensor< T > project_xy (const std::vector< CCPairFunction< T, NDIM > > &bra, const Function< T, NDIM > &ket) const
Tensor< T > project_xy (const std::vector< CCPairFunction< T, NDIM > > &bra, const std::vector< CCPairFunction< T, NDIM > > &ket) const
Tensor< T > ref_Gab (const ElementProvider &elements, double energy, double lo, double eps=-1.0) const
Tensor< T > ref_GQab (const ElementProvider &elements, const std::vector< Function< T, LDIM > > &occ_ket, const std::vector< Function< T, LDIM > > &occ_bra, double energy, double lo, double eps=-1.0) const

Public Attributes

std::vector< Function< T, LDIM > > ao_basis
 orthonormalized observer basis
std::map< std::string, DiagnosticEntry< T > > entries
double time = 0.0

Static Public Attributes

static constexpr std::size_t LDIM = NDIM / 2
 one-particle space dimension

Private Attributes

World & world_

Detailed Description

template<typename T = double, std::size_t NDIM = 6>
class madness::DiagnosticMatrix< T, NDIM >

Container for named <ab|op|ij> diagnostic matrix elements.

Each named entry holds a pair (ref, result) of nbasis×nbasis tensors and their Frobenius-norm difference. The caller fills ref from LDIM-D analytic formulas; the project_ab / project_Gab methods fill result by projecting NDIM-D functions onto the AO observer basis pairs |ab>.

Template Parameters
Tscalar type (default double)
NDIMpair-space dimension (default 6); LDIM = NDIM/2 is the one-particle space

Member Typedef Documentation

◆ ElementProvider

template<typename T = double, std::size_t NDIM = 6>
using madness::DiagnosticMatrix< T, NDIM >::ElementProvider
Initial value:
std::function<Tensor<T>(
const std::vector<Function<T,LDIM>>&,
const std::vector<Function<T,LDIM>>&)>
A multiresolution adaptive numerical function.
Definition mra.h:141

element provider: M(x,y) = <p1[x](1) p2[y](2) | X | ij> for arbitrary LDIM-D bra lists p1, p2 — the operator-specific unit plugged into ref_Gab / ref_GQab. Build via the provider factories of the operator classes (CorrelationFactor::ue_*_provider, ExchangeCommutator::*_provider), which hoist convolution operators and intermediates into the closure.

Constructor & Destructor Documentation

◆ DiagnosticMatrix()

template<typename T, std::size_t NDIM>
madness::DiagnosticMatrix< T, NDIM >::DiagnosticMatrix ( World & world,
std::vector< Function< T, LDIM > > ao_basis_in,
bool orthonormalize = true )

Construct with a World reference and an AO basis. If the basis is not orthonormal (||S - I||_F > 1e-10) it is orthonormalized in-place via symmetric (Löwdin) orthonormalization. Pass orthonormalize=false to keep the basis as given (e.g. when matrix elements in the raw basis carry physical meaning, like pair energies).

References ao_basis, madness::copy(), diff(), e(), madness::matrix_inner(), madness::orthonormalize(), madness::orthonormalize_symmetric(), madness::print(), madness::World::rank(), and world_.

Member Function Documentation

◆ build_Gab_bra()

template<typename T, std::size_t NDIM>
std::vector< CCPairFunction< T, NDIM > > madness::DiagnosticMatrix< T, NDIM >::build_Gab_bra ( double energy,
double lo,
double eps = -1.0 ) const

Multi-slot Schwinger bra for <ab|G| projection (BSH fit for energy). bra[n].get_a()[a] = w_n * (g_n * ao_basis[a]) (weight absorbed into particle 1) bra[n].get_b()[b] = g_n * ao_basis[b]

Parameters
[in]epsfit/convolution accuracy for the Schwinger G representation; if <=0 falls back to FunctionDefaults<LDIM>::get_thresh(). (the diagnostics pass tight_thresh_3d to make the 3D reference a stable, threshold-decoupled yardstick).

References alpha, ao_basis, madness::GFit< T, NDIM >::BSHFit(), madness::copy(), energy, fit(), madness::FunctionDefaults< NDIM >::thresh, madness::FunctionDefaults< NDIM >::get_cell_width(), madness::FunctionDefaults< NDIM >::get_thresh(), LDIM, lo, MADNESS_CHECK_THROW, mu, madness::Tensor< T >::normf(), madness::OT_GAUSS, madness::constants::pi, madness::scale(), and world_.

Referenced by project_Gab(), project_Gab(), ref_Gab(), and ref_GQab().

◆ build_simple_bra()

template<typename T = double, std::size_t NDIM = 6>
std::vector< CCPairFunction< T, NDIM > > madness::DiagnosticMatrix< T, NDIM >::build_simple_bra ( ) const
inline

Single-slot bra for plain.

References ao_basis.

◆ compute_errors()

template<typename T, std::size_t NDIM>
void madness::DiagnosticMatrix< T, NDIM >::compute_errors ( )

Compute error = ||ref - result||_F for every initialized entry.

References e(), entries, and madness::name().

Referenced by madness::ExchangeCommutator::diagnose_GKffK(), madness::ExchangeCommutator::diagnose_GQKffK(), and madness::ExchangeCommutator::diagnose_KffK().

◆ init()

template<typename T = double, std::size_t NDIM = 6>
Tensor< T > & madness::DiagnosticMatrix< T, NDIM >::init ( const std::string & name)
inline

Allocate zero tensors for a new named quantity. Returns the ref tensor by reference so the caller can fill it in-place.

References e(), entries, madness::name(), and nbasis().

Referenced by madness::ExchangeCommutator::diagnose_GKffK(), madness::ExchangeCommutator::diagnose_GQKffK(), and madness::ExchangeCommutator::diagnose_KffK().

◆ nbasis()

template<typename T = double, std::size_t NDIM = 6>
int madness::DiagnosticMatrix< T, NDIM >::nbasis ( ) const
inline

◆ print_report()

template<typename T, std::size_t NDIM>
void madness::DiagnosticMatrix< T, NDIM >::print_report ( const std::string & tag = "") const

Print a compact report: name, ||ref||, ||result||, error.

References e(), entries, madness::name(), madness::print(), and time.

Referenced by main(), and test_diagnose_GQKffK().

◆ project_ab() [1/2]

template<typename T, std::size_t NDIM>
Tensor< T > madness::DiagnosticMatrix< T, NDIM >::project_ab ( const Function< T, NDIM > & ket) const

◆ project_ab() [2/2]

template<typename T, std::size_t NDIM>
Tensor< T > madness::DiagnosticMatrix< T, NDIM >::project_ab ( const std::vector< CCPairFunction< T, NDIM > > & ket) const

References ao_basis, and project_xy().

◆ project_Gab() [1/2]

template<typename T, std::size_t NDIM>
Tensor< T > madness::DiagnosticMatrix< T, NDIM >::project_Gab ( const Function< T, NDIM > & ket,
double energy,
double lo ) const

Returns T(a,b) ≈ <ao_basis[a] ao_basis[b] | G · ket> via Schwinger BSH quadrature.

References build_Gab_bra(), energy, lo, and project_xy().

◆ project_Gab() [2/2]

template<typename T, std::size_t NDIM>
Tensor< T > madness::DiagnosticMatrix< T, NDIM >::project_Gab ( const std::vector< CCPairFunction< T, NDIM > > & ket,
double energy,
double lo ) const

References build_Gab_bra(), energy, lo, and project_xy().

◆ project_xy() [1/2]

template<typename T, std::size_t NDIM>
Tensor< T > madness::DiagnosticMatrix< T, NDIM >::project_xy ( const std::vector< CCPairFunction< T, NDIM > > & bra,
const Function< T, NDIM > & ket ) const

Core primitive: returns T(a,b) = Σ_k inner(bra[k].get_a()[a](1) bra[k].get_b()[b](2), ket_piece) summed over all assigned ket pieces and all bra slots k. Weight is absorbed into bra[k].get_a() by the bra builder (project_Gab etc.). Loop order: ket-pieces outer, (a,b) middle, bra-slots k innermost. Caller assigns the returned tensor to entries[name].result.

References a, b, madness::FunctionDefaults< NDIM >::k, madness::inner(), nbasis(), and madness::Function< T, NDIM >::project_out().

Referenced by project_ab(), project_ab(), project_Gab(), and project_Gab().

◆ project_xy() [2/2]

template<typename T, std::size_t NDIM>
Tensor< T > madness::DiagnosticMatrix< T, NDIM >::project_xy ( const std::vector< CCPairFunction< T, NDIM > > & bra,
const std::vector< CCPairFunction< T, NDIM > > & ket ) const

◆ ref_Gab()

template<typename T, std::size_t NDIM>
Tensor< T > madness::DiagnosticMatrix< T, NDIM >::ref_Gab ( const ElementProvider & elements,
double energy,
double lo,
double eps = -1.0 ) const

ref(a,b) = Σ_n w_n <ã_n b̃_n | X | ij> with ã_n = w_n g_{α_n}⋆a, b̃_n = g_{α_n}⋆b (Schwinger/BSH fit of G moved onto the bra; X supplied as an element provider).

References build_Gab_bra(), energy, lo, and nbasis().

Referenced by madness::ExchangeCommutator::diagnose_GKffK().

◆ ref_GQab()

template<typename T, std::size_t NDIM>
Tensor< T > madness::DiagnosticMatrix< T, NDIM >::ref_GQab ( const ElementProvider & elements,
const std::vector< Function< T, LDIM > > & occ_ket,
const std::vector< Function< T, LDIM > > & occ_bra,
double energy,
double lo,
double eps = -1.0 ) const

ref(a,b) = Σ_n w_n <ã_n b̃_n | Q₁₂ X | ij> with Q₁₂ = (1-O₁)(1-O₂), O = Σ_k |k_ket><k_bra| (plain sum, matching StrongOrthogonalityProjector). Q₁₂ is expanded on the ket side as scalar contractions: per slot A − S1·B − C·S2ᵀ + S1·D·S2ᵀ with element blocks over p1 = {ã_a} ∪ {occ_bra_k}, p2 = {b̃_b} ∪ {occ_bra_l} and overlaps S1(a,k) = <ã_a|occ_ket_k>, S2(b,l) = <b̃_b|occ_ket_l>. No nearly-vanishing functions like Q(g_n⋆a) are ever formed — applying Q to the bra functions suffers catastrophic cancellation when the convolved observers lie nearly in the occupied space (see operator_diagnostics.md).

References build_Gab_bra(), madness::copy(), energy, madness::inner(), lo, MADNESS_CHECK_THROW, madness::matrix_inner(), nbasis(), madness::transpose(), and world_.

Referenced by madness::ExchangeCommutator::diagnose_GQKffK().

Member Data Documentation

◆ ao_basis

template<typename T = double, std::size_t NDIM = 6>
std::vector<Function<T,LDIM> > madness::DiagnosticMatrix< T, NDIM >::ao_basis

◆ entries

◆ LDIM

template<typename T = double, std::size_t NDIM = 6>
std::size_t madness::DiagnosticMatrix< T, NDIM >::LDIM = NDIM / 2
staticconstexpr

one-particle space dimension

Referenced by build_Gab_bra().

◆ time

◆ world_

template<typename T = double, std::size_t NDIM = 6>
World& madness::DiagnosticMatrix< T, NDIM >::world_
private

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