35#ifndef MADNESS_MRA_FUNCTION_INTERFACE_H__INCLUDED
36#define MADNESS_MRA_FUNCTION_INTERFACE_H__INCLUDED
51 template<
typename T, std::
size_t NDIM>
54 template<
typename T, std::
size_t NDIM>
57 template<
typename T, std::
size_t NDIM>
58 Tensor<T>
fcube(
const Key<NDIM>&,
T (*
f)(
const Vector<double,NDIM>&),
const Tensor<double>&);
67 template<
typename T, std::
size_t NDIM>
82 double lo_sim=
lo/Lmax;
95 MADNESS_EXCEPTION(
"FunctionFunctorInterface: This function should not be called!", 0);
99 MADNESS_EXCEPTION(
"FunctionFunctorInterface: This function should not be called!", 0);
103 MADNESS_EXCEPTION(
"FunctionFunctorInterface: This function should not be called!", 0);
107 MADNESS_EXCEPTION(
"FunctionFunctorInterface: This function should not be called!", 0);
111 MADNESS_EXCEPTION(
"FunctionFunctorInterface: This function should not be called!", 0);
115 MADNESS_EXCEPTION(
"FunctionFunctorInterface: This function should not be called!", 0);
123 return std::vector< Vector<double,NDIM> >();
151 template <
typename T, std::
size_t NDIM>
153 void fcube(
const Key<NDIM>& key,
const FunctionFunctorInterface<T,NDIM>&
f,
const Tensor<double>& qx, Tensor<T>& fval);
164 template<
typename T, std::
size_t NDIM, std::
size_t MDIM>
190 pimplL v1,
pimplL v2, std::vector<pimplL> p1, std::vector<pimplL> p2)
207 for (
auto& p1 :
impl_p1_vector)
if (p1 and (not p1->is_on_demand())) p1->replicate(
false);
208 for (
auto& p2 :
impl_p2_vector)
if (p2 and (not p2->is_on_demand())) p2->replicate(
false);
246 print(
"there is no operator()(coordT&) in CompositeFunctorInterface, for good reason");
265 template<
typename T, std::
size_t NDIM>
286 template<
typename T, std::
size_t NDIM,
typename opT>
301 template<
typename T,
size_t NDIM,
typename opT>
325 template<
typename T, std::
size_t NDIM>
362 print(
"there is no operator()(coordT&) in TwoElectronInterface, for good reason");
378 }
else if (
NDIM==4) {
381 }
else if (
NDIM==6) {
394 if (
NDIM>=2) r0=(
ops[
mu].getop(0)->rnlij(n,l0)).reshape(
k*
k);
395 if (
NDIM>=4) r1=(
ops[
mu].getop(1)->rnlij(n,l1)).reshape(
k*
k);
396 if (
NDIM>=6)
r2=(
ops[
mu].getop(2)->rnlij(n,l2)).reshape(
k*
k);
403 }
else if (
NDIM==4) {
405 }
else if (
NDIM==6) {
419 else if (
NDIM==4)
return inner(scr1,scr3,0,0);
420 else if (
NDIM==6)
return inner(scr1,scr2,0,0);
429 std::vector<long> map(
NDIM);
433 }
else if (
NDIM==4) {
436 return copy(
c.reshape(
k,
k,
k,
k).mapdim(map));
437 }
else if (
NDIM==6) {
438 map[0]=0; map[1]=3; map[2]=1;
439 map[3]=4; map[4]=2; map[5]=5;
466 for (std::size_t
d=0;
d<
LDIM; ++
d) {
476 mutable std::vector< ConvolutionND<double,NDIM> >
ops;
494 template<
typename T, std::
size_t NDIM>
525 template<
typename T, std::
size_t NDIM>
676 template<
typename T, std::
size_t NDIM>
677 class ElectronRepulsionInterface :
public FunctionFunctorInterface<T,NDIM> {
679 typedef GenTensor<T>
coeffT;
680 typedef Vector<double, NDIM>
coordT;
683 ElectronRepulsion eri;
689 ElectronRepulsionInterface(World& world,
double lo,
double eps,
692 : eri(ElectronRepulsion(eps,eps,bc,
k)) {
698 print(
"there is no operator()(coordT&) in ElectronRepulsionInterface, for good reason");
717 template<
typename T, std::
size_t NDIM>
718 class FGIntegralInterface :
public FunctionFunctorInterface<T,NDIM> {
720 typedef GenTensor<T> coeffT;
721 typedef Vector<double, NDIM>
coordT;
724 ElectronRepulsion eri;
731 FGIntegralInterface(World& world,
double lo,
double eps,
double gamma,
732 const BoundaryConditions<NDIM>& bc=FunctionDefaults<NDIM>::get_bc(),
733 int k=FunctionDefaults<NDIM>::get_k())
734 : eri(ElectronRepulsion(eps,eps,0.0,bc,
k))
735 , bsh(BSHFunction(eps,eps,gamma,bc,
k)) {
738 bool provides_coeff()
const {
743 T operator()(
const coordT& x)
const {
744 print(
"there is no operator()(coordT&) in FGIntegralInterface, for good reason");
750 coeffT coeff(
const Key<NDIM>& key)
const {
752 tensorT e_b=eri.coeff(key)-bsh.coeff(key);
753 return coeffT(e_b,FunctionDefaults<NDIM>::get_thresh(),TT_FULL);
a function like f(x) = exp(-mu x)/x
Definition function_interface.h:551
GFit< double, 3 > fit(const double eps) const
derived classes must implement this – cf GFit.h
Definition function_interface.h:571
double mu
Definition function_interface.h:569
BSHFunctionInterface(double mu, double lo, double eps, const BoundaryConditions< 6 > &bc=FunctionDefaults< 6 >::get_bc(), int kk=FunctionDefaults< 6 >::get_k())
constructor: cf the Coulomb kernel
Definition function_interface.h:559
This class is used to specify boundary conditions for all operators.
Definition funcdefaults.h:101
CompositeFunctorInterface implements a wrapper of holding several functions and functors.
Definition function_interface.h:165
FunctionImpl< T, NDIM > implT
Definition function_interface.h:168
CompositeFunctorInterface(World &world, std::vector< pimplT > ket, pimplT g12, pimplL v1, pimplL v2, std::vector< pimplL > p1, std::vector< pimplL > p2)
constructor takes its Factory
Definition function_interface.h:189
std::vector< std::shared_ptr< implT > > impl_ket_vector
various MRA functions of NDIM dimensionality
Definition function_interface.h:177
std::shared_ptr< implT > pimplT
Definition function_interface.h:170
bool provides_coeff() const
does this functor directly provide sum coefficients? or only function values?
Definition function_interface.h:251
T operator()(const coordT &x) const
return value at point x; fairly inefficient
Definition function_interface.h:245
World & world
Definition function_interface.h:173
std::vector< std::shared_ptr< implL > > impl_p1_vector
supposedly orbital 1
Definition function_interface.h:183
std::shared_ptr< implL > pimplL
Definition function_interface.h:171
std::shared_ptr< implL > impl_m1
various MRA functions of MDIM dimensionality (e.g. 3, if NDIM==6)
Definition function_interface.h:181
FunctionImpl< T, MDIM > implL
Definition function_interface.h:169
std::shared_ptr< implT > impl_eri
supposedly 1/r12
Definition function_interface.h:178
std::shared_ptr< implL > impl_m2
supposedly 1/r2
Definition function_interface.h:182
void make_redundant(const bool fence)
Definition function_interface.h:212
bool check_redundant() const
return true if all constituent functions are in redundant tree state
Definition function_interface.h:231
std::vector< std::shared_ptr< implL > > impl_p2_vector
supposedly orbital 2
Definition function_interface.h:184
Vector< double, NDIM > coordT
Type of vector holding coordinates.
Definition function_interface.h:167
void replicate_low_dim_functions(const bool fence)
replicate low-dimensional functions over all ranks of this world
Definition function_interface.h:203
a function like f(x)=1/x
Definition function_interface.h:526
static constexpr std::size_t LDIM
Definition function_interface.h:543
GFit< double, LDIM > fit(const double eps) const
derived classes must implement this – cf GFit.h
Definition function_interface.h:545
ElectronRepulsionInterface(double lo, double eps, const BoundaryConditions< NDIM > &bc=FunctionDefaults< NDIM >::get_bc(), int kk=FunctionDefaults< NDIM >::get_k())
constructor: cf the Coulomb kernel
Definition function_interface.h:534
ElementaryInterface (formerly FunctorInterfaceWrapper) interfaces a c-function.
Definition function_interface.h:266
ElementaryInterface(T(*f)(const coordT &))
Definition function_interface.h:274
T operator()(const coordT &x) const
You should implement this to return f(x)
Definition function_interface.h:276
T(* f)(const coordT &)
Definition function_interface.h:272
coeffT values(const Key< NDIM > &key, const Tensor< double > &quad_x) const
Definition function_interface.h:278
GenTensor< T > coeffT
Definition function_interface.h:270
Vector< double, NDIM > coordT
Type of vector holding coordinates.
Definition function_interface.h:269
FunctionDefaults holds default paramaters as static class members.
Definition funcdefaults.h:204
static int get_k()
Returns the default wavelet order.
Definition funcdefaults.h:266
static const double & get_thresh()
Returns the default threshold.
Definition funcdefaults.h:279
static const Tensor< double > & get_cell_width()
Returns the width of each user cell dimension.
Definition funcdefaults.h:468
static const BoundaryConditions< NDIM > & get_bc()
Returns the default boundary conditions.
Definition funcdefaults.h:413
Abstract base class interface required for functors used as input to Functions.
Definition function_interface.h:68
virtual ~FunctionFunctorInterface()
Definition function_interface.h:129
virtual T operator()(const Vector< double, NDIM > &x) const =0
You should implement this to return f(x)
virtual bool provides_coeff() const
does this functor directly provide sum coefficients? or only function values?
Definition function_interface.h:142
virtual void operator()(const Vector< double *, 4 > &xvals, T *fvals, int npts) const
Definition function_interface.h:106
virtual bool supports_vectorized() const
Does the interface support a vectorized operator()?
Definition function_interface.h:92
GenTensor< T > coeffT
Definition function_interface.h:71
virtual coeffT coeff(const keyT &) const
Definition function_interface.h:131
virtual coeffT values(const keyT &key, const Tensor< double > &tensor) const
Definition function_interface.h:136
virtual bool screened(const Vector< double, NDIM > &c1, const Vector< double, NDIM > &c2) const
Can we screen this function based on the bounding box information?
Definition function_interface.h:87
T value_type
Definition function_interface.h:73
virtual void operator()(const Vector< double *, 1 > &xvals, T *fvals, int npts) const
Definition function_interface.h:94
Level special_level_
Definition function_interface.h:75
void set_length_scale(double lo)
adapt the special level to resolve the smallest length scale
Definition function_interface.h:80
virtual void operator()(const Vector< double *, 2 > &xvals, T *fvals, int npts) const
Definition function_interface.h:98
virtual void operator()(const Vector< double *, 5 > &xvals, T *fvals, int npts) const
Definition function_interface.h:110
virtual Level special_level()
Override this change level refinement for special points (default is 6)
Definition function_interface.h:127
virtual void operator()(const Vector< double *, 3 > &xvals, T *fvals, int npts) const
Definition function_interface.h:102
FunctionFunctorInterface()
Definition function_interface.h:77
Key< NDIM > keyT
Definition function_interface.h:72
virtual std::vector< Vector< double, NDIM > > special_points() const
Override this to return list of special points to be refined more deeply.
Definition function_interface.h:122
virtual void operator()(const Vector< double *, 6 > &xvals, T *fvals, int npts) const
Definition function_interface.h:114
FunctionImpl holds all Function state to facilitate shallow copy semantics.
Definition funcimpl.h:942
FunctionInterface implements a wrapper around any class with the operator()()
Definition function_interface.h:302
const opT op
Definition function_interface.h:307
bool provides_coeff() const
does this functor directly provide sum coefficients? or only function values?
Definition function_interface.h:314
Vector< double, NDIM > coordT
Type of vector holding coordinates.
Definition function_interface.h:305
GenTensor< T > coeffT
Definition function_interface.h:304
FunctionInterface(const opT &op)
Definition function_interface.h:310
T operator()(const coordT &coord) const
You should implement this to return f(x)
Definition function_interface.h:312
FunctorInterface interfaces a class or struct with an operator()()
Definition function_interface.h:287
GenTensor< T > coeffT
Definition function_interface.h:291
Vector< double, NDIM > coordT
Type of vector holding coordinates.
Definition function_interface.h:290
FunctorInterface(const opT &op)
Definition function_interface.h:295
opT op
Definition function_interface.h:293
T operator()(const coordT &x) const
You should implement this to return f(x)
Definition function_interface.h:297
static GFit BSHFit(double mu, double lo, double hi, double eps, bool prnt=false)
return a fit for the bound-state Helmholtz function
Definition gfit.h:117
static GFit F12Fit(double gamma, double lo, double hi, double eps, bool prnt=false)
return a fit for the F12 correlation factor
Definition gfit.h:183
static GFit SlaterFit(double gamma, double lo, double hi, double eps, bool prnt=false)
return a fit for the Slater function
Definition gfit.h:140
static GFit CoulombFit(double lo, double hi, double eps, bool prnt=false)
return a fit for the Coulomb function
Definition gfit.h:102
Definition lowranktensor.h:59
long dim(const int i) const
return the number of entries in dimension i
Definition lowranktensor.h:391
a function like f(x)=1/x
Definition function_interface.h:495
static constexpr std::size_t LDIM
Definition function_interface.h:517
GeneralTwoElectronInterface(OperatorInfo info, const BoundaryConditions< NDIM > &bc=FunctionDefaults< NDIM >::get_bc(), int kk=FunctionDefaults< NDIM >::get_k())
constructor: cf the Coulomb kernel
Definition function_interface.h:502
GFit< double, LDIM > fit(const double eps) const
derived classes must implement this – cf GFit.h
Definition function_interface.h:519
OperatorInfo info
Definition function_interface.h:516
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:66
Level level() const
Definition key.h:159
const Vector< Translation, NDIM > & translation() const
Definition key.h:164
a function like f(x) = (1 - exp(-mu x))/(2 gamma)
Definition function_interface.h:602
GFit< double, 3 > fit(const double eps) const
derived classes must implement this – cf GFit.h
Definition function_interface.h:638
double mu
Definition function_interface.h:636
SlaterF12Interface(double mu, double lo, double eps, const BoundaryConditions< 6 > &bc=FunctionDefaults< 6 >::get_bc(), int kk=FunctionDefaults< 6 >::get_k())
constructor: cf the Coulomb kernel
Definition function_interface.h:610
a function like f(x)=exp(-mu x)
Definition function_interface.h:577
GFit< double, 3 > fit(const double eps) const
derived classes must implement this – cf GFit.h
Definition function_interface.h:596
SlaterFunctionInterface(double mu, double lo, double eps, const BoundaryConditions< 6 > &bc=FunctionDefaults< 6 >::get_bc(), int kk=FunctionDefaults< 6 >::get_k())
constructor: cf the Coulomb kernel
Definition function_interface.h:585
double mu
Definition function_interface.h:594
A slice defines a sub-range or patch of a dimension.
Definition slice.h:103
A tensor is a multidimension array.
Definition tensor.h:317
float_scalar_type normf() const
Returns the Frobenius norm of the tensor.
Definition tensor.h:1726
T max(long *ind=0) const
Return the maximum value (and if ind is non-null, its index) in the Tensor.
Definition tensor.h:1703
base class to compute the wavelet coefficients for an isotropic 2e-operator
Definition function_interface.h:326
double hi
the largest length scale that needs to be represented
Definition function_interface.h:488
coeffT coeff(const Key< NDIM > &key) const
return the coefficients of the function in 6D (x1,y1,z1, x2,y2,z2)
Definition function_interface.h:356
TwoElectronInterface(double lo, double eps, const BoundaryConditions< NDIM > &bc=FunctionDefaults< NDIM >::get_bc(), int kk=FunctionDefaults< NDIM >::get_k())
constructor: cf the Coulomb kernel
Definition function_interface.h:337
int rank
the number of terms in the Gaussian quadrature
Definition function_interface.h:479
T operator()(const Vector< double, NDIM > &x) const
You should implement this to return f(x)
Definition function_interface.h:361
Tensor< double > map_coeff(const Tensor< double > &c) const
the dimensions are a bit confused (x1,x2, y1,y2, z1,z2) -> (x1,y1,z1, x2,y2,z2)
Definition function_interface.h:428
std::vector< ConvolutionND< double, NDIM > > ops
storing the coefficients
Definition function_interface.h:476
Tensor< double > make_coeff(const Key< NDIM > &key) const
make the coefficients from the 1d convolution
Definition function_interface.h:370
bool provides_coeff() const
does this functor directly provide sum coefficients? or only function values?
Definition function_interface.h:351
virtual GFit< double, LDIM > fit(const double eps) const =0
derived classes must implement this – cf GFit.h
double lo
the smallest length scale that needs to be represented
Definition function_interface.h:485
static constexpr std::size_t LDIM
Definition function_interface.h:328
void initialize(const double eps)
initialize the Gaussian fit; uses the virtual function fit() to fit
Definition function_interface.h:446
int k
the wavelet order
Definition function_interface.h:482
GenTensor< T > coeffT
Definition function_interface.h:331
A simple, fixed dimension vector.
Definition vector.h:64
void fence(bool debug=false)
Synchronizes all processes in communicator AND globally ensures no pending AM or tasks.
Definition worldgop.cc:161
A parallel world class.
Definition world.h:132
WorldGopInterface & gop
Global operations.
Definition world.h:205
Compuates most matrix elements over 1D operators (including Gaussians)
static double lo
Definition dirac-hatom.cc:23
fit isotropic functions to a set of Gaussians with controlled precision
auto T(World &world, response_space &f) -> response_space
Definition global_functions.cc:34
Multidimension Key for MRA tree and associated iterators.
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition madness_exception.h:134
#define MADNESS_CHECK_THROW(condition, msg)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition madness_exception.h:207
Tensor< double > tensorT
Definition mcpfit.cc:52
Vector< double, 3 > coordT
Definition mcpfit.cc:48
void print(const tensorT &t)
Definition mcpfit.cc:140
const double pi
Mathematical constant .
Definition constants.h:48
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
@ BC_PERIODIC
Definition funcdefaults.h:56
const std::vector< Function< T, NDIM > > & change_tree_state(const std::vector< Function< T, NDIM > > &v, const TreeState finalstate, const bool fence=true)
change tree state of the functions
Definition vmra.h:277
Vector< double, 3 > coordT
Definition corepotential.cc:54
@ redundant
s coeffs everywhere
Definition funcdefaults.h:64
static double r2(const coord_3d &x)
Definition smooth.h:45
Tensor< double > tensorT
Definition distpm.cc:21
std::vector< Function< T, NDIM > > impl2function(const std::vector< std::shared_ptr< FunctionImpl< T, NDIM > > > vimpl)
Definition vmra.h:676
int64_t Translation
Definition key.h:54
static const Slice _(0,-1, 1)
int Level
Definition key.h:55
std::enable_if< std::is_base_of< ProjectorBase, projT >::value, OuterProjector< projT, projQ > >::type outer(const projT &p0, const projQ &p1)
Definition projector.h:457
void print(const T &t, const Ts &... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition print.h:225
Tensor< T > fcube(const Key< NDIM > &, T(*f)(const Vector< double, NDIM > &), const Tensor< double > &)
Definition mraimpl.h:2163
@ TT_FULL
Definition gentensor.h:120
NDIM & f
Definition mra.h:2416
double inner(response_space &a, response_space &b)
Definition response_functions.h:442
Function< T, NDIM > copy(const Function< T, NDIM > &f, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool fence=true)
Create a new copy of the function with different distribution and optional fence.
Definition mra.h:2002
const double mu
Definition navstokes_cosines.cc:95
static const double d
Definition nonlinschro.cc:121
static const double c
Definition relops.cc:10
static const double thresh
Definition rk.cc:45
static const long k
Definition rk.cc:44
Definition convolution1d.h:849
Definition operatorinfo.h:58
double hi
Definition operatorinfo.h:65
double thresh
Definition operatorinfo.h:63
Defines and implements most of Tensor.
static const std::size_t NDIM
Definition testpdiff.cc:42