sisi4s
Loading...
Searching...
No Matches
OneBodyReducedDensityMatrix.hpp
Go to the documentation of this file.
1#ifndef EOM_1RDM_DENSITY_MATRIX_DEFINED
2#define EOM_1RDM_DENSITY_MATRIX_DEFINED
3
4#include <iostream>
6#include <util/Tensor.hpp>
7#include <util/Log.hpp>
8#include <math/FockVector.hpp>
9
10namespace sisi4s {
11
12template <typename F>
14public:
16 virtual PTR(Tensor<F>) getIA() = 0;
17 virtual PTR(Tensor<F>) getAI() = 0;
18 virtual PTR(Tensor<F>) getIJ() = 0;
19 virtual PTR(Tensor<F>) getAB() = 0;
20};
21
22template <typename F>
25 : R(r) {}
26
27 PTR(Tensor<F>) getIJ() override {
28 if (Rij) { return Rij; }
29 const int No(R.get(0)->lens[1]);
30 const int oo[] = {No, No};
31 const int syms[] = {NS, NS};
32 Rij = NEW(Tensor<F>, 2, oo, syms, *Sisi4s::world, "Rij");
33 auto Rconj = Tensor<F>(*Rij);
34 // TODO: Conjugate R
35 conjugate(Rconj);
36 (*Rij)["ii"] = (*R.get(0))["aj"] * (*R.get(0))["aj"];
37 (*Rij)["ij"] += (-1.0) * (*R.get(0))["ai"] * (*R.get(0))["aj"];
38 return Rij;
39 }
40
41 PTR(Tensor<F>) getAB() override {
42 if (Rab) { return Rab; }
43 const int Nv(R.get(0)->lens[0]);
44 const int vv[] = {Nv, Nv};
45 const int syms[] = {NS, NS};
46 Rab = NEW(Tensor<F>, 2, vv, syms, *Sisi4s::world, "Rab");
47 auto Rconj = Tensor<F>(*Rab);
48 conjugate(Rconj);
49 (*Rab)["ab"] = (*R.get(0))["ai"] * (*R.get(0))["bi"];
50 return Rab;
51 }
52
53private:
54 PTR(Tensor<F>) Rai, Ria, Rij, Rab;
55 const SFockVector<F> &R;
56};
57
66template <typename F>
68public:
70 Tensor<F> *Tabij_,
71 const SDFockVector<F> *L_,
72 const SDFockVector<F> *R_)
73 : Tai(Tai_)
74 , Tabij(Tabij_)
75 , L(L_)
76 , R(R_) {
77 LOG(0, "OneBodyRDM") << "Calculating eom ccsd 1rdm" << std::endl;
78 }
79
80 PTR(Tensor<F>) getAI() override {
81 if (Rai) { return Rai; }
82 Rai = NEW(Tensor<F>, *Tai);
83
84 (*Rai)["ai"] = 0;
85 (*Rai)["ai"] += (*L->get(0))["ke"] * (*R->get(1))["eaki"];
86 (*Rai)["ai"] += (*L->get(0))["ke"] * (*R->get(0))["ak"] * (*Tai)["ei"];
87 (*Rai)["ai"] += (*L->get(0))["ke"] * (*R->get(0))["ei"] * (*Tai)["ak"];
88 (*Rai)["ai"] +=
89 (-0.5) * (*L->get(1))["kled"] * (*R->get(0))["di"] * (*Tabij)["eakl"];
90 (*Rai)["ai"] +=
91 (-0.5) * (*L->get(1))["kled"] * (*R->get(0))["al"] * (*Tabij)["edki"];
92 (*Rai)["ai"] +=
93 (-0.5) * (*L->get(1))["kled"] * (*Tai)["di"] * (*R->get(1))["eakl"];
94 (*Rai)["ai"] +=
95 (-0.5) * (*L->get(1))["kled"] * (*Tai)["al"] * (*R->get(1))["edki"];
96
97 return Rai;
98 }
99
100 PTR(Tensor<F>) getIJ() override {
101 if (Rij) { return Rij; }
102 const int No(Tai->lens[1]);
103 const int oo[] = {No, No};
104 const int syms[] = {NS, NS};
105 Rij = NEW(Tensor<F>, 2, oo, syms, *Sisi4s::world, "Rij");
106
107 (*Rij)["ij"] = 0;
108 (*Rij)["ij"] += (*L->get(0))["je"] * (*R->get(0))["ei"];
109 (*Rij)["ij"] += 0.5 * (*L->get(1))["kjed"] * (*R->get(1))["edki"];
110 (*Rij)["ij"] += (*L->get(1))["kjed"] * (*R->get(0))["ek"] * (*Tai)["di"];
111 // This is not in the paper
112 (*Rij)["ij"] += (*L->get(1))["kjed"] * (*R->get(0))["di"] * (*Tai)["ek"];
113
114 return Rij;
115 }
116
117 PTR(Tensor<F>) getAB() override {
118 if (Rab) { return Rab; }
119 const int Nv(Tai->lens[0]);
120 const int vv[] = {Nv, Nv};
121 const int syms[] = {NS, NS};
122 Rab = NEW(Tensor<F>, 2, vv, syms, *Sisi4s::world, "Rab");
123
124 (*Rab)["ab"] = 0;
125 (*Rab)["ab"] += (-1.0) * (*L->get(0))["ka"] * (*R->get(0))["bk"];
126 (*Rab)["ab"] += (-0.5) * (*L->get(1))["klea"] * (*R->get(1))["ebkl"];
127 (*Rab)["ab"] +=
128 (-1.0) * (*L->get(1))["klea"] * (*R->get(0))["ek"] * (*Tai)["bl"];
129 // This is not in the paper
130 (*Rab)["ab"] +=
131 (-1.0) * (*L->get(1))["klea"] * (*R->get(0))["bl"] * (*Tai)["ek"];
132
133 return Rab;
134 }
135
136 PTR(Tensor<F>) getIA() override {
137 if (Ria) { return Ria; }
138 const int Nv(Tai->lens[0]), No(Tai->lens[1]);
139 const int ov[] = {No, Nv};
140 const int syms[] = {NS, NS};
141
142 Ria = NEW(Tensor<F>, 2, ov, syms, *Sisi4s::world, "Ria");
143
144 (*Ria)["ia"] = 0;
145 // this is 0 because r0 is 0
146 //(*Ria)["ia"] += (*L->get(0))["ia"];
147 (*Ria)["ia"] += (*L->get(1))["oifa"] * (*R->get(0))["fo"];
148 // this is 0 because r0 is 0
149 //(*Ria)["ia"] += (*L->get(1))["oifa"] * Tai["fo"];
150
151 return Ria;
152 }
153
154private:
155 PTR(Tensor<F>) Rai, Ria, Rij, Rab;
156 Tensor<F> *Tai, *Tabij;
157 const SDFockVector<F> *L, *R;
158};
159
160} // namespace sisi4s
161
162#endif
#define LOG(...)
Definition Log.hpp:119
#define NEW(TYPE,...)
Definition SharedPointer.hpp:10
#define PTR(TYPE)
Definition SharedPointer.hpp:8
Definition OneBodyReducedDensityMatrix.hpp:23
This implements one body rdm for eom ccsd In principle it calculates p T <0| L \rho R e |0> q For L a...
Definition OneBodyReducedDensityMatrix.hpp:67
EomOneBodyReducedDensityMatrix(Tensor< F > *Tai_, Tensor< F > *Tabij_, const SDFockVector< F > *L_, const SDFockVector< F > *R_)
Definition OneBodyReducedDensityMatrix.hpp:69
std::shared_ptr< Tensor< F > > getAB() override
Definition OneBodyReducedDensityMatrix.hpp:117
std::shared_ptr< Tensor< F > > getIA() override
Definition OneBodyReducedDensityMatrix.hpp:136
std::shared_ptr< Tensor< F > > getIJ() override
Definition OneBodyReducedDensityMatrix.hpp:100
std::shared_ptr< Tensor< F > > getAI() override
Definition OneBodyReducedDensityMatrix.hpp:80
Definition OneBodyReducedDensityMatrix.hpp:13
~OneBodyReducedDensityMatrix()
Definition OneBodyReducedDensityMatrix.hpp:15
virtual std::shared_ptr< Tensor< F > > getAI()=0
virtual std::shared_ptr< Tensor< F > > getAB()=0
virtual std::shared_ptr< Tensor< F > > getIJ()=0
virtual std::shared_ptr< Tensor< F > > getIA()=0
Definition FockVector.hpp:631
Definition FockVector.hpp:589
static CTF::World * world
Definition Sisi4s.hpp:17
Definition Algorithm.hpp:10
CTF::Tensor< F > Tensor
Definition Tensor.hpp:9
void conjugate(Tensor< double > &c)
Definition ComplexTensor.cxx:96