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