MPQC  3.0.0-alpha
fockbuild_runtime.h
1 //
2 // fockbuild_runtime.h
3 //
4 // Copyright (C) 2009 Edward Valeev
5 //
6 // Author: Edward Valeev <evaleev@vt.edu>
7 // Maintainer: EV
8 //
9 // This file is part of the SC Toolkit.
10 //
11 // The SC Toolkit is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU Library General Public License as published by
13 // the Free Software Foundation; either version 2, or (at your option)
14 // any later version.
15 //
16 // The SC Toolkit is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU Library General Public License for more details.
20 //
21 // You should have received a copy of the GNU Library General Public License
22 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 //
25 // The U.S. Government is granted a limited license as per AL 91-7.
26 //
27 
28 #ifndef _mpqc_src_lib_chemistry_qc_lcao_fockbuildruntime_h
29 #define _mpqc_src_lib_chemistry_qc_lcao_fockbuildruntime_h
30 
31 #include <util/ref/ref.h>
32 #include <util/group/thread.h>
33 #include <util/group/message.h>
34 #include <math/scmat/matrix.h>
35 #include <chemistry/qc/basis/basis.h>
36 #include <chemistry/qc/basis/integral.h>
37 #include <util/misc/registry.h>
38 #include <chemistry/qc/wfn/spin.h>
39 #include <chemistry/qc/lcao/df_runtime.h>
40 
41 namespace sc {
42 
44  class FockBuildRuntime : virtual public SavableState {
45  public:
46 
47  typedef RefSCMatrix ResultType;
48 
50  const Ref<AOSpaceRegistry>& aoreg,
51  const Ref<GaussianBasisSet>& refbasis,
52  const RefSymmSCMatrix& aodensity_alpha,
53  const RefSymmSCMatrix& aodensity_beta,
54  const Ref<Integral>& integral,
59  void save_data_state(StateOut& so);
60 
62  void obsolete();
63 
66  bool exists(const std::string& key) const;
67 
73  ResultType get(const std::string& key); // non-const: can add transforms
74 
75  const Ref<Integral>& integral() const { return integral_; }
76  const Ref<MessageGrp>& msg() const { return msg_; }
77  const Ref<ThreadGrp>& thr() const { return thr_; }
78  const Ref<GaussianBasisSet>& basis() const { return basis_; }
79  const Ref<DensityFittingInfo>& dfinfo() const { return dfinfo_; }
80  void dfinfo(const Ref<DensityFittingInfo>& d) { dfinfo_ = d; }
81  const Ref<OrbitalSpaceRegistry>& orbital_registry() const { return oreg_; }
83  const Ref<FockMatrixRegistry>& fock_registry() const { return registry_; }
84  const Ref<AOSpaceRegistry>& ao_registry() const { return aoreg_; }
89  double log2_precision() const { return log2_precision_; }
90 
92  void set_densities(const RefSymmSCMatrix& aodensity_alpha,
93  const RefSymmSCMatrix& aodensity_beta);
95  RefSymmSCMatrix P() const { return P_; }
97  RefSymmSCMatrix Po() const { return Po_; }
98 
100  const RefSCVector& electric_field() const { return efield_; }
104  void set_electric_field(const RefSCVector& efield);
105 
116  void set_log2_precision(double prec);
117 
118  private:
119 
121  void obsolete_density_dependents();
122 
123  // set to 1 to debug this class
124  static int debug() { return 0; }
125 
126  Ref<DensityFittingInfo> dfinfo_;
127  bool use_density_fitting() { return dfinfo_; }
128 
129  Ref<OrbitalSpaceRegistry> oreg_;
130  Ref<AOSpaceRegistry> aoreg_;
131  Ref<Integral> integral_;
132  Ref<MessageGrp> msg_;
133  Ref<ThreadGrp> thr_;
134  Ref<GaussianBasisSet> basis_;
135  RefSCVector efield_;
136  bool spin_polarized_;
137  double log2_precision_;
138 
139  // Densities
140  RefSymmSCMatrix P_, Po_;
141 
142  // Registry of known Fock matrices
143  Ref<FockMatrixRegistry> registry_;
144 
146  void validate_key(const std::string& key) const;
147 
154  RefSCMatrix electric_field_contribution(std::string bra_key,
155  std::string ket_key);
156 
157  public:
160  typedef Registry<RefSymmSCMatrix, Ref<OrbitalSpace>,
161  detail::NonsingletonCreationPolicy,
163  private:
164  Ref<PSqrtRegistry> psqrtregistry_;
165 
166  };
167 
172  public:
174  ParsedOneBodyOperSetKey(const std::string& key);
175 
176  const std::string& key() const { return key_; }
177  const std::string& oper() const { return oper_; }
178  const std::string& params() const { return params_; }
179 
181  static std::string key(const std::string& oper,
182  const std::string& params);
184  template <int NumCenters>
185  static std::string key(const Ref<typename NCentersToIntDescr<NumCenters,1>::value>& descr)
186  {
187  return OneBodyOperSetDescr::instance(descr->operset())->key() + ParamsRegistry::instance()->key(descr->params());
188  }
189 
191  template<int NumCenters>
193  const std::string& operset_key, const Ref<IntParams>& p,
194  const Ref<Integral>& integral) {
195  if (operset_key
196  == OneBodyOperSetDescr::instance(OneBodyOperSet::S)->key()) {
198  integral, p);
199  }
200  if (operset_key
201  == OneBodyOperSetDescr::instance(OneBodyOperSet::T)->key()) {
203  integral, p);
204  }
205  throw ProgrammingError(
206  "ParsedOneBodyOperKey::create_descr() -- unknown oper",
207  __FILE__,
208  __LINE__);
209  }
210 
211 
212  private:
213  std::string key_;
214  std::string oper_;
215  std::string params_;
216  };
217 
220  public:
221  ParsedOneBodyIntKey(const std::string& key);
222 
223  const std::string& key() const { return key_; }
224  const std::string& bra() const { return bra_; }
225  const std::string& ket() const { return ket_; }
226  const std::string& oper() const { return oper_; }
227  SpinCase1 spin() const { return spin_; }
228 
230  static std::string key(const std::string& bra,
231  const std::string& ket,
232  const std::string& oper,
233  SpinCase1 spin = AnySpinCase1);
234 
235  private:
236  std::string key_;
237  std::string bra_, ket_;
238  std::string oper_;
239  SpinCase1 spin_;
240  };
241 
242 } // end of namespace sc
243 
244 #endif // end of header guard
245 
246 
247 // Local Variables:
248 // mode: c++
249 // c-file-style: "CLJ-CONDENSED"
250 // End:
sc::MessageGrp::get_default_messagegrp
static MessageGrp * get_default_messagegrp()
Returns the default message group.
sc::FockBuildRuntime::obsolete
void obsolete()
obsoletes this object
sc::FockBuildRuntime::set_electric_field
void set_electric_field(const RefSCVector &efield)
sets uniform electric field.
sc::RefSymmSCMatrix
The RefSymmSCMatrix class is a smart pointer to an SCSymmSCMatrix specialization.
Definition: matrix.h:265
sc::FockBuildRuntime
Build Fock matrices using some combination of FockBuilder objects.
Definition: fockbuild_runtime.h:44
sc::FockBuildRuntime::get
ResultType get(const std::string &key)
Returns the matrix corresponding to key.
sc::FockBuildRuntime::PSqrtRegistry
Registry< RefSymmSCMatrix, Ref< OrbitalSpace >, detail::NonsingletonCreationPolicy, RefSymmSCMatrixEqual, RefObjectEqual< OrbitalSpace > > PSqrtRegistry
the way I compute exchange matrices is by computing square root of the density (P) this Registry keep...
Definition: fockbuild_runtime.h:162
sc::NCentersToIntDescr
Definition: intdescr.h:156
sc::ParsedOneBodyOperSetKey::create_descr
static Ref< typename NCentersToIntDescr< NumCenters, 1 >::value > create_descr(const std::string &operset_key, const Ref< IntParams > &p, const Ref< Integral > &integral)
this factory method constructs a descriptor given operator key + IntParams object + Integrals object
Definition: fockbuild_runtime.h:192
sc::RefSCMatrix
The RefSCMatrix class is a smart pointer to an SCMatrix specialization.
Definition: matrix.h:135
sc::Ref
A template class that maintains references counts.
Definition: ref.h:361
sc::ParsedOneBodyOperSetKey
Parsed representation of a string key that represents a one-body operator set (OneBodyOperSet + assoc...
Definition: fockbuild_runtime.h:171
sc::OneBodyOperSet::S
{S}
Definition: operator.h:169
sc::FockBuildRuntime::electric_field
const RefSCVector & electric_field() const
returns the uniform electric field (may be a null reference)
Definition: fockbuild_runtime.h:100
sc::ParsedOneBodyOperSetKey::key
static std::string key(const Ref< typename NCentersToIntDescr< NumCenters, 1 >::value > &descr)
computes key from the given OneBodyOperSetDescr object
Definition: fockbuild_runtime.h:185
sc::StateIn
Definition: statein.h:79
sc::FockBuildRuntime::set_log2_precision
void set_log2_precision(double prec)
Specifies the precision of the computed operator matrices.
sc::ParamsRegistry::instance
static const Ref< ParamsRegistry > & instance()
this is a singleton
sc::ParsedOneBodyIntKey
Parsed representation of a string key that represents a set of one-body integrals.
Definition: fockbuild_runtime.h:219
sc::RefSymmSCMatrixEqual
this functor compares RefSymmSCMatrix objects.
Definition: matrix.h:537
sc::OneBodyOperSet::T
{T}
Definition: operator.h:170
sc::RefSCVector
The RefSCVector class is a smart pointer to an SCVector specialization.
Definition: matrix.h:55
sc::StateOut
Definition: stateout.h:71
sc::OneBodyNCenterIntDescr
Implements descriptors for various two-body evaluators.
Definition: intdescr.h:254
sc::FockBuildRuntime::exists
bool exists(const std::string &key) const
Returns true if the given matrix is available.
sc::ProgrammingError
This is thrown when a situations arises that should be impossible.
Definition: scexception.h:92
sc::FockBuildRuntime::save_data_state
void save_data_state(StateOut &so)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::FockBuildRuntime::Po
RefSymmSCMatrix Po() const
return open-shell density in AO basis
Definition: fockbuild_runtime.h:97
sc::FockBuildRuntime::set_densities
void set_densities(const RefSymmSCMatrix &aodensity_alpha, const RefSymmSCMatrix &aodensity_beta)
sets AO densities. Unless these are identical to the current densities, density-dependent contents wi...
sc::SavableState
Base class for objects that can save/restore state.
Definition: state.h:45
sc::ThreadGrp::get_default_threadgrp
static ThreadGrp * get_default_threadgrp()
Returns the default ThreadGrp.
sc::FockBuildRuntime::P
RefSymmSCMatrix P() const
return total density in AO basis
Definition: fockbuild_runtime.h:95
sc::FockBuildRuntime::log2_precision
double log2_precision() const
Definition: fockbuild_runtime.h:89
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14
sc::Registry
Registry wraps std::map and can be policy-configured to act as a Singleton or a regular object.
Definition: registry.h:112
sc::RefObjectEqual
this functor can be used as a binary predicate for standard algorithms.
Definition: ref.h:659

Generated at Sun Jan 26 2020 23:23:58 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.