MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
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#include <util/group/memory.h>
32#include <util/group/message.h>
33#include <util/group/thread.h>
34#include <chemistry/qc/basis/obint.h>
35#include <chemistry/qc/basis/tbint.h>
36#include <chemistry/qc/scf/scf.h>
37
38namespace sc {
39
40// //////////////////////////////////////////////////////////////////////////
41
44class MBPT2: public Wavefunction {
45 protected:
46 static double ref_to_mp2_acc() { return 100.0; }
47
48 Ref<SCF> reference_;
50 int nfzc, nfzv;
51 size_t mem_alloc;
52
53 double cphf_epsilon_;
54 int eliminate_in_gmat_;
55 const double *intbuf_;
56 Ref<TwoBodyInt> tbint_;
57 Ref<TwoBodyInt> *tbints_;
58 Ref<TwoBodyDerivInt> *tbintder_;
59 int nbasis;
60 int noso;
61 Ref<MessageGrp> msg_;
62 int nvir, nocc, nsocc;
63
64 Ref<ThreadGrp> thr_;
65
66 // use a dynamic load balance algorithm if possible if true
67 // (will not work if messagegrp not thread safe and
68 // memorygrp needs catchup to work)
69 int dynamic_;
70
71 // control how frequently progress is printed
72 double print_percent_;
73
74 // The maximum number of orbitals in a pass.
75 int max_norb_;
76
77 // the irreps of the orbitals and the offset within the irrep
78 int *symorb_irrep_;
79 int *symorb_num_;
80
81 std::string method_;
82 std::string algorithm_;
83 // if do_d1_ is true, D1(MP2) will be computed even if the gradient is not
84 int do_d1_;
85 // if do_d2_ is true, D2(MP1) will be computed
86 int do_d2_;
87
88 int nfuncmax;
89
90 double hf_energy_;
91 RefSCVector hf_gradient_;
92
93 double restart_ecorr_;
94 int restart_orbital_v1_;
95 int restart_orbital_memgrp_;
96
97 protected:
98 void init_variables();
99
100 // implement the Compute::compute() function
101 void compute();
102
103 // Fill in the eigenvectors and eigenvalues (Guest & Saunders general
104 // form is used for the Fock matrix in the open shell case).
105 void eigen(RefDiagSCMatrix &vals, RefSCMatrix &vecs,
106 RefDiagSCMatrix &occs);
107
108 // calculate the opt2 energy using algorithm v1
109 void compute_hsos_v1();
110
111 // calculate the opt2 energy using algorithm v2
112 distsize_t compute_v2_memory(int ni,
113 int nfuncmax, int nbfme, int nshell,
114 int ndocc, int nsocc, int nvir, int nproc);
115 void compute_hsos_v2();
116
117 // calculate the opt2 energy using the load balanced version of v2
118 void compute_hsos_v2_lb();
119
120 // calculate the closed shell mp2 energy and gradient
121 int compute_cs_batchsize(size_t mem_static, int nocc_act);
122 // distsize_t is used to allow memory requirements to be
123 // estimated by starting the calculation on a single processor
124 distsize_t compute_cs_dynamic_memory(int ni, int nocc_act);
125 int make_cs_gmat(RefSymmSCMatrix& Gmat, double *DPmat);
126 int make_cs_gmat_new(RefSymmSCMatrix& Gmat, const RefSymmSCMatrix& DPmat);
127 void form_max_dens(double *DPmat, signed char *maxp);
128 int init_cs_gmat();
129 void done_cs_gmat();
130 int make_g_d_nor(RefSymmSCMatrix& Gmat,
131 double *DPmat, const double *mgdbuff);
132 void cs_cphf(double **scf_vector,
133 double *Laj, double *eigval, RefSCMatrix& P2aj);
134 void s2pdm_contrib(const double *intderbuf, double *PHF,
135 double *P2AO, double **hf_ginter, double **ginter);
136 void hcore_cs_grad(double *PHF, double *PMP2,
137 double **hf_ginter, double **ginter);
138 void overlap_cs_grad(double *WHF, double *WMP2,
139 double **hf_ginter, double **ginter);
140 void compute_cs_grad();
141 public:
142 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
247 double magnetic_moment() const;
248
250 int value_implemented() const;
254
255 // override compute's obsolete so we can call the reference's obsolete
256 void obsolete();
257
258 void print(std::ostream&o=ExEnv::out0()) const;
259};
260
261}
262
263#endif
264
265// Local Variables:
266// mode: c++
267// c-file-style: "CLJ"
268// 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:44
bool analytic_gradient_implemented() const
must overload this in a derived class if analytic gradient can be computed
void set_desired_value_accuracy(double)
set the value accuracy
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 ...
void symmetry_changed()
Call this if you have changed the molecular symmetry of the molecule contained by this MolecularEnerg...
int value_implemented() const
double magnetic_moment() const
Computes the S (or J) magnetic moment of the target state(s), in units of .
MBPT2(const Ref< KeyVal > &)
The KeyVal constructor.
The RefDiagSCMatrix class is a smart pointer to an DiagSCMatrix specialization.
Definition matrix.h:389
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:265
A template class that maintains references counts.
Definition ref.h:361
Restores fundamental and user-defined types from images created with StateOut.
Definition statein.h:79
Serializes fundamental and user-defined types.
Definition stateout.h:71
A Wavefunction is a MolecularEnergy that utilizies a GaussianBasisSet.
Definition wfn.h:52
Contains all MPQC code up to version 3.
Definition mpqcin.h:14

Generated at Wed Sep 25 2024 02:45:29 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.