MADNESS 0.10.1
test6.cc File Reference

test various functionality for 6d functions More...

#include <madness/mra/mra.h>
#include <madness/world/test_utilities.h>
#include <map>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
Include dependency graph for test6.cc:

Functions

int check (bool b, const std::string message)
int check_small (const double val, const double eps, const std::string message)
static double gauss_3d (const coord_3d &r)
static double gauss_plus_one_3d (const coord_3d &r)
static double gauss_plus_tight_3d (const coord_3d &r)
bool is_large (const double &val, const double &eps)
bool is_small (const double &val, const double &eps)
template<size_t NDIM>
void load_function (World &world, Function< double, NDIM > &pair, const std::string name)
int main (int argc, char **argv)
std::string ok (const bool b)
static double one_3d (const coord_3d &r)
static double one_6d (const coord_6d &r)
template<size_t NDIM>
void save_function (World &world, Function< double, NDIM > &pair, const std::string name)
int test (World &world, const long &k, const double thresh)
int test_add (World &world, const long &k, const double thresh)
 test f(1,2) + g(1,2) for both f and g reconstructed
int test_convolution (World &world, const long &k, const double thresh)
 test 6D convolution
int test_exchange (World &world, const long &k, const double thresh)
 test f(1,2) + g(1,2) for both f and g reconstructed
template<typename T, std::size_t NDIM>
int test_hartree_product (World &world, const long &k, const double thresh)
 test f(1,2) = g(1) h(2)
int test_inner (World &world, const long &k, const double thresh)
 test inner product using redundant wave functions
template<typename T, std::size_t NDIM>
int test_multiply (World &world, const long &k, double thresh)
 test f(1,2)*g(1)
int test_replicate (World &world, const long &k, const double thresh)
template<typename T, std::size_t NDIM>
int test_sum_down (World &world, const long &k, double thresh)
template<typename T, std::size_t NDIM>
int test_sum_down_files (World &world, const long &k, double thresh)
template<typename T, std::size_t NDIM>
int test_vector_composite (World &world, const long &k, const double thresh)
template<typename T, std::size_t NDIM>
int test_Vphi_ij_u (World &world, const long &k, double thresh)
static double tightgauss_3d (const coord_3d &r)
static double V (const Vector< double, 3 > &r)
static double zero_3d (const coord_3d &r)

Detailed Description

test various functionality for 6d functions

Function Documentation

◆ check()

int check ( bool b,
const std::string message )

References b, ok(), and madness::print().

Referenced by test_add().

◆ check_small()

int check_small ( const double val,
const double eps,
const std::string message )

References is_small(), ok(), and madness::print().

Referenced by test_add().

◆ gauss_3d()

double gauss_3d ( const coord_3d & r)
static

References norm(), and madness::r2().

Referenced by gauss_plus_one_3d(), and gauss_plus_tight_3d().

◆ gauss_plus_one_3d()

double gauss_plus_one_3d ( const coord_3d & r)
static

References gauss_3d(), and one_3d().

Referenced by test_add().

◆ gauss_plus_tight_3d()

double gauss_plus_tight_3d ( const coord_3d & r)
static

References gauss_3d(), and tightgauss_3d().

Referenced by test_add().

◆ is_large()

bool is_large ( const double & val,
const double & eps )

◆ is_small()

◆ load_function()

◆ main()

◆ ok()

◆ one_3d()

double one_3d ( const coord_3d & r)
static

Referenced by gauss_plus_one_3d(), and test_add().

◆ one_6d()

double one_6d ( const coord_6d & r)
static

Referenced by test_add().

◆ save_function()

template<size_t NDIM>
void save_function ( World & world,
Function< double, NDIM > & pair,
const std::string name )

◆ test()

◆ test_add()

◆ test_convolution()

◆ test_exchange()

◆ test_hartree_product()

◆ test_inner()

int test_inner ( World & world,
const long & k,
const double thresh )

◆ test_multiply()

◆ test_replicate()

◆ test_sum_down()

template<typename T, std::size_t NDIM>
int test_sum_down ( World & world,
const long & k,
double thresh )

Attribute the error of the accumulate_trees+sum_down addition path to its two stages.

We add an s-type function f_s(r) = exp(-a|r|) and a p-type function f_p(r) = r[0]*exp(-a|r|) (Slater cusp + nodal plane -> deeply refined, so the low-rank / sum_down error is pronounced).

