QMCPACK
test_multiquintic_spline.cpp
Go to the documentation of this file.
1 
2 //////////////////////////////////////////////////////////////////////////////////////
3 // This file is distributed under the University of Illinois/NCSA Open Source License.
4 // See LICENSE file in top directory for details.
5 //
6 // Copyright (c) 2018 Jeongnim Kim and QMCPACK developers.
7 //
8 // File developed by: Mark Dewing, mdewing@anl.gov, Argonne National Laboratory
9 //
10 // File created by: Mark Dewing, mdewing@anl.gov, Argonne National Laboratory
11 //////////////////////////////////////////////////////////////////////////////////////
12 
13 
14 #include "catch.hpp"
15 
16 #include "Configuration.h"
17 
18 #include "Message/Communicate.h"
19 #include "OhmmsPETE/OhmmsMatrix.h"
22 
23 namespace qmcplusplus
24 {
25 TEST_CASE("LogGridLight", "[wavefunction][LCAO]")
26 {
28  grid.set(0.1, 1.0, 5);
29 
30  int idx = grid.locate(0.1);
31  REQUIRE(idx == 0);
32 
33  int idx2 = grid.locate(0.9);
34  REQUIRE(idx2 == 3);
35 
36  double t = grid(0);
37  CHECK(t == Approx(0.1));
38 
39  int idx3 = 0;
40  double t2 = grid.getCLForQuintic(0.1, idx3);
41  REQUIRE(idx3 == 0);
42  CHECK(t2 == Approx(0.0));
43 }
44 
45 
46 TEST_CASE("MultiQuinticSpline", "[wavefunction][LCAO]")
47 {
48  Vector<double> data(5);
49  data[0] = 0.0;
50  data[1] = 1.0;
51  data[2] = 2.0;
52  data[3] = 3.0;
53  data[4] = 4.0;
54 
55  Vector<double> data2(5);
56  data[0] = 2.0;
57  data[1] = 9.0;
58  data[2] = 1.0;
59  data[3] = 2.0;
60  data[4] = 0.1;
61 
62  auto agrid = std::make_unique<LogGrid<double>>();
63  agrid->set(.1, 1.0, 5);
64 
65  OneDimQuinticSpline<double> spline1(agrid->makeClone());
66  spline1.set(data);
67  spline1.spline();
68 
69  OneDimQuinticSpline<double> spline2(agrid->makeClone());
70  spline2.set(data2);
71  spline2.spline();
72 
73 
75 
76  m_spline.initialize(*agrid, 2);
77  m_spline.add_spline(0, spline1);
78  m_spline.add_spline(1, spline2);
79 
80 
81  // Compare the values from the multi-spline routines against the values from
82  // the original single-spline routines.
83 
84  double u[2];
85  double du[2];
86  double d2u[2];
87  double d3u[2];
88 
89  double u1, u2;
90  double du1 = 0.0, du2 = 0.0;
91  double d2u1 = 0.0, d2u2 = 0.0;
92  double d3u1 = 0.0, d3u2 = 0.0;
93  for (int i = 0; i < 10; i++)
94  {
95  double r = 0.08 * i + 0.1;
96  m_spline.evaluate(r, u, du, d2u);
97 
98  u1 = spline1.splint(r, du1, d2u1);
99  u2 = spline2.splint(r, du2, d2u2);
100 
101  CHECK(u[0] == Approx(u1));
102  CHECK(du[0] == Approx(du1));
103  CHECK(d2u[0] == Approx(d2u1));
104  CHECK(u[1] == Approx(u2));
105  CHECK(du[1] == Approx(du2));
106  CHECK(d2u[1] == Approx(d2u2));
107 
108  m_spline.evaluate(r, u, du, d2u, d3u);
109  u1 = spline1.splint(r, du1, d2u1, d3u1);
110  u2 = spline2.splint(r, du2, d2u2, d3u2);
111 
112  CHECK(u[0] == Approx(u1));
113  CHECK(du[0] == Approx(du1));
114  CHECK(d2u[0] == Approx(d2u1));
115  CHECK(d3u[0] == Approx(d3u1));
116  CHECK(u[1] == Approx(u2));
117  CHECK(du[1] == Approx(du2));
118  CHECK(d2u[1] == Approx(d2u2));
119  CHECK(d3u[1] == Approx(d3u2));
120  }
121 }
122 
123 } // namespace qmcplusplus
multivalue implementation for OneDimQuintic Real valued only calling any eval method with r >= r_max ...
void set(T ri, T rf, int n)
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
TEST_CASE("complex_helper", "[type_traits]")
REQUIRE(std::filesystem::exists(filename))
void evaluate(T r, T *restrict u) const
void add_spline(int ispline, OneDimQuinticSpline< T1 > &in)
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
T getCLForQuintic(T r, int &loc) const
void initialize(GT &agrid, int norbs, int order=5)
initialize grid and container
Assume that coeffs.D1 and the LogLightGrid r_values.size() are equal Therefore r must be < r_max...