1 #ifndef MPQC_CI_SIGMA_HPP
2 #define MPQC_CI_SIGMA_HPP
4 #include "mpqc/ci/ci.hpp"
5 #include "mpqc/ci/string.hpp"
6 #include "mpqc/ci/sigma2.hpp"
7 #include "mpqc/ci/sigma3.hpp"
8 #include "mpqc/ci/vector.hpp"
10 #include "mpqc/utility/timer.hpp"
11 #include "mpqc/range.hpp"
12 #include "mpqc/math/matrix.hpp"
13 #include "mpqc/mpi.hpp"
14 #include "mpqc/mpi/task.hpp"
16 #include "mpqc/utility/profile.hpp"
29 template<
class Type,
class Index>
34 struct {
double s1, s2, s3;
timer t; } time = { };
38 size_t no = ci.
alpha[0].size();
40 for (
int j = 0; j < no; ++j) {
41 for (
int i = 0; i <= j; ++i) {
43 for (
int k = 0; k < no; ++k) {
44 v += V(index(i,k), index(k,j));
46 H(index(i,j)) -= 0.5*v;
50 const std::vector< Subspace<Alpha> > &alpha = ci.
subspace.
alpha();
51 const std::vector< Subspace<Beta> > &beta = ci.
subspace.
beta();
52 const auto &blocks = ci::blocks(alpha, beta);
54 std::unique_ptr<MPI::Task> task;
60 auto next = task->next(blocks.begin(), blocks.end());
61 if (next == blocks.end())
break;
63 auto Ia = alpha.at(next->alpha);
64 auto Ib = beta.at(next->beta);
65 if (!ci.
test(Ia,Ib))
continue;
67 Matrix s = Matrix::Zero(Ia.size(), Ib.size());
70 BOOST_FOREACH (
auto Jb, beta) {
73 if (!ci.
test(Ia,Jb) || ci.
diff(Ib,Jb) > 2)
continue;
76 sigma12(ci, Ib, Jb, H, V, c, s);
82 if (ci.
config.ms == 0)
goto end;
86 BOOST_FOREACH (
auto Ja, alpha) {
88 if (!ci.
test(Ja,Ib) || ci.
diff(Ia,Ja) > 2)
continue;
91 sigma12(ci, Ia, Ja, H, V, c, s);
108 auto next = task->next(blocks.begin(), blocks.end());
109 if (next == blocks.end())
break;
111 if (ci.
config.ms == 0 && next->alpha > next->beta)
continue;
113 auto Ia = alpha.at(next->alpha);
114 auto Ib = beta.at(next->beta);
115 if (!ci.
test(Ia,Ib))
continue;
118 std::vector< Excitations<Beta> > BB;
119 BOOST_FOREACH (
auto Jb, beta) {
125 std::vector< Excitations<Alpha> > AA;
126 BOOST_FOREACH (
auto Ja, alpha) {
134 if (ci.
config.ms == 0 && next->alpha == next->beta)
135 s +=
Matrix(s).transpose();
137 for (
auto bb = BB.begin(); bb != BB.end(); ++bb) {
139 if (!bb->size())
continue;
141 for (
auto aa = AA.begin(); aa != AA.end(); ++aa) {
142 if (!aa->size())
continue;
144 if (!ci.
test(Ja,Jb))
continue;
147 sigma3(*aa, *bb, V, c, s);
156 if (ci.
config.ms == 0 && next->alpha != next->beta) {
173 sc::ExEnv::out0() << sc::indent <<
"sigma took " << double(time.t) << std::endl;
174 sc::ExEnv::out0() << sc::indent <<
" sigma1: " << time.s1 << std::endl;
175 sc::ExEnv::out0() << sc::indent <<
" sigma2: " << time.s2 << std::endl;
176 sc::ExEnv::out0() << sc::indent <<
" sigma3: " << time.s3 << std::endl;