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>
38 template<
typename T, std::
size_t NDIM>
47 template<
typename T, std::
size_t NDIM>
102 virtual std::string
type()
const override {
return "PProjector";}
124 World& world=
f[0].world();
138 template<std::
size_t KDIM>
139 typename std::enable_if<KDIM==2*NDIM, Function<T,KDIM> >
::type
152 std::pair<std::vector<Function<T,NDIM>>,std::vector<Function<T,NDIM>>>
156 f.reconstruct(
false);
158 std::vector<Function<T,NDIM>> projected;
159 for (
const auto& i :
mo_bra_) {
160 projected.push_back(
f.project_out(i,
particle));
165 MADNESS_EXCEPTION(
"confused particles in Projector::get_vector_for_outer_products",1);
171 template<
typename argT>
173 ->
typename std::enable_if<
174 !std::is_same<argT, Function<T, 2 * NDIM>>
::value,
176 std::declval<const argT&>()))
194 template<
typename T, std::
size_t NDIM>
220 std::string
type()
const override {
return "QProjector";}
227 O.set_spaces(bra,ket);
231 return (rhs-
O(rhs)).truncate();
235 if (rhs.size()==0)
return vecfuncT();
245 template<
typename argT>
246 std::vector<argT>
operator()(
const std::vector<argT>& argument)
const {
250 template<
typename argT>
267 return O.get_particle();
282 template<
typename T, std::
size_t NDIM>
292 std::string
type()
const override {
return "SOProjector";}
335 template<
typename argT>
336 std::vector<argT>
operator()(
const std::vector<argT>& argument)
const {
340 template<
typename argT>
349 std::pair<std::vector<Function<T,NDIM>>,std::vector<Function<T,NDIM>>>
356 for (
size_t k = 0;
k <
bra1_.size(); ++
k) {
357 for (
size_t l = 0; l <
bra2_.size(); ++l) {
366 std::vector<Function<T, NDIM>> h2(
bra1_.size());
367 std::vector<Function<T, NDIM>> h1(
ket2_.size());
370 for (
size_t k = 0;
k <
bra1_.size(); ++
k) {
379 h1[l] =
f.project_out(
bra2_[l], 1);
401 return std::make_pair(-1.0*left,right);
418 double tight_thresh=
thresh*0.1;
422 tmp.truncate(tight_thresh);
443 template<
typename projT,
typename projQ>
451 static_assert(std::is_base_of<ProjectorBase,projT>::value,
"projT must be a ProjectorBase");
452 static_assert(std::is_base_of<ProjectorBase,projQ>::value,
"projQ must be a ProjectorBase");
457 std::string
type()
const override {
458 return "OuterProjector";
461 template<
typename resultT>
474 template<
typename projT,
typename projQ>
475 typename std::enable_if<std::is_base_of<ProjectorBase,projT>::value, OuterProjector<projT,projQ>>
::type
476 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:328
CompositeFactory & particle1(const Function< T, MDIM > &f)
Definition function_factory.h:391
CompositeFactory & particle2(const Function< T, MDIM > &f)
Definition function_factory.h:407
static void set_thresh(double value)
Sets the default threshold.
Definition funcdefaults.h:190
static const double & get_thresh()
Returns the default threshold.
Definition funcdefaults.h:183
A multiresolution adaptive numerical function.
Definition mra.h:141
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:718
an outer product of two projectors
Definition projector.h:444
std::string type() const override
Definition projector.h:457
resultT operator()(const resultT &argument) const
Definition projector.h:462
OuterProjector(const projT &p0, const projQ &p1)
Definition projector.h:450
projQ projector1
Definition projector.h:446
projT projector0
Definition projector.h:445
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:48
Projector(const Function< T, NDIM > &mo)
simple constructor with only one orbital to project
Definition projector.h:65
std::vector< Function< T, NDIM > > mo_ket_
the space onto which the test functions will be projected: |ket>
Definition projector.h:54
std::vector< funcT > vecfuncT
Definition projector.h:51
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:153
funcT operator()(const funcT &f) const
project f on p:
Definition projector.h:111
void set_spaces(const vecfuncT &p)
Definition projector.h:91
std::enable_if< KDIM==2 *NDIM, Function< T, KDIM > >::type operator()(const Function< T, KDIM > &f, int particle1=-1) const
Definition projector.h:140
virtual std::string type() const override
Definition projector.h:102
Projector(const funcT &bra, const funcT &ket)
simple constructor with only one orbital to project
Definition projector.h:71
Projector(const vecfuncT &bra, const vecfuncT &ket)
constructor with a set of orbitals to project out
Definition projector.h:86
auto operator()(const argT &argument) const -> typename std::enable_if< !std::is_same< argT, Function< T, 2 *NDIM > >::value, decltype(madness::apply(std::declval< const Projector< T, NDIM > & >(), std::declval< const argT & >())) >::type
Definition projector.h:172
vecfuncT operator()(const vecfuncT &f) const
project f on p:
Definition projector.h:122
std::vector< Function< T, NDIM > > mo_bra_
the dual space onto which the test functions will be projected: <bra|
Definition projector.h:56
vecfuncT get_bra_vector() const
Definition projector.h:181
Function< T, NDIM > funcT
Definition projector.h:50
vecfuncT get_ket_vector() const
Definition projector.h:183
Projector()
Definition projector.h:60
void set_spaces(const vecfuncT &bra, const vecfuncT &ket)
Definition projector.h:96
Projector(const vecfuncT &p)
constructor with a set of orbitals to project out
Definition projector.h:79
QProjector(const vecfuncT &bra, const vecfuncT &ket)
constructor with asymmetric bra and ket spaces
Definition projector.h:214
QProjector(const vecfuncT &amo)
constructor with symmetric bra and ket spaces
Definition projector.h:211
void set_spaces(const vecfuncT &bra, const vecfuncT &ket)
Definition projector.h:226
vecfuncT get_bra_vector() const
Definition projector.h:255
QProjector(World &world, const vecfuncT &bra, const vecfuncT &ket)
constructor with asymmetric bra and ket spaces
Definition projector.h:207
void set_particle(const int p) override
Definition projector.h:261
std::vector< Function< T, NDIM > > vecfuncT
Definition projector.h:196
Projector< T, NDIM > get_P_projector() const
Definition projector.h:259
std::vector< argT > operator()(const argT &argument) const
Definition projector.h:251
int get_particle() const override
Definition projector.h:266
QProjector(World &world, const vecfuncT &amo)
constructor with symmetric bra and ket spaces
Definition projector.h:204
Function< T, NDIM > operator()(const Function< T, NDIM > &rhs) const
Definition projector.h:230
Projector< T, NDIM > O
Definition projector.h:271
void set_spaces(const vecfuncT &p)
Definition projector.h:222
QProjector()=default
default ctor
std::vector< argT > operator()(const std::vector< argT > &argument) const
Definition projector.h:246
vecfuncT get_ket_vector() const
Definition projector.h:257
vecfuncT operator()(const vecfuncT &rhs) const
Definition projector.h:234
std::string type() const override
Definition projector.h:220
Function< T, 2 *NDIM > operator()(const Function< T, 2 *NDIM > &f, const size_t particle=-1) const
Definition projector.h:241
QProjector(const QProjector &other)=default
copy ctor
vecfuncT bra2() const
return the orbital space for the bra of particle 2
Definition projector.h:329
std::vector< Function< T, NDIM > > vecfuncT
Definition projector.h:285
std::string type() const override
Definition projector.h:292
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:309
StrongOrthogonalityProjector(World &world)
default ctor
Definition projector.h:290
vecfuncT ket2() const
return the orbital space for the ket of particle 2
Definition projector.h:326
vecfuncT bra1() const
return the orbital space for the bra of particle 1
Definition projector.h:323
World & world
the world
Definition projector.h:434
std::vector< argT > operator()(const argT &argument) const
Definition projector.h:341
void set_particle(const int p) override
Definition projector.h:331
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:408
std::vector< Function< T, NDIM > > bra2_
Definition projector.h:437
vecfuncT ket1() const
return the orbital space for the ket of particle 1
Definition projector.h:320
std::vector< Function< T, NDIM > > bra1_
Definition projector.h:437
std::vector< Function< T, NDIM > > ket1_
the spaces of the projector of particles 1 and 2
Definition projector.h:437
std::vector< Function< T, NDIM > > ket2_
Definition projector.h:437
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:350
void set_spaces(const vecfuncT &p)
set the same spaces for the projectors for particle 1 and 2
Definition projector.h:295
std::vector< argT > operator()(const std::vector< argT > &argument) const
Definition projector.h:336
A tensor is a multidimensional array.
Definition tensor.h:313
A parallel world class.
Definition world.h:134
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
Tensor< T > transpose(const Tensor< T > &t)
Returns a new deep copy of the transpose of the input tensor.
Definition tensor.h:2039
#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 DFConvergence.h:9
double FunctionDefaults< NDIM >::thresh
Definition mraimpl.h:3879
int FunctionDefaults< NDIM >::k
Definition mraimpl.h:3878
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:807
@ reconstructed
s coeffs at the leaves only
Definition funcdefaults.h:61
void truncate(World &world, std::vector< Function< T, NDIM > > &v, double tol=0.0, bool fence=true)
Truncates a vector of functions.
Definition vmra.h:336
const std::vector< Function< T, NDIM > > & reconstruct(const std::vector< Function< T, NDIM > > &v)
reconstruct a vector of functions
Definition vmra.h:163
std::enable_if< std::is_base_of< ProjectorBase, projT >::value, OuterProjector< projT, projQ > >::type outer(const projT &p0, const projQ &p1)
Definition projector.h:476
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:767
NDIM & f
Definition mra.h:2817
const Function< T, NDIM > & change_tree_state(const Function< T, NDIM > &f, const TreeState finalstate, bool fence=true)
change tree state of a function
Definition mra.h:3143
const Future< void > Future< void >::value
Definition future.cc:44
std::string type(const PairType &n)
Definition PNOParameters.h:18
CCPairFunction< T, NDIM > apply(const SeparatedConvolution< T, NDIM/2 > &op, const CCPairFunction< T, NDIM > &arg)
apply the operator to the argument
Definition ccpairfunction.h:901
Function< T, CCPairFunction< T, NDIM >::LDIM > inner(const CCPairFunction< T, NDIM > &c, const Function< T, CCPairFunction< T, NDIM >::LDIM > &f, const std::tuple< int, int, int > v1, const std::tuple< int, int, int > v2)
Definition ccpairfunction.h:1007
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:2068
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:2239
@ mo
moldft orbitals psi
Definition Restart.h:59
int P
Definition test_binsorter.cc:9