MPQC 2.3.1

- Main Page
- Related Pages
- Classes
- Files

- File List

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
246 RefSymmSCMatrix density();
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: