MADNESS  version 0.9
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  $Id$
32 */
33 #ifndef HARTREEFOCK_H_
34 #define HARTREEFOCK_H_
35 
36 #include <madness/mra/mra.h>
37 #include <madness/world/world.h>
38 #include <vector>
39 
40 #include "eigsolver.h"
41 
42 namespace madness
43 {
44 
45  //***************************************************************************
46  template <typename T, int NDIM>
47  // Typedef's
49  {
50  public:
52  //*************************************************************************
53  // Constructor
54  HartreeFockNuclearPotentialOp(World& world, funcT V, double coeff, double thresh);
55  //*************************************************************************
56 
57  //*************************************************************************
58  // Is there an orbitally-dependent term?
59  virtual bool is_od() {return false;}
60  //*************************************************************************
61 
62  //*************************************************************************
63  // Is there a density-dependent term?
64  virtual bool is_rd() {return true;}
65  //*************************************************************************
66 
67  //*************************************************************************
68  virtual funcT op_r(const funcT& rho, const funcT& rhon, const funcT& psi);
69  //*************************************************************************
70 
71  private:
72  //*************************************************************************
73  funcT _V;
74  //*************************************************************************
75  };
76  //***************************************************************************
77 
78  //***************************************************************************
79  template <typename T, int NDIM>
80  // Typedef's
81  class HartreeFockCoulombOp : public EigSolverOp<T,NDIM>
82  {
83  public:
85  //*************************************************************************
86  // Constructor
87  HartreeFockCoulombOp(World& world, double coeff, double thresh);
88  //*************************************************************************
89 
90  //*************************************************************************
91  // Is there an orbitally-dependent term?
92  virtual bool is_od() {return false;}
93  //*************************************************************************
94 
95  //*************************************************************************
96  // Is there a density-dependent term?
97  virtual bool is_rd() {return true;}
98  //*************************************************************************
99 
100  //*************************************************************************
101  virtual funcT op_r(const funcT& rho, const funcT& rhon, const funcT& psi);
102  //*************************************************************************
103 
104  };
105  //***************************************************************************
106 
107  //***************************************************************************
108  template <typename T, int NDIM>
109  // Typedef's
110  class HartreeFockExchangeOp : public EigSolverOp<T,NDIM>
111  {
112  public:
114  //*************************************************************************
115  // Constructor
116  HartreeFockExchangeOp(World& world, double coeff, double thresh);
117  //*************************************************************************
118 
119  //*************************************************************************
120  // Is there an orbitally-dependent term?
121  virtual bool is_od() {return true;}
122  //*************************************************************************
123 
124  //*************************************************************************
125  // Is there a density-dependent term?
126  virtual bool is_rd() {return false;}
127  //*************************************************************************
128 
129  //*************************************************************************
130  virtual funcT op_o(const std::vector<funcT>& phis, const funcT& psi);
131  //*************************************************************************
132 
133  };
134  //***************************************************************************
135 
136  //***************************************************************************
137  template <typename T, int NDIM>
138  class HartreeFock : public IEigSolverObserver<T,NDIM>
139  {
140  public:
142  //*************************************************************************
143  // Constructor
144  HartreeFock(World& world, funcT V, std::vector<funcT> phis,
145  std::vector<double> eigs, bool bCoulomb, bool bExchange, double thresh);
146  //*************************************************************************
147 
148  //*************************************************************************
149  // Destructor
150  virtual ~HartreeFock();
151  //*************************************************************************
152 
153  //*************************************************************************
154  void hartree_fock(int maxits);
155  //*************************************************************************
156 
157  //*************************************************************************
158  funcT calculate_coulomb(funcT psi);
159  //*************************************************************************
160 
161  //*************************************************************************
162  funcT calculate_exchange(funcT psi);
163  //*************************************************************************
164 
165  //*************************************************************************
166  double calculate_ke_sp(funcT psi);
167  //*************************************************************************
168 
169  //*************************************************************************
170  double calculate_pe_sp(funcT psi);
171  //*************************************************************************
172 
173  //*************************************************************************
174  double calculate_coulomb_energy(const std::vector<funcT>& phis,
175  const funcT& psi);
176  //*************************************************************************
177 
178  //*************************************************************************
179  double calculate_exchange_energy(const std::vector<funcT>& phis,
180  const funcT& psi);
181  //*************************************************************************
182 
183  //*************************************************************************
184  T matrix_element(const funcT& phii, const funcT& phij)
185  {
186  return _solver->matrix_element(phii, phij);
187  }
188  //*************************************************************************
189 
190  //*************************************************************************
191  virtual void iterateOutput(const std::vector<funcT>& phis,
192  const std::vector<double>& eigs, const funcT& rho, const int& iter);
193  //*************************************************************************
194 
195  //*************************************************************************
197  {
198  return _bCoulomb;
199  }
200  //*************************************************************************
201 
202  //*************************************************************************
204  {
205  return _bExchange;
206  }
207  //*************************************************************************
208 
209  //*************************************************************************
210  double get_eig(int indx)
211  {
212  return _solver->get_eig(indx);
213  }
214  //*************************************************************************
215 
216  //*************************************************************************
217  funcT get_phi(int indx)
218  {
219  return _solver->get_phi(indx);
220  }
221  //*************************************************************************
222 
223  //*************************************************************************
224  const std::vector<double>& eigs()
225  {
226  return _solver->eigs();
227  }
228  //*************************************************************************
229 
230  //*************************************************************************
231  const std::vector<funcT>& phis()
232  {
233  return _solver->phis();
234  }
235  //*************************************************************************
236 
237  //*************************************************************************
238  double calculate_tot_ke_sp(const std::vector<funcT>& phis);
239  //*************************************************************************
240 
241  //*************************************************************************
242  double calculate_tot_pe_sp(const std::vector<funcT>& phis);
243  //*************************************************************************
244 
245  //*************************************************************************
246  double calculate_tot_coulomb_energy(const std::vector<funcT>& phis);
247  //*************************************************************************
248 
249  //*************************************************************************
250  double calculate_tot_exchange_energy(const std::vector<funcT>& phis);
251  //*************************************************************************
252 
253 private:
254 
255  //*************************************************************************
256  // Eigenvalue solver
257  EigSolver<T,NDIM>* _solver;
258  //*************************************************************************
259 
260  //*************************************************************************
261  // Flags for whether to include the coulomb and exchange
262  bool _bCoulomb;
263  bool _bExchange;
264  //*************************************************************************
265 
266  //*************************************************************************
267  World& _world;
268  //*************************************************************************
269 
270  //*************************************************************************
271  funcT _V;
272  //*************************************************************************
273 
274  //*************************************************************************
275  double _thresh;
276  //*************************************************************************
277 
278  //*************************************************************************
279  World& world() {return _world;}
280  //*************************************************************************
281 
282  //*************************************************************************
283  double thresh() {return _thresh;}
284  //*************************************************************************
285 
286  };
287  //***************************************************************************
288 
289 }
290 
291 #endif /*HARTREEFOCK_H_*/
funcT calculate_coulomb(funcT psi)
Definition: eigsolver.h:52
double thresh()
Definition: eigsolver.h:194
Function< T, NDIM > funcT
Definition: hartreefock.h:113
Main include file for MADNESS and defines Function interface.
bool include_exchange()
Definition: hartreefock.h:203
virtual bool is_rd()
Is there a density-dependent term?
Definition: hartreefock.h:97
double calculate_ke_sp(funcT psi)
Definition: hartreefock.cc:167
virtual bool is_od()
Is there an orbitally-dependent term?
Definition: hartreefock.h:92
double coeff()
Definition: eigsolver.h:178
Definition: hartreefock.h:81
void hartree_fock(int maxits)
Definition: hartreefock.cc:159
double calculate_coulomb_energy(const std::vector< funcT > &phis, const funcT &psi)
Definition: hartreefock.cc:190
HartreeFockCoulombOp(World &world, double coeff, double thresh)
Definition: hartreefock.cc:53
double V(const Vector< double, 3 > &r)
Definition: apps/ii/hatom_energy.cc:46
This header should include pretty much everything needed for the parallel runtime.
Function< T, NDIM > funcT
Definition: hartreefock.h:141
Function< T, NDIM > funcT
Definition: hartreefock.h:84
Definition: hartreefock.h:48
const std::vector< funcT > & phis()
Definition: hartreefock.h:231
double calculate_tot_ke_sp(const std::vector< funcT > &phis)
Definition: hartreefock.cc:252
virtual bool is_od()
Is there an orbitally-dependent term?
Definition: hartreefock.h:59
Function< T, NDIM > funcT
Definition: hartreefock.h:51
virtual funcT op_r(const funcT &rho, const funcT &rhon, const funcT &psi)
Definition: hartreefock.cc:73
virtual ~HartreeFock()
Definition: hartreefock.cc:151
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)
Definition: hartreefock.h:110
double calculate_tot_coulomb_energy(const std::vector< funcT > &phis)
Definition: hartreefock.cc:284
double calculate_pe_sp(funcT psi)
Definition: hartreefock.cc:181
funcT get_phi(int indx)
Definition: hartreefock.h:217
double psi(const Vector< double, 3 > &r)
Definition: apps/ii/hatom_energy.cc:42
HartreeFockExchangeOp(World &world, double coeff, double thresh)
Definition: hartreefock.cc:63
double calculate_tot_pe_sp(const std::vector< funcT > &phis)
Definition: hartreefock.cc:268
HartreeFock(World &world, std::shared_ptr< SCF > calc1)
Definition: mp2.h:104
funcT calculate_exchange(funcT psi)
Definition: eigsolver.h:99
A parallel world with full functionality wrapping an MPI communicator.
Definition: worldfwd.h:416
virtual bool is_rd()
Is there a density-dependent term?
Definition: hartreefock.h:126
A multiresolution adaptive numerical function.
Definition: derivative.h:61
double calculate_exchange_energy(const std::vector< funcT > &phis, const funcT &psi)
Definition: hartreefock.cc:222
HartreeFockNuclearPotentialOp(World &world, funcT V, double coeff, double thresh)
Definition: hartreefock.cc:41
virtual funcT op_r(const funcT &rho, const funcT &rhon, const funcT &psi)
Definition: hartreefock.cc:82
Definition: eigsolver.h:226
virtual bool is_od()
Is there an orbitally-dependent term?
Definition: hartreefock.h:121
Definition: mp2.h:85
virtual void iterateOutput(const std::vector< funcT > &phis, const std::vector< double > &eigs, const funcT &rho, const int &iter)
Definition: hartreefock.cc:316
virtual funcT op_o(const std::vector< funcT > &phis, const funcT &psi)
Orbital-dependent portion of operator.
Definition: hartreefock.cc:96
T matrix_element(const funcT &phii, const funcT &phij)
Definition: hartreefock.h:184
virtual bool is_rd()
Is there a density-dependent term?
Definition: hartreefock.h:64
double calculate_tot_exchange_energy(const std::vector< funcT > &phis)
Definition: hartreefock.cc:300
bool include_coulomb()
Definition: hartreefock.h:196
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
double get_eig(int indx)
Definition: hartreefock.h:210
const std::vector< double > & eigs()
Definition: hartreefock.h:224