Psi4
v.h
Go to the documentation of this file.
1 /*
2  * @BEGIN LICENSE
3  *
4  * Psi4: an open-source quantum chemistry software package
5  *
6  * Copyright (c) 2007-2017 The Psi4 Developers.
7  *
8  * The copyrights for code used from other parties are included in
9  * the corresponding files.
10  *
11  * This file is part of Psi4.
12  *
13  * Psi4 is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU Lesser General Public License as published by
15  * the Free Software Foundation, version 3.
16  *
17  * Psi4 is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License along
23  * with Psi4; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  *
26  * @END LICENSE
27  */
28 
29 #ifndef LIBFOCK_DFT_H
30 #define LIBFOCK_DFT_H
31 #include "psi4/libmints/typedefs.h"
32 #include <vector>
33 #include <map>
34 #include <string>
35 
36 namespace psi {
37 class BasisSet;
38 class Options;
39 class DFTGrid;
40 class PointFunctions;
41 class SuperFunctional;
42 class BlockOPoints;
43 
44 // => BASE CLASS <= //
45 
53 class VBase {
54 
55 protected:
57  int debug_;
59  int print_;
63  int nbf_;
71  std::shared_ptr<BasisSet> primary_;
73  std::shared_ptr<SuperFunctional> functional_;
75  std::vector<std::shared_ptr<SuperFunctional>> functional_workers_;
77  std::vector<std::shared_ptr<PointFunctions>> point_workers_;
79  std::shared_ptr<DFTGrid> grid_;
81  std::map<std::string, double> quad_values_;
82 
86 
88  std::vector<SharedMatrix> D_AO_;
89 
90  // GRAC data
92 
93  // VV10 dispersion, return vv10_nlc energy
94  double vv10_nlc(SharedMatrix ret);
95 
97  void common_init();
98 public:
99  VBase(std::shared_ptr<SuperFunctional> functional,
100  std::shared_ptr<BasisSet> primary, Options& options);
101  virtual ~VBase();
102 
103  static std::shared_ptr<VBase> build_V(std::shared_ptr<BasisSet> primary,
104  std::shared_ptr<SuperFunctional> functional,
105  Options& options,
106  const std::string& type = "RV");
107 
108  std::shared_ptr<BasisSet> basis() const { return primary_; }
109  std::shared_ptr<SuperFunctional> functional() const { return functional_; }
110  std::vector<std::shared_ptr<PointFunctions>> properties() const { return point_workers_; }
111  std::shared_ptr<DFTGrid> grid() const { return grid_; }
112  std::shared_ptr<BlockOPoints> get_block(int block);
113  size_t nblocks();
114  std::map<std::string, double>& quadrature_values() { return quad_values_; }
115 
116  // Set the D matrix, get it back if needed
117  void set_D(std::vector<SharedMatrix> Dvec);
118  const std::vector<SharedMatrix>& Dao() const { return D_AO_; }
119 
120  // Set the site of the grac shift
121  void set_grac_shift(double value);
122 
124  virtual void compute_V(std::vector<SharedMatrix> ret);
125  virtual void compute_Vx(std::vector<SharedMatrix> Dx, std::vector<SharedMatrix> ret);
126  virtual SharedMatrix compute_gradient();
127  virtual SharedMatrix compute_hessian();
128 
129  void set_print(int print) { print_ = print; }
130  void set_debug(int debug) { debug_ = debug; }
131 
132  virtual void initialize();
133  virtual void finalize();
134 
135  virtual void print_header() const;
136 };
137 
138 // => Derived Classes <= //
139 
140 class RV : public VBase {
141 
142 protected:
143 
144 public:
145  RV(std::shared_ptr<SuperFunctional> functional,
146  std::shared_ptr<BasisSet> primary,
147  Options& options);
148  virtual ~RV();
149 
150  virtual void initialize();
151  virtual void finalize();
152 
153  virtual void compute_V(std::vector<SharedMatrix> ret);
154  virtual void compute_Vx(std::vector<SharedMatrix> Dx, std::vector<SharedMatrix> ret);
155  virtual SharedMatrix compute_gradient();
156  virtual SharedMatrix compute_hessian();
157 
158  virtual void print_header() const;
159 };
160 
161 class UV : public VBase {
162 
163 protected:
164 
165 public:
166  UV(std::shared_ptr<SuperFunctional> functional,
167  std::shared_ptr<BasisSet> primary,
168  Options& options);
169  virtual ~UV();
170 
171  virtual void initialize();
172  virtual void finalize();
173 
174  virtual void compute_V(std::vector<SharedMatrix> ret);
175  virtual void compute_Vx(std::vector<SharedMatrix> Dx, std::vector<SharedMatrix> ret);
176  virtual SharedMatrix compute_gradient();
177 
178  virtual void print_header() const;
179 };
180 
181 
182 }
183 #endif
void set_debug(int debug)
Definition: v.h:130
virtual void print_header() const
Definition: v.cc:419
std::shared_ptr< DFTGrid > grid_
Integration grid, built by KSPotential.
Definition: v.h:79
std::vector< std::shared_ptr< PointFunctions > > properties() const
Definition: v.h:110
void set_grac_shift(double value)
Definition: v.cc:148
int debug_
Debug flag.
Definition: v.h:57
std::map< std::string, double > & quadrature_values()
Definition: v.h:114
double vv10_rho_cutoff_
VV10 interior kernel threshold.
Definition: v.h:67
virtual void compute_Vx(std::vector< SharedMatrix > Dx, std::vector< SharedMatrix > ret)
Definition: v.cc:636
std::shared_ptr< DFTGrid > grid() const
Definition: v.h:111
Options & options_
Options object, used to build grid.
Definition: v.h:69
void set_D(std::vector< SharedMatrix > Dvec)
Definition: v.cc:94
double v2_rho_cutoff_
Rho threshold for the second derivative;.
Definition: v.h:65
virtual void compute_Vx(std::vector< SharedMatrix > Dx, std::vector< SharedMatrix > ret)
Definition: v.cc:1704
virtual void print_header() const
Definition: v.cc:195
virtual void compute_V(std::vector< SharedMatrix > ret)
Throws by default.
Definition: v.cc:420
virtual void compute_V(std::vector< SharedMatrix > ret)
Throws by default.
Definition: v.cc:1442
virtual void compute_V(std::vector< SharedMatrix > ret)
Throws by default.
Definition: v.cc:142
void set_print(int print)
Definition: v.h:129
std::shared_ptr< BasisSet > primary_
Basis set used in the integration.
Definition: v.h:71
std::vector< std::shared_ptr< SuperFunctional > > functional_workers_
Desired superfunctional kernal.
Definition: v.h:75
virtual SharedMatrix compute_hessian()
Definition: v.cc:141
void common_init()
Set things up.
Definition: v.cc:64
virtual void finalize()
Definition: v.cc:202
size_t nblocks()
Definition: v.cc:201
virtual ~RV()
Definition: v.cc:406
SharedMatrix USO2AO_
Definition: v.h:85
std::shared_ptr< BlockOPoints > get_block(int block)
Definition: v.cc:200
virtual void finalize()
Definition: v.cc:1440
virtual void initialize()
Definition: v.cc:130
virtual void print_header() const
Definition: v.cc:1441
Definition: v.h:53
bool grac_initialized_
Definition: v.h:91
std::map< std::string, double > quad_values_
Quadrature values obtained during integration.
Definition: v.h:81
double vv10_nlc(SharedMatrix ret)
Definition: v.cc:204
Definition: v.h:161
SharedMatrix AO2USO_
AO2USO matrix (if not C1)
Definition: v.h:84
int print_
Print flag.
Definition: v.h:59
std::vector< SharedMatrix > D_AO_
Vector of C1 D matrices (built by USO2AO)
Definition: v.h:88
UV(std::shared_ptr< SuperFunctional > functional, std::shared_ptr< BasisSet > primary, Options &options)
Definition: v.cc:1426
virtual ~VBase()
Definition: v.cc:63
virtual void initialize()
Definition: v.cc:407
Definition: liboptions.h:355
VBase(std::shared_ptr< SuperFunctional > functional, std::shared_ptr< BasisSet > primary, Options &options)
Definition: v.cc:59
std::shared_ptr< BasisSet > basis() const
Definition: v.h:108
RV(std::shared_ptr< SuperFunctional > functional, std::shared_ptr< BasisSet > primary, Options &options)
Definition: v.cc:404
virtual SharedMatrix compute_gradient()
Definition: v.cc:900
int num_threads_
Number of threads.
Definition: v.h:61
static std::shared_ptr< VBase > build_V(std::shared_ptr< BasisSet > primary, std::shared_ptr< SuperFunctional > functional, Options &options, const std::string &type="RV")
Definition: v.cc:75
virtual ~UV()
Definition: v.cc:1428
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
int nbf_
Number of basis functions;.
Definition: v.h:63
virtual void finalize()
Definition: v.cc:418
std::shared_ptr< SuperFunctional > functional() const
Definition: v.h:109
virtual SharedMatrix compute_gradient()
Definition: v.cc:140
Definition: v.h:140
std::vector< std::shared_ptr< PointFunctions > > point_workers_
Point function computer (densities, gammas, basis values)
Definition: v.h:77
const std::vector< SharedMatrix > & Dao() const
Definition: v.h:118
std::shared_ptr< SuperFunctional > functional_
Desired superfunctional kernal.
Definition: v.h:73
virtual void compute_Vx(std::vector< SharedMatrix > Dx, std::vector< SharedMatrix > ret)
Definition: v.cc:145
virtual void initialize()
Definition: v.cc:1429
virtual SharedMatrix compute_gradient()
Definition: v.cc:2177
virtual SharedMatrix compute_hessian()
Definition: v.cc:1166