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;
63 template <Rank R>
class RDMCumulant;
71 typedef typename __spincase<R>::type spincase;
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;
148 (std::string(
"RDM<") +
152 "virtual public SavableState", 0, 0, 0 );
165 typedef typename __spincase<R>::type spincase;
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",
216 (std::string(
"RDMCumulant<") +
220 "virtual public SavableState", 0, 0, 0 );
228 typedef typename __spincase<R>::type spincase;
244 kv->describedclassvalue(
"wfn").
pointer(),
268 const double energy = wfn_->value();
276 throw ProgrammingError(
"SpinFreeRDM<R>::obtain_block() is not yet implemented",
282 throw ProgrammingError(
"SpinFreeRDM<R>::release_block() is not yet implemented",
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;
383 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_;
This class is used to contain information about classes.
Definition class.h:147
The Compute class provides a means of keeping results up to date.
Definition compute.h:52
OBWfnRDMCumulantTwo is the cumulant of OBWfnRDMTwo.
Definition rdm.h:361
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 ...
void compute()
Recompute at least the results that have compute true and are not already computed.
OBWfnRDMOne is a 1-RDM from a OneBodyWavefunction.
Definition rdm.h:442
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 ...
OBWfnRDMOne(const Ref< KeyVal > &kv)
A KeyVal constructor is used to generate a OBWfnRDMOne object from the input.
Ref< OrbitalSpace > orbs(SpinCase1 s) const
the orbital space of spincase s in which the density is reported
OBWfnRDMTwo is a 2-RDM from a OneBodyWavefunction.
Definition rdm.h:324
OBWfnRDMTwo(const Ref< KeyVal > &kv)
A KeyVal constructor is used to generate a OBWfnRDMTwo object from the input.
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< cumulant_type > cumulant() const
cumulant of rank R
Ref< OrbitalSpace > orbs(SpinCase1 s) const
the orbital space of spincase s in which the density is reported
Ref< rdm_m_1_type > rdm_m_1() const
RDM of rank decreased by 1.
Class OrbitalSpace describes a range of orbitals that are linear combinations of Gaussian basis funct...
Definition orbitalspace.h:342
This is thrown when a situations arises that should be impossible.
Definition scexception.h:92
RDMCumulant<R> is a reduced density matrix cumulant of rank R.
Definition rdm.h:162
virtual const double * obtain_block(spincase spin, size_t bra) const
returns the ket block for the given bra index
Definition rdm.h:191
Ref< density_type > density() const
the corresponding Density
Definition rdm.h:187
void compute()
Recompute at least the results that have compute true and are not already computed.
Definition rdm.h:185
size_t ndim(spincase spincase) const
bra/ket dimension
Definition rdm.h:189
void obsolete()
Marks all results as being out of date.
Definition rdm.h:177
Ref< Wavefunction > wfn() const
the corresponding Wavefunction
Definition rdm.h:184
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
virtual RefSymmSCMatrix scmat(spincase spin) const
full cumulant matrix
virtual void release_block(spincase spin, size_t bra, double *) const
releases the ket block
Definition rdm.h:197
RDM<R> is a reduced density matrix of rank R.
Definition rdm.h:69
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
virtual size_t ndim(spincase spincase) const
bra/ket dimension
virtual Ref< RDM< static_cast< Rank >(R-1) > > rdm_m_1() const
RDM of rank decreased by 1.
RDM(const Ref< KeyVal > &kv)
A KeyVal constructor is used to generate a RDM<R> object from the input.
Definition rdm.h:85
virtual void release_block(spincase spin, size_t bra, double *) const
releases the ket block
Definition rdm.h:124
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:118
virtual RefSymmSCMatrix scmat(spincase spin) const
full density matrix
virtual void obsolete()
Marks all results as being out of date.
Definition rdm.h:102
virtual Ref< OrbitalSpace > orbs(SpinCase1 s) const =0
the orbital space of spincase s in which the density is reported
Ref< Wavefunction > wfn() const
the corresponding Wavefunction
Definition rdm.h:109
virtual void compute()
Recompute at least the results that have compute true and are not already computed.
Definition rdm.h:110
The base class for all reference counted objects.
Definition ref.h:192
The RefSymmSCMatrix class is a smart pointer to an SCSymmSCMatrix specialization.
Definition matrix.h:265
A template class that maintains references counts.
Definition ref.h:361
T * pointer() const
Returns a pointer the reference counted object.
Definition ref.h:413
Base class for objects that can save/restore state.
Definition state.h:45
static SavableState * restore_state(StateIn &si)
Restores objects saved with save_state.
void save_state(StateOut &)
Save the state of the object as specified by the StateOut object.
SpinFreeRDM<R> is a spin-free reduced density matrix of rank R.
Definition rdm.h:226
virtual void compute()
Recompute at least the results that have compute true and are not already computed.
Definition rdm.h:267
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 void release_block(spincase spin, size_t bra, double *) const
releases the ket block
Definition rdm.h:281
virtual Ref< OrbitalSpace > orbs() const =0
the orbital space of spincase s in which the density is reported
virtual size_t ndim() const
bra/ket dimension
virtual Ref< SpinFreeRDM< static_cast< Rank >(R-1) > > rdm_m_1() const
RDM of rank decreased by 1.
virtual const double * obtain_block(spincase spin, size_t bra) const
returns the ket block for the given bra index
Definition rdm.h:275
virtual const Ref< DistArray4 > & da4() const
should only be used for R=2
SpinFreeRDM(const Ref< KeyVal > &kv)
A KeyVal constructor is used to generate a SpinFreeRDM<R> object from the input.
Definition rdm.h:242
virtual void obsolete()
Marks all results as being out of date.
Definition rdm.h:259
virtual RefSymmSCMatrix scmat() const
full density matrix, can be used for RDM of any rank
Ref< Wavefunction > wfn() const
the corresponding Wavefunction
Definition rdm.h:266
Restores fundamental and user-defined types from images created with StateOut.
Definition statein.h:79
Serializes fundamental and user-defined types.
Definition stateout.h:71
Contains all MPQC code up to version 3.
Definition mpqcin.h:14
T require_dynamic_cast(DescribedClass *p, const char *errmsg,...)
Attempt to cast a DescribedClass pointer to a DescribedClass descendent.
Definition class.h:274
Rank
Rank of the RDM.
Definition rdm.h:39