8#ifndef MADNESS_CHEM_PROJECTOR_H__INCLUDED
9#define MADNESS_CHEM_PROJECTOR_H__INCLUDED
29 virtual std::string
type()
const = 0;
32 template<
typename T, std::
size_t NDIM>
35 template<
typename T, std::
size_t NDIM>
44 template<
typename T, std::
size_t NDIM>
99 virtual std::string
type()
const override {
return "PProjector";}
121 World& world=
f[0].world();
135 template<std::
size_t KDIM>
136 typename std::enable_if<KDIM==2*NDIM, Function<T,KDIM> >
::type
149 std::pair<std::vector<Function<T,NDIM>>,std::vector<Function<T,NDIM>>>
153 f.reconstruct(
false);
155 std::vector<Function<T,NDIM>> projected;
156 for (
const auto& i :
mo_bra_) {
157 projected.push_back(
f.project_out(i,
particle));
162 MADNESS_EXCEPTION(
"confused particles in Projector::get_vector_for_outer_products",1);
166 template<
typename argT>
167 typename std::enable_if<!std::is_same<argT,Function<T,2*NDIM> >::value, argT>
::type
185 template<
typename T, std::
size_t NDIM>
211 std::string
type()
const override {
return "QProjector";}
218 O.set_spaces(bra,ket);
222 return (rhs-
O(rhs)).truncate();
226 if (rhs.size()==0)
return vecfuncT();
236 template<
typename argT>
253 return O.get_particle();
268 template<
typename T, std::
size_t NDIM>
278 std::string
type()
const override {
return "SOProjector";}
321 template<
typename argT>
330 std::pair<std::vector<Function<T,NDIM>>,std::vector<Function<T,NDIM>>>
337 for (
size_t k = 0;
k <
bra1_.size(); ++
k) {
338 for (
size_t l = 0; l <
bra2_.size(); ++l) {
347 std::vector<Function<T, NDIM>> h2(
bra1_.size());
348 std::vector<Function<T, NDIM>> h1(
ket2_.size());
351 for (
size_t k = 0;
k <
bra1_.size(); ++
k) {
360 h1[l] =
f.project_out(
bra2_[l], 1);
382 return std::make_pair(-1.0*left,right);
399 double tight_thresh=
thresh*0.1;
424 template<
typename projT,
typename projQ>
432 static_assert(std::is_base_of<ProjectorBase,projT>::value,
"projT must be a ProjectorBase");
433 static_assert(std::is_base_of<ProjectorBase,projQ>::value,
"projQ must be a ProjectorBase");
438 std::string
type()
const override {
439 return "OuterProjector";
442 template<
typename resultT>
455 template<
typename projT,
typename projQ>
456 typename std::enable_if<std::is_base_of<ProjectorBase,projT>::value, OuterProjector<projT,projQ>>
::type
457 outer(
const projT& p0 ,
const projQ& p1) {
a 6D function, either in full or low rank form, possibly including an 2-particle function
Definition ccpairfunction.h:373
Factory for facile setup of a CompositeFunctorInterface and its FuncImpl.
Definition function_factory.h:321
CompositeFactory & particle1(const Function< T, MDIM > &f)
Definition function_factory.h:384
CompositeFactory & particle2(const Function< T, MDIM > &f)
Definition function_factory.h:400
static void set_thresh(double value)
Sets the default threshold.
Definition funcdefaults.h:286
static const double & get_thresh()
Returns the default threshold.
Definition funcdefaults.h:279
A multiresolution adaptive numerical function.
Definition mra.h:122
Function< T, NDIM > & truncate(double tol=0.0, bool fence=true)
Truncate the function with optional fence. Compresses with fence if not compressed.
Definition mra.h:602
an outer product of two projectors
Definition projector.h:425
std::string type() const override
Definition projector.h:438
resultT operator()(const resultT &argument) const
Definition projector.h:443
OuterProjector(const projT &p0, const projQ &p1)
Definition projector.h:431
projQ projector1
Definition projector.h:427
projT projector0
Definition projector.h:426
Definition projector.h:17
int particle
a projector might work only on a subset of dimensions, e.g. P(1) | \psi(1,2) >
Definition projector.h:20
virtual std::string type() const =0
virtual int get_particle() const
Definition projector.h:28
virtual ~ProjectorBase()
Definition projector.h:22
virtual void set_particle(const int p)
Definition projector.h:23
simple projector class
Definition projector.h:45
Projector(const Function< T, NDIM > &mo)
simple constructor with only one orbital to project
Definition projector.h:62
std::vector< Function< T, NDIM > > mo_ket_
the space onto which the test functions will be projected: |ket>
Definition projector.h:51
std::vector< funcT > vecfuncT
Definition projector.h:48
std::pair< std::vector< Function< T, NDIM > >, std::vector< Function< T, NDIM > > > get_vectors_for_outer_product(const Function< T, 2 *NDIM > &f) const
apply the projection parts of the operator on a function f
Definition projector.h:150
funcT operator()(const funcT &f) const
project f on p:
Definition projector.h:108
void set_spaces(const vecfuncT &p)
Definition projector.h:88
std::enable_if< KDIM==2 *NDIM, Function< T, KDIM > >::type operator()(const Function< T, KDIM > &f, int particle1=-1) const
Definition projector.h:137
virtual std::string type() const override
Definition projector.h:99
Projector(const funcT &bra, const funcT &ket)
simple constructor with only one orbital to project
Definition projector.h:68
Projector(const vecfuncT &bra, const vecfuncT &ket)
constructor with a set of orbitals to project out
Definition projector.h:83
vecfuncT operator()(const vecfuncT &f) const
project f on p:
Definition projector.h:119
std::vector< Function< T, NDIM > > mo_bra_
the dual space onto which the test functions will be projected: <bra|
Definition projector.h:53
vecfuncT get_bra_vector() const
Definition projector.h:172
Function< T, NDIM > funcT
Definition projector.h:47
vecfuncT get_ket_vector() const
Definition projector.h:174
Projector()
Definition projector.h:57
std::enable_if<!std::is_same< argT, Function< T, 2 *NDIM > >::value, argT >::type operator()(const argT &argument) const
Definition projector.h:168
void set_spaces(const vecfuncT &bra, const vecfuncT &ket)
Definition projector.h:93
Projector(const vecfuncT &p)
constructor with a set of orbitals to project out
Definition projector.h:76
orthogonality projector
Definition projector.h:186
QProjector(const vecfuncT &bra, const vecfuncT &ket)
constructor with asymmetric bra and ket spaces
Definition projector.h:205
QProjector(const vecfuncT &amo)
constructor with symmetric bra and ket spaces
Definition projector.h:202
void set_spaces(const vecfuncT &bra, const vecfuncT &ket)
Definition projector.h:217
vecfuncT get_bra_vector() const
Definition projector.h:241
QProjector(World &world, const vecfuncT &bra, const vecfuncT &ket)
constructor with asymmetric bra and ket spaces
Definition projector.h:198
void set_particle(const int p) override
Definition projector.h:247
argT operator()(const argT &argument) const
Definition projector.h:237
std::vector< Function< T, NDIM > > vecfuncT
Definition projector.h:187
Projector< T, NDIM > get_P_projector() const
Definition projector.h:245
int get_particle() const override
Definition projector.h:252
QProjector(World &world, const vecfuncT &amo)
constructor with symmetric bra and ket spaces
Definition projector.h:195
Function< T, NDIM > operator()(const Function< T, NDIM > &rhs) const
Definition projector.h:221
Projector< T, NDIM > O
Definition projector.h:257
void set_spaces(const vecfuncT &p)
Definition projector.h:213
QProjector()=default
default ctor
vecfuncT get_ket_vector() const
Definition projector.h:243
vecfuncT operator()(const vecfuncT &rhs) const
Definition projector.h:225
std::string type() const override
Definition projector.h:211
Function< T, 2 *NDIM > operator()(const Function< T, 2 *NDIM > &f, const size_t particle=-1) const
Definition projector.h:232
QProjector(const QProjector &other)=default
copy ctor
a SO projector class
Definition projector.h:269
vecfuncT bra2() const
return the orbital space for the bra of particle 2
Definition projector.h:315
std::vector< Function< T, NDIM > > vecfuncT
Definition projector.h:271
std::string type() const override
Definition projector.h:278
void set_spaces(const vecfuncT &bra1, const vecfuncT &ket1, const vecfuncT &bra2, const vecfuncT &ket2)
set different spaces for the projectors for particle 1 and 2
Definition projector.h:295
StrongOrthogonalityProjector(World &world)
default ctor
Definition projector.h:276
vecfuncT ket2() const
return the orbital space for the ket of particle 2
Definition projector.h:312
vecfuncT bra1() const
return the orbital space for the bra of particle 1
Definition projector.h:309
World & world
the world
Definition projector.h:415
argT operator()(const argT &argument) const
Definition projector.h:322
void set_particle(const int p) override
Definition projector.h:317
Function< T, 2 *NDIM > operator()(const Function< T, 2 *NDIM > &f) const
apply the strong orthogonality operator Q12 on a function f
Definition projector.h:389
std::vector< Function< T, NDIM > > bra2_
Definition projector.h:418
vecfuncT ket1() const
return the orbital space for the ket of particle 1
Definition projector.h:306
std::vector< Function< T, NDIM > > bra1_
Definition projector.h:418
std::vector< Function< T, NDIM > > ket1_
the spaces of the projector of particles 1 and 2
Definition projector.h:418
std::vector< Function< T, NDIM > > ket2_
Definition projector.h:418
std::pair< std::vector< Function< T, NDIM > >, std::vector< Function< T, NDIM > > > get_vectors_for_outer_product(const Function< T, 2 *NDIM > &f) const
apply the projection parts of the strong orthogonality operator Q12 on a function f
Definition projector.h:331
void set_spaces(const vecfuncT &p)
set the same spaces for the projectors for particle 1 and 2
Definition projector.h:281
A tensor is a multidimension array.
Definition tensor.h:317
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
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
#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
Main include file for MADNESS and defines Function interface.
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
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
void truncate(World &world, response_space &v, double tol, bool fence)
Definition basic_operators.cc:30
std::vector< Function< TENSOR_RESULT_TYPE(T, R), NDIM > > transform(World &world, const std::vector< Function< T, NDIM > > &v, const Tensor< R > &c, bool fence=true)
Transforms a vector of functions according to new[i] = sum[j] old[j]*c[j,i].
Definition vmra.h:689
@ reconstructed
s coeffs at the leaves only
Definition funcdefaults.h:59
const std::vector< Function< T, NDIM > > & reconstruct(const std::vector< Function< T, NDIM > > &v)
reconstruct a vector of functions
Definition vmra.h:156
response_space transpose(response_space &f)
Definition basic_operators.cc:10
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
response_space apply(World &world, std::vector< std::vector< std::shared_ptr< real_convolution_3d > > > &op, response_space &f)
Definition basic_operators.cc:39
std::vector< Function< T, NDIM > > append(const std::vector< Function< T, NDIM > > &lhs, const std::vector< Function< T, NDIM > > &rhs)
combine two vectors
Definition vmra.h:649
NDIM & f
Definition mra.h:2416
double inner(response_space &a, response_space &b)
Definition response_functions.h:442
std::string type(const PairType &n)
Definition PNOParameters.h:18
void matrix_inner(DistributedMatrix< T > &A, const std::vector< Function< T, NDIM > > &f, const std::vector< Function< T, NDIM > > &g, bool sym=false)
Definition distpm.cc:46
Function< T, KDIM+LDIM > hartree_product(const std::vector< Function< T, KDIM > > &left, const std::vector< Function< T, LDIM > > &right)
Performs a Hartree/outer product on the two given low-dimensional function vectors.
Definition mra.h:1832
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
static const double thresh
Definition rk.cc:45
static const long k
Definition rk.cc:44
Definition lowrankfunction.h:332
int P
Definition test_binsorter.cc:9