4 #include <util/misc/formio.h>
5 #include "mpqc/ci/subspace.hpp"
6 #include "mpqc/ci/string.hpp"
7 #include "mpqc/math/matrix.hpp"
8 #include "mpqc/mpi.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()));
132 auto sa = sort<Alpha>(this->alpha);
133 auto sb = sort<Beta>(this->beta);
135 this->subspace = CIFunctor::grid(*
this,
144 this->config.orbitals, (this->config.electrons.alpha+
145 this->config.electrons.beta))
146 <<
sc::scprintf(
"alpha = %lu, beta = %lu, dets = %lu\n",
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);
300 #endif // MPQC_CI_CI_HPP
static void print(std::ostream &out, const std::string &header, const std::vector< Subspace< Spin > > &S)
prints CI configuration summary
Definition: ci.hpp:223
bool test(const Space< Alpha > &a, const Space< Beta > &b) const
test if space configuration is allowed
Definition: ci.hpp:198
Grid of subspaces, represented as blocks of determinants defined by alpha/beta pair,...
Definition: subspace.hpp:103
void ToStateOut(const Atom &a, StateOut &so, int &count)
writes Atom to sc::StateOut
size_t block
CI matrix blocking factor (values 1024 to 8192 are ok)
Definition: ci.hpp:34
Contains new MPQC code since version 3.
Definition: integralenginepool.hpp:37
size_t rank
Restricted CI order, rank=0 implies Full CI.
Definition: ci.hpp:27
ci::String::List< Index > alpha
Alpha string list.
Definition: ci.hpp:81
bool direct
HDF5 direct I/O.
Definition: ci.hpp:39
const ci::Config config
CI configuration.
Definition: ci.hpp:79
int chunk
HDF5 chunking (should be about 256k)
Definition: ci.hpp:37
void guess()
initialize guess vector
Definition: ci.hpp:212
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
compare-by-rank functor
Definition: ci.hpp:267
ci::String::List< Index > beta
Beta string list.
Definition: ci.hpp:82
size_t ms
magnetic moment/Ms
Definition: ci.hpp:26
size_t dets() const
Returns number of determinants in the grid.
Definition: subspace.hpp:164
size_t roots
number of roots to find
Definition: ci.hpp:28
#define MPQC_EXCEPTION(...)
Definition: exception.hpp:51
std::string string_cast(const T &value)
cast type T to string
Definition: string.hpp:14
bool test(const String &a) const
test if string is allowed
Definition: ci.hpp:193
int incore
determines if arrays C+S (2), C (1), or none(0) will be in core
Definition: ci.hpp:35
SubspaceGrid subspace
CI subspaces grid.
Definition: ci.hpp:84
struct mpqc::ci::Config::@55 electrons
number of electrons of each spin in CI
static int diff(const Space< Spin > &a, const Space< Spin > &b)
test if space configuration is allowed
Definition: ci.hpp:188
CI configuration.
Definition: ci.hpp:21
CI class template.
Definition: ci.hpp:71
Directory-like container that holds datasets and other groups.
Definition: file.hpp:682
A range of a space where all objects in the subspace range are assumed to have the same space rank.
Definition: subspace.hpp:51
double convergence
energy convergence criteria
Definition: ci.hpp:33
int compress
GZIP compress level (0 to 9)
Definition: ci.hpp:38
Definition: stateout.h:71
std::vector< range > partition(const range &R, size_t N)
Partition range into N blocks.
Definition: range.hpp:76
MPI::Comm comm
CI communicator.
Definition: ci.hpp:86
size_t max
maximum number of iterations
Definition: ci.hpp:29
A CI space, marked by Spin S and rank.
Definition: subspace.hpp:32
std::vector< range > split(range r, size_t N)
Split range into blocks of size N.
Definition: range.hpp:94
mpqc::ci::CI::IO vector
CI vectors b (aka C), Hb (aka sigma) file datasets.
static std::ostream & out0()
Return an ostream that writes from node 0.
CI(const Config &config, MPI::Comm comm, File::Group io)
Construct CI base given configuration and communicator.
Definition: ci.hpp:125
virtual int put(const ClassDesc *)
Write out information about the given ClassDesc.
MPI_Comm object wrapper/stub.
Definition: comm.hpp:14
virtual int get(const ClassDesc **)
This restores ClassDesc's.
Vector class derived from Eigen::Matrix with additional MPQC integration.
Definition: matrix.hpp:133
void FromStateIn(Atom &a, StateIn &si, int &count)
reads Atom from sc::StateIn
This class allows printf-like output to be sent to an ostream.
Definition: formio.h:97
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14
int excitation(const String &s) const
rank/excitation of the string relative to its ground state, ie [11..00]
Definition: ci.hpp:117
Definition: string.hpp:24
Generated at Sun Jan 26 2020 23:24:01 for MPQC
3.0.0-alpha using the documentation package Doxygen
1.8.16.