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