The path used by transform_reconstructed()/finalize_sum() has TWO lossy stages, each truncating low-rank tensors to the impl's stored TensorArgs.thresh:

  1. accumulate_trees (+ consolidate_buffer): add_SVD merges S-coeffs into a redundant_after_merge tree, re-truncating rank at every touched node.
  2. sum_down: propagates S-coeffs from ancestors down to the leaves, unfiltering and re-truncating rank at every level. Because both stages read the same stored TensorArgs but run at different times, we can dial each stage's truncation threshold independently and see which one carries the error. Running the path four ways:
    run       accumulate thr   sum_down thr    isolates
    A_tight   tight            tight           near-exact sum (internal gold)
    A0        tau              tau             full path
    A1        tau              tight           accumulate error only
    A2        tight            tau             sum_down error only
    

then ||A1-A_tight|| = accumulate_trees error, ||A2-A_tight|| = sum_down error. Using the internal gold A_tight (not the analytic function) removes the shared projection error of f_s,f_p so only the arithmetic error of the two stages remains.

References A2(), c, madness::test_output::checkpoint(), madness::test_output::end(), madness::Function< T, NDIM >::err(), madness::FunctionFactory< T, NDIM >::f(), madness::WorldGopInterface::fence(), madness::Function< T, NDIM >::get_impl(), madness::FunctionDefaults< NDIM >::get_k(), madness::FunctionDefaults< NDIM >::get_thresh(), madness::World::gop, madness::inner(), k, NDIM, madness::norm2(), madness::print(), madness::Function< T, NDIM >::reconstruct(), madness::redundant_after_merge, madness::test_output::set_cout_to_terminal(), madness::FunctionDefaults< NDIM >::set_k(), madness::FunctionDefaults< NDIM >::set_tensor_type(), madness::FunctionDefaults< NDIM >::set_thresh(), madness::Function< T, NDIM >::sum_down(), thresh, madness::TT_2D, madness::TT_FULL, and madness::zero_functions().

◆ test_sum_down_files()

template<typename T, std::size_t NDIM>
int test_sum_down_files ( World & world,
const long & k,
double thresh )

◆ test_vector_composite()

◆ test_Vphi_ij_u()

template<typename T, std::size_t NDIM>
int test_Vphi_ij_u ( World & world,
const long & k,
double thresh )

test Vphi_ij_u_op_NS: u(1,2) * [phi(1)] * [phi(2)] and inner product with on-demand ERI.

Setup avoids all 6D fill_tree by using Gaussian orbitals (LDIM) and a separable 2-particle Gaussian factor: gauss(1,2) = g(r1) * g(r2), u(1,2) = (g*a)(1) ⊗ (g*b)(2) so u is a pure Hartree product. f12 is a Gaussian-r12 kernel; combined with the (separable) gauss factor it is absorbed into the orbital products, so the reference <k(1) l(2) | f12 | u(1,2)> = <g*a*k | conv | g*b*l> is a single LDIM convolution-then-inner — no explicit functor for f12, no 6D ref.

References a, std::abs(), madness::apply(), b, beta, madness::Function< T, NDIM >::change_tree_state(), madness::test_output::checkpoint(), madness::copy(), madness::test_output::end(), madness::Function< T, NDIM >::err(), madness::FunctionFactory< T, NDIM >::f(), f12_lambda(), madness::g, gauss_a(), gauss_b(), madness::GaussOperator(), madness::Function< T, NDIM >::get_impl(), madness::FunctionDefaults< NDIM >::get_thresh(), madness::hartree_product(), madness::inner(), madness::FunctionFactory< T, NDIM >::is_on_demand(), k, madness::multiply(), madness::name(), NDIM, madness::print(), madness::r2(), madness::redundant, madness::test_output::set_cout_to_terminal(), madness::Function< T, NDIM >::set_impl(), madness::FunctionDefaults< NDIM >::set_tensor_type(), madness::FunctionDefaults< NDIM >::set_thresh(), madness::Function< T, NDIM >::thresh(), thresh, madness::Function< T, NDIM >::tree_size(), madness::TT_2D, madness::TT_FULL, u(), and madness::wall_time().

◆ tightgauss_3d()

double tightgauss_3d ( const coord_3d & r)
static

References norm(), and madness::r2().

Referenced by gauss_plus_tight_3d(), and test_add().

◆ V()

double V ( const Vector< double, 3 > & r)
static

References e().

◆ zero_3d()

double zero_3d ( const coord_3d & r)
static

Referenced by test_add().