MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
hamiltonian.hpp
1#ifndef MPQC_CI_HAMILTONIAN_HPP
2#define MPQC_CI_HAMILTONIAN_HPP
3
4#include "mpqc/ci/string.hpp"
5#include "mpqc/math/matrix.hpp"
6#include <boost/foreach.hpp>
7
8// #define MPQC_PROFILE_ENABLE
9// #include "mpqc/profile.hpp"
10
11
12namespace mpqc {
13namespace ci {
14
15 double diagonal(const String &alpha,
16 const mpqc::Vector &h,
17 const mpqc::Matrix &V) {
18 //MPQC_PROFILE_LINE;
19 double q = 0;
20 const auto &o = alpha.occ();
21 for (auto i = o.begin(); i < o.end(); ++i) {
22 size_t ii = index(*i,*i);
23 q += h(ii);
24 for (auto j = o.begin(); j < i; ++j) {
25 size_t jj = index(*j,*j);
26 size_t ij = index(*i,*j);
27 q += V(ii,jj) - V(ij,ij);
28 }
29 }
30 //printf("Hd %e\n", q);
31 return q;
32 }
33
34 template<typename Index>
35 void diagonal2(const String::List<Index> &alpha, const String &beta,
36 const mpqc::Matrix &V, mpqc::Vector &d) {
37 //MPQC_PROFILE_LINE;
38 const auto &b = beta.occ();
39 BOOST_FOREACH (auto j, b) {
40 size_t jj = index(j,j);
41 auto const &Vj = V.col(jj);
42 for (int k = 0; k < alpha.size(); ++k) {
43 double q = 0;
44 const auto &a = alpha[k].occ();
45 BOOST_FOREACH (auto i, a) {
46 size_t ii = index(i,i);
47 q += Vj(i);
48 }
49 d(k) += q;
50 }
51 }
52 }
53
54 double diagonal2(const String &alpha, const String &beta,
55 const mpqc::Matrix &V) {
56 //MPQC_PROFILE_LINE;
57 double q = 0;
58 const auto &a = alpha.occ();
59 const auto &b = beta.occ();
60 BOOST_FOREACH (auto j, b) {
61 size_t jj = index(j,j);
62 auto const &Vj = V.col(jj);
63 BOOST_FOREACH (auto i, a) {
64 size_t ii = index(i,i);
65 q += Vj(ii);
66 }
67 }
68 return q;
69 }
70
71} // namespace ci
72} // namespace mpqc
73
74
75#endif /* MPQC_CI_HAMILTONIAN_HPP */
Contains new MPQC code since version 3.
Definition integralenginepool.hpp:37
Matrix class derived from Eigen::Matrix with additional MPQC integration.
Definition matrix.hpp:23
Vector class derived from Eigen::Matrix with additional MPQC integration.
Definition matrix.hpp:133

Generated at Wed Sep 25 2024 02:45:30 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.