Psi4
functional.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 FUNCTIONAL_H
29 #define FUNCTIONAL_H
30 
31 #include "psi4/libmints/typedefs.h"
32 #include <map>
33 #include <vector>
34 #include <string>
35 
36 namespace psi {
37 
48 class Functional {
49 
50 protected:
51 
52  // => Meta-Data <= //
53 
54  // Actually (1-\alpha)*w, the final scale of all computed values
55  double alpha_;
56  // Omega, defaults to zero, throws if set for non-omega functionals
57  double omega_;
58 
59  // Name of the functional (shorthand)
60  std::string name_;
61  // Description of functional
62  std::string description_;
63  // Citations(s) defining functionals
64  std::string citation_;
65 
66  // Is GGA?
67  bool gga_;
68  // Is Meta?
69  bool meta_;
70  // Is LRC?
71  bool lrc_;
72 
73  // Parameter set
74  std::map<std::string, double> parameters_;
75 
76  // Densty-based cutoff
77  double lsda_cutoff_;
78  // Tau-based cutoff
79  double meta_cutoff_;
80 
81  // Initialize null functional
82  void common_init();
83 
84 public:
85 
86  // => Constructors (Use the factory constructor, or really know what's up) <= //
87 
88  Functional();
89  virtual ~Functional();
90 
91  // Build a base version of a DFA functional (say B97_X)
92  static std::shared_ptr<Functional> build_base(const std::string& alias);
93 
94  // => Computers <= //
95 
96  virtual void compute_functional(const std::map<std::string,SharedVector>& in, const std::map<std::string,SharedVector>& out, int npoints, int deriv, double alpha) = 0;
97 
98  // => Parameters <= //
99 
100  const std::map<std::string, double>& parameters() { return parameters_; }
101  virtual void set_parameter(const std::string& key, double val);
102 
103  // => Setters <= //
104 
105  void set_gga(bool gga) { gga_ = gga; }
106  void set_meta(bool meta) { meta_ = meta; }
107  void set_alpha(double alpha) { alpha_ = alpha; }
108  void set_omega(double omega) { omega_ = omega; lrc_ = (omega_ != 0.0); }
109  void set_name(const std::string & name) { name_ = name; }
110  void set_description(const std::string & description) { description_ = description; }
111  void set_citation(const std::string & citation) { citation_ = citation; }
112 
113  void set_lsda_cutoff(double cut) { lsda_cutoff_ = cut; }
114  void set_meta_cutoff(double cut) { meta_cutoff_ = cut; }
115 
116  // => Accessors <= //
117 
118  std::string name() const { return name_; }
119  std::string description() const { return description_; }
120  std::string citation() const { return citation_; }
121 
122  bool is_meta() const { return meta_; }
123  bool is_gga() const { return gga_; }
124  bool is_lrc() const { return lrc_; }
125 
126  double alpha() const { return alpha_; }
127  double omega() const { return omega_; }
128 
129  double lsda_cutoff() const { return lsda_cutoff_; }
130  double meta_cutoff() const { return meta_cutoff_; }
131 
132  // => Utility <= //
133  virtual void print(std::string OutFileRMR = "outfile", int print = 1) const;
134  void py_print() const { print("outfile", 1); }
135  void py_print_detail(int level) const { print("outfile", level); }
136 
137 };
138 
139 }
140 
141 #endif
void set_citation(const std::string &citation)
Definition: functional.h:111
std::string name_
Definition: functional.h:60
Functional()
Definition: functional.cc:33
void set_name(const std::string &name)
Definition: functional.h:109
virtual void print(std::string OutFileRMR="outfile", int print=1) const
Definition: functional.cc:58
void set_description(const std::string &description)
Definition: functional.h:110
static std::shared_ptr< Functional > build_base(const std::string &alias)
Definition: libfunctional/factory.cc:51
virtual void set_parameter(const std::string &key, double val)
Definition: functional.cc:54
Definition: functional.h:48
double omega_
Definition: functional.h:57
void set_meta(bool meta)
Definition: functional.h:106
void py_print_detail(int level) const
Definition: functional.h:135
bool is_lrc() const
Definition: functional.h:124
bool lrc_
Definition: functional.h:71
void set_omega(double omega)
Definition: functional.h:108
double alpha() const
Definition: functional.h:126
double lsda_cutoff() const
Definition: functional.h:129
virtual void compute_functional(const std::map< std::string, SharedVector > &in, const std::map< std::string, SharedVector > &out, int npoints, int deriv, double alpha)=0
Definition: functional.cc:87
double meta_cutoff_
Definition: functional.h:79
const std::map< std::string, double > & parameters()
Definition: functional.h:100
void set_gga(bool gga)
Definition: functional.h:105
bool gga_
Definition: functional.h:67
std::string description_
Definition: functional.h:62
std::map< std::string, double > parameters_
Definition: functional.h:74
void set_meta_cutoff(double cut)
Definition: functional.h:114
double lsda_cutoff_
Definition: functional.h:77
std::string description() const
Definition: functional.h:119
double omega() const
Definition: functional.h:127
std::string citation() const
Definition: functional.h:120
std::string name() const
Definition: functional.h:118
void set_lsda_cutoff(double cut)
Definition: functional.h:113
bool is_meta() const
Definition: functional.h:122
void py_print() const
Definition: functional.h:134
double alpha_
Definition: functional.h:55
bool meta_
Definition: functional.h:69
bool is_gga() const
Definition: functional.h:123
std::string citation_
Definition: functional.h:64
double meta_cutoff() const
Definition: functional.h:130
void common_init()
Definition: functional.cc:40
void set_alpha(double alpha)
Definition: functional.h:107
virtual ~Functional()
Definition: functional.cc:37