MADNESS 0.10.1
test_low_rank_function.cc File Reference
#include <madness.h>
#include <madness/chem/lowrankfunction.h>
#include <madness/chem/SCFOperators.h>
#include <madness/world/test_utilities.h>
#include <madness/world/timing_utilities.h>
#include <cstdio>
#include <random>
Include dependency graph for test_low_rank_function.cc:

Functions

int main (int argc, char **argv)
template<std::size_t LDIM>
int make_ri_basis (World &world, LowRankFunctionParameters parameters)
 make an RI basis for an atom, namely Gaussian functions
int test_adaptive_diagnosis (World &world)
template<std::size_t LDIM>
int test_adaptive_grid_projection (World &world, LowRankFunctionParameters parameters)
template<std::size_t LDIM>
int test_adaptive_project (World &world, LowRankFunctionParameters &parameters)
template<std::size_t LDIM>
int test_arithmetic (World &world, LowRankFunctionParameters parameters)
int test_combine_generic (World &world)
template<std::size_t LDIM>
int test_construction (World &world, LowRankFunctionParameters parameters)
int test_coulomb_gfit_discard_large_alpha (World &world)
template<std::size_t LDIM>
int test_direct_projection (World &world, LowRankFunctionParameters parameters)
template<std::size_t LDIM>
int test_inner (World &world, LowRankFunctionParameters parameters)
 test partial inner products
int test_inv_rsq_gfit (World &world)
int test_invrsq_operator (World &world)
int test_lowrank_function (World &world, LowRankFunctionParameters parameters)
template<std::size_t LDIM>
int test_molecular_grid (World &world, LowRankFunctionParameters parameters)
template<std::size_t LDIM>
int test_numerics (World &world, LowRankFunctionParameters &parameters)
template<std::size_t LDIM>
int test_recursive_apply (World &world)
template<std::size_t LDIM>
int test_remove_lindep (World &world, LowRankFunctionParameters parameters)
int test_stuff (World &world, LowRankFunctionParameters parameters)

Function Documentation

◆ main()

◆ make_ri_basis()

◆ test_adaptive_diagnosis()

int test_adaptive_diagnosis ( World & world)

◆ test_adaptive_grid_projection()

◆ test_adaptive_project()

◆ test_arithmetic()

◆ test_combine_generic()

int test_combine_generic ( World & world)

Verify the generic outer-product combine: Slater(μ_A) × Slater(μ_B) ≈ exp(-(μ_A+μ_B) r) pointwise. Compares the outer-product (c, α) tensors against a direct SlaterFit at μ_A+μ_B on a log-spaced grid.

References std::abs(), madness::test_output::checkpoint(), madness::SeparatedConvolution< Q, NDIM >::combine_generic(), madness::SeparatedConvolution< Q, NDIM >::combine_generic_coeffs(), madness::test_output::end(), exact, k, lo, np, madness::print(), and madness::GFit< T, NDIM >::SlaterFit().

Referenced by main().

◆ test_construction()

◆ test_coulomb_gfit_discard_large_alpha()

int test_coulomb_gfit_discard_large_alpha ( World & world)

Analyze the error of discarding large-alpha terms in the GFit of the Coulomb kernel 1/r ≈ Σ_μ c_μ exp(-α_μ r²).

