28 #ifndef _mpqc_src_lib_chemistry_qc_mbptr12_rdm_h
29 #define _mpqc_src_lib_chemistry_qc_mbptr12_rdm_h
31 #include <chemistry/qc/wfn/wfn.h>
32 #include <chemistry/qc/wfn/obwfn.h>
33 #include <chemistry/qc/wfn/spin.h>
34 #include <math/distarray4/distarray4.h>
39 typedef enum {Zero=0, One = 1, Two = 2, Three = 3, Four = 4}
Rank;
45 template <Rank R>
struct __spincase;
46 template <>
struct __spincase<One> {
47 typedef SpinCase1 type;
49 template <>
struct __spincase<Two> {
50 typedef SpinCase2 type;
53 template <Rank R>
struct __nspincases;
54 template <>
struct __nspincases<One> {
55 static const int value = NSpinCases1;
57 template <>
struct __nspincases<Two> {
58 static const int value = NSpinCases2;
71 typedef typename __spincase<R>::type spincase;
86 wfn_ = require_dynamic_cast<Wavefunction*>(
87 kv->describedclassvalue(
"wfn").
pointer(),
94 RDM(
const Ref<Wavefunction>&
wfn) : wfn_(
wfn) {
104 for(
int s=0; s<__nspincases<R>::value; ++s)
111 const double energy = wfn_->value();
116 virtual size_t ndim(spincase spincase)
const;
147 RDM<R>::class_desc_(
typeid(this_type),
148 (std::string(
"RDM<") +
152 "virtual public SavableState", 0, 0, 0 );
164 typedef RDM<R> density_type;
165 typedef typename __spincase<R>::type spincase;
169 RDMCumulant(StateIn& si) : SavableState(si) {
178 density_->obsolete();
179 for(
int s=0; s<__nspincases<R>::value; ++s)
189 size_t ndim(spincase spincase)
const {
return density_->ndim(); }
192 throw ProgrammingError(
"RDMCumulant<R>::obtain_block() is not yet implemented",
198 throw ProgrammingError(
"RDMCumulant<R>::release_block() is not yet implemented",
215 RDMCumulant<R>::class_desc_(
typeid(this_type),
216 (std::string(
"RDMCumulant<") +
220 "virtual public SavableState", 0, 0, 0 );
228 typedef typename __spincase<R>::type spincase;
243 wfn_ = require_dynamic_cast<Wavefunction*>(
244 kv->describedclassvalue(
"wfn").
pointer(),
268 const double energy = wfn_->value();
273 virtual size_t ndim()
const;
276 throw ProgrammingError(
"SpinFreeRDM<R>::obtain_block() is not yet implemented",
282 throw ProgrammingError(
"SpinFreeRDM<R>::release_block() is not yet implemented",
309 SpinFreeRDM<R>::class_desc_(
typeid(this_type),
310 (std::string(
"SpinFreeRDM<") +
314 "virtual public SavableState", 0, 0, 0 );
369 const double* obtain_block(SpinCase2 spin,
size_t bra)
const;
370 void release_block(SpinCase2,
size_t bra,
double*)
const;
381 class WfnRDMOne :
public RDM<One> {
406 size_t ndim(SpinCase1 spincase)
const;
407 const double* obtain_block(SpinCase1 spin,
size_t bra)
const;
408 void release_block(SpinCase1,
size_t bra,
double*)
const;
409 RefSymmSCMatrix scmat(SpinCase1 spincase)
const;
410 Ref<cumulant_type> cumulant()
const;
411 Ref< RDM<Zero> > rdm_m_1()
const;
414 Ref<Wavefunction> wfn_;
415 mutable RefSymmSCMatrix scmat_[NSpinCases1];
417 static ClassDesc class_desc_;
421 class WfnRDMCumulantOne :
public RDMCumulant<One> {
423 WfnRDMCumulantOne(
const Ref<WfnRDMOne>& density);
424 WfnRDMCumulantOne(StateIn& si);
425 ~WfnRDMCumulantOne();
426 void save_data_state(StateOut& so);
429 const double* obtain_block(SpinCase1 spin,
size_t bra)
const;
430 void release_block(SpinCase1,
size_t bra,
double*)
const;
431 RefSymmSCMatrix scmat(SpinCase1 spincase)
const;
434 Ref<WfnRDMOne> density_;
435 mutable RefSymmSCMatrix scmat_[NSpinCases1];
437 static ClassDesc class_desc_;
477 #endif // end of header guard
SpinFreeRDM(const Ref< KeyVal > &kv)
A KeyVal constructor is used to generate a SpinFreeRDM<R> object from the input.
Definition: rdm.h:242
size_t ndim(spincase spincase) const
bra/ket dimension
Definition: rdm.h:189
void save_data_state(StateOut &so)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
virtual void release_block(spincase spin, size_t bra, double *) const
releases the ket block
Definition: rdm.h:281
virtual const Ref< DistArray4 > & da4() const
should only be used for R=2
virtual void release_block(spincase spin, size_t bra, double *) const
releases the ket block
Definition: rdm.h:124
Ref< density_type > density() const
the corresponding Density
Definition: rdm.h:187
RDM(const Ref< KeyVal > &kv)
A KeyVal constructor is used to generate a RDM<R> object from the input.
Definition: rdm.h:85
virtual size_t ndim() const
bra/ket dimension
The RefSymmSCMatrix class is a smart pointer to an SCSymmSCMatrix specialization.
Definition: matrix.h:265
virtual Ref< RDM< static_cast< Rank >R-1) > > rdm_m_1() const
RDM of rank decreased by 1.
void obsolete()
Marks all results as being out of date.
Definition: rdm.h:177
A template class that maintains references counts.
Definition: ref.h:361
OBWfnRDMTwo(const Ref< KeyVal > &kv)
A KeyVal constructor is used to generate a OBWfnRDMTwo object from the input.
Ref< OrbitalSpace > orbs(SpinCase1 s) const
the orbital space of spincase s in which the density is reported
void save_data_state(StateOut &so)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
Ref< Wavefunction > wfn() const
the corresponding Wavefunction
Definition: rdm.h:109
virtual void obsolete()
Marks all results as being out of date.
Definition: rdm.h:259
Ref< Wavefunction > wfn() const
the corresponding Wavefunction
Definition: rdm.h:184
virtual const double * obtain_block(spincase spin, size_t bra) const
returns the ket block for the given bra index
Definition: rdm.h:191
OBWfnRDMCumulantTwo is the cumulant of OBWfnRDMTwo.
Definition: rdm.h:361
Ref< cumulant_type > cumulant() const
cumulant of rank R
T * pointer() const
Returns a pointer the reference counted object.
Definition: ref.h:413
Ref< OrbitalSpace > orbs(SpinCase1 s) const
the orbital space of spincase s in which the density is reported
RDM<R> is a reduced density matrix of rank R.
Definition: rdm.h:69
virtual void release_block(spincase spin, size_t bra, double *) const
releases the ket block
Definition: rdm.h:197
void save_data_state(StateOut &so)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
Definition: rdm.h:255
virtual RefSymmSCMatrix scmat(spincase spin) const
full cumulant matrix
This class is used to contain information about classes.
Definition: class.h:147
virtual RefSymmSCMatrix scmat() const
full density matrix, can be used for RDM of any rank
Class OrbitalSpace describes a range of orbitals that are linear combinations of Gaussian basis funct...
Definition: orbitalspace.h:342
virtual void compute()
Recompute at least the results that have compute true and are not already computed.
Definition: rdm.h:110
static SavableState * restore_state(StateIn &si)
Restores objects saved with save_state.
virtual void obsolete()
Marks all results as being out of date.
Definition: rdm.h:102
OBWfnRDMOne is a 1-RDM from a OneBodyWavefunction.
Definition: rdm.h:442
Rank
Rank of the RDM.
Definition: rdm.h:39
OBWfnRDMOne(const Ref< KeyVal > &kv)
A KeyVal constructor is used to generate a OBWfnRDMOne object from the input.
SpinFreeRDM<R> is a spin-free reduced density matrix of rank R.
Definition: rdm.h:226
void save_data_state(StateOut &so)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
virtual size_t ndim(spincase spincase) const
bra/ket dimension
Definition: stateout.h:71
virtual Ref< SpinFreeRDM< static_cast< Rank >R-1) > > rdm_m_1() const
RDM of rank decreased by 1.
virtual void compute()
Recompute at least the results that have compute true and are not already computed.
Definition: rdm.h:267
RDMCumulant<R> is a reduced density matrix cumulant of rank R.
Definition: rdm.h:63
void compute()
Recompute at least the results that have compute true and are not already computed.
Definition: rdm.h:185
The Compute class provides a means of keeping results up to date.
Definition: compute.h:51
void save_data_state(StateOut &so)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
Definition: rdm.h:98
void save_state(StateOut &)
Save the state of the object as specified by the StateOut object.
This is thrown when a situations arises that should be impossible.
Definition: scexception.h:92
virtual Ref< OrbitalSpace > orbs() const =0
the orbital space of spincase s in which the density is reported
virtual RefSymmSCMatrix scmat(spincase spin) const
full density matrix
virtual Ref< OrbitalSpace > orbs(SpinCase1 s) const =0
the orbital space of spincase s in which the density is reported
virtual const double * obtain_block(spincase spin, size_t bra) const
returns the ket block for the given bra index
Definition: rdm.h:118
Ref< Wavefunction > wfn() const
the corresponding Wavefunction
Definition: rdm.h:266
Ref< rdm_m_1_type > rdm_m_1() const
RDM of rank decreased by 1.
virtual Ref< RDMCumulant< R > > cumulant() const
cumulant of rank R
virtual const double * obtain_block(spincase spin, size_t bra) const
returns the ket block for the given bra index
Definition: rdm.h:275
Base class for objects that can save/restore state.
Definition: state.h:45
void compute()
Recompute at least the results that have compute true and are not already computed.
The base class for all reference counted objects.
Definition: ref.h:192
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14
void save_data_state(StateOut &so)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
Definition: rdm.h:174
OBWfnRDMTwo is a 2-RDM from a OneBodyWavefunction.
Definition: rdm.h:324
Generated at Sun Jan 26 2020 23:24:00 for MPQC
3.0.0-alpha using the documentation package Doxygen
1.8.16.