MADNESS  0.10.1
hartreefock.h
Go to the documentation of this file.
1 /*
2  This file is part of MADNESS.
3 
4  Copyright (C) 2007,2010 Oak Ridge National Laboratory
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 
20  For more information please contact:
21 
22  Robert J. Harrison
23  Oak Ridge National Laboratory
24  One Bethel Valley Road
25  P.O. Box 2008, MS-6367
26 
27  email: harrisonrj@ornl.gov
28  tel: 865-241-3937
29  fax: 865-572-0680
30 */
31 
32 #ifndef HARTREEFOCK_H_
33 #define HARTREEFOCK_H_
34 
35 #include <madness/mra/mra.h>
36 #include <madness/world/MADworld.h>
37 #include <vector>
38 
39 #include "eigsolver.h"
40 
41 namespace madness
42 {
43 
44  //***************************************************************************
45  template <typename T, int NDIM>
46  // Typedef's
48  {
49  public:
51  //*************************************************************************
52  // Constructor
53  HartreeFockNuclearPotentialOp(World& world, funcT V, double coeff, double thresh);
54  //*************************************************************************
55 
56  //*************************************************************************
57  // Is there an orbitally-dependent term?
58  virtual bool is_od() {return false;}
59  //*************************************************************************
60 
61  //*************************************************************************
62  // Is there a density-dependent term?
63  virtual bool is_rd() {return true;}
64  //*************************************************************************
65 
66  //*************************************************************************
67  virtual funcT op_r(const funcT& rho, const funcT& rhon, const funcT& psi);
68  //*************************************************************************
69 
70  private:
71  //*************************************************************************
73  //*************************************************************************
74  };
75  //***************************************************************************
76 
77  //***************************************************************************
78  template <typename T, int NDIM>
79  // Typedef's
80  class HartreeFockCoulombOp : public EigSolverOp<T,NDIM>
81  {
82  public:
84  //*************************************************************************
85  // Constructor
86  HartreeFockCoulombOp(World& world, double coeff, double thresh);
87  //*************************************************************************
88 
89  //*************************************************************************
90  // Is there an orbitally-dependent term?
91  virtual bool is_od() {return false;}
92  //*************************************************************************
93 
94  //*************************************************************************
95  // Is there a density-dependent term?
96  virtual bool is_rd() {return true;}
97  //*************************************************************************
98 
99  //*************************************************************************
100  virtual funcT op_r(const funcT& rho, const funcT& rhon, const funcT& psi);
101  //*************************************************************************
102 
103  };
104  //***************************************************************************
105 
106  //***************************************************************************
107  template <typename T, int NDIM>
108  // Typedef's
109  class HartreeFockExchangeOp : public EigSolverOp<T,NDIM>
110  {
111  public:
113  //*************************************************************************
114  // Constructor
115  HartreeFockExchangeOp(World& world, double coeff, double thresh);
116  //*************************************************************************
117 
118  //*************************************************************************
119  // Is there an orbitally-dependent term?
120  virtual bool is_od() {return true;}
121  //*************************************************************************
122 
123  //*************************************************************************
124  // Is there a density-dependent term?
125  virtual bool is_rd() {return false;}
126  //*************************************************************************
127 
128  //*************************************************************************
129  virtual funcT op_o(const std::vector<funcT>& phis, const funcT& psi);
130  //*************************************************************************
131 
132  };
133  //***************************************************************************
134 
135  //***************************************************************************
136  template <typename T, int NDIM>
137  class HartreeFock : public IEigSolverObserver<T,NDIM>
138  {
139  public:
141  //*************************************************************************
142  // Constructor
143  HartreeFock(World& world, funcT V, std::vector<funcT> phis,
144  std::vector<double> eigs, bool bCoulomb, bool bExchange, double thresh);
145  //*************************************************************************
146 
147  //*************************************************************************
148  // Destructor
149  virtual ~HartreeFock();
150  //*************************************************************************
151 
152  //*************************************************************************
153  void hartree_fock(int maxits);
154  //*************************************************************************
155 
156  //*************************************************************************
158  //*************************************************************************
159 
160  //*************************************************************************
162  //*************************************************************************
163 
164  //*************************************************************************
165  double calculate_ke_sp(funcT psi);
166  //*************************************************************************
167 
168  //*************************************************************************
169  double calculate_pe_sp(funcT psi);
170  //*************************************************************************
171 
172  //*************************************************************************
173  double calculate_coulomb_energy(const std::vector<funcT>& phis,
174  const funcT& psi);
175  //*************************************************************************
176 
177  //*************************************************************************
178  double calculate_exchange_energy(const std::vector<funcT>& phis,
179  const funcT& psi);
180  //*************************************************************************
181 
182  //*************************************************************************
183  T matrix_element(const funcT& phii, const funcT& phij)
184  {
185  return _solver->matrix_element(phii, phij);
186  }
187  //*************************************************************************
188 
189  //*************************************************************************
190  virtual void iterateOutput(const std::vector<funcT>& phis,
191  const std::vector<double>& eigs, const funcT& rho, const int& iter);
192  //*************************************************************************
193 
194  //*************************************************************************
196  {
197  return _bCoulomb;
198  }
199  //*************************************************************************
200 
201  //*************************************************************************
203  {
204  return _bExchange;
205  }
206  //*************************************************************************
207 
208  //*************************************************************************
209  double get_eig(int indx)
210  {
211  return _solver->get_eig(indx);
212  }
213  //*************************************************************************
214 
215  //*************************************************************************
216  funcT get_phi(int indx)
217  {
218  return _solver->get_phi(indx);
219  }
220  //*************************************************************************
221 
222  //*************************************************************************
223  const std::vector<double>& eigs()
224  {
225  return _solver->eigs();
226  }
227  //*************************************************************************
228 
229  //*************************************************************************
230  const std::vector<funcT>& phis()
231  {
232  return _solver->phis();
233  }
234  //*************************************************************************
235 
236  //*************************************************************************
237  double calculate_tot_ke_sp(const std::vector<funcT>& phis);
238  //*************************************************************************
239 
240  //*************************************************************************
241  double calculate_tot_pe_sp(const std::vector<funcT>& phis);
242  //*************************************************************************
243 
244  //*************************************************************************
245  double calculate_tot_coulomb_energy(const std::vector<funcT>& phis);
246  //*************************************************************************
247 
248  //*************************************************************************
249  double calculate_tot_exchange_energy(const std::vector<funcT>& phis);
250  //*************************************************************************
251 
252 private:
253 
254  //*************************************************************************
255  // Eigenvalue solver
257  //*************************************************************************
258 
259  //*************************************************************************
260  // Flags for whether to include the coulomb and exchange
261  bool _bCoulomb;
263  //*************************************************************************
264 
265  //*************************************************************************
267  //*************************************************************************
268 
269  //*************************************************************************
271  //*************************************************************************
272 
273  //*************************************************************************
274  double _thresh;
275  //*************************************************************************
276 
277  //*************************************************************************
278  World& world() {return _world;}
279  //*************************************************************************
280 
281  //*************************************************************************
282  double thresh() {return _thresh;}
283  //*************************************************************************
284 
285  };
286  //***************************************************************************
287 
288 }
289 
290 #endif /*HARTREEFOCK_H_*/
This header should include pretty much everything needed for the parallel runtime.
Definition: eigsolver.h:99
double thresh()
Definition: eigsolver.h:193
double coeff()
Definition: eigsolver.h:177
Definition: eigsolver.h:226
A multiresolution adaptive numerical function.
Definition: mra.h:122
Definition: hartreefock.h:81
HartreeFockCoulombOp(World &world, double coeff, double thresh)
Definition: hartreefock.cc:52
virtual funcT op_r(const funcT &rho, const funcT &rhon, const funcT &psi)
Definition: hartreefock.cc:81
virtual bool is_rd()
Is there a density-dependent term?
Definition: hartreefock.h:96
Function< T, NDIM > funcT
Definition: hartreefock.h:83
virtual bool is_od()
Is there an orbitally-dependent term?
Definition: hartreefock.h:91
Definition: hartreefock.h:110
virtual funcT op_o(const std::vector< funcT > &phis, const funcT &psi)
Orbital-dependent portion of operator.
Definition: hartreefock.cc:95
HartreeFockExchangeOp(World &world, double coeff, double thresh)
Definition: hartreefock.cc:62
Function< T, NDIM > funcT
Definition: hartreefock.h:112
virtual bool is_rd()
Is there a density-dependent term?
Definition: hartreefock.h:125
virtual bool is_od()
Is there an orbitally-dependent term?
Definition: hartreefock.h:120
Definition: hartreefock.h:48
funcT _V
Definition: hartreefock.h:72
virtual bool is_rd()
Is there a density-dependent term?
Definition: hartreefock.h:63
HartreeFockNuclearPotentialOp(World &world, funcT V, double coeff, double thresh)
Definition: hartreefock.cc:40
virtual funcT op_r(const funcT &rho, const funcT &rhon, const funcT &psi)
Definition: hartreefock.cc:72
virtual bool is_od()
Is there an orbitally-dependent term?
Definition: hartreefock.h:58
Function< T, NDIM > funcT
Definition: hartreefock.h:50
Definition: hartreefock.h:138
void hartree_fock(int maxits)
Definition: hartreefock.cc:158
EigSolver< T, NDIM > * _solver
Definition: hartreefock.h:256
double thresh()
Definition: hartreefock.h:282
const std::vector< funcT > & phis()
Definition: hartreefock.h:230
bool include_coulomb()
Definition: hartreefock.h:195
World & world()
Definition: hartreefock.h:278
bool include_exchange()
Definition: hartreefock.h:202
double calculate_tot_pe_sp(const std::vector< funcT > &phis)
Definition: hartreefock.cc:267
T matrix_element(const funcT &phii, const funcT &phij)
Definition: hartreefock.h:183
funcT calculate_coulomb(funcT psi)
funcT _V
Definition: hartreefock.h:270
double get_eig(int indx)
Definition: hartreefock.h:209
bool _bCoulomb
Definition: hartreefock.h:261
virtual void iterateOutput(const std::vector< funcT > &phis, const std::vector< double > &eigs, const funcT &rho, const int &iter)
Definition: hartreefock.cc:315
double calculate_tot_coulomb_energy(const std::vector< funcT > &phis)
Definition: hartreefock.cc:283
double calculate_coulomb_energy(const std::vector< funcT > &phis, const funcT &psi)
Definition: hartreefock.cc:189
World & world
Definition: mp2.h:77
HartreeFock(World &world, funcT V, std::vector< funcT > phis, std::vector< double > eigs, bool bCoulomb, bool bExchange, double thresh)
Definition: hartreefock.cc:123
double calculate_ke_sp(funcT psi)
Definition: hartreefock.cc:166
funcT get_phi(int indx)
Definition: hartreefock.h:216
virtual ~HartreeFock()
Definition: hartreefock.cc:150
double calculate_tot_exchange_energy(const std::vector< funcT > &phis)
Definition: hartreefock.cc:299
funcT calculate_exchange(funcT psi)
double calculate_tot_ke_sp(const std::vector< funcT > &phis)
Definition: hartreefock.cc:251
double calculate_exchange_energy(const std::vector< funcT > &phis, const funcT &psi)
Definition: hartreefock.cc:221
double calculate_pe_sp(funcT psi)
Definition: hartreefock.cc:180
double _thresh
Definition: hartreefock.h:274
World & _world
Definition: hartreefock.h:266
const std::vector< double > & eigs()
Definition: hartreefock.h:223
Function< T, NDIM > funcT
Definition: hartreefock.h:140
bool _bExchange
Definition: hartreefock.h:262
Definition: eigsolver.h:52
A parallel world class.
Definition: world.h:132
auto T(World &world, response_space &f) -> response_space
Definition: global_functions.cc:34
double psi(const Vector< double, 3 > &r)
Definition: hatom_energy.cc:78
Main include file for MADNESS and defines Function interface.
File holds all helper structures necessary for the CC_Operator and CC2 class.
Definition: DFParameters.h:10
static double V(const coordT &r)
Definition: tdse.cc:288