MADNESS  version 0.9
tkato/SCF.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 $Id$
33 */
34 
38 
39 #ifndef MADNESS_SCF_H
40 #define MADNESS_SCF_H
41 
42 #include <madness/mra/mra.h>
43 #include <moldft/xcfunctional.h>
44 #include <moldft/molecule.h>
45 #include <moldft/molecularbasis.h>
46 #include <tkato/scfparam.h>
47 #include <tkato/molsys.h>
48 
50 tensorT Q3(const madness::Tensor<double>& s);
51 
52 struct SCF {
54  typedef std::vector<functionT> vecfuncT;
55  typedef std::pair<vecfuncT,vecfuncT> pairvecfuncT;
56  typedef std::vector<pairvecfuncT> subspaceT;
57  typedef madness::Tensor<double> tensorT;
60 
66  functionT vnuc;
67  functionT mask;
68  vecfuncT ao;
69  std::vector<int> at_to_bf, at_nbf;
70  poperatorT coulop;
71  std::vector< std::shared_ptr<real_derivative_3d> > gradop;
72  double vtol;
74 
75  SCF(World & world, const char *filename);
76 
77  void set_protocol(World & world, double thresh);
78 
79  void save_mos(World& world);
80 
81  void load_mos(World& world);
82 
83  void do_plots(World& world);
84 
85  void project(World & world);
86 
87  void make_nuclear_potential(World & world);
88 
89  void project_ao_basis(World & world);
90 
91  double PM_q(const tensorT & S, const tensorT & C, int i, int j, int lo, int nbf);
92 
93  void localize_PM_task_kernel(tensorT & Q, std::vector<tensorT> & Svec, tensorT & C,
94  const bool & doprint, const std::vector<int> & set,
95  const double thetamax, tensorT & U, const double thresh);
96 
97  tensorT localize_PM(World & world, const vecfuncT & mo, const std::vector<int> & set, const double thresh = 1e-9, const double thetamax = 0.5, const bool randomize = true, const bool doprint = true);
98 
99  void analyze_vectors(World & world, const vecfuncT & mo, const tensorT & occ = tensorT(), const tensorT & energy = tensorT(), const std::vector<int> & set = std::vector<int>());
100 
101  inline double DIP(const tensorT & dip, int i, int j, int k, int l);
102 
103  tensorT localize_boys(World & world, const vecfuncT & mo, const std::vector<int> & set, const double thresh = 1e-9, const double thetamax = 0.5, const bool randomize = true);
104 
105  tensorT kinetic_energy_matrix(World & world, const vecfuncT & v);
106 
107  vecfuncT core_projection(World & world, const vecfuncT & psi, const bool include_Bc = true);
108 
109  double core_projector_derivative(World & world, const vecfuncT & mo, const tensorT & occ, int atom, int axis);
110 
111  void initial_guess(World & world);
112 
113  void initial_load_bal(World & world);
114 
115  functionT make_density(World & world, const tensorT & occ, const vecfuncT & v);
116 
117  std::vector<poperatorT> make_bsh_operators(World & world, const tensorT & evals);
118 
119  vecfuncT apply_hf_exchange(World & world, const tensorT & occ, const vecfuncT & psi, const vecfuncT & f);
120 
121  // Used only for initial guess that is always spin-restricted LDA
122  functionT make_lda_potential(World & world, const functionT & arho);
123 
124 
125  functionT make_dft_potential(World & world, const vecfuncT& vf, int what);
126 
127  double make_dft_energy(World & world, const vecfuncT& vf);
128 
129  vecfuncT apply_potential(World & world, const tensorT & occ, const vecfuncT & amo,
130  const vecfuncT& vf, const vecfuncT& delrho, const functionT & vlocal, double & exc, int ispin);
131 
132  tensorT derivatives(World & world);
133 
134  tensorT dipole(World & world);
135 
136  void vector_stats(const std::vector<double> & v, double & rms, double & maxabsval);
137 
138  vecfuncT compute_residual(World & world, tensorT & occ, tensorT & fock, const vecfuncT & psi, vecfuncT & Vpsi, double & err);
139 
140  tensorT make_fock_matrix(World & world, const vecfuncT & psi, const vecfuncT & Vpsi, const tensorT & occ, double & ekinetic);
141 
143 
146  Tensor<double> twoint(World& world, const vecfuncT& psi);
147 
148  tensorT matrix_exponential(const tensorT& A);
149 
150  tensorT diag_fock_matrix(World & world, tensorT& fock, vecfuncT & psi, vecfuncT & Vpsi, tensorT & evals, const tensorT & occ, double thresh);
151 
152  void loadbal(World & world, functionT & arho, functionT & brho, functionT & arho_old, functionT & brho_old, subspaceT & subspace);
153 
154  void rotate_subspace(World& world, const tensorT& U, subspaceT& subspace, int lo, int nfunc, double trantol);
155 
156  void update_subspace(World & world,
157  vecfuncT & Vpsia, vecfuncT & Vpsib,
158  tensorT & focka, tensorT & fockb,
159  subspaceT & subspace, tensorT & Q,
160  double & bsh_residual, double & update_residual);
161 
162  // For given protocol, solve the DFT/HF/response equations
163  void solve(World & world);
164 };
165 
166 
167 #endif
168 
SCFParameters param
Definition: tkato/SCF.h:63
std::vector< int > at_to_bf
Definition: tkato/SCF.h:69
tensorT dipole(World &world)
vecfuncT apply_hf_exchange(World &world, const tensorT &occ, const vecfuncT &psi, const vecfuncT &f)
Definition: tkato/SCF.cc:1126
std::shared_ptr< operatorT > poperatorT
Definition: tkato/SCF.h:59
Tensor< double > tensorT
Definition: DFcode/distpm.cc:13
Main include file for MADNESS and defines Function interface.
void localize_PM_task_kernel(tensorT &Q, std::vector< tensorT > &Svec, tensorT &C, const bool &doprint, const std::vector< int > &set, const double thetamax, tensorT &U, const double thresh)
Definition: tkato/SCF.cc:568
void set_protocol(World &world, double thresh)
double make_dft_energy(World &world, const vecfuncT &vf)
Definition: tkato/SCF.cc:1213
MolecularSystem molsys
Definition: tkato/SCF.h:61
std::vector< poperatorT > make_bsh_operators(World &world, const tensorT &evals)
madness::Function< double, 3 > functionT
Definition: tkato/SCF.h:53
std::vector< pairvecfuncT > subspaceT
Definition: tkato/SCF.h:56
madness::SeparatedConvolution< double, 3 > operatorT
Definition: tkato/SCF.h:58
madness::Tensor< double > tensorT
Definition: tkato/SCF.h:57
void make_nuclear_potential(World &world)
void initial_guess(World &world)
Simplified interface to XC functionals.
Definition: DFcode/xcfunctional.h:52
void solve(World &world)
NDIM & f
Definition: mra.h:2179
Definition: DFcode/molecule.h:82
std::pair< vecfuncT, vecfuncT > pairvecfuncT
Definition: tkato/SCF.h:55
double vtol
Definition: tkato/SCF.h:72
vecfuncT compute_residual(World &world, tensorT &occ, tensorT &fock, const vecfuncT &psi, vecfuncT &Vpsi, double &err)
void loadbal(World &world, functionT &arho, functionT &brho, functionT &arho_old, functionT &brho_old, subspaceT &subspace)
AtomicBasisSet aobasis
Definition: tkato/SCF.h:65
SCF(World &world, const char *filename)
double PM_q(const tensorT &S, const tensorT &C, int i, int j, int lo, int nbf)
Definition: tkato/SCF.cc:549
JLOOP2 NK jnz KLOOP2 mov C
Definition: mtxm_gen.h:10
void update_subspace(World &world, vecfuncT &Vpsia, vecfuncT &Vpsib, tensorT &focka, tensorT &fockb, subspaceT &subspace, tensorT &Q, double &bsh_residual, double &update_residual)
Tensor< double > twoint(World &world, const vecfuncT &psi)
Compute the two-electron integrals over the provided set of orbitals.
Definition: tkato/SCF.cc:1462
tensorT Q3(const madness::Tensor< double > &s)
Given overlap matrix, return rotation with 3rd order error to orthonormalize the vectors.
Definition: chem/SCF.cc:161
tensorT localize_boys(World &world, const vecfuncT &mo, const std::vector< int > &set, const double thresh=1e-9, const double thetamax=0.5, const bool randomize=true)
Definition: tkato/SCF.cc:734
double psi(const Vector< double, 3 > &r)
Definition: apps/ii/hatom_energy.cc:42
tensorT kinetic_energy_matrix(World &world, const vecfuncT &v)
Definition: tkato/SCF.cc:860
poperatorT coulop
Definition: tkato/SCF.h:70
functionT make_dft_potential(World &world, const vecfuncT &vf, int what)
Definition: tkato/SCF.cc:1208
std::vector< std::shared_ptr< real_derivative_3d > > gradop
Definition: tkato/SCF.h:71
Definition: scfparam.h:49
void save_mos(World &world)
Definition: molsys.h:46
functionT make_density(World &world, const tensorT &occ, const vecfuncT &v)
tensorT matrix_exponential(const tensorT &A)
Definition: tkato/SCF.cc:1483
XCfunctional xc
Definition: tkato/SCF.h:64
double core_projector_derivative(World &world, const vecfuncT &mo, const tensorT &occ, int atom, int axis)
Molecule molecule
Definition: tkato/SCF.h:62
void vector_stats(const std::vector< double > &v, double &rms, double &maxabsval)
Definition: tkato/SCF.cc:1377
double current_energy
Definition: tkato/SCF.h:73
vecfuncT apply_potential(World &world, const tensorT &occ, const vecfuncT &amo, const vecfuncT &vf, const vecfuncT &delrho, const functionT &vlocal, double &exc, int ispin)
Definition: tkato/SCF.cc:1219
functionT make_lda_potential(World &world, const functionT &arho)
double energy(World &world, const Function< T, 3 > &psi, const Function< T, 3 > &potn)
Definition: extra.cc:272
void project_ao_basis(World &world)
Parameters of the SCF calculation.
void initial_load_bal(World &world)
std::vector< int > at_nbf
Definition: tkato/SCF.h:69
void project(World &world)
Definition: tkato/SCF.h:52
void do_plots(World &world)
tensorT make_fock_matrix(World &world, const vecfuncT &psi, const vecfuncT &Vpsi, const tensorT &occ, double &ekinetic)
Definition: tkato/SCF.cc:1439
tensorT localize_PM(World &world, const vecfuncT &mo, const std::vector< int > &set, const double thresh=1e-9, const double thetamax=0.5, const bool randomize=true, const bool doprint=true)
represents molecular system
void rotate_subspace(World &world, const tensorT &U, subspaceT &subspace, int lo, int nfunc, double trantol)
Definition: tkato/SCF.cc:1643
void load_mos(World &world)
vecfuncT ao
Definition: tkato/SCF.h:68
functionT mask
Definition: tkato/SCF.h:67
tensorT diag_fock_matrix(World &world, tensorT &fock, vecfuncT &psi, vecfuncT &Vpsi, tensorT &evals, const tensorT &occ, double thresh)
Definition: tkato/SCF.cc:1519
void analyze_vectors(World &world, const vecfuncT &mo, const tensorT &occ=tensorT(), const tensorT &energy=tensorT(), const std::vector< int > &set=std::vector< int >())
vecfuncT core_projection(World &world, const vecfuncT &psi, const bool include_Bc=true)
std::vector< functionT > vecfuncT
Definition: tkato/SCF.h:54
functionT vnuc
Definition: tkato/SCF.h:66
Contracted Gaussian basis.
Definition: DFcode/molecularbasis.h:390
double DIP(const tensorT &dip, int i, int j, int k, int l)
tensorT derivatives(World &world)