40 const char* gaussian_xml_abc = R
"(<function id="g0"> 41 <var name="A" opt="true">-1.5 0.353553390593273 -0.353553390593273 -2.25 -0.75 -2.25</var> 42 <var name="B" opt="true">-1.5 0.353553390593273 -0.353553390593273</var> 43 <var name="C" opt="true">-1.5</var> 45 const char* gaussian_xml_adk = R
"(<function id="g1"> 46 <var name="A" opt="true">-1.5 0.353553390593273 -0.353553390593273 -2.25 -0.75 -2.25</var> 47 <var name="D" opt="true">1.0 0.0 0.0</var> 48 <var name="K" opt="true">0.0</var> 53 xmlNodePtr root_abc = doc_abc.
getRoot();
54 xmlNodePtr root_adk = doc_adk.
getRoot();
55 bool put_abc = gf_abc.
put(root_abc);
56 bool put_adk = gf_adk.
put(root_adk);
57 REQUIRE((parse_abc && parse_adk && put_abc && put_adk) ==
true);
61 PosType r2(1.707106781186547, 0.5, -0.5);
62 PosType r3(0.4714617144631338, 0.1499413068889379, 0.2932213074999387);
69 std::vector<RealType> dfval;
70 std::vector<PosType> dfgrad;
71 std::vector<RealType> dflap;
77 gf_adk.
evaluate(r1, fval, fgrad, flap);
79 CHECK(fval == Approx(1));
80 CHECK(fgrad[0] == Approx(0));
81 CHECK(fgrad[1] == Approx(0));
82 CHECK(fgrad[2] == Approx(0));
83 CHECK(flap == Approx(-12));
84 CHECK(lval == Approx(0));
85 CHECK(lgrad[0] == Approx(0));
86 CHECK(lgrad[1] == Approx(0));
87 CHECK(lgrad[2] == Approx(0));
88 CHECK(llap == Approx(-12));
90 gf_abc.
evaluate(r1, fval, fgrad, flap);
92 CHECK(fval == Approx(1));
93 CHECK(fgrad[0] == Approx(0));
94 CHECK(fgrad[1] == Approx(0));
95 CHECK(fgrad[2] == Approx(0));
96 CHECK(flap == Approx(-12));
97 CHECK(lval == Approx(0));
98 CHECK(lgrad[0] == Approx(0));
99 CHECK(lgrad[1] == Approx(0));
100 CHECK(lgrad[2] == Approx(0));
101 CHECK(llap == Approx(-12));
104 CHECK(dfval[0] == Approx(0.113120472934));
105 CHECK(dfval[1] == Approx(0.071952529875));
106 CHECK(dfval[2] == Approx(0.140708490047));
107 CHECK(dfval[3] == Approx(0.011441709933));
108 CHECK(dfval[4] == Approx(0.044750218821));
109 CHECK(dfval[5] == Approx(0.043756180154));
110 CHECK(dfval[6] == Approx(-0.47987130010));
111 CHECK(dfval[7] == Approx(-0.15261584911));
112 CHECK(dfval[8] == Approx(-0.29845157248));
113 CHECK(dfval[9] == Approx(0.508918630484));
116 CHECK(dfval[0] == Approx(0.222276148205));
117 CHECK(dfval[1] == Approx(0.141383171229));
118 CHECK(dfval[2] == Approx(0.276485240702));
119 CHECK(dfval[3] == Approx(0.022482395511));
120 CHECK(dfval[4] == Approx(0.087931972108));
121 CHECK(dfval[5] == Approx(0.085978735172));
122 CHECK(dfval[6] == Approx(-0.94292342892));
123 CHECK(dfval[7] == Approx(-0.29988261377));
124 CHECK(dfval[8] == Approx(-0.58644261500));
125 CHECK(dfval[9] == Approx(1));
135 using LogValue = std::complex<QMCTraits::QTFull::RealType>;
142 std::vector<int> egroup(1);
147 PosType Re[] = {
PosType(2.4601162537, 6.7476360528, -1.9073129953),
148 PosType(2.2585811248, 2.1282254384, 0.051545776028),
149 PosType(0.84796873937, 5.1735597110, 0.84642416761),
150 PosType(3.1597337850, 5.1079432473, 1.0545953717)};
151 for (
int i = 0; i < num_els; ++i)
152 for (
int k = 0; k < 3; ++k)
153 elec.
R[i][k] = Re[i][k];
156 std::vector<int> igroup(1);
159 ion0.setName(
"ion0");
161 PosType Ri[] = {
PosType(2.61363352510301, 5.01928226905281, 0.0),
PosType(3.74709851167814, 3.70007145722224, 0.0),
162 PosType(6.11011670934565, 1.66504047681825, 0.0),
PosType(8.10584803421091, 7.78608266172472, 0.0)};
164 for (
int i = 0; i < num_ion; ++i)
165 for (
int k = 0; k < 3; ++k)
166 ion0.R[i][k] = Ri[i][k];
168 const char* cj_normgauss_xml = R
"(<jastrow name="ncjf_normgauss" type="Counting"> 169 <var name="F" opt="true"> 170 4.4903e-01 5.3502e-01 5.2550e-01 6.8081e-01 171 5.1408e-01 4.8658e-01 6.2182e-01 172 2.7189e-01 9.4951e-01 175 <region type="normalized_gaussian" reference_id="g0" opt="true" > 177 <var name="A" opt="False">-1.0 -0.0 -0.0 -1.0 -0.0 -1.0</var> 178 <var name="B" opt="False">-2.6136335251 -5.01928226905 0.0</var> 179 <var name="C" opt="False">-32.0242747</var> 182 <var name="A" opt="true">-1.0 -0.0 -0.0 -1.0 -0.0 -1.0</var> 183 <var name="B" opt="true">-3.74709851168 -3.70007145722 0.0</var> 184 <var name="C" opt="true">-27.7312760448</var> 187 <var name="A" opt="true">-1.0 -0.0 -0.0 -1.0 -0.0 -1.0</var> 188 <var name="B" opt="true">-6.11011670935 -1.66504047682 0.0</var> 189 <var name="C" opt="true">-40.1058859913</var> 192 <var name="A" opt="true">-1.0 -0.0 -0.0 -1.0 -0.0 -1.0</var> 193 <var name="B" opt="true">-8.10584803421 -7.78608266172 0.0</var> 194 <var name="C" opt="true">-126.327855569</var> 210 RealType Jval_exact = 7.8100074447e+00;
212 PosType(2.2032083234
e-02, -2.5647245917
e-02, 0),
213 PosType(6.0625112202
e-04, -7.0560012380
e-04, 0),
214 PosType(1.0622511249
e-01, -1.2363268199
e-01, 0)};
215 RealType Jlap_exact[] = {1.9649428566e-03, -1.1385706794e-01, 3.2312809658e-03, 4.0668060285e-01};
220 for (
int i = 0; i < num_els; ++i)
222 for (
int k = 0; k < 3; ++k)
226 CHECK(ComplexApprox(Jval_exact) == logval);
229 const char* cj_voronoi_xml = R
"(<jastrow name="ncjf_voronoi" type="Counting" source="ion0"> 230 <var name="F" opt="true"> 231 4.4903e-01 5.3502e-01 5.2550e-01 6.8081e-01 232 5.1408e-01 4.8658e-01 6.2182e-01 233 2.7189e-01 9.4951e-01 236 <region type="voronoi" opt="true"> 237 <var name="alpha">1.0</var> 245 xmlNodePtr cjv_root = doc2.
getRoot();
252 for (
int i = 0; i < num_els; ++i)
254 for (
int k = 0; k < 3; ++k)
260 for (
int i = 0; i < num_els; ++i)
262 for (
int k = 0; k < 3; ++k)
266 CHECK(ComplexApprox(Jval_exact) == logval);
269 for (
int iat = 0; iat < num_els; ++iat)
272 for (
int k = 0; k < 3; ++k)
277 PosType dr[] = {
PosType(0.0984629815, 0.0144420719, 0.1334309321),
278 PosType(-0.1026409581, 0.2289767772, 0.490138058592),
279 PosType(0.03517477469, 0.2693941041, 0.16922043039),
280 PosType(0.3851116893, -0.1387760973, 0.1980082182)};
282 RealType ratioval_exact[] = {1.00003304765, 0.987624289443, 0.999873210738, 1.09014860194};
285 PosType(4.8722465115
e-02, -5.6707785196
e-02, 0),
286 PosType(3.2691265772
e-04, -3.8048525335
e-04, 0),
287 PosType(2.0373800011
e-01, -2.3712542045
e-01, 0)};
290 for (
int iat = 0; iat < num_els; ++iat)
299 CHECK(ratioval_exact[iat] == Approx(gradratioval));
300 for (
int k = 0; k < 3; ++k)
309 PosType(9.7075155012, 7.2984775093, -8.1975111678
e-01),
310 PosType(5.7514912378, 5.2001615327, 6.6673589235
e-01),
311 PosType(8.3805220665, 7.9424368608, -3.5106422506
e-02)};
313 PosType(-7.0561066397
e-01, 1.7863210008
e-01, 3.5677994771
e-01),
314 PosType(-9.2302398033
e-01, -5.0740272660
e-01, -2.6078603626
e-01),
315 PosType(-8.3764545416
e-01, -4.9181684009
e-01, 1.0675382607
e-01)};
316 for (
int i = 0; i < num_els; ++i)
317 for (
int k = 0; k < 3; ++k)
319 elec.
R[i][k] = R2[i][k];
320 elec.
G[i][k] = G2[i][k];
324 RealType dlogpsi_exact[] = {7.0982172306e-04, 9.8329357367e-02, 6.6879065207e-03, 1.0670293004e-01,
325 3.4053136887e+00, 4.6322726464e-01, 7.3906096412e+00, 1.5753284303e-02,
326 5.0267496641e-01, -1.3874695168e+00, -2.6249136239e+00, -4.2223002567e+00,
327 -3.0798330637e+00, 3.7905326800e+00, 8.4038996349e+00, 2.2816901707e+00,
328 4.1911712810e+00, -9.3658177215e+00, -1.2434457046e+01, 1.6771424507e+00,
329 2.3712452266e+00, 3.6980955070e+00, 2.5407601111e+00, 1.8976924460e-01,
330 -1.0446470315e+00, -1.2992491105e+00, -8.5624882767e-01, 9.8686287993e+00,
331 1.1847431541e+01, -2.5193792283e-01, -3.0763224769e-01, 1.2429858182e-01,
332 1.3295440602e-02, 6.4178676394e-02, 1.2758462324e-01, 7.5131761426e-02,
333 1.1629004831e-01, 3.9639061816e-01, 6.7088705514e-01};
334 RealType dhpsioverpsi_exact[] = {-1.6695881381e-02, -4.8902571790e-01, -1.2725397012e-01, -6.6714806635e-01,
335 6.9379259933e+00, -4.8393983437e+00, 7.4947765640e+00, -8.8373306290e-01,
336 -6.8244030879e+00, 7.9150085031e-01, -1.4313255643e+00, 3.7225112718e+01,
337 1.7787191536e+01, -1.6672327906e+01, -4.1705496948e+01, -9.9674671566e+00,
338 -2.0150790757e+01, 1.1226368249e+02, 1.2744525474e+02, -1.5801247401e+01,
339 -1.3618595564e+01, -2.8161585388e+01, -1.4057266918e+01, 1.7626748997e+00,
340 7.8913447811e+00, 9.2144952390e+00, 4.6068416473e+00, -9.3975889104e+01,
341 -8.8298321426e+01, 1.5097063606e+01, 1.8605794463e+01, -7.3647009565e+00,
342 -5.9114663448e-01, -3.9243955679e+00, -7.8630886487e+00, -4.4437106408e+00,
343 -7.0313362338e+00, -2.3986142270e+01, -4.0724297500e+01};
346 dlogpsi.
resize(num_derivs);
347 dhpsioverpsi.
resize(num_derivs);
348 std::fill(dlogpsi.
begin(), dlogpsi.
end(), 0);
349 std::fill(dhpsioverpsi.
begin(), dhpsioverpsi.
end(), 0);
355 optVars.resetIndex();
358 optVars.print(std::cout);
362 for (
int p = 0; p < num_derivs; ++p)
364 CHECK(dlogpsi_exact[p] == Approx(
std::real(dlogpsi[p])).epsilon(1
e-3));
365 CHECK(dhpsioverpsi_exact[p] == Approx(
std::real(dhpsioverpsi[p])).epsilon(1
e-3));
372 std::fill(dlogpsi.
begin(), dlogpsi.
end(), 0);
373 std::fill(dhpsioverpsi.
begin(), dhpsioverpsi.
end(), 0);
376 VariableSet optVars2;
379 optVars2.resetIndex();
382 optVars2.print(std::cout);
385 for (
int p = 0; p < num_derivs; ++p)
387 CHECK(dlogpsi_exact[p] == Approx(
std::real(dlogpsi[p])).epsilon(1
e-3));
388 CHECK(dhpsioverpsi_exact[p] == Approx(
std::real(dhpsioverpsi[p])).epsilon(1
e-3));
392 for (
int p = 0; p < num_derivs; ++p)
void resize(size_type n, Type_t val=Type_t())
Resize the container.
void setName(const std::string &aname)
class that handles xmlDoc
PsiValue ratioGrad(ParticleSet &P, int iat, GradType &grad_iat) override
evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient ...
helper functions for EinsplineSetBuilder
QTBase::GradType GradType
QTBase::RealType RealType
void resetParametersExclusive(const opt_variables_type &active) override
reset the parameters during optimizations.
void checkInVariablesExclusive(opt_variables_type &active) final
check in variational parameters to the global list of parameters used by the optimizer.
PsiValue ratio(ParticleSet &P, int iat) override
evaluate the ratio of the new to old WaveFunctionComponent value
void evaluateDerivatives(PosType r, std::vector< RealType > &dfval, std::vector< GradType > &dfgrad, std::vector< RealType > &dflap)
TEST_CASE("complex_helper", "[type_traits]")
GradType evalGrad(ParticleSet &P, int iat) override
return the current gradient for the iat-th particle
LatticeGaussianProduct::GradType GradType
Communicate * Controller
Global Communicator for a process.
ParticleLaplacian L
laplacians of the particles
std::unique_ptr< WaveFunctionComponent > makeClone(ParticleSet &tqp) const override
make clone
Wrapping information on parallelism.
Specialized paritlce class for atomistic simulations.
void evaluateLogDerivatives(PosType r, std::vector< RealType > &dlval, std::vector< GradType > &dlgrad, std::vector< RealType > &dllap)
QTBase::ValueType ValueType
REQUIRE(std::filesystem::exists(filename))
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false) override
a move for iat-th particle is accepted.
ParticleGradient G
gradients of the particles
class to handle a set of variables that can be modified during optimizations
std::unique_ptr< WaveFunctionComponent > buildComponent(xmlNodePtr cur) override
process a xml node at cur
void recompute(const ParticleSet &P) override
recompute the value of the WaveFunctionComponents which require critical accuracy.
void evaluateLog(PosType r, RealType &lval, GradType &lgrad, RealType &llap)
void create(const std::vector< int > &agroup)
create grouped particles
void evaluate(PosType r, RealType &fval, GradType &fgrad, RealType &flap)
const LogValue & get_log_value() const
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate the value of the WaveFunctionComponent from scratch
bool parseFromString(const std::string_view data)
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
TinyVector< double, 3 > PosType
LatticeGaussianProduct::ValueType ValueType
bool makeMoveAndCheck(Index_t iat, const SingleParticlePos &displ)
move the iat-th particle to active_pos_
std::complex< double > LogValue
QTBase::TensorType TensorType
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
void checkOutVariables(const opt_variables_type &active) override
check out variational optimizable variables