Psi4
gaussquad.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) 2016-2017 Robert A. Shaw.
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 /* class GCQuadrature contains the information and methods needed to carry out
30  Gauss-Chebyshev quadrature of the second kind.
31 
32  Robert A. Shaw 2016
33 
34  REFERENCES:
35  (Perez92) J.M. Perez-Jorda et al., Comput. Phys. Comm. 70 (1992), 271-284
36  (Perez93) J.M. Perez-Jorda et al., Comput. Phys. Comm. 77 (1993), 46-56
37  (Krack98) M. Krack, A.M. Koster, J. Chem. Phys. 108 (1998), 3226 - 3234
38  (Flores06) R. Flores-Moreno et al., J. Comput. Chem. 27 (2006), 1009-1019
39 */
40 
41 #ifndef GC_QUAD_HEAD
42 #define GC_QUAD_HEAD
43 
44 #include <vector>
45 #include <functional>
46 
47 namespace psi {
48 
49 enum GCTYPE {
50  ONEPOINT, // Described in Perez92
51  TWOPOINT // Described in Perez93
52 };
53 
62 class GCQuadrature {
63  private:
65  int maxN;
67  int M;
68 
70  std::vector<double> x;
72  std::vector<double> w;
74  double I;
75 
78 
80  double sumTerms(std::function<double(double, double *, int)> &f, double *p, int limit, int shift, int skip);
81 
82  public:
84  int start, end;
85 
87  GCQuadrature();
89  GCQuadrature(const GCQuadrature &other);
90 
99  void initGrid(int points, GCTYPE t);
100 
108  bool integrate(std::function<double(double, double *, int)> &f, double *params, const double tolerance);
109 
113  void transformZeroInf();
121  void transformRMinMax(double z, double p); // Transfromation from [-1, 1] to [rmin, rmax] from Flores06
122 
124  double getI() const { return I; }
125 
127  int getN() const { return maxN; }
128 
130  std::vector<double> &getX() { return x; }
131 };
132 } // namespace psi
133 
134 #endif
void transformZeroInf()
Definition: gaussquad.cc:250
int end
Definition: gaussquad.h:84
double sumTerms(std::function< double(double, double *, int)> &f, double *p, int limit, int shift, int skip)
Worker function for integration routines, should not be called directly.
Definition: gaussquad.cc:233
Definition: gaussquad.h:50
double getI() const
Returns the calculated integral value - must have called integrate first.
Definition: gaussquad.h:124
Performs adaptive Gauss-Chebyshev quadrature for any given function.
Definition: gaussquad.h:62
std::vector< double > & getX()
Returns a reference to the abscissae.
Definition: gaussquad.h:130
void initGrid(int points, GCTYPE t)
Definition: gaussquad.cc:58
double I
Integration value.
Definition: gaussquad.h:74
std::vector< double > x
Weights.
Definition: gaussquad.h:70
void transformRMinMax(double z, double p)
Definition: gaussquad.cc:261
int M
Index of midpoint.
Definition: gaussquad.h:67
Definition: gaussquad.h:51
std::vector< double > w
Abscissae.
Definition: gaussquad.h:72
int getN() const
Returns the maximum number of quadrature points.
Definition: gaussquad.h:127
GCTYPE t
Algorithm to be used.
Definition: gaussquad.h:77
int start
Start and endpoints of integration, used for prescreening.
Definition: gaussquad.h:84
EXTERN struct Params params
Definition: cc/ccdensity/globals.h:55
bool integrate(std::function< double(double, double *, int)> &f, double *params, const double tolerance)
Definition: gaussquad.cc:130
GCQuadrature()
Default constructor, creates empty object.
Definition: gaussquad.cc:41
int maxN
Maximum number of points to use in quadrature.
Definition: gaussquad.h:65
GCTYPE
Definition: gaussquad.h:49