35 #ifndef MADNESS_MRA_FUNCTION_INTERFACE_H__INCLUDED
36 #define MADNESS_MRA_FUNCTION_INTERFACE_H__INCLUDED
49 template<
typename T, std::
size_t NDIM>
52 template<
typename T, std::
size_t NDIM>
53 Tensor<T>
fcube(
const Key<NDIM>&,
T (*
f)(
const Vector<double,NDIM>&),
const Tensor<double>&);
57 template<
typename T, std::
size_t NDIM>
73 MADNESS_EXCEPTION(
"FunctionFunctorInterface: This function should not be called!", 0);
77 MADNESS_EXCEPTION(
"FunctionFunctorInterface: This function should not be called!", 0);
81 MADNESS_EXCEPTION(
"FunctionFunctorInterface: This function should not be called!", 0);
85 MADNESS_EXCEPTION(
"FunctionFunctorInterface: This function should not be called!", 0);
89 MADNESS_EXCEPTION(
"FunctionFunctorInterface: This function should not be called!", 0);
93 MADNESS_EXCEPTION(
"FunctionFunctorInterface: This function should not be called!", 0);
101 return std::vector< Vector<double,NDIM> >();
109 virtual coeffT
coeff(
const keyT&)
const {
114 virtual coeffT
values(
const keyT& key,
const Tensor<double>& tensor)
const {
136 template<
typename T, std::
size_t NDIM, std::
size_t MDIM>
137 class CompositeFunctorInterface :
public FunctionFunctorInterface<T,NDIM> {
139 typedef Vector<double, NDIM>
coordT;
140 typedef FunctionImpl<T,NDIM> implT;
141 typedef FunctionImpl<T,MDIM> implL;
162 pimplL v1, pimplL v2, pimplL p1, pimplL p2)
163 : world(world), impl_ket(ket), impl_eri(g12)
164 , impl_m1(v1), impl_m2(v2), impl_p1(p1), impl_p2(p2)
169 MADNESS_ASSERT(impl_ket or (impl_p1 and impl_p2));
180 if (impl_p2 and (not impl_p2->is_on_demand())) impl_p2->make_redundant(
false);
187 print(
"there is no operator()(coordT&) in CompositeFunctorInterface, for good reason");
206 template<
typename T, std::
size_t NDIM>
213 T (*
f)(
const coordT&);
227 template<
typename T, std::
size_t NDIM,
typename opT>
242 template<
typename T,
size_t NDIM,
typename opT>
266 template<
typename T, std::
size_t NDIM>
280 :
rank(),
k(kk), lo(lo),
hi(1.0) {
283 for (std::size_t d=1; d<6; ++d) {MADNESS_ASSERT(bc(d,0)==bc(0,0));}
302 print(
"there is no operator()(coordT&) in TwoElectronInterface, for good reason");
319 Tensor<double> scr1(
rank,
k*
k), scr2(
rank,k*k,k*k);
323 const Tensor<double> r0=(
ops[
mu].getop(0)->rnlij(n,l0)).reshape(k*k);
324 const Tensor<double> r1=(
ops[
mu].getop(1)->rnlij(n,l1)).reshape(k*k);
325 const Tensor<double> r2=(
ops[
mu].getop(2)->rnlij(n,l2)).reshape(k*k);
334 Tensor<double>
c=
inner(scr1,scr2,0,0);
340 std::vector<long> map(6);
341 map[0]=0; map[1]=3; map[2]=1;
342 map[3]=4; map[4]=2; map[5]=5;
343 return copy(c.reshape(
k,
k,
k,
k,
k,
k).mapdim(map));
367 for (std::size_t d=0; d<3; ++d) {
377 mutable std::vector< ConvolutionND<double,6> >
ops;
498 *pow(0.5,0.5*6*key.
level());
499 std::vector<long> v0(6,0
L);
548 template<
typename T, std::
size_t NDIM>
549 class ElectronRepulsionInterface :
public FunctionFunctorInterface<T,NDIM> {
551 typedef GenTensor<T>
coeffT;
552 typedef Vector<double, NDIM>
coordT;
555 ElectronRepulsion eri;
562 const BoundaryConditions<NDIM>& bc=FunctionDefaults<NDIM>::get_bc(),
563 int k=FunctionDefaults<NDIM>::get_k())
564 : eri(ElectronRepulsion(eps,eps,bc,
k)) {
570 print(
"there is no operator()(coordT&) in ElectronRepulsionInterface, for good reason");
577 coeffT
coeff(
const Key<NDIM>& key)
const {
589 template<
typename T, std::
size_t NDIM>
590 class FGIntegralInterface :
public FunctionFunctorInterface<T,NDIM> {
592 typedef GenTensor<T> coeffT;
593 typedef Vector<double, NDIM>
coordT;
596 ElectronRepulsion eri;
603 FGIntegralInterface(World& world,
double lo,
double eps,
double gamma,
604 const BoundaryConditions<NDIM>& bc=FunctionDefaults<NDIM>::get_bc(),
605 int k=FunctionDefaults<NDIM>::get_k())
606 : eri(ElectronRepulsion(eps,eps,0.0,bc,
k))
607 , bsh(BSHFunction(eps,eps,gamma,bc,
k)) {
610 bool provides_coeff()
const {
615 T operator()(
const coordT& x)
const {
616 print(
"there is no operator()(coordT&) in FGIntegralInterface, for good reason");
622 coeffT coeff(
const Key<NDIM>& key)
const {
624 tensorT e_b=eri.coeff(key)-bsh.coeff(key);
625 return coeffT(e_b,FunctionDefaults<NDIM>::get_thresh(),
TT_FULL);
634 #endif // MADNESS_MRA_FUNCTION_INTERFACE_H__INCLUDED
virtual void operator()(const Vector< double *, 4 > &xvals, T *fvals, int npts) const
Definition: function_interface.h:84
a function like f(x)=exp(-mu x)
Definition: function_interface.h:446
WorldGopInterface & gop
Global operations.
Definition: worldfwd.h:462
Definition: shared_ptr_bits.h:38
std::shared_ptr< implL > impl_m2
supposedly 1/r2
Definition: function_interface.h:154
virtual bool provides_coeff() const
does this functor directly provide sum coefficients? or only function values?
Definition: function_interface.h:120
const double pi
Mathematical constant pi.
Definition: constants.h:44
void initialize(const double eps)
initialize the Gaussian fit; uses the virtual function fit() to fit
Definition: function_interface.h:347
FunctionDefaults holds default paramaters as static class members.
Definition: funcdefaults.h:175
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:339
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:482
static GFit SlaterFit(double gamma, double lo, double hi, double eps, bool prnt=false)
return a fit for the Slater function
Definition: gfit.h:86
const Vector< Translation, NDIM > & translation() const
Definition: key.h:225
CompositeFunctorInterface(World &world, pimplT ket, pimplT g12, pimplL v1, pimplL v2, pimplL p1, pimplL p2)
constructor takes its Factory
Definition: function_interface.h:161
T operator()(const Vector< double, NDIM > &x) const
You should implement this to return f(x)
Definition: function_interface.h:301
virtual void operator()(const Vector< double *, 3 > &xvals, T *fvals, int npts) const
Definition: function_interface.h:80
GenTensor< T > outer(const GenTensor< T > &left, const GenTensor< T > &right)
Outer product ... result(i,j,...,p,q,...) = left(i,k,...)*right(p,q,...)
Definition: gentensor.h:230
Tensor< double > make_coeff(const Key< 6 > &key) const
make the coefficients from the 1d convolution
Definition: function_interface.h:310
Provides a tensor with taking advantage of possibly low rank.
const double L
Definition: 3dharmonic.cc:123
FunctionInterface implements a wrapper around any class with the operator()()
Definition: function_interface.h:243
std::shared_ptr< implL > impl_p2
supposedly orbital 2
Definition: function_interface.h:156
a function like f(x) = (1 - exp(-mu x))/x
Definition: function_interface.h:516
GenTensor< T > coeffT
Definition: function_interface.h:232
virtual void operator()(const Vector< double *, 6 > &xvals, T *fvals, int npts) const
Definition: function_interface.h:92
virtual coeffT values(const keyT &key, const Tensor< double > &tensor) const
Definition: function_interface.h:114
int k
the wavelet order
Definition: function_interface.h:383
double lo
the smallest length scale that needs to be represented
Definition: function_interface.h:386
virtual GFit< double, 3 > fit(const double eps) const =0
derived classes must implement this – cf GFit.h
ElementaryInterface(T(*f)(const coordT &))
Definition: function_interface.h:215
NDIM & f
Definition: mra.h:2179
Tensor< T > coeffs() const
return the coefficients of the fit
Definition: gfit.h:102
Definition: funcdefaults.h:56
static const double & get_thresh()
Returns the default threshold.
Definition: funcdefaults.h:225
Tensor< T > fcube(const Key< NDIM > &, T(*f)(const Vector< double, NDIM > &), const Tensor< double > &)
Definition: mraimpl.h:2047
Vector< double, 3 > coordT
Definition: chem/corepotential.cc:57
GenTensor< T > coeffT
Definition: function_interface.h:61
T inner(const vecfunc< T, NDIM > &a, const vecfunc< T, NDIM > &b)
the non-linear solver requires an inner product
Definition: nemo.h:112
Vector< double, NDIM > coordT
Type of vector holding coordinates.
Definition: function_interface.h:231
bool provides_coeff() const
does this functor directly provide sum coefficients? or only function values?
Definition: function_interface.h:255
std::vector< ConvolutionND< double, 6 > > ops
storing the coefficients
Definition: function_interface.h:377
Defines and implements most of Tensor.
std::shared_ptr< implT > impl_ket
various MRA functions of NDIM dimensionality
Definition: function_interface.h:149
FunctorInterface(const opT &op)
Definition: function_interface.h:236
Tensor< T > exponents() const
return the exponents of the fit
Definition: gfit.h:105
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:428
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:100
T operator()(const coordT &x) const
You should implement this to return f(x)
Definition: function_interface.h:238
T operator()(const coordT &x) const
You should implement this to return f(x)
Definition: function_interface.h:217
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)
base class to compute the wavelet coefficients for an isotropic 2e-operator
Definition: function_interface.h:267
virtual void operator()(const Vector< double *, 5 > &xvals, T *fvals, int npts) const
Definition: function_interface.h:88
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:70
const int k
Definition: dielectric.cc:184
coeffT values(const Key< NDIM > &key, const Tensor< double > &quad_x) const
Definition: function_interface.h:219
int rank
the number of terms in the Gaussian quadrature
Definition: function_interface.h:380
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:1835
double hi
the largest length scale that needs to be represented
Definition: function_interface.h:389
std::shared_ptr< implL > impl_p1
supposedly orbital 1
Definition: function_interface.h:155
Level level() const
Definition: key.h:220
bool provides_coeff() const
does this functor directly provide sum coefficients? or only function values?
Definition: function_interface.h:291
const double mu
Definition: navstokes_cosines.cc:96
GenTensor< T > coeffT
Definition: function_interface.h:211
Tensor< double > tensorT
Definition: chem/distpm.cc:13
virtual void operator()(const Vector< double *, 1 > &xvals, T *fvals, int npts) const
Definition: function_interface.h:72
Vector< double, 3 > coordT
Definition: DFcode/corepotential.cc:55
Namespace for mathematical applications.
Definition: muParser.cpp:47
a function like f(x) = (1 - exp(-mu x))/(2 gamma)
Definition: function_interface.h:473
virtual Level special_level()
Override this change level refinement for special points (default is 6)
Definition: function_interface.h:105
ElementaryInterface (formerly FunctorInterfaceWrapper) interfaces a c-function.
Definition: function_interface.h:207
bool & is_on_demand()
Definition: mraimpl.h:269
coeffT coeff(const Key< 6 > &key) const
overload the function of the base class
Definition: function_interface.h:491
a function like f(x)=1/x
Definition: function_interface.h:394
tensorT sqrt(const tensorT &s, double tol=1e-8)
Computes matrix square root (not used any more?)
Definition: DFcode/moldft.cc:446
A parallel world with full functionality wrapping an MPI communicator.
Definition: worldfwd.h:416
void fence()
Synchronizes all processes in communicator AND globally ensures no pending AM or tasks.
Definition: worldgop.cc:52
const mpreal gamma(const mpreal &v, mp_rnd_t rnd_mode)
Definition: mpreal.h:2429
int Level
Definition: key.h:58
virtual void operator()(const Vector< double *, 2 > &xvals, T *fvals, int npts) const
Definition: function_interface.h:76
std::shared_ptr< implT > impl_eri
supposedly 1/r12
Definition: function_interface.h:150
Abstract base class interface required for functors used as input to Functions.
Definition: function_interface.h:58
virtual ~FunctionFunctorInterface()
Definition: function_interface.h:107
fit isotropic functions to a set of Gaussians with controlled precision
static GFit CoulombFit(double lo, double hi, double eps, bool prnt=false)
return a fit for the Coulomb function
Definition: gfit.h:55
Key< NDIM > keyT
Definition: function_interface.h:62
Definition: convolution1d.h:837
T operator()(const coordT &x) const
return value at point x; fairly inefficient
Definition: function_interface.h:186
Vector< double, NDIM > coordT
Type of vector holding coordinates.
Definition: function_interface.h:210
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:455
FunctorInterface interfaces a class or struct with an operator()()
Definition: function_interface.h:228
static const Tensor< double > & get_cell_width()
Returns the width of each user cell dimension.
Definition: funcdefaults.h:391
TwoElectronInterface(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:277
void print(const A &a)
Print a single item to std::cout terminating with new line.
Definition: print.h:122
#define MADNESS_EXCEPTION(msg, value)
Definition: worldexc.h:88
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:65
a function like f(x) = exp(-mu x)/x
Definition: function_interface.h:419
A slice defines a sub-range or patch of a dimension.
Definition: slice.h:103
T operator()(const coordT &coord) const
You should implement this to return f(x)
Definition: function_interface.h:253
Multidimension Key for MRA tree and associated iterators.
Definition: gentensor.h:123
int64_t Translation
Definition: key.h:57
virtual coeffT coeff(const keyT &) const
Definition: function_interface.h:109
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
const double c
Definition: gfit.cc:200
std::shared_ptr< implL > impl_m1
various MRA functions of MDIM dimensionality (e.g. 3, if NDIM==6)
Definition: function_interface.h:153
FGInterface(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:525
bool provides_coeff() const
does this functor directly provide sum coefficients? or only function values?
Definition: function_interface.h:192
FunctionInterface(const opT &op)
Definition: function_interface.h:251
opT op
Definition: function_interface.h:234
Key is the index for a node of the 2^NDIM-tree.
Definition: key.h:69
GenTensor< T > coeffT
Definition: function_interface.h:270
T(* f)(const coordT &)
Definition: function_interface.h:213
Compuates most matrix elements over 1D operators (including Gaussians)
virtual bool supports_vectorized() const
Does the interface support a vectorized operator()?
Definition: function_interface.h:70
ElectronRepulsionInterface(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:403
void make_redundant(const bool fence)
convert this to redundant, i.e. have sum coefficients on all levels
Definition: mraimpl.h:1485
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:296