Context: in the k-commutator algorithm [k̂₁, f(1,2)] |ij⟩ with k̂₁ carrying the Coulomb kernel, large-α_μ Gaussians act like δ(r₁-r₁') and their contribution cancels between the two pieces of the commutator. The leading non-cancelling contribution per term is c_μ · π^{3/2} / (4 α_μ^{5/2}) · ∇²F(r₁) so the relevant error proxies for a discard threshold α* are weight Σ_{α_μ > α*} |c_μ| (π/α_μ)^{3/2} err_proxy Σ_{α_μ > α*} |c_μ| π^{3/2} / (4 α_μ^{5/2})

This routine runs CoulombFit at several target epsilons and reports both the per-term spectrum and the cumulative drop-curve.

References a, std::abs(), c, madness::GFit< T, NDIM >::CoulombFit(), madness::test_output::end(), fit(), lo, mu, madness::constants::pi, pi, and madness::print().

Referenced by main().

◆ test_direct_projection()

template<std::size_t LDIM>
int test_direct_projection ( World & world,
LowRankFunctionParameters parameters )

◆ test_inner()

◆ test_inv_rsq_gfit()

int test_inv_rsq_gfit ( World & world)

Verify that 1/r² can be represented as a sum of Gaussians via the Beylkin–Monzón integral representation

1/r^α = (1/Γ(α/2)) ∫_0^∞ t^{α/2-1} exp(-t r²) dt

For α=2 (i.e. 1/r²) this reduces to

1/r² = ∫_0^∞ exp(-t r²) dt

Substituting t = exp(2s):

1/r² = 2 ∫_{-∞}^{∞} exp(2s) exp(-exp(2s) r²) ds

Trapezoidal discretization on s with step h yields

1/r² ≈ 2h · Σ_k exp(2 s_k) · exp(-exp(2 s_k) r²)      (c_k, α_k) pair
      =      Σ_k c_k · exp(-α_k r²)

with c_k = 2 h · exp(2 s_k), α_k = exp(2 s_k). This is exactly the d=4 case of MADNESS's private bsh_fit_ndim(4, μ=0, …), whose per-term coefficient is c = h · exp((d-2) s) · 0.5/π^{d/2} (the d=4 BSH normalization carries a factor 0.5/π² that is not present in the pointwise-fit convention here).

This routine builds the pointwise fit directly and reports the number of Gaussians and the maximum relative error on a range of r values.

References std::abs(), alpha, e(), madness::test_output::end(), exact, h(), k, lo, np, and madness::print().

Referenced by main().

◆ test_invrsq_operator()

◆ test_lowrank_function()

◆ test_molecular_grid()

◆ test_numerics()

template<std::size_t LDIM>
int test_numerics ( World & world,
LowRankFunctionParameters & parameters )

2D numerical results for tol, volume_element with thresh 1.e-6 (canonical representation) lrf l2 err, tol, volume 1.00e-05 1.00e-01 error 1.216274e-02 lrf l2 err, tol, volume 1.00e-06 1.00e-01 error 5.161666e-03 lrf l2 err, tol, volume 1.00e-07 1.00e-01 error 1.629885e-03 lrf l2 err, tol, volume 1.00e-08 1.00e-01 error 6.962729e-04 lrf l2 err, tol, volume 1.00e-09 1.00e-01 error 2.404550e-04

3D numerical results: numerical parameters: k, eps(3D), eps(6D) 6 3.000000e-05 1.000000e-03 lrf l2 err, tol, volume 1.00e-05 1.00e-01 error 3.389503e-02 lrf l2 err, tol, volume 1.00e-06 1.00e-01 error 1.216609e-02 lrf l2 err, tol, volume 1.00e-07 1.00e-01 error 5.161720e-03 lrf l2 err, tol, volume 1.00e-08 1.00e-01 error 3.033423e-03 lrf l2 err, tol, volume 1.00e-09 1.00e-01 error 2.738746e-03

References a, b, madness::test_output::checkpoint(), madness::test_output::end(), madness::FunctionFactory< T, NDIM >::functor(), gauss1(), madness::GaussOperatorPtr(), madness::inner(), NDIM, one(), madness::print(), madness::QCCalculationParametersBase::print(), madness::QCCalculationParametersBase::set_derived_value(), madness::LowRankFunctionParameters::tol(), and madness::LowRankFunctionParameters::volume_element().

◆ test_recursive_apply()

template<std::size_t LDIM>
int test_recursive_apply ( World & world)

test recursive_apply: apply a full-dimensional operator on a Hartree product

Build f(1)*g(2), apply a 2D BSH operator via the recursive_apply pathway (which calls do_apply_directed_screening with opdim==NDIM), and compare against applying the same operator on an explicitly constructed Hartree product.

References a, madness::apply(), madness::BSHOperator(), c, madness::test_output::checkpoint(), diff(), madness::test_output::end(), error(), f, madness::g, madness::LowRankFunction< T, NDIM, LDIM >::get_g(), madness::LowRankFunction< T, NDIM, LDIM >::get_h(), madness::FunctionDefaults< NDIM >::get_tensor_type(), madness::FunctionDefaults< NDIM >::get_thresh(), madness::inner(), mu, NDIM, madness::Function< T, NDIM >::norm2(), op(), madness::print(), madness::LowRankFunction< T, NDIM, LDIM >::reconstruct(), madness::FunctionDefaults< NDIM >::set_tensor_type(), thresh, and madness::TT_2D.

Referenced by main().

◆ test_remove_lindep()

◆ test_stuff()

int test_stuff ( World & world,
LowRankFunctionParameters parameters )