46 #ifndef MADNESS_MRA_FUNCTION_FACTORY_H__INCLUDED
47 #define MADNESS_MRA_FUNCTION_FACTORY_H__INCLUDED
59 template<
typename T, std::
size_t NDIM>
62 template<
typename T, std::
size_t NDIM>
65 template<
typename T, std::
size_t NDIM>
66 Tensor<T>
fcube(
const Key<NDIM>&,
T (*
f)(
const Vector<double, NDIM>&),
const Tensor<double>&);
68 template<
typename T, std::
size_t NDIM>
85 template<
typename T, std::
size_t NDIM>
108 std::shared_ptr<WorldDCPmapInterface<Key<NDIM> > >
_pmap;
116 std::shared_ptr<FunctionFunctorInterface<T, NDIM> >
_functor;
150 template<
typename opT>
151 typename std::enable_if<std::is_base_of<FunctionFunctorInterface<T, NDIM>, opT>::value,
153 _functor = std::shared_ptr<FunctionFunctorInterface<T, NDIM> >(
new opT(
op));
160 template<
typename opT>
161 typename std::enable_if<not std::is_base_of<FunctionFunctorInterface<T, NDIM>, opT>::value,
163 _functor = std::shared_ptr<FunctionInterface<T, NDIM, opT> >
299 virtual std::shared_ptr<FunctionFunctorInterface<T, NDIM> >
get_functor()
const {
320 template<
typename T, std::
size_t NDIM, std::
size_t MDIM>
327 std::vector<implT_ptr_hidim>
_ket;
329 std::shared_ptr<FunctionImpl<T, NDIM> >
_g12;
330 std::shared_ptr<FunctionImpl<T, MDIM> >
_v1;
331 std::shared_ptr<FunctionImpl<T, MDIM> >
_v2;
332 std::vector<std::shared_ptr<FunctionImpl<T, MDIM> >>
_particle1;
333 std::vector<std::shared_ptr<FunctionImpl<T, MDIM> >>
_particle2;
336 std::shared_ptr<CompositeFunctorInterface<T, NDIM, MDIM> >
_func;
350 _ket.push_back(
f.get_impl());
356 for (
auto f: vf)
_ket.push_back(
f.get_impl());
414 std::shared_ptr<FunctionFunctorInterface<T, NDIM> >
get_functor()
const {
417 if (this->_func)
return this->
_func;
422 const_cast< std::shared_ptr<CompositeFunctorInterface<T, NDIM, MDIM>
>& >(this->
_func) =
435 template<
typename T=
double, std::
size_t NDIM=6>
439 typedef std::shared_ptr<FunctionFunctorInterface<T, NDIM> >
InterfacePtr;
447 constexpr std::size_t LDIM=
NDIM/2;
448 static_assert(
NDIM==2*LDIM,
"NDIM must be even");
504 const_cast<InterfacePtr&
>(this->
interface_) =
554 InterfacePtr get_functor()
const {
557 if (this->interface_)
return this->interface_;
560 const_cast<InterfacePtr&
>(this->interface_)=
561 InterfacePtr(
new ElectronRepulsionInterface(
562 dcut_,thresh_,bc_,k_));
563 return this->interface_;
566 ERIFactory&
self() {
return *
this;}
571 class SlaterFunctionFactory :
public TwoElectronFactory<SlaterFunctionFacto> {
573 SlaterFunctionFactory(World& world)
574 : TwoElectronFactory(world), gamma_(-1.0), f12_(false) {}
577 SlaterFunctionFactory& gamma(
double gamma) {
578 this->gamma_ = gamma;
583 SlaterFunctionFactory& f12() {
589 InterfacePtr get_functor()
const {
592 if (this->interface_)
return this->interface_;
599 const_cast<InterfacePtr&
>(this->interface_)=
600 InterfacePtr(
new SlaterF12Interface(
601 gamma_,dcut_,this->_thresh,bc_,this->_k));
603 const_cast<InterfacePtr&
>(this->interface_)=
604 InterfacePtr(
new SlaterFunctionInterface(
605 gamma_,dcut_,this->_thresh,bc_,this->_k));
607 return this->interface_;
610 SlaterFunctionFactory&
self() {
return *
this;}
619 template<
typename T, std::
size_t NDIM>
620 class ERIFactory :
public FunctionFactory<T, NDIM> {
623 std::shared_ptr<ElectronRepulsionInterface> _eri;
629 BoundaryConditions<NDIM> _bc;
632 ERIFactory(World& world)
633 : FunctionFactory<
T,
NDIM>(world)
635 , _dcut(FunctionDefaults<
NDIM>::get_thresh())
636 , _bc(FunctionDefaults<
NDIM>::get_bc())
638 this->_is_on_demand=
true;
655 std::shared_ptr<FunctionFunctorInterface<T, NDIM> > get_functor()
const {
658 if (this->_eri)
return this->_eri;
663 const_cast< std::shared_ptr<ElectronRepulsionInterface>&
>(this->_eri)=
664 std::shared_ptr<ElectronRepulsionInterface>(
665 new ElectronRepulsionInterface(_dcut,this->_thresh,
This class is used to specify boundary conditions for all operators.
Definition: funcdefaults.h:101
Factory for facile setup of a CompositeFunctorInterface and its FuncImpl.
Definition: function_factory.h:321
std::shared_ptr< FunctionFunctorInterface< T, NDIM > > get_functor() const
return the functor; override this if the functor needs deferred construction
Definition: function_factory.h:414
CompositeFactory(World &world)
Definition: function_factory.h:342
std::shared_ptr< FunctionImpl< T, MDIM > > _v2
supposedly a potential for particle 2
Definition: function_factory.h:331
std::shared_ptr< FunctionImpl< T, NDIM > > _g12
supposedly a interaction potential
Definition: function_factory.h:329
CompositeFactory & V_for_particle1(const Function< T, MDIM > &f)
a one-particle potential, acting on particle 1
Definition: function_factory.h:369
CompositeFactory & particle2(const std::vector< Function< T, MDIM >> &vf)
Definition: function_factory.h:408
std::shared_ptr< FunctionImpl< T, MDIM > > _v1
supposedly a potential for particle 1
Definition: function_factory.h:330
std::shared_ptr< FunctionImpl< T, MDIM > > implT_ptr_lodim
Definition: function_factory.h:323
CompositeFactory & particle2(const Function< T, MDIM > &f)
Definition: function_factory.h:400
std::vector< implT_ptr_hidim > _ket
Definition: function_factory.h:327
CompositeFactory & g12(const Function< T, NDIM > &f)
g12 is the interaction potential (6D)
Definition: function_factory.h:362
std::shared_ptr< CompositeFunctorInterface< T, NDIM, MDIM > > _func
Definition: function_factory.h:336
CompositeFactory & ket(const std::vector< Function< T, NDIM >> &vf)
Definition: function_factory.h:355
CompositeFactory & ket(const Function< T, NDIM > &f)
provide directly the NDIM (6D) pair function ket
Definition: function_factory.h:349
CompositeFactory & V_for_particle2(const Function< T, MDIM > &f)
a one-particle potential, acting on particle 2
Definition: function_factory.h:376
std::shared_ptr< FunctionImpl< T, NDIM > > implT_ptr_hidim
Definition: function_factory.h:324
CompositeFactory & particle1(const Function< T, MDIM > &f)
Definition: function_factory.h:384
CompositeFactory & particle1(const std::vector< Function< T, MDIM >> &vf)
Definition: function_factory.h:392
std::vector< std::shared_ptr< FunctionImpl< T, MDIM > > > _particle2
supposedly particle 2
Definition: function_factory.h:333
std::vector< std::shared_ptr< FunctionImpl< T, MDIM > > > _particle1
supposedly particle 1
Definition: function_factory.h:332
CompositeFunctorInterface implements a wrapper of holding several functions and functors.
Definition: function_interface.h:165
ElementaryInterface (formerly FunctorInterfaceWrapper) interfaces a c-function.
Definition: function_interface.h:266
FunctionDefaults holds default paramaters as static class members.
Definition: funcdefaults.h:204
static int get_special_level()
Returns the default projection level for special boxes.
Definition: funcdefaults.h:296
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 int get_initial_level()
Returns the default initial projection level.
Definition: funcdefaults.h:291
FunctionFactory implements the named-parameter idiom for Function.
Definition: function_factory.h:86
std::enable_if< not std::is_base_of< FunctionFunctorInterface< T, NDIM >, opT >::value, FunctionFactory & >::type functor(const opT &op)
pass in a functor that is not derived from FunctionFunctorInterface
Definition: function_factory.h:162
FunctionFactory & noautorefine()
Definition: function_factory.h:251
FunctionFactory & pmap(const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap)
Definition: function_factory.h:287
std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > _pmap
Definition: function_factory.h:108
std::enable_if< std::is_base_of< FunctionFunctorInterface< T, NDIM >, opT >::value, FunctionFactory & >::type functor(const opT &op)
pass in a functor that is derived from FunctionFunctorInterface
Definition: function_factory.h:152
FunctionFactory & refine(bool refine=true)
Definition: function_factory.h:227
int _truncate_mode
Definition: function_factory.h:98
FunctionFactory(World &world)
Definition: function_factory.h:120
FunctionFactory & empty()
Definition: function_factory.h:239
FunctionFactory & fence(bool fence=true)
Definition: function_factory.h:269
World & _world
Definition: function_factory.h:91
bool _refine
Definition: function_factory.h:99
FunctionFactory & special_points(std::vector< Vector< double, NDIM > > &special_points)
Definition: function_factory.h:209
TreeState _tree_state
Definition: function_factory.h:106
int _initial_level
Definition: function_factory.h:94
FunctionFactory & notruncate_on_project()
Definition: function_factory.h:263
FunctionFactory & max_refine_level(int max_refine_level)
Definition: function_factory.h:215
int _special_level
Definition: function_factory.h:95
FunctionFactory & nofence()
Definition: function_factory.h:275
FunctionFactory & special_level(int special_level)
Definition: function_factory.h:203
FunctionFactory & compressed(bool value=true)
Definition: function_factory.h:168
virtual FunctionFactory & is_on_demand()
Definition: function_factory.h:281
int _max_refine_level
Definition: function_factory.h:97
bool _autorefine
Definition: function_factory.h:101
bool _empty
Definition: function_factory.h:100
FunctionFactory & autorefine()
Definition: function_factory.h:245
bool _truncate_on_project
Definition: function_factory.h:102
FunctionFactory & f(T(*f)(const coordT &))
Definition: function_factory.h:180
virtual FunctionFactory & thresh(double thresh)
Definition: function_factory.h:191
int _k
Definition: function_factory.h:92
virtual std::shared_ptr< FunctionFunctorInterface< T, NDIM > > get_functor() const
return the functor; override this if the functor needs deferred construction
Definition: function_factory.h:299
FunctionFactory & functor(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > &f)
Definition: function_factory.h:141
FunctionFactory & no_functor()
Definition: function_factory.h:174
double _thresh
Definition: function_factory.h:93
FunctionFactory & truncate_mode(int truncate_mode)
Definition: function_factory.h:221
World & get_world() const
Definition: function_factory.h:296
virtual ~FunctionFactory()
Definition: function_factory.h:138
FunctionFactory & initial_level(int initial_level)
Definition: function_factory.h:197
bool _fence
Definition: function_factory.h:103
FunctionFactory & truncate_on_project()
Definition: function_factory.h:257
std::vector< Vector< double, NDIM > > _special_points
Definition: function_factory.h:96
virtual FunctionFactory & k(int k)
Definition: function_factory.h:186
Vector< double, NDIM > coordT
Type of vector holding coordinates.
Definition: function_factory.h:89
double get_thresh() const
Definition: function_factory.h:294
std::shared_ptr< FunctionFunctorInterface< T, NDIM > > _functor
Definition: function_factory.h:116
FunctionFactory & norefine(bool norefine=true)
Definition: function_factory.h:233
int get_k() const
Definition: function_factory.h:292
Abstract base class interface required for functors used as input to Functions.
Definition: function_interface.h:68
FunctionImpl holds all Function state to facilitate shallow copy semantics.
Definition: funcimpl.h:941
FunctionInterface implements a wrapper around any class with the operator()()
Definition: function_interface.h:302
A multiresolution adaptive numerical function.
Definition: mra.h:122
a function like f(x)=1/x
Definition: function_interface.h:495
Key is the index for a node of the 2^NDIM-tree.
Definition: key.h:66
A tensor is a multidimension array.
Definition: tensor.h:317
factory for generating TwoElectronInterfaces
Definition: function_factory.h:436
std::shared_ptr< FunctionFunctorInterface< T, NDIM > > InterfacePtr
Definition: function_factory.h:439
OperatorInfo info
Definition: function_factory.h:534
TwoElectronFactory & BSH()
return the BSH operator
Definition: function_factory.h:487
InterfacePtr interface_
the interface providing the actual coefficients
Definition: function_factory.h:538
BoundaryConditions< NDIM > bc_
Definition: function_factory.h:544
InterfacePtr get_functor() const
return the functor; override this if the functor needs deferred construction
Definition: function_factory.h:499
TwoElectronFactory & dcut(double dcut)
the smallest length scale to be represented (aka lo)
Definition: function_factory.h:456
TwoElectronFactory & gamma(double g)
the exponent of a slater function
Definition: function_factory.h:469
TwoElectronFactory & set_info(const OperatorInfo info1)
return the BSH operator
Definition: function_factory.h:493
TwoElectronFactory(World &world)
Definition: function_factory.h:442
TwoElectronFactory & thresh(double thresh)
the requested precision
Definition: function_factory.h:462
TwoElectronFactory & f12()
return the operator (1 - exp(-gamma x) / (2 gamma)
Definition: function_factory.h:475
TwoElectronFactory & slater()
return the operator (1 - exp(-gamma x) / (2 gamma)
Definition: function_factory.h:481
Interface to be provided by any process map.
Definition: worlddc.h:82
A parallel world class.
Definition: world.h:132
auto T(World &world, response_space &f) -> response_space
Definition: global_functions.cc:34
static const double dcut
Definition: he.cc:13
Tensor< double > op(const Tensor< double > &x)
Definition: kain.cc:508
Multidimension Key for MRA tree and associated iterators.
#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
File holds all helper structures necessary for the CC_Operator and CC2 class.
Definition: DFParameters.h:10
TreeState
Definition: funcdefaults.h:58
@ on_demand
no coeffs anywhere, but a functor providing if necessary
Definition: funcdefaults.h:66
@ reconstructed
s coeffs at the leaves only
Definition: funcdefaults.h:59
@ compressed
d coeffs in internal nodes, s and d coeffs at the root
Definition: funcdefaults.h:60
@ OT_SLATER
1/r
Definition: operatorinfo.h:15
@ OT_BSH
(1-exp(-r))^2/r = 1/r + exp(-2r)/r - 2 exp(-r)/r
Definition: operatorinfo.h:21
@ OT_F12
exp(-r2)
Definition: operatorinfo.h:17
@ OT_G12
indicates the identity
Definition: operatorinfo.h:14
Tensor< T > fcube(const Key< NDIM > &, T(*f)(const Vector< double, NDIM > &), const Tensor< double > &)
Definition: mraimpl.h:2163
NDIM & f
Definition: mra.h:2416
NDIM const Function< R, NDIM > & g
Definition: mra.h:2416
std::string type(const PairType &n)
Definition: PNOParameters.h:18
static const double thresh
Definition: rk.cc:45
Definition: test_dc.cc:47
Definition: operatorinfo.h:58
double thresh
Definition: operatorinfo.h:63
OpType type
introspection
Definition: operatorinfo.h:64
double mu
some introspection
Definition: operatorinfo.h:61
double lo
Definition: operatorinfo.h:62
Defines and implements most of Tensor.
static const std::size_t NDIM
Definition: testpdiff.cc:42