Psi4
superfunctional.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 program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program 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 General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  *
25  * @END LICENSE
26  */
27 
28 #ifndef SUPERFUNCTIONAL_H
29 #define SUPERFUNCTIONAL_H
30 
31 #include "psi4/libmints/typedefs.h"
32 #include <map>
33 #include <vector>
34 #include <cstdlib>
35 #include <string>
36 namespace psi {
37 
38 class Options;
39 class Functional;
40 
69 
70 protected:
71 
72  // => Meta-Data <= //
73 
74  std::string name_;
75  std::string description_;
76  std::string citation_;
77 
78  // => Exchange-side DFA functionals <= //
79 
80  std::vector<std::shared_ptr<Functional> > x_functionals_;
81  double x_alpha_;
82  double x_omega_;
83 
84  // => Correlation-side DFA functionals <= //
85 
86  std::vector<std::shared_ptr<Functional> > c_functionals_;
87  double c_alpha_;
88  double c_ss_alpha_;
89  double c_os_alpha_;
90  double c_omega_;
91 
92  // => Functional values and partials <= //
93 
95  int deriv_;
96  std::map<std::string, SharedVector> values_;
97 
98  // The omegas or alphas have changed, we're in a GKS environment.
99  // Update the short-range DFAs
100  void partition_gks();
101  // Set up a null Superfunctional
102  void common_init();
103 
104 public:
105 
106  // => Constructors (Use the factory constructor, or really know what's up) <= //
107 
108  SuperFunctional();
109  virtual ~SuperFunctional();
110 
111  static std::shared_ptr<SuperFunctional> blank();
112 
113  // Allocate values (MUST be called after adding new functionals to the superfunctional)
114  void allocate();
115 
116  // => Computers <= //
117 
118  std::map<std::string, SharedVector>& compute_functional(const std::map<std::string, SharedVector>& vals, int npoints = -1);
119  void test_functional(SharedVector rho_a,
120  SharedVector rho_b,
121  SharedVector gamma_aa,
122  SharedVector gamma_ab,
123  SharedVector gamma_bb,
124  SharedVector tau_a,
125  SharedVector tau_b);
126 
127  // => Input/Output <= //
128 
129  std::map<std::string, SharedVector>& values() { return values_; }
130  SharedVector value(const std::string& key);
131 
132  std::vector<std::shared_ptr<Functional> >& x_functionals() { return x_functionals_; }
133  std::vector<std::shared_ptr<Functional> >& c_functionals() { return c_functionals_; }
134 
135  std::shared_ptr<Functional> x_functional(const std::string& name);
136  std::shared_ptr<Functional> c_functional(const std::string& name);
137  void add_x_functional(std::shared_ptr<Functional> fun);
138  void add_c_functional(std::shared_ptr<Functional> fun);
139 
140  // => Setters <= //
141 
142  void set_name(const std::string & name) { name_ = name; }
143  void set_description(const std::string & description) { description_ = description; }
144  void set_citation(const std::string & citation) { citation_ = citation; }
145 
147  void set_deriv(int deriv) { deriv_ = deriv; allocate(); }
148 
149  void set_x_omega(double omega) { x_omega_ = omega; partition_gks(); }
150  void set_c_omega(double omega) { c_omega_ = omega; partition_gks(); }
151  void set_x_alpha(double alpha) { x_alpha_ = alpha; partition_gks(); }
152  void set_c_alpha(double alpha) { c_alpha_ = alpha; partition_gks(); }
153  void set_c_ss_alpha(double alpha) { c_ss_alpha_ = alpha; partition_gks(); }
154  void set_c_os_alpha(double alpha) { c_os_alpha_ = alpha; partition_gks(); }
155 
156  // => Accessors <= //
157 
158  std::string name() const { return name_; }
159  std::string description() const { return description_; }
160  std::string citation() const { return citation_; }
161 
162  int ansatz() const;
163  int max_points() const { return max_points_; }
164  int deriv() const { return deriv_; }
165 
166  double x_omega() const { return x_omega_; }
167  double c_omega() const { return c_omega_; }
168  double x_alpha() const { return x_alpha_; }
169  double c_alpha() const { return c_alpha_; }
170  double c_ss_alpha() const { return c_ss_alpha_; }
171  double c_os_alpha() const { return c_os_alpha_; }
172 
173  bool needs_xc() const { return ((c_functionals_.size() + x_functionals_.size()) > 0); }
174  bool is_meta() const;
175  bool is_gga() const;
176  bool is_x_lrc() const { return x_omega_ != 0.0; }
177  bool is_c_lrc() const { return c_omega_ != 0.0; }
178  bool is_x_hybrid() const { return x_alpha_ != 0.0; }
179  bool is_c_hybrid() const { return c_alpha_ != 0.0; }
180  bool is_c_scs_hybrid() const { return c_os_alpha_ != 0.0 || c_ss_alpha_ != 0.0; }
181 
182  // => Utility <= //
183 
184  void print(std::string OutFileRMR = "outfile", int print = 1) const;
185  void py_print() const { print("outfile", 1); }
186  void py_print_detail(int level) const { print("outfile", level); }
187 
188 };
189 
190 }
191 
192 #endif
void set_c_alpha(double alpha)
Definition: superfunctional.h:152
std::map< std::string, SharedVector > & values()
Definition: superfunctional.h:129
std::vector< std::shared_ptr< Functional > > & x_functionals()
Definition: superfunctional.h:132
void allocate()
Definition: superfunctional.cc:205
double c_ss_alpha() const
Definition: superfunctional.h:170
void set_c_ss_alpha(double alpha)
Definition: superfunctional.h:153
double c_alpha() const
Definition: superfunctional.h:169
std::map< std::string, SharedVector > values_
Definition: superfunctional.h:96
double x_omega_
Definition: superfunctional.h:82
double c_omega_
Definition: superfunctional.h:90
bool is_meta() const
Definition: superfunctional.cc:182
int deriv_
Definition: superfunctional.h:95
std::string description() const
Definition: superfunctional.h:159
void set_deriv(int deriv)
Definition: superfunctional.h:147
std::vector< std::shared_ptr< Functional > > & c_functionals()
Definition: superfunctional.h:133
void set_max_points(int max_points)
Definition: superfunctional.h:146
bool is_c_hybrid() const
Definition: superfunctional.h:179
std::string name() const
Definition: superfunctional.h:158
void add_x_functional(std::shared_ptr< Functional > fun)
Definition: superfunctional.cc:146
bool is_c_scs_hybrid() const
Definition: superfunctional.h:180
double x_alpha_
Definition: superfunctional.h:81
std::vector< std::shared_ptr< Functional > > c_functionals_
Definition: superfunctional.h:86
bool is_c_lrc() const
Definition: superfunctional.h:177
double x_alpha() const
Definition: superfunctional.h:168
void set_c_os_alpha(double alpha)
Definition: superfunctional.h:154
SuperFunctional()
Definition: superfunctional.cc:37
void py_print() const
Definition: superfunctional.h:185
std::shared_ptr< Functional > x_functional(const std::string &name)
Definition: superfunctional.cc:162
bool is_x_lrc() const
Definition: superfunctional.h:176
std::shared_ptr< Functional > c_functional(const std::string &name)
Definition: superfunctional.cc:154
double c_os_alpha_
Definition: superfunctional.h:89
void set_name(const std::string &name)
Definition: superfunctional.h:142
void test_functional(SharedVector rho_a, SharedVector rho_b, SharedVector gamma_aa, SharedVector gamma_ab, SharedVector gamma_bb, SharedVector tau_a, SharedVector tau_b)
Definition: superfunctional.cc:311
void set_x_omega(double omega)
Definition: superfunctional.h:149
void set_c_omega(double omega)
Definition: superfunctional.h:150
double c_ss_alpha_
Definition: superfunctional.h:88
std::string description_
Definition: superfunctional.h:75
int deriv() const
Definition: superfunctional.h:164
void partition_gks()
Definition: superfunctional.cc:194
bool is_x_hybrid() const
Definition: superfunctional.h:178
int max_points() const
Definition: superfunctional.h:163
void common_init()
Definition: superfunctional.cc:44
bool needs_xc() const
Definition: superfunctional.h:173
void add_c_functional(std::shared_ptr< Functional > fun)
Definition: superfunctional.cc:150
std::string citation() const
Definition: superfunctional.h:160
std::string name_
Definition: superfunctional.h:74
void print(std::string OutFileRMR="outfile", int print=1) const
Definition: superfunctional.cc:62
double x_omega() const
Definition: superfunctional.h:166
void set_description(const std::string &description)
Definition: superfunctional.h:143
void set_x_alpha(double alpha)
Definition: superfunctional.h:151
double c_alpha_
Definition: superfunctional.h:87
Definition: superfunctional.h:68
void py_print_detail(int level) const
Definition: superfunctional.h:186
static std::shared_ptr< SuperFunctional > blank()
Definition: superfunctional.cc:58
bool is_gga() const
Definition: superfunctional.cc:170
int ansatz() const
Definition: superfunctional.cc:333
std::vector< std::shared_ptr< Functional > > x_functionals_
Definition: superfunctional.h:80
double c_omega() const
Definition: superfunctional.h:167
double c_os_alpha() const
Definition: superfunctional.h:171
std::string citation_
Definition: superfunctional.h:76
int max_points_
Definition: superfunctional.h:94
void set_citation(const std::string &citation)
Definition: superfunctional.h:144
std::map< std::string, SharedVector > & compute_functional(const std::map< std::string, SharedVector > &vals, int npoints=-1)
Definition: superfunctional.cc:293
std::shared_ptr< Vector > SharedVector
Definition: adc.h:52
virtual ~SuperFunctional()
Definition: superfunctional.cc:41
SharedVector value(const std::string &key)
Definition: superfunctional.cc:329