28 #ifndef _chemistry_qc_mbptr12_orbitalspace_h
29 #define _chemistry_qc_mbptr12_orbitalspace_h
35 #include <util/ref/ref.h>
36 #include <util/state/statein.h>
37 #include <util/state/stateout.h>
38 #include <util/group/thread.h>
39 #include <math/scmat/abstract.h>
40 #include <util/state/statein.h>
41 #include <chemistry/qc/basis/basis.h>
42 #include <chemistry/qc/basis/operator.h>
43 #include <chemistry/qc/wfn/spin.h>
44 #include <util/misc/registry.h>
52 template <
typename Attributes>
56 DecoratedOrbital(
size_t index,
const Attributes& attr) : index_(index), attr_(attr) {}
58 size_t index()
const {
return index_; }
59 const Attributes& attr()
const {
return attr_; }
74 irrep_(irrep), energy_(energy), occnum_(occnum) {
77 unsigned int irrep()
const {
80 double energy()
const {
83 double occnum()
const {
102 SpinCase1 spin()
const {
return spin_; }
132 if (o1.attr().irrep() < o2.attr().irrep())
134 else if (o1.attr().irrep() == o2.attr().irrep()) {
135 if (o1.attr().energy() < o2.attr().energy())
137 else if (o1.attr().energy() == o2.attr().energy()) {
138 if (o1.attr().occnum() < o2.attr().occnum())
145 return o.attr().irrep();
147 unsigned int nblocks()
const {
152 unsigned int nirreps_;
156 template <
typename EnergyCompare = std::less<
double> >
struct EnergyMOOrder {
159 if ( ecompare(o1.attr().energy(), o2.attr().energy()) )
161 else if (o1.attr().energy() == o2.attr().energy()) {
162 if (o1.attr().irrep() < o2.attr().irrep())
170 unsigned int nblocks()
const {
174 EnergyCompare ecompare;
184 if (o1.attr().occnum() > o2.attr().occnum())
186 else if (o1.attr().occnum() == o2.attr().occnum()) {
187 if (o1.attr().irrep() < o2.attr().irrep())
189 else if (o1.attr().irrep() == o2.attr().irrep()) {
190 if (o1.attr().energy() < o2.attr().energy())
198 const unsigned int irrep = o.attr().irrep();
199 const double occnum = o.attr().occnum();
201 const int occblock = (occnum == 1.0) ? 0 : 1;
202 return occblock * nirreps_ + irrep;
204 unsigned int nblocks()
const {
209 unsigned int nirreps_;
219 if (o1.attr().occnum() > o2.attr().occnum())
221 else if (o1.attr().occnum() == o2.attr().occnum()) {
222 if (o1.attr().spin() < o2.attr().spin())
224 else if (o1.attr().spin() == o2.attr().spin()) {
225 if (o1.attr().irrep() < o2.attr().irrep())
227 else if (o1.attr().irrep() == o2.attr().irrep()) {
228 if (o1.attr().energy() < o2.attr().energy())
237 const unsigned int irrep = o.attr().irrep();
238 const SpinCase1 spin = o.attr().spin();
239 const unsigned int spincase = (spin == Alpha) ? 0 : 1;
240 const double occnum = o.attr().occnum();
241 const unsigned int occblock = (occnum == 1.0) ? 0 : 1;
243 const unsigned int result = (occblock * 2 + spincase) * nirreps_ + irrep;
246 unsigned int nblocks()
const {
251 unsigned int nirreps_;
258 typedef typename Container::value_type value_type;
260 size_t size()
const {
return cont_.size(); }
261 value_type elem(
size_t i)
const {
return cont_[i]; }
264 const Container& cont_;
270 typedef double value_type;
272 size_t size()
const {
return cont_.dim().n(); }
273 value_type elem(
size_t i)
const {
return cont_(i); }
282 template <
typename Attribute,
283 typename AttributeContainer,
284 typename Compare = std::less<Attribute> >
289 bool operator()(
const MO& mo1,
290 const MO& mo2)
const {
292 return comp(mo1.attr(), mo2.attr());
298 const AttributeContainer& attributes) :
303 const size_t nmos = mask_.size();
304 MPQC_ASSERT(n < nmos);
309 for(
size_t mo=0; mo<nmos; ++mo) {
310 mos.push_back(
MO(mo,contadaptor.elem(mo)));
315 std::stable_sort(mos.begin(), mos.end(), comp);
318 for(
unsigned int t=0; t<n; ++t) {
319 mask_[ mos[t].index() ] =
false;
323 const std::vector<bool>& mask()
const {
return mask_; }
325 bool operator[](
size_t o)
const {
return mask_[o]; }
328 std::vector<bool> mask_;
358 static const unsigned int max_id_length = 30;
367 std::vector<unsigned int> orbsym_;
368 std::vector<unsigned int> block_offsets_;
369 std::vector<unsigned int> block_sizes_;
372 void check_orbsym()
const;
375 std::vector<unsigned int>
376 frozen_to_blockinfo(
unsigned int nfzc,
unsigned int nfzv,
381 void full_coefs_to_coefs(
const RefSCMatrix& full_coefs,
383 const std::vector<unsigned int>& offsets,
389 static void dquicksort(
double *item,
unsigned int *index,
unsigned int n);
395 void init(
const std::string&
id,
const std::string&
name,
399 const std::vector<unsigned int>& orbsyms,
401 const std::vector<BlockedOrbital>& indexmap);
426 const std::vector<unsigned int>& block_offsets,
451 const std::vector<unsigned int>& block_offsets,
464 unsigned int nfzc,
unsigned int nfzv,
486 const std::string&
name()
const;
496 const std::string&
id()
const;
510 const std::vector<unsigned int>&
orbsym()
const;
512 unsigned int rank()
const;
516 const std::vector<unsigned int>&
block_sizes()
const;
530 bool operator==(
const OrbitalSpace& space1,
const OrbitalSpace& space2);
535 std::logic_error(
"Cannot map given OrbitalSpaces") {
539 typedef std::vector<unsigned int> MOIndexMap;
554 typedef std::vector<std::pair<unsigned int, double> > SparseMOIndexMap;
607 const std::string& key()
const {
610 const std::string& label()
const {
613 SpinCase1 spin()
const {
617 static std::string key(
const std::string& label, SpinCase1 spin);
642 const std::string& key()
const {
645 const std::string& label()
const {
648 SpinCase1 spin()
const {
651 const std::string& support_label()
const {
652 return support_label_;
654 SpinCase1 support_spin()
const {
658 return transform_operator_;
661 static std::string key(
const std::string& label, SpinCase1 spin,
662 const std::string& original_label,
665 static bool valid_key(
const std::string& key);
671 std::string support_label_;
672 SpinCase1 support_spin_;
677 typedef Registry<std::string, Ref<OrbitalSpace> ,
678 detail::NonsingletonCreationPolicy,
679 std::equal_to<std::string>,
691 std::equal_to< Ref<GaussianBasisSet> >,
700 template <
typename Order>
708 const std::vector<unsigned int>& orbsyms,
724 template <
typename Order>
736 const std::vector<unsigned int>& orbsyms_alpha,
737 const std::vector<unsigned int>& orbsyms_beta,
759 const std::vector<bool>& mask);
808 bool merge_blocks =
true);
837 #include <chemistry/qc/wfn/orbitalspace.timpl.h>
static ParticleHoleOrbitalAttributes None
neither holes nor particles can be created
Definition: orbitalspace.h:120
void print(std::ostream &o=ExEnv::out0()) const
Prints out this.
std::string new_unique_key(const Ref< OrbitalSpaceRegistry > &oreg)
helper function to create a key basename (i.e.
Registry< std::string, Ref< OrbitalSpace >, detail::NonsingletonCreationPolicy, std::equal_to< std::string >, RefObjectEqual< OrbitalSpace > > OrbitalSpaceRegistry
registry of globally-known OrbitalSpace objects
Definition: orbitalspace.h:680
type
Types of one-body operators, includes various context-dependent "projectors", such as 1-RDM,...
Definition: operator.h:103
static ParticleHoleOrbitalAttributes Particle
only particles can be created
Definition: orbitalspace.h:118
RefSCMatrix overlap(const OrbitalSpace &space2, const OrbitalSpace &space1, const Ref< SCMatrixKit > &kit=SCMatrixKit::default_matrixkit())
overlap(s2,s1) returns the overlap matrix between s2 and s1.
any other
Definition: orbitalspace.h:353
const RefDiagSCMatrix & evals() const
Returns the "eigenvalues" matrix.
void print_summary(std::ostream &os) const
Produces a short summary.
energy corresponds to orbitals ordered by energy.
Definition: orbitalspace.h:349
The RefSCMatrix class is a smart pointer to an SCMatrix specialization.
Definition: matrix.h:135
A template class that maintains references counts.
Definition: ref.h:361
order by energy first, then by symmetry. EnergyCompare specifies the weak strict ordering of orbitals...
Definition: orbitalspace.h:156
const std::vector< unsigned int > & orbsym() const
Returns the orbital symmetry array.
const RefSCMatrix & coefs() const
Returns the coefficient matrix.
ParsedOrbitalSpaceKey(const std::string &key)
throws if key is not properly formatted
const std::vector< unsigned int > & block_sizes() const
Returns the number of orbitals in each block.
const std::string & id() const
Returns a short (preferably, one, max 10 character) identifier for the space.
correlated corresponds to orbitals ordered as: frozen occupied, active occupied, active virtual,...
Definition: orbitalspace.h:350
const Ref< Integral > & integral() const
Returns the integral factory used to instantiate the coefficient matrix.
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
NonsingletonCreationPolicy is used to create non-Singletons on heap.
Definition: registry.h:73
bool in(const std::pair< I, I > &r, const std::pair< I, I > &range)
return true if r is contained in range defined as pair<start,fence>, i.e. [start, fence)
Definition: mtensor.h:58
Definition: orbitalspace.h:602
The RefDiagSCMatrix class is a smart pointer to an DiagSCMatrix specialization.
Definition: matrix.h:389
This is an OrbitalSpace produced from an existing one by getting rid of the blocking.
Definition: orbitalspace.h:771
static ParticleHoleOrbitalAttributes Any
holes and particles can be created
Definition: orbitalspace.h:119
This is an empty OrbitalSpace.
Definition: orbitalspace.h:818
IndexOrder
Describes the ordering of indices.
Definition: orbitalspace.h:347
Definition: orbitalspace.h:532
unsigned int rank() const
Returns the rank of the space.
mask out first n MOs in the order defined by Compare. By default mask the n lowest-energy MOs
Definition: orbitalspace.h:285
Registry< Ref< GaussianBasisSet >, Ref< OrbitalSpace >, detail::NonsingletonCreationPolicy, std::equal_to< Ref< GaussianBasisSet > >, RefObjectEqual< OrbitalSpace > > AOSpaceRegistry
registry of globally-known OrbitalSpace objects that describe AO basis spaces
Definition: orbitalspace.h:692
const RefSCDimension & dim() const
returns the dimension corresponding to this space
The RefSCDimension class is a smart pointer to an SCDimension specialization.
Definition: dim.h:152
This class is used to contain information about classes.
Definition: class.h:147
Class OrbitalSpace describes a range of orbitals that are linear combinations of Gaussian basis funct...
Definition: orbitalspace.h:342
void print_detail(std::ostream &o=ExEnv::out0()) const
Prints out this in details (coefficients, etc.)
Describes particle-hole attributes of orbitals.
Definition: orbitalspace.h:112
This is an OrbitalSpace describing a set of atomic orbitals.
Definition: orbitalspace.h:786
Same as MolecularOrbitalAttributes, plus spin.
Definition: orbitalspace.h:93
static SCMatrixKit * default_matrixkit()
This returns the default matrix kit.
std::vector< unsigned int > operator<<(const GaussianBasisSet &B, const GaussianBasisSet &A)
computes a map from basis functions in A to the equivalent basis functions in B.
OrbitalSpace()
Empty constructor only useful for derived classes – don't forget to call init()
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
DecoratedOrbital< unsigned int > BlockedOrbital
Orbital in a blocked space.
Definition: orbitalspace.h:67
This is a union of two OrbitalSpaces s1 and s2.
Definition: orbitalspace.h:801
std::vector< int > map(const GaussianBasisSet &B, const GaussianBasisSet &A)
same as operator<<, except A does not have to be contained in B, map[a] = -1 if function a is not in ...
SpinCase1 other(SpinCase1 S)
given 1-spin return the other 1-spin
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
Definition: stateout.h:71
This is an OrbitalSpace produced from an existing one by masking out some Orbitals.
Definition: orbitalspace.h:755
const std::string & name() const
Returns a self-contained expressive label.
symmetry corresponds to orbitals ordered by symmetry, then (i.e. within each symmetry block) by energ...
Definition: orbitalspace.h:348
order by symmetry first, then by energy, then by occ num
Definition: orbitalspace.h:127
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
Definition: orbitalspace.timpl.h:55
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
static std::ostream & out0()
Return an ostream that writes from node 0.
Definition: orbitalspace.h:256
std::pair< std::string, Ref< OrbitalSpace > > make_keyspace_pair(const Ref< OrbitalSpace > &space, SpinCase1 spin=AnySpinCase1)
helper function to form a key/space pair from a OrbitalSpace
SparseMOIndexMap sparsemap(const OrbitalSpace &space2, const OrbitalSpace &space1, double hardzero=1e-12)
sparsemap(s2,s1) returns a sparse one-to-one map from s1 to s2.
RefSCMatrix transform(const OrbitalSpace &space2, const OrbitalSpace &space1, const Ref< SCMatrixKit > &kit=SCMatrixKit::default_matrixkit())
transform(s2,s1) returns matrix that transforms s1 to s2.
size_t memory_in_use() const
Returns how much "significant" (i.e. O^2) memory this object uses.
Orbital = index + attributes.
Definition: orbitalspace.h:53
Base class for objects that can save/restore state.
Definition: state.h:45
bool operator==(const Atom &a, const Atom &b)
unsigned int nblocks() const
Returns the number of blocks.
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
Definition: orbitalspace.timpl.h:129
This is an OrbitalSpace ordered according to the Order type.
Definition: orbitalspace.h:701
OrbitalSpaceUnion(const std::string &id, const std::string &name, const OrbitalSpace &s1, const OrbitalSpace &s2, bool merge_blocks=true)
Parses keys of OrbitalSpace.
Definition: orbitalspace.h:600
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14
RefSCMatrix coefs_nb() const
Returns the coefficient matrix built with a non-blocked kit.
static ParticleHoleOrbitalAttributes Hole
only holes can be created
Definition: orbitalspace.h:117
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
Same as OrderedOrbitalSpace, except for spin-orbitals.
Definition: orbitalspace.h:725
Registry wraps std::map and can be policy-configured to act as a Singleton or a regular object.
Definition: registry.h:112
const Ref< GaussianBasisSet > & basis() const
Returns the AO basis set.
MO is irrep, energy, occupation number.
Definition: orbitalspace.h:70
this functor can be used as a binary predicate for standard algorithms.
Definition: ref.h:659
Generated at Sun Jan 26 2020 23:24:00 for MPQC
3.0.0-alpha using the documentation package Doxygen
1.8.16.