MPQC  2.3.1
mbpt.h
1 //
2 // mbpt.h
3 //
4 // Copyright (C) 1996 Limit Point Systems, Inc.
5 //
6 // Author: Ida Nielsen <ibniels@kemi.aau.dk>
7 // Maintainer: LPS
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 _chemistry_qc_mbpt_mbpt_h
29 #define _chemistry_qc_mbpt_mbpt_h
30 
31 #ifdef __GNUC__
32 #pragma interface
33 #endif
34 
35 #include <util/group/memory.h>
36 #include <util/group/message.h>
37 #include <util/group/thread.h>
38 #include <chemistry/qc/basis/obint.h>
39 #include <chemistry/qc/basis/tbint.h>
40 #include <chemistry/qc/scf/scf.h>
41 
42 namespace sc {
43 
44 // //////////////////////////////////////////////////////////////////////////
45 
48 class MBPT2: public Wavefunction {
49  protected:
50 #define ref_to_mp2_acc 100.0
51 
52  Ref<SCF> reference_;
53  Ref<MemoryGrp> mem;
54  int nfzc, nfzv;
55  size_t mem_alloc;
56 
57  double cphf_epsilon_;
58  int eliminate_in_gmat_;
59  const double *intbuf_;
60  Ref<TwoBodyInt> tbint_;
61  Ref<TwoBodyInt> *tbints_;
62  Ref<TwoBodyDerivInt> *tbintder_;
63  int nbasis;
64  int noso;
65  Ref<MessageGrp> msg_;
66  int nvir, nocc, nsocc;
67 
68  Ref<ThreadGrp> thr_;
69 
70  // use a dynamic load balance algorithm if possible if true
71  // (will not work if messagegrp not thread safe and
72  // memorygrp needs catchup to work)
73  int dynamic_;
74 
75  // control how frequently progress is printed
76  double print_percent_;
77 
78  // The maximum number of orbitals in a pass.
79  int max_norb_;
80 
81  // the irreps of the orbitals and the offset within the irrep
82  int *symorb_irrep_;
83  int *symorb_num_;
84 
85  char *method_;
86  char *algorithm_;
87  // if do_d1_ is true, D1(MP2) will be computed even if the gradient is not
88  int do_d1_;
89  // if do_d2_ is true, D2(MP1) will be computed
90  int do_d2_;
91 
92  int nfuncmax;
93 
94  double hf_energy_;
95  RefSCVector hf_gradient_;
96 
97  double restart_ecorr_;
98  int restart_orbital_v1_;
99  int restart_orbital_memgrp_;
100 
101  protected:
102  void init_variables();
103 
104  // implement the Compute::compute() function
105  void compute();
106 
107  // Fill in the eigenvectors and eigenvalues (Guest & Saunders general
108  // form is used for the Fock matrix in the open shell case).
109  void eigen(RefDiagSCMatrix &vals, RefSCMatrix &vecs,
110  RefDiagSCMatrix &occs);
111 
112  // calculate the opt2 energy using algorithm v1
113  void compute_hsos_v1();
114 
115  // calculate the opt2 energy using algorithm v2
116  distsize_t compute_v2_memory(int ni,
117  int nfuncmax, int nbfme, int nshell,
118  int ndocc, int nsocc, int nvir, int nproc);
119  void compute_hsos_v2();
120 
121  // calculate the opt2 energy using the load balanced version of v2
122  void compute_hsos_v2_lb();
123 
124  // calculate the closed shell mp2 energy and gradient
125  int compute_cs_batchsize(size_t mem_static, int nocc_act);
126  // distsize_t is used to allow memory requirements to be
127  // estimated by starting the calculation on a single processor
128  distsize_t compute_cs_dynamic_memory(int ni, int nocc_act);
129  int make_cs_gmat(RefSymmSCMatrix& Gmat, double *DPmat);
130  int make_cs_gmat_new(RefSymmSCMatrix& Gmat, const RefSymmSCMatrix& DPmat);
131  void form_max_dens(double *DPmat, signed char *maxp);
132  int init_cs_gmat();
133  void done_cs_gmat();
134  int make_g_d_nor(RefSymmSCMatrix& Gmat,
135  double *DPmat, const double *mgdbuff);
136  void cs_cphf(double **scf_vector,
137  double *Laj, double *eigval, RefSCMatrix& P2aj);
138  void s2pdm_contrib(const double *intderbuf, double *PHF,
139  double *P2AO, double **hf_ginter, double **ginter);
140  void hcore_cs_grad(double *PHF, double *PMP2,
141  double **hf_ginter, double **ginter);
142  void overlap_cs_grad(double *WHF, double *WMP2,
143  double **hf_ginter, double **ginter);
144  void compute_cs_grad();
145  public:
146  MBPT2(StateIn&);
230  MBPT2(const Ref<KeyVal>&);
231  ~MBPT2();
232 
233  void save_data_state(StateOut&);
234 
235  Ref<SCF> ref() { return reference_; }
236  double ref_energy();
237  double corr_energy();
238  RefSCVector ref_energy_gradient();
239  RefSCVector corr_energy_gradient();
240 
241  int nelectron();
242 
243  int nfzcore() const { return nfzc; };
244  int nfzvirt() const { return nfzv; };
245 
247  int spin_polarized();
248 
249  int gradient_implemented() const;
250  int value_implemented() const;
251 
252  void symmetry_changed();
253 
254  // override compute's obsolete so we can call the reference's obsolete
255  void obsolete();
256 
257  void print(std::ostream&o=ExEnv::out0()) const;
258 };
259 
260 }
261 
262 #endif
263 
264 // Local Variables:
265 // mode: c++
266 // c-file-style: "CLJ"
267 // End:
sc::RefSymmSCMatrix
The RefSymmSCMatrix class is a smart pointer to an SCSymmSCMatrix specialization.
Definition: matrix.h:261
sc::MBPT2::density
RefSymmSCMatrix density()
Returns the SO density.
sc::MBPT2::print
void print(std::ostream &o=ExEnv::out0()) const
Print information about the object.
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:332
sc::MBPT2::value_implemented
int value_implemented() const
Information about the availability of values, gradients, and hessians.
sc::MBPT2::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::Wavefunction
A Wavefunction is a MolecularEnergy that utilizies a GaussianBasisSet.
Definition: wfn.h:48
sc::RefDiagSCMatrix
The RefDiagSCMatrix class is a smart pointer to an DiagSCMatrix specialization.
Definition: matrix.h:380
sc::MBPT2::nelectron
int nelectron()
Returns the number of electrons.
sc::StateIn
Restores objects that derive from SavableState.
Definition: statein.h:70
sc::MBPT2
The MBPT2 class implements several second-order perturbation theory methods.
Definition: mbpt.h:48
sc::distsize_t
Definition: memory.h:44
sc::RefSCVector
The RefSCVector class is a smart pointer to an SCVector specialization.
Definition: matrix.h:55
sc::StateOut
Serializes objects that derive from SavableState.
Definition: stateout.h:61
sc::MBPT2::spin_polarized
int spin_polarized()
Return 1 if the alpha density is not equal to the beta density.
sc::ExEnv::out0
static std::ostream & out0()
Return an ostream that writes from node 0.
sc::MBPT2::symmetry_changed
void symmetry_changed()
Call this if you have changed the molecular symmetry of the molecule contained by this MolecularEnerg...
sc::MBPT2::obsolete
void obsolete()
Marks all results as being out of date.
sc::MBPT2::compute
void compute()
Recompute at least the results that have compute true and are not already computed.

Generated at Sun Jan 26 2020 23:33:04 for MPQC 2.3.1 using the documentation package Doxygen 1.8.16.