QMCPACK
test_gaussian_basis.cpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
8 //
9 // File created by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "catch.hpp"
15 
16 #include <stdio.h>
17 #include <string>
18 
19 using std::string;
20 
22 
23 namespace qmcplusplus
24 {
25 TEST_CASE("Basic Gaussian", "[numerics]")
26 {
28 
29  real_type alpha = 3.0;
30  g1.reset(alpha, 1.0);
31 
32  real_type r = 1.2;
33 
34  real_type f = g1.f(r * r);
35  //std::cout << "f = " << f << std::endl << std::endl;
36  CHECK(f == Approx(0.0132998835424438));
37 
38  real_type df = g1.df(r, r * r);
39  //std::cout << "df = " << df << std::endl << std::endl;
40  CHECK(df == Approx(-0.0957591615055951));
41 
42  df = 0.0;
43  real_type ddf = 0.0;
44  f = g1.evaluate(r, r * r, df, ddf);
45  //std::cout << "f = " << f << " " << df << " " << ddf << std::endl;
46  CHECK(f == Approx(0.0132998835424438));
47  CHECK(df == Approx(-0.0957591615055951));
48  CHECK(ddf == Approx(0.609666661585622));
49 
50  df = 0.0;
51  ddf = 0.0;
52  real_type d3f = 0.0;
53  f = g1.evaluate(r, r * r, df, ddf, d3f);
54  //std::cout << "f = " << f << " " << df << " " << ddf << " " << d3f << std::endl;
55  CHECK(f == Approx(0.0132998835424438));
56  CHECK(df == Approx(-0.0957591615055951));
57  CHECK(ddf == Approx(0.609666661585622));
58  CHECK(d3f == Approx(-3.24049002534934));
59 }
60 
61 TEST_CASE("Gaussian Combo", "[numerics]")
62 {
63  GaussianCombo<real_type> gc(0, false);
64 
65  // STO-3G for H
66  gc.addGaussian(0.15432897, 3.42525091);
67  gc.addGaussian(0.53532814, 0.62391373);
68  gc.addGaussian(0.44463454, 0.16885540);
69 
70  REQUIRE(gc.size() == 3);
71 
72  real_type r = 1.3;
73  real_type f = gc.f(r);
74  //std::cout << "f = " << f << std::endl << std::endl;
75  CHECK(f == Approx(0.556240444149480));
76 
77  f = gc.evaluate(r, 1.0 / r);
78  CHECK(f == Approx(0.556240444149480));
79 
80  real_type df = gc.df(r);
81  CHECK(df == Approx(-0.661028435778766));
82 
83  gc.evaluateAll(r, 1.0 / r);
84  CHECK(gc.Y == Approx(0.556240444149480));
85  CHECK(gc.dY == Approx(-0.661028435778766));
86  CHECK(gc.d2Y == Approx(0.643259180749128));
87 
88  gc.evaluateWithThirdDeriv(r, 1.0 / r);
89  CHECK(gc.Y == Approx(0.556240444149480));
90  CHECK(gc.dY == Approx(-0.661028435778766));
91  CHECK(gc.d2Y == Approx(0.643259180749128));
92  CHECK(gc.d3Y == Approx(-0.896186412781167));
93 }
94 
95 TEST_CASE("Gaussian Combo P", "[numerics]")
96 {
97  GaussianCombo<real_type> gc(1, false);
98 
99  // cc-pVDZ for C, the 2P basis
100  gc.addGaussian(0.0381090, 9.4390000);
101  gc.addGaussian(0.2094800, 2.0020000);
102  gc.addGaussian(0.5085570, 0.5456000);
103 
104  REQUIRE(gc.size() == 3);
105 
106  real_type r = 1.3;
107  real_type f = gc.f(r);
108 
109  CHECK(f == Approx(0.326057642350121));
110 
111  f = gc.evaluate(r, 1.0 / r);
112  CHECK(f == Approx(0.326057642350121));
113 
114  real_type df = gc.df(r);
115  CHECK(df == Approx(-0.649531407846947));
116 
117  gc.evaluateAll(r, 1.0 / r);
118  CHECK(gc.Y == Approx(0.326057642350121));
119  CHECK(gc.dY == Approx(-0.649531407846947));
120  CHECK(gc.d2Y == Approx(1.39522444199589));
121 
122  gc.evaluateWithThirdDeriv(r, 1.0 / r);
123  CHECK(gc.Y == Approx(0.326057642350121));
124  CHECK(gc.dY == Approx(-0.649531407846947));
125  CHECK(gc.d2Y == Approx(1.39522444199589));
126  CHECK(gc.d3Y == Approx(-3.38467690038774));
127 }
128 
129 TEST_CASE("Gaussian Combo D", "[numerics]")
130 {
131  GaussianCombo<real_type> gc(2, false);
132 
133  // cc-pVDZ for C, the 3D basis
134  gc.addGaussian(1.0, 0.5500000);
135 
136  REQUIRE(gc.size() == 1);
137 
138  real_type r = 1.3;
139  real_type f = gc.f(r);
140 
141  CHECK(f == Approx(0.361815669819519));
142 
143  f = gc.evaluate(r, 1.0 / r);
144  CHECK(f == Approx(0.361815669819519));
145 
146  real_type df = gc.df(r);
147  CHECK(df == Approx(-0.517396407841913));
148 
149  gc.evaluateAll(r, 1.0 / r);
150  CHECK(gc.Y == Approx(0.361815669819519));
151  CHECK(gc.dY == Approx(-0.517396407841913));
152  CHECK(gc.d2Y == Approx(0.341879626412464));
153 
154  gc.evaluateWithThirdDeriv(r, 1.0 / r);
155  CHECK(gc.Y == Approx(0.361815669819519));
156  CHECK(gc.dY == Approx(-0.517396407841913));
157  CHECK(gc.d2Y == Approx(0.341879626412464));
158  CHECK(gc.d3Y == Approx(0.649384231482385));
159 }
160 } // namespace qmcplusplus
real_type evaluate(real_type r, real_type rinv)
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
void reset(real_type sig, real_type c)
#define OHMMS_PRECISION
Definition: config.h:70
TEST_CASE("complex_helper", "[type_traits]")
real_type f(real_type r)
void evaluateWithThirdDeriv(real_type r, real_type rinv)
int size() const
return the number Gaussians
real_type df(real_type r)
REQUIRE(std::filesystem::exists(filename))
real_type evaluate(real_type r, real_type rr, real_type &du, real_type &d2u)
OHMMS_PRECISION real_type
void evaluateAll(real_type r, real_type rinv)
OHMMS_PRECISION real_type
real_type df(real_type r, real_type rr) const
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
void addGaussian(real_type c, real_type alpha)