8 #ifndef MADNESS_CHEM_PROJECTOR_H__INCLUDED
9 #define MADNESS_CHEM_PROJECTOR_H__INCLUDED
16 template<
typename T, std::
size_t NDIM>
20 std::vector<Function<T,NDIM> > p_;
29 MADNESS_ASSERT(particle_==0 or particle_==1);
35 MADNESS_ASSERT(particle_==0 or particle_==1);
39 const int&
particle()
const {
return particle_;}
42 const std::vector<Function<T,NDIM> >&
p()
const {
return p_;}
45 template<std::
size_t FDIM>
58 Tensor<double> ovlp=
inner(world,f,p_);
60 for (std::size_t i=0; i<p_.size(); ++i) {
61 if (ovlp(i) !=
T(0.0)) sum.
gaxpy(1.0,p_[i],ovlp(i),
false);
70 template<std::
size_t FDIM>
74 for (
unsigned int i=0; i<p_.size(); ++i) {
77 MADNESS_EXCEPTION(
"Projector class: the hartree product is inaccurate -- don't use it",1);
95 template<
typename T, std::
size_t NDIM>
98 typedef std::vector<Function<T,NDIM> > vecfuncT;
121 const vecfuncT&
bra2,
const vecfuncT&
ket2) {
129 vecfuncT
ket1()
const {
return ket1_;}
132 vecfuncT
bra1()
const {
return bra1_;}
135 vecfuncT
ket2()
const {
return ket2_;}
138 vecfuncT
bra2()
const {
return bra2_;}
155 Tensor<double> g_kl(bra1_.size(),bra2_.size());
156 for (
size_t k=0;
k<bra1_.size(); ++
k) {
157 for (
size_t l=0; l<bra2_.size(); ++l) {
159 .particle1(
copy(bra1_[
k])).particle2(
copy(bra2_[l]));
160 g_kl(k,l)=
inner(f,kl);
168 for (
size_t k=0;
k<bra1_.size(); ++
k) {
174 for (
size_t l=0; l<ket2_.size(); ++l) {
175 h2-=0.5*g_kl(k,l)*ket2_[l];
189 for (
size_t l=0; l<ket2_.size(); ++l) {
195 for (
size_t k=0;
k<ket1_.size(); ++
k) {
196 h1-=0.5*g_kl(
k,l)*ket1_[
k];
230 std::vector<Function<T,NDIM> > ket1_, bra1_, ket2_, bra2_;
const double thresh
Definition: dielectric.cc:185
WorldGopInterface & gop
Global operations.
Definition: worldfwd.h:462
Main include file for MADNESS and defines Function interface.
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:577
simple projector class for 1- and 2-particle projectors
Definition: projector.h:17
const int NDIM
Definition: tdse1.cc:44
vecfuncT bra1() const
return the orbital space for the bra of particle 1
Definition: projector.h:132
const Function< T, NDIM > & compress(bool fence=true) const
Compresses the function, transforming into wavelet basis. Possible non-blocking comm.
Definition: mra.h:683
FunctionFactory< double, 6 > real_factory_6d
Definition: functypedefs.h:96
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:194
int & particle()
Definition: projector.h:38
Definition: mpreal.h:3066
NDIM & f
Definition: mra.h:2179
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:144
static const double & get_thresh()
Returns the default threshold.
Definition: funcdefaults.h:225
enable_if_c< NDIM==FDIM, Function< T, FDIM > >::type operator()(const Function< T, FDIM > &f) const
project f on p: |result> = | p>
Definition: projector.h:47
Function< T, KDIM+LDIM > hartree_product(const Function< T, KDIM > &left2, const Function< T, LDIM > &right2)
Performs a Hartree product on the two given low-dimensional functions.
Definition: mra.h:1657
void set_thresh(double value, bool fence=true)
Sets the vaule of the truncation threshold. Optional global fence.
Definition: mra.h:552
a SO projector class
Definition: projector.h:96
Projector(const std::vector< Function< T, NDIM > > &p, const int particle=0)
constructor with a set of orbitals to project out
Definition: projector.h:33
enable_if_c< 2 *NDIM==FDIM, Function< T, FDIM > >::type operator()(const Function< T, FDIM > &f) const
project p out of f: |result(1,2)> = sum_p | p(1)>
Definition: projector.h:72
T inner(const vecfunc< T, NDIM > &a, const vecfunc< T, NDIM > &b)
the non-linear solver requires an inner product
Definition: nemo.h:112
const std::vector< Function< T, NDIM > > & p() const
get a const reference to the orbitals
Definition: projector.h:42
World & world() const
Returns the world.
Definition: mra.h:622
Factory for facile setup of a CompositeFunctorInterface and its FuncImpl.
Definition: function_factory.h:264
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)
const int k
Definition: dielectric.cc:184
vecfuncT ket2() const
return the orbital space for the ket of particle 2
Definition: projector.h:135
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
Projector()
Definition: projector.h:24
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:120
Projector(const Function< T, NDIM > &p, const int particle=0)
simple constructor with only one orbital to project out
Definition: projector.h:27
enable_if_c from Boost for conditionally instantiating templates based on type
Definition: enable_if.h:46
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
StrongOrthogonalityProjector(World &world)
default ctor
Definition: projector.h:103
A multiresolution adaptive numerical function.
Definition: derivative.h:61
void print_size(const std::string name) const
print some info about this
Definition: mra.h:478
static void set_thresh(double value)
Sets the default threshold.
Definition: funcdefaults.h:232
const mpreal sum(const mpreal tab[], unsigned long int n, mp_rnd_t rnd_mode)
Definition: mpreal.cc:241
const int & particle() const
Definition: projector.h:39
Function< T, NDIM > & gaxpy(const T &alpha, const Function< Q, NDIM > &other, const R &beta, bool fence=true)
Inplace, general bi-linear operation in wavelet basis. No communication except for optional fence...
Definition: mra.h:924
#define MADNESS_EXCEPTION(msg, value)
Definition: worldexc.h:88
vecfuncT ket1() const
return the orbital space for the ket of particle 1
Definition: projector.h:129
FunctionFactory implements the named-parameter idiom for Function.
Definition: funcimpl.h:70
void set_spaces(const vecfuncT &p)
set the same spaces for the projectors for particle 1 and 2
Definition: projector.h:106
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
Function< TENSOR_RESULT_TYPE(T, R), NDIM-LDIM > project_out(const Function< R, LDIM > &g, const int dim) const
project this on the low-dim function g: h(x) =
Definition: mra.h:1294
vecfuncT bra2() const
return the orbital space for the bra of particle 2
Definition: projector.h:138
void compress(World &world, const std::vector< Function< T, NDIM > > &v, bool fence=true)
Compress a vector of functions.
Definition: vmra.h:130