QMCPACK
test_EwaldRef.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) 2017 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
8 // Ye Luo, yeluo@anl.gov, Argonne National Laboratory
9 //
10 // File created by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
11 //////////////////////////////////////////////////////////////////////////////////////
12 
13 
14 #include "catch.hpp"
15 
16 #include "EwaldRef.h"
17 
18 namespace qmcplusplus
19 {
20 TEST_CASE("EwaldRef", "[hamiltonian]")
21 {
22  SECTION("diamondC_2x1x1")
23  {
27 
28  A = {6.7463223, 6.7463223, 0.0, 0.0, 3.37316115, 3.37316115, 3.37316115, 0.0, 3.37316115};
29 
30  const int num_centers = 4;
31  R.resize(num_centers);
32  Q.resize(num_centers, 4);
33 
34  R[0] = {0.0, 0.0, 0.0};
35  R[1] = {1.68658058, 1.68658058, 1.68658058};
36  R[2] = {3.37316115, 3.37316115, 0.0};
37  R[3] = {5.05974173, 5.05974173, 1.68658058};
38 
39  auto Vii_ref = ewaldref::ewaldEnergy(A, R, Q);
40  CHECK(Approx(Vii_ref) == -25.551326969);
41  }
42 
43  SECTION("diamondC_2x1x1 fake 5 ions")
44  {
48 
49  A = {6.7463223, 6.7463223, 0.0, 0.0, 3.37316115, 3.37316115, 3.37316115, 0.0, 3.37316115};
50 
51  const int num_centers = 5;
52  R.resize(num_centers);
53  Q.resize(num_centers, 4);
54 
55  R[0] = {0.0, 0.0, 0.0};
56  R[1] = {1.68658058, 1.68658058, 1.68658058};
57  R[2] = {3.37316115, 3.37316115, 0.0};
58  R[3] = {5.05974173, 5.05974173, 1.68658058};
59  R[4] = {5.05974173, 3.37316115, 0.0};
60 
61  auto Vii_ref = ewaldref::ewaldEnergy(A, R, Q);
62  CHECK(Approx(Vii_ref) == -30.9149928426);
63  }
64 
65  SECTION("32 H2O particle outside the box")
66  {
70 
71  A = {19.09677861, 0.0, 0.0, 0.0, 19.09677861, 0.0, 0.0, 0.0, 19.09677861};
72 
73 
74  const int num_centers = 96;
75  R.resize(num_centers);
76  Q.resize(num_centers, 1);
77  for (int i = 0; i < 32; i++)
78  Q[i] = 6;
79 
80  R[0] = {24.26616224, 34.23786910, -19.88728885};
81  R[1] = {32.99764184, 4.89042226, 1.78485767};
82  R[2] = {-15.27579016, 6.65758075, 38.82499031};
83  R[3] = {22.42481310, 11.92337821, -7.60669570};
84  R[4] = {10.09818623, -36.83076232, 19.09171414};
85  R[5] = {-11.23287228, 13.50815924, 31.73549375};
86  R[6] = {10.92768151, 24.86633926, 5.76944727};
87  R[7] = {-9.78708061, -29.22574847, -17.44821933};
88  R[8] = {-6.13987138, -55.38050301, 14.01883883};
89  R[9] = {29.88923132, -31.53574970, 35.33598895};
90  R[10] = {1.56789254, 17.86637793, -32.73459196};
91  R[11] = {34.80913331, 3.65144222, 9.38999246};
92  R[12] = {31.77272136, 32.05504644, 0.27278764};
93  R[13] = {-30.27341264, -39.32009856, 23.29068561};
94  R[14] = {35.83412076, 27.63459907, -1.26540786};
95  R[15] = {-10.87943680, 19.57945246, 13.17998940};
96  R[16] = {-49.64178269, -16.61639968, -11.19560688};
97  R[17] = {-18.60134911, 26.58693490, 31.83659410};
98  R[18] = {-7.11236224, -4.03040790, -14.07090078};
99  R[19] = {20.17679489, -3.46141136, -4.44342644};
100  R[20] = {4.56091071, 11.36220514, -16.19497185};
101  R[21] = {1.01714887, 38.91116182, -8.61870074};
102  R[22] = {6.32924084, 24.01974195, 15.37836450};
103  R[23] = {16.24028749, 10.66064431, 42.29377160};
104  R[24] = {-4.79620051, 8.82201637, 27.72832949};
105  R[25] = {14.76737825, 16.42141774, -3.33612251};
106  R[26] = {12.32262065, 48.53912749, 13.07764183};
107  R[27] = {32.35702468, 53.07692686, 10.72873114};
108  R[28] = {1.07544125, 32.48798270, 26.25604386};
109  R[29] = {23.46321761, 24.58760466, 10.48820680};
110  R[30] = {-0.36077140, 1.66652869, 38.94706662};
111  R[31] = {-23.26460739, -0.01549386, 5.84212613};
112  R[32] = {23.12061026, 34.20139738, -21.54098818};
113  R[33] = {25.71709396, 35.41932587, -20.30737496};
114  R[34] = {32.34058406, 4.98169603, 3.41910039};
115  R[35] = {34.23881396, 3.52021963, 1.85762346};
116  R[36] = {-16.89611694, 7.01972787, 37.90563855};
117  R[37] = {-15.44556316, 5.09009072, 39.54044062};
118  R[38] = {21.69575675, 12.50539496, -9.29422114};
119  R[39] = {23.01100614, 10.18061608, -8.16520426};
120  R[40] = {9.64824243, -36.16879126, 17.52365719};
121  R[41] = {11.76927104, -35.90555241, 19.85176199};
122  R[42] = {-12.91138372, 13.13055416, 31.33014750};
123  R[43] = {-10.51838573, 15.20947967, 31.45713709};
124  R[44] = {11.74992025, 26.05252035, 6.83177571};
125  R[45] = {10.06245150, 23.90673633, 7.06776471};
126  R[46] = {-11.38983293, -28.87482633, -16.90048221};
127  R[47] = {-9.53954539, -30.85828288, -16.37814301};
128  R[48] = {-5.28280499, -56.90059871, 14.29589158};
129  R[49] = {-6.34785464, -54.53220495, 15.61287951};
130  R[50] = {30.43498423, -30.47429053, 34.19138183};
131  R[51] = {28.79111146, -30.62452376, 36.34283503};
132  R[52] = {3.13093605, 17.57864822, -33.46648289};
133  R[53] = {1.80647236, 18.35957755, -30.90609295};
134  R[54] = {33.81438147, 3.51511737, 10.72884453};
135  R[55] = {36.42957346, 2.91758597, 10.24448882};
136  R[56] = {30.42780327, 30.93406090, 0.87568775};
137  R[57] = {32.79128374, 30.78533945, -1.03389184};
138  R[58] = {-29.69458953, -38.26714316, 21.99376657};
139  R[59] = {-28.86462181, -40.40102190, 23.51121665};
140  R[60] = {36.71076471, 27.30559775, -2.81622106};
141  R[61] = {34.26640396, 26.73301073, -1.26900023};
142  R[62] = {-11.52912465, 20.45741922, 14.45016882};
143  R[63] = {-9.10093995, 20.61124293, 13.03026640};
144  R[64] = {-49.34339494, -18.22820379, -12.45131100};
145  R[65] = {-49.56260317, -17.21553735, -9.34201231};
146  R[66] = {-17.19834084, 26.24035913, 31.22659050};
147  R[67] = {-18.92504030, 28.31660123, 31.41764182};
148  R[68] = {-7.14036799, -3.82826389, -15.73108188};
149  R[69] = {-5.62450527, -2.61343455, -13.47412527};
150  R[70] = {21.17457029, -4.96871361, -5.39550826};
151  R[71] = {18.32229325, -3.88765798, -4.78556136};
152  R[72] = {4.79809024, 12.59595064, -17.41898526};
153  R[73] = {4.16523985, 10.11729136, -17.19852981};
154  R[74] = {2.05683461, 40.37683341, -8.69740783};
155  R[75] = {0.68774693, 38.51526420, -6.82102317};
156  R[76] = {5.61021894, 24.83648159, 16.74378612};
157  R[77] = {8.04554680, 24.11120470, 14.94801717};
158  R[78] = {16.46450349, 9.58389726, 40.56712883};
159  R[79] = {15.21996765, 11.84690099, 41.50821245};
160  R[80] = {-4.28433040, 9.40845508, 26.07368529};
161  R[81] = {-3.68044951, 7.39886362, 27.87667299};
162  R[82] = {13.85105004, 15.06287472, -2.04540177};
163  R[83] = {14.57808438, 15.47487281, -5.04968838};
164  R[84] = {10.70881343, 49.55504426, 12.80342367};
165  R[85] = {12.59744352, 47.50941572, 11.51291080};
166  R[86] = {32.33170235, 51.27639580, 11.02301820};
167  R[87] = {32.17825658, 53.42766003, 8.99734516};
168  R[88] = {0.52424026, 31.64270820, 24.77015220};
169  R[89] = {0.82794193, 34.25468766, 25.37769915};
170  R[90] = {24.21797422, 23.99064017, 8.99006972};
171  R[91] = {24.04997757, 24.10648038, 11.99720981};
172  R[92] = {-0.60767545, 0.82025264, 37.32228009};
173  R[93] = {0.85953248, 0.69664754, 40.03347017};
174  R[94] = {-22.87267819, 0.93691110, 7.30758985};
175  R[95] = {-21.48731996, 0.09036670, 5.18794074};
176 
177  auto Vii_ref = ewaldref::ewaldEnergy(A, R, Q);
178  CHECK(Approx(Vii_ref) == -210.2521866119);
179  }
180 }
181 
182 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
TEST_CASE("complex_helper", "[type_traits]")
std::vector< real_t > ChargeArray
Type for lists of particle charges.
Definition: EwaldRef.h:54
Computes Ewald sums of the potential energy to a given tolerance for arbitrary collections of charges...
real_t ewaldEnergy(const RealMat &a, const PosArray &R, const ChargeArray &Q, real_t tol)
Compute the total Ewald potential energy for a collection of charges.
Definition: EwaldRef.cpp:337
std::vector< RealVec > PosArray
Type for lists of particle positions.
Definition: EwaldRef.h:52
Tensor<T,D> class for D by D tensor.
Definition: OhmmsTinyMeta.h:32
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))