4#include <util/misc/formio.h>
5#include "mpqc/ci/subspace.hpp"
6#include "mpqc/ci/string.hpp"
7#include "mpqc/math/matrix.hpp"
9#include "mpqc/file.hpp"
10#include "mpqc/utility/check.hpp"
11#include "mpqc/utility/exception.hpp"
22 size_t core, orbitals;
32 mutable double e_core;
61 o << sc::indent <<
"rank = " <<
rank << std::endl;
62 o << sc::indent <<
"# of roots = " <<
roots << std::endl;
63 o << sc::indent <<
"# of electrons = {" <<
electrons.alpha <<
"," <<
electrons.beta <<
"}" << std::endl;
64 o << sc::indent <<
"magnetic moment = " <<
ms << std::endl;
70 template<
class CIFunctor,
class Index = String::Index>
74 template<
class CIFunctor,
class Index>
75 struct CI : boost::noncopyable {
88 struct IO : boost::noncopyable {
93 std::vector<mpqc::range> locals_;
99 if (Spin::value == Alpha::value)
101 if (Spin::value == Beta::value)
108 size_t dets()
const {
112 const std::vector<mpqc::range>& local()
const {
113 return this->locals_;
118 return String::difference(s,
String(s.size(), s.count()));
135 this->subspace = CIFunctor::grid(*
this,
136 split(sa, this->config.
block),
137 split(sb, this->config.
block));
144 this->config.orbitals, (this->config.electrons.alpha+
145 this->config.electrons.beta))
146 <<
sc::scprintf(
"alpha = %lu, beta = %lu, dets = %lu\n",
147 alpha.size(),
beta.size(), this->subspace.dets())
150 print(out,
"Alpha excitations:\n", sb);
151 print(out,
"Beta excitations:\n", sa);
156 size_t dets = this->subspace.
dets();
159 MPQC_CHECK(locals.size() > 0);
160 std::vector<range> extents(2);
162 extents[1] =
range(0,this->config.
max);
164 if (this->config.hdf5.
chunk) {
165 hsize_t chunk[] = { 1, std::min<hsize_t>(locals.size(), this->config.hdf5.chunk) };
166 H5Pset_chunk(dcpl.id(), 2, chunk);
167 std::cout <<
"hdf5.chunk=" << this->config.hdf5.
chunk << std::endl;
171 H5Pset_deflate (dcpl.id(), this->config.hdf5.compress);
172 std::cout <<
"hdf5.compress=" << this->config.hdf5.
compress << std::endl;
176 this->locals_ = split(locals, this->config.
block*this->config.block);
189 return abs(a.rank() - b.rank());
194 return CIFunctor::test(*
this, a);
199 return CIFunctor::test(*
this, a, b);
213 BOOST_FOREACH (
auto r, this->local()) {
215 if (r.test(0)) b(0) = 1;
223 static void print(std::ostream &out,
const std::string &header,
227 for (
int i = 0; i < S.size(); ++i) {
243 std::vector< Subspace<Spin> > R;
244 int begin = 0, end = 0;
245 BOOST_FOREACH (
const auto &s, S) {
262 MPQC_ASSERT(S.size() == *R.back().end());
268 explicit Sort(
const CI *ci) : ci_(ci) {}
269 bool operator()(
const String &a,
const String &b)
const {
288 const char* a_cast =
reinterpret_cast<const char*
>(&a);
294 char* a_cast =
reinterpret_cast<char*
>(&a);
295 count += si.
get(a_cast);
String::List represents a set of String objects.
Definition string.hpp:195
static std::ostream & out0()
Return an ostream that writes from node 0.
Restores fundamental and user-defined types from images created with StateOut.
Definition statein.h:79
virtual int get(const ClassDesc **)
This restores ClassDesc's.
Serializes fundamental and user-defined types.
Definition stateout.h:71
virtual int put(const ClassDesc *)
Write out information about the given ClassDesc.
This class allows printf-like output to be sent to an ostream.
Definition formio.h:97
void FromStateIn(Atom &a, StateIn &si, int &count)
reads Atom from sc::StateIn
void ToStateOut(const Atom &a, StateOut &so, int &count)
writes Atom to sc::StateOut
std::string string_cast(const T &value)
cast type T to string
Definition string.hpp:14
#define MPQC_EXCEPTION(...)
Constructs mpqc::Exception with file, line information and an optional printf-style format and argume...
Definition exception.hpp:51
std::vector< range > partition(const range &R, size_t N)
Partition range into N blocks.
Definition range.hpp:76
Contains new MPQC code since version 3.
Definition integralenginepool.hpp:37
Contains all MPQC code up to version 3.
Definition mpqcin.h:14
Array-like collection of data.
Definition file.hpp:515
Directory-like container that holds datasets and other groups.
Definition file.hpp:682
MPI_Comm object wrapper/stub.
Definition comm.hpp:14
compare-by-rank functor
Definition ci.hpp:267
CI class template.
Definition ci.hpp:75
mpqc::ci::CI::IO vector
CI vectors b (aka C), Hb (aka sigma) file datasets.
int excitation(const String &s) const
rank/excitation of the string relative to its ground state, ie [11..00]
Definition ci.hpp:117
bool test(const String &a) const
test if string is allowed
Definition ci.hpp:193
ci::String::List< Index > beta
Beta string list.
Definition ci.hpp:82
const ci::Config config
CI configuration.
Definition ci.hpp:79
bool test(const Space< Alpha > &a, const Space< Beta > &b) const
test if space configuration is allowed
Definition ci.hpp:198
SubspaceGrid subspace
CI subspaces grid.
Definition ci.hpp:84
std::vector< Subspace< Spin > > sort(ci::String::List< Index > &S) const
sort string list by rank/excitation and return vector of spaces, where each space corresponds to rang...
Definition ci.hpp:240
static int diff(const Space< Spin > &a, const Space< Spin > &b)
test if space configuration is allowed
Definition ci.hpp:188
static void print(std::ostream &out, const std::string &header, const std::vector< Subspace< Spin > > &S)
prints CI configuration summary
Definition ci.hpp:223
MPI::Comm comm
CI communicator.
Definition ci.hpp:86
ci::String::List< Index > alpha
Alpha string list.
Definition ci.hpp:81
CI(const Config &config, MPI::Comm comm, File::Group io)
Construct CI base given configuration and communicator.
Definition ci.hpp:125
void guess()
initialize guess vector
Definition ci.hpp:212
CI configuration.
Definition ci.hpp:21
bool direct
HDF5 direct I/O.
Definition ci.hpp:39
size_t ms
magnetic moment/Ms
Definition ci.hpp:26
int compress
GZIP compress level (0 to 9)
Definition ci.hpp:38
struct mpqc::ci::Config::@53 electrons
number of electrons of each spin in CI
int chunk
HDF5 chunking (should be about 256k)
Definition ci.hpp:37
size_t block
CI matrix blocking factor (values 1024 to 8192 are ok)
Definition ci.hpp:34
double convergence
energy convergence criteria
Definition ci.hpp:33
size_t max
maximum number of iterations
Definition ci.hpp:29
size_t roots
number of roots to find
Definition ci.hpp:28
int incore
determines if arrays C+S (2), C (1), or none(0) will be in core
Definition ci.hpp:35
size_t rank
Restricted CI order, rank=0 implies Full CI.
Definition ci.hpp:27
A CI space, marked by Spin S and rank.
Definition subspace.hpp:32
Grid of subspaces, represented as blocks of determinants defined by alpha/beta pair,...
Definition subspace.hpp:103
size_t dets() const
Returns number of determinants in the grid.
Definition subspace.hpp:164
A range of a space where all objects in the subspace range are assumed to have the same space rank.
Definition subspace.hpp:51
Vector class derived from Eigen::Matrix with additional MPQC integration.
Definition matrix.hpp:133