1 #ifndef MPQC_CI_DIRECT_HPP
2 #define MPQC_CI_DIRECT_HPP
4 #include <util/misc/formio.h>
6 #include "mpqc/ci/string.hpp"
7 #include "mpqc/ci/vector.hpp"
8 #include "mpqc/ci/sigma.hpp"
9 #include "mpqc/ci/preconditioner.hpp"
11 #include "mpqc/math/matrix.hpp"
12 #include "mpqc/file.hpp"
14 #include "mpqc/utility/profile.hpp"
16 #define MPQC_CI_VERBOSE 0
26 const std::vector<mpqc::range> &local) {
29 BOOST_FOREACH (
auto r, local) {
36 printf(
"read took %f s, %f mb/s\n", (
double)t, count*
sizeof(
double)/(t*(1<<20)));
42 const std::vector<mpqc::range> &local) {
45 BOOST_FOREACH (
auto r, local) {
52 printf(
"write took %f s, %f mb/s\n", (
double)t, count*
sizeof(
double)/(t*(1<<20)));
60 template<
class Type,
class Index>
65 MPQC_PROFILE_REGISTER_THREAD;
69 size_t R = ci.
config.roots;
72 const auto &alpha = ci.
alpha;
73 const auto &beta = ci.
beta;
83 std::map<int, Iter> iters;
84 iters[-1].E = iters[-1].D = 0;
93 std::vector<double> E;
95 for (
size_t it = 0;; ++it) {
113 sigma(ci, h, V, C, D);
125 BOOST_FOREACH (
auto r, ci.local()) {
129 for (
int j = 0; j < M; ++j) {
134 comm.sum(g.data(), M);
146 iters[it].lambda = lambda;
152 for (
int k = 0; k < R; ++k) {
155 for (
auto r : ci.local()) {
160 for (
int i = 0; i < M; ++i) {
162 double r = -a(i,k)*lambda(k);
165 for (
int i = 0; i < M; ++i) {
173 iters[it].E = lambda[0];
174 iters[it].D =
norm(D, ci.local(), comm);
176 if (comm.rank() == 0) {
177 double dc = fabs(iters[it - 1].D - iters[it].D);
178 double de = fabs(iters[it - 1].E - iters[it].E);
182 "del.E=%4.2e, del.C=%4.2e\n",
188 preconditioner(ci, h, V, lambda[0], D);
191 for (
int i = 0; i < M; ++i) {
198 if (it+1 == ci.
config.max)
break;
205 MPQC_PROFILE_DUMP(std::cout);
207 sc::ExEnv::out0() << sc::indent <<
"Davidson iteration time: " << t << std::endl;
209 if (fabs(iters[it - 1].E - iters[it].E) < ci.
config.convergence) {
210 E.push_back(iters[it].E);
214 if (it+1 == ci.
config.max) {
void orthonormalize(matrix< T > &d, const matrix< T > &b)
orthormalize matrix d wrt to normalized matrix b d = normalize(d - (<d|b>*b))
Definition: matrix.hpp:224
void sigma(const CI< Type, Index > &ci, const mpqc::Vector &h, const Matrix &V, ci::Vector &C, ci::Vector &S)
Computes sigma 1,2,3 contributions.
Definition: sigma.hpp:30
Contains new MPQC code since version 3.
Definition: integralenginepool.hpp:37
ci::String::List< Index > alpha
Alpha string list.
Definition: ci.hpp:81
const ci::Config config
CI configuration.
Definition: ci.hpp:79
Matrix class derived from Eigen::Matrix with additional MPQC integration.
Definition: matrix.hpp:21
Block CI Vector, with 1-d (vector) and 2-d (matrix) access.
Definition: vector.hpp:18
ci::String::List< Index > beta
Beta string list.
Definition: ci.hpp:82
#define MPQC_EXCEPTION(...)
Definition: exception.hpp:51
A subset of File::Dataset.
Definition: file.hpp:208
SubspaceGrid subspace
CI subspaces grid.
Definition: ci.hpp:84
T norm(const matrix< T > &a)
Matrix norm.
Definition: matrix.hpp:209
CI class template.
Definition: ci.hpp:71
void write(ci::Vector &V, File::Dataspace< double > F, const std::vector< mpqc::range > &local)
write local segments of V to F
Definition: direct.hpp:41
size_t size() const
Number of elements in the set.
Definition: file.hpp:356
MPI::Comm comm
CI communicator.
Definition: ci.hpp:86
mpqc::ci::CI::IO vector
CI vectors b (aka C), Hb (aka sigma) file datasets.
void read(ci::Vector &V, File::Dataspace< double > F, const std::vector< mpqc::range > &local)
read local segments into V from F
Definition: direct.hpp:25
static std::ostream & out0()
Return an ostream that writes from node 0.
Vector class derived from Eigen::Matrix with additional MPQC integration.
Definition: matrix.hpp:133
std::vector< double > direct(CI< Type, Index > &ci, const mpqc::Vector &h, const mpqc::Matrix &V)
Direct Davidson.
Definition: direct.hpp:61
This class allows printf-like output to be sent to an ostream.
Definition: formio.h:97
Eigen::SelfAdjointEigenSolver< Matrix::EigenType > symmetric(const matrix< T > &a)
Computes (Eigen::SelfAdjointEigenSolver) eigensystem of a matrix.
Definition: matrix.hpp:199
Generated at Sun Jan 26 2020 23:24:01 for MPQC
3.0.0-alpha using the documentation package Doxygen
1.8.16.