MPQC  3.0.0-alpha
lmp2.h
1 
2 /*
3  * Copyright 2009 Sandia Corporation. Under the terms of Contract
4  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
5  * retains certain rights in this software.
6  *
7  * This file is a part of the MPQC LMP2 library.
8  *
9  * The MPQC LMP2 library is free software: you can redistribute it
10  * and/or modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation, either
12  * version 3 of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this program. If not, see
21  * <http://www.gnu.org/licenses/>.
22  *
23  */
24 
25 #ifndef _chemistry_qc_lmp2_lmp2_h
26 #define _chemistry_qc_lmp2_lmp2_h
27 
28 #include <math.h>
29 
30 #include <math/optimize/diis.h>
31 #include <math/scmat/repl.h>
32 #include <math/scmat/matrix.h>
33 
34 #include <chemistry/qc/basis/basis.h>
35 #include <chemistry/qc/basis/tbint.h>
36 #include <chemistry/qc/scf/scf.h>
37 
38 #include <chemistry/qc/lmp2/sma.h>
39 #include <chemistry/qc/lmp2/domain.h>
40 #include <chemistry/qc/lmp2/util.h>
41 #include <chemistry/qc/lmp2/lcorr.h>
42 #include <chemistry/qc/lmp2/parallel.h>
43 
44 namespace sc {
45 
46 typedef std::vector<std::pair<int,int> > my_occ_pairs_t;
47 
48 typedef std::set<std::pair<int,int> > k_2occ_local_pairs_t;
49 
50 typedef std::set<std::pair<int,int> > k_3_4_occ_local_pairs_t;
51 
52 typedef std::map<sma2::triplet<int,int,int>, domainmapvirbs_t > domainmap_triple;
53 
78 class LMP2: public LCorr {
79 
81 
82  sc::Ref<sc::SCF> ref_;
83 
84  int max_iter_;
85 
86  int nfzc_;
87 
88  double bound_;
89  double S_threshold_;
90  double integral_threshold_;
91  double q1_threshold_;
92  double q2_threshold_;
93  double q3_threshold_;
94  double q4_threshold_;
95  double threshold_factor_;
96  double distance_threshold_;
97  double completeness_threshold_;
98 
99  // "canonical" or "pipek-mezey"
100  std::string occ_orbitals_;
101  // "canonical" or "projected_atomic"
102  std::string vir_orbitals_;
103 
104  int parallel_transform123a_;
105  int parallel_transform123b_;
106  int parallel_transform4a_;
107  int parallel_transform4b_;
108  int parallel_iterations_;
109  int completedomains_;
110  bool singlevirb_;
111 
112  bool i_ge_j_;
113  bool m_ge_n_;
114  bool minimize_q2_;
115  bool always_use_dist_t_;
116 
118 
121  sma2::Range ao_;
124  sma2::Range vir_;
126  sma2::Range occ_act_;
130  sma2::Array<2> P_;
132  sma2::Array<2> L_;
135  domainmap_t domainmap_;
138  my_occ_pairs_t my_occ_pairs_;
141  std::vector<std::set<int> > paired_occ_;
142 
143  // Maps occ pairs to node numbers.
144  sc::Ref<sma2::PairMapping> pair_mapping_;
145 
152  sma2::Array<4> K_2occ_;
153 
156  sma2::Array<4> T_;
159  sma2::Array<4> T_jirs_;
161  sma2::Array<4> T_local_;
163  double T_n_element_;
164 
165  sma2::Array<2> F_occ_;
166  sma2::Array<2> F_vir_;
167  sma2::Array<2> S_;
168 
169  std::vector<double> F_diag_;
170 
172  void clear();
173 
175  bool analyze_occ_orbs_;
176  std::vector<SCVector3> r_i_;
177  std::vector<double> dist_ij_;
178  std::vector<double> emp2_ij_;
180  void analyze_occ_orbs(const RefSCMatrix& scf_local);
181 
182  double compute_lmp2_energy();
183  double compute_ecorr_lmp2();
184 
185  void rearrange_q2_all_ij(sma2::Array<4> &q2_K_oo);
186  void rearrange_q2_i_ge_j(sma2::Array<4> &q2_K_oo);
187 
188  void compute_K_2occ(
189  sc::RefSCMatrix &T_schwarz, sc::RefSCVector &T_schwarz_maxvec,
190  double T_schwarz_maxval, sc::RefSCMatrix &Pmax,
191  sc::RefSCVector &Pmaxvec,
192  std::vector<std::vector<double> > &Lmax,
193  sc::RefSCMatrix &Lshellmax,
194  std::vector<std::vector<double> > &PPmax,
195  const std::vector<std::vector<double> > &Dmax, double &Dmax_maxval, std::vector<double> &Lmaxvec,
196  std::vector<std::multimap<double,int,std::greater<double> > > &L_map);
197 
198  void compute_Schwarz_screening_quantities(sc::Ref<sc::TwoBodyInt> &tbint,
199  sc::RefSCMatrix &T_schwarz,
200  sc::RefSCVector &T_schwarz_maxvec,
201  double &T_schwarz_maxval,
202  int nshell);
203 
204  void compute_P_screening_quantities(sc::RefSCMatrix &Pmax,
205  sc::RefSCMatrix &Pmatrix,
206  sc::RefSCVector &Pmaxvec,
207  double &Pmax_maxval);
208 
209  void compute_L_and_D_screening_quantities(std::vector<std::vector<double> > &Dmax,
210  double &Dmax_maxval,
211  std::vector<std::vector<double> > &Lmax,
212  std::vector<double> &Lmaxvec,
213  sc::RefSCMatrix &Lshellmax,
214  std::vector<std::vector<int> > &L_blocks,
215  std::vector<std::multimap<double,int,std::greater<double> > > &L_map,
216  double &Lmax_maxval,
217  double T_schwarz_maxval,
218  double Pmax_maxval);
219 
220  void compute_PPmax_screening_matrix(std::vector<std::vector<double > > &PPmax,
221  sc::RefSCMatrix &Pmax,
222  const std::vector<std::set<int> >
223  &virb_united_pair_domains,
224  double T_schwarz_maxval,
225  double Pmax_maxval,
226  double Lmax_maxval);
227 
228  void compute_doubles_W();
229 
230  void compute_LMP2_residual(sma2::Array<4> &Res);
231  void compute_LMP2_residual_SFT(sma2::Array<4> &R);
232  void compute_LMP2_residual_SFTS(sma2::Array<4> &R);
233  void compute_LMP2_residual_SFTS_i(sma2::Array<4> &R);
234  void compute_LMP2_residual_SFTS_ij(sma2::Array<4> &R);
235 
236  double iterate_LMP2_equations(double energy_tolerance, double rms_tolerance);
237 
238  void compute_delta_T(sma2::Array<4> &Res,
239  sma2::Array<4> &delta_T);
240 
241  public:
348  LMP2(const sc::Ref<sc::KeyVal> &);
349  LMP2(sc::StateIn &);
350  ~LMP2();
352  void compute(void);
353  int nelectron(void);
355  double magnetic_moment() const;
356  int value_implemented(void) const;
357 
358 };
359 
360 }
361 
362 #endif
sc::LMP2
Computes the local second order perturbation theory energy.
Definition: lmp2.h:78
sc::LMP2::magnetic_moment
double magnetic_moment() const
Computes the S (or J) magnetic moment of the target state(s), in units of .
sc::RefSymmSCMatrix
The RefSymmSCMatrix class is a smart pointer to an SCSymmSCMatrix specialization.
Definition: matrix.h:265
sc::LMP2::density
sc::RefSymmSCMatrix density(void)
Returns the SO density.
sc::RefSCMatrix
The RefSCMatrix class is a smart pointer to an SCMatrix specialization.
Definition: matrix.h:135
sc::Ref< sc::MessageGrp >
sc::LMP2::LMP2
LMP2(const sc::Ref< sc::KeyVal > &)
Construct an LMP2 object from KeyVal input.
sc::LMP2::compute
void compute(void)
Recompute at least the results that have compute true and are not already computed.
sc::StateIn
Definition: statein.h:79
sc::sma2::Array< 2 >
sc::sma2::Range
An Range represent a set of integers, [0, N).
Definition: sma.h:93
sc::LMP2::nelectron
int nelectron(void)
Returns the number of electrons.
sc::LCorr
A base class for local correlation methods.
Definition: lcorr.h:48
sc::RefSCVector
The RefSCVector class is a smart pointer to an SCVector specialization.
Definition: matrix.h:55
sc::StateOut
Definition: stateout.h:71
sc::LMP2::value_implemented
int value_implemented(void) const
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14
sc::LMP2::save_data_state
void save_data_state(sc::StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...

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