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
42namespace sc {
43
44// //////////////////////////////////////////////////////////////////////////
45
48class MBPT2: public Wavefunction {
49 protected:
50#define ref_to_mp2_acc 100.0
51
52 Ref<SCF> reference_;
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&);
231 ~MBPT2();
232
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
242
243 int nfzcore() const { return nfzc; };
244 int nfzvirt() const { return nfzv; };
245
248
249 int gradient_implemented() const;
250 int value_implemented() const;
251
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:
static std::ostream & out0()
Return an ostream that writes from node 0.
The MBPT2 class implements several second-order perturbation theory methods.
Definition mbpt.h:48
void print(std::ostream &o=ExEnv::out0()) const
Print information about the object.
void obsolete()
Marks all results as being out of date.
int nelectron()
Returns the number of electrons.
void compute()
Recompute at least the results that have compute true and are not already computed.
RefSymmSCMatrix density()
Returns the SO density.
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
int spin_polarized()
Return 1 if the alpha density is not equal to the beta density.
void symmetry_changed()
Call this if you have changed the molecular symmetry of the molecule contained by this MolecularEnerg...
int value_implemented() const
Information about the availability of values, gradients, and hessians.
MBPT2(const Ref< KeyVal > &)
The KeyVal constructor.
The RefDiagSCMatrix class is a smart pointer to an DiagSCMatrix specialization.
Definition matrix.h:380
The RefSCMatrix class is a smart pointer to an SCMatrix specialization.
Definition matrix.h:135
The RefSCVector class is a smart pointer to an SCVector specialization.
Definition matrix.h:55
The RefSymmSCMatrix class is a smart pointer to an SCSymmSCMatrix specialization.
Definition matrix.h:261
A template class that maintains references counts.
Definition ref.h:332
Restores objects that derive from SavableState.
Definition statein.h:70
Serializes objects that derive from SavableState.
Definition stateout.h:61
A Wavefunction is a MolecularEnergy that utilizies a GaussianBasisSet.
Definition wfn.h:48
Definition memory.h:44

Generated at Mon Sep 2 2024 00:00:00 for MPQC 2.3.1 using the documentation package Doxygen 1.12.0.