QMCPACK
test_TrialWaveFunction.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) 2020 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 "OhmmsData/Libxml2Doc.h"
17 #include "Particle/ParticleSet.h"
24 #include "TWFGrads.hpp"
26 #include <ResourceCollection.h>
29 #include "Utilities/ProjectData.h"
30 
31 namespace qmcplusplus
32 {
33 #if defined(ENABLE_CUDA) && !defined(QMC_CUDA2HIP)
34 using DiracDet = DiracDeterminant<DelayedUpdateCUDA<QMCTraits::ValueType, QMCTraits::QTFull::ValueType>>;
35 #else
37 #endif
38 
42 
43 TEST_CASE("TrialWaveFunction_diamondC_1x1x1", "[wavefunction]")
44 {
46 
47 #if defined(ENABLE_OFFLOAD)
49 #else
51 #endif
52  // diamondC_1x1x1
54  lattice.R = {3.37316115, 3.37316115, 0.0, 0.0, 3.37316115, 3.37316115, 3.37316115, 0.0, 3.37316115};
55  lattice.BoxBConds = {1, 1, 1};
56  lattice.reset();
57 
60  auto ions_uptr = std::make_unique<ParticleSet>(ptcl.getSimulationCell(), kind_selected);
61  auto elec_uptr = std::make_unique<ParticleSet>(ptcl.getSimulationCell(), kind_selected);
62  ParticleSet& ions_(*ions_uptr);
63  ParticleSet& elec_(*elec_uptr);
64 
65  ions_.setName("ion");
66  ptcl.addParticleSet(std::move(ions_uptr));
67  ions_.create({2});
68  ions_.R[0] = {0.0, 0.0, 0.0};
69  ions_.R[1] = {1.68658058, 1.68658058, 1.68658058};
70  ions_.update();
71 
72 
73  elec_.setName("elec");
74  ptcl.addParticleSet(std::move(elec_uptr));
75  elec_.create({2, 2});
76  elec_.R[0] = {0.0, 0.0, 0.0};
77  elec_.R[1] = {0.0, 1.0, 1.0};
78  elec_.R[2] = {1.0, 1.0, 0.0};
79  elec_.R[3] = {1.0, 0.0, 1.0};
80 
81  SpeciesSet& tspecies = elec_.getSpeciesSet();
82  int upIdx = tspecies.addSpecies("u");
83  int downIdx = tspecies.addSpecies("d");
84  int chargeIdx = tspecies.addAttribute("charge");
85  tspecies(chargeIdx, upIdx) = -1;
86  tspecies(chargeIdx, downIdx) = -1;
87 
88  elec_.addTable(ions_);
89  elec_.resetGroups();
90  elec_.createSK(); // needed by AoS J2 for ChiesaKEcorrection
91 
92  // make a ParticleSet Clone
93  ParticleSet elec_clone(elec_);
94 
95  //diamondC_1x1x1
96  const char* spo_xml = R"(<tmp> \
97 <determinantset type="einspline" href="diamondC_1x1x1.pwscf.h5" tilematrix="1 0 0 0 1 0 0 0 1" twistnum="0" source="ion" meshfactor="1.0" precision="float" size="2"/>
98 </tmp>
99 )";
100 
102  bool okay = doc.parseFromString(spo_xml);
103  REQUIRE(okay);
104 
105  xmlNodePtr spo_root = doc.getRoot();
106  xmlNodePtr ein1 = xmlFirstElementChild(spo_root);
107 
108  EinsplineSetBuilder einSet(elec_, ptcl.getPool(), c, ein1);
109  auto spo = einSet.createSPOSetFromXML(ein1);
110  REQUIRE(spo != nullptr);
111 
112  std::vector<std::unique_ptr<DiracDeterminantBase>> dets;
113  dets.push_back(std::make_unique<DiracDet>(spo->makeClone(), 0, 2));
114  dets.push_back(std::make_unique<DiracDet>(spo->makeClone(), 2, 4));
115 
116  auto slater_det = std::make_unique<SlaterDet>(elec_, std::move(dets));
117 
118  RuntimeOptions runtime_options;
119  TrialWaveFunction psi(runtime_options);
120  psi.addComponent(std::move(slater_det));
121 
122  const char* jas_input = R"(<tmp>
123 <jastrow name="J2" type="Two-Body" function="Bspline" print="yes">
124  <correlation size="10" speciesA="u" speciesB="u">
125  <coefficients id="uu" type="Array"> 0.02904699284 -0.1004179 -0.1752703883 -0.2232576505 -0.2728029201 -0.3253286875 -0.3624525145 -0.3958223107 -0.4268582166 -0.4394531176</coefficients>
126  </correlation>
127 </jastrow>
128 </tmp>
129 )";
130  Libxml2Document doc_jas;
131  okay = doc.parseFromString(jas_input);
132  REQUIRE(okay);
133 
134  xmlNodePtr jas_root = doc.getRoot();
135  xmlNodePtr jas1 = xmlFirstElementChild(jas_root);
136 
137  RadialJastrowBuilder jb(c, elec_);
138  psi.addComponent(jb.buildComponent(jas1));
139 
140  // should not find MSD
141  CHECK(psi.findMSD().empty());
142 
143  // initialize distance tables.
144  elec_.update();
145  double logpsi = psi.evaluateLog(elec_);
146 
147  //app_log() << "debug before YYY " << std::setprecision(16) << psi.getLogPsi() << " " << psi.getPhase()<< std::endl;
148 #if defined(QMC_COMPLEX)
149  CHECK(logpsi == Approx(-0.1201465271523596));
150 #else
151  CHECK(logpsi == Approx(-1.471840358291562));
152 #endif
153 
154  // make a TrialWaveFunction Clone
155  std::unique_ptr<TrialWaveFunction> psi_clone(psi.makeClone(elec_clone));
156 
157  elec_clone.update();
158  double logpsi_clone = psi_clone->evaluateLog(elec_clone);
159 #if defined(QMC_COMPLEX)
160  CHECK(logpsi_clone == Approx(-0.1201465271523596));
161 #else
162  CHECK(logpsi_clone == Approx(-1.471840358291562));
163 #endif
164 
165  const int moved_elec_id = 0;
166 
167  using PosType = QMCTraits::PosType;
170  PosType delta(0.1, 0.1, 0.2);
171 
172  elec_.makeMove(moved_elec_id, delta);
173 
174  ValueType r_all_val = psi.calcRatio(elec_, moved_elec_id);
175  ValueType r_fermionic_val = psi.calcRatio(elec_, moved_elec_id, TrialWaveFunction::ComputeType::FERMIONIC);
176  ValueType r_bosonic_val = psi.calcRatio(elec_, moved_elec_id, TrialWaveFunction::ComputeType::NONFERMIONIC);
177 
178  //app_log() << "debug YYY " << std::setprecision(16) << r_all_val << std::endl;
179  //app_log() << "debug YYY " << std::setprecision(16) << r_fermionic_val << std::endl;
180  //app_log() << "debug YYY " << std::setprecision(16) << r_bosonic_val << std::endl;
181 #if defined(QMC_COMPLEX)
182  CHECK(r_all_val == ComplexApprox(ValueType(1.653821746120792, 0.5484992491019633)));
183  CHECK(r_fermionic_val == ComplexApprox(ValueType(1.804065087219802, 0.598328295048828)));
184 #else
185  CHECK(r_all_val == Approx(2.305591774210242));
186  CHECK(r_fermionic_val == ValueApprox(2.515045914101833));
187 #endif
188  CHECK(r_bosonic_val == ValueApprox(0.9167195562048454));
189 
190  psi.acceptMove(elec_, moved_elec_id);
191  elec_.acceptMove(moved_elec_id);
192 #if defined(QMC_COMPLEX)
193  CHECK(psi.getLogPsi() == Approx(0.4351202455204972));
194 #else
195  CHECK(psi.getLogPsi() == Approx(-0.63650297977845492));
196 #endif
197 
198  elec_.update(true);
199  psi.evaluateLog(elec_);
200 #if defined(QMC_COMPLEX)
201  CHECK(psi.getLogPsi() == Approx(0.4351202455204972));
202 #else
203  CHECK(psi.getLogPsi() == Approx(-0.63650297977845492));
204 #endif
205 
206  const auto opt_obj_refs = psi.extractOptimizableObjectRefs();
207  REQUIRE(opt_obj_refs.size() == 1);
208 
209  // testing batched interfaces
210  ResourceCollection pset_res("test_pset_res");
211  ResourceCollection twf_res("test_twf_res");
212 
213  elec_.createResource(pset_res);
214  psi.createResource(twf_res);
215 
216  //Temporary as switch to std::reference_wrapper proceeds
217  // testing batched interfaces
218  RefVectorWithLeader<ParticleSet> p_ref_list(elec_, {elec_, elec_clone});
219  RefVectorWithLeader<TrialWaveFunction> wf_ref_list(psi, {psi, *psi_clone});
220 
221  ResourceCollectionTeamLock<ParticleSet> mw_pset_lock(pset_res, p_ref_list);
222  ResourceCollectionTeamLock<TrialWaveFunction> mw_twf_lock(twf_res, wf_ref_list);
223 
224  ParticleSet::mw_update(p_ref_list);
225  TrialWaveFunction::mw_evaluateLog(wf_ref_list, p_ref_list);
226 #if defined(QMC_COMPLEX)
227  REQUIRE(std::complex<RealType>(wf_ref_list[0].getLogPsi(), wf_ref_list[0].getPhase()) ==
228  LogComplexApprox(std::complex<RealType>(0.4351202455204972, 6.665972664860828)));
229  REQUIRE(std::complex<RealType>(wf_ref_list[1].getLogPsi(), wf_ref_list[1].getPhase()) ==
230  LogComplexApprox(std::complex<RealType>(-0.1201465271523596, 6.345732826640545)));
231 #else
232  REQUIRE(std::complex<RealType>(wf_ref_list[0].getLogPsi(), wf_ref_list[0].getPhase()) ==
233  LogComplexApprox(std::complex<RealType>(-0.6365029797784554, 3.141592653589793)));
234  REQUIRE(std::complex<RealType>(wf_ref_list[1].getLogPsi(), wf_ref_list[1].getPhase()) ==
235  LogComplexApprox(std::complex<RealType>(-1.471840358291562, 3.141592653589793)));
236 #endif
237 
238  TWFGrads<CoordsType::POS> grad_old(2);
239 
240  grad_old.grads_positions[0] = wf_ref_list[0].evalGrad(p_ref_list[0], moved_elec_id);
241  grad_old.grads_positions[1] = wf_ref_list[1].evalGrad(p_ref_list[1], moved_elec_id);
242 
243  app_log() << "evalGrad " << std::setprecision(14) << grad_old.grads_positions[0][0] << " "
244  << grad_old.grads_positions[0][1] << " " << grad_old.grads_positions[0][2] << " "
245  << grad_old.grads_positions[1][0] << " " << grad_old.grads_positions[1][1] << " "
246  << grad_old.grads_positions[1][2] << std::endl;
247 
248  TrialWaveFunction::mw_evalGrad(wf_ref_list, p_ref_list, moved_elec_id, grad_old);
249 #if defined(QMC_COMPLEX)
250  CHECK(grad_old.grads_positions[0][0] == ComplexApprox(ValueType(18.817970466022, -6.5837500306076)));
251  CHECK(grad_old.grads_positions[0][1] == ComplexApprox(ValueType(-22.840838391977, 3.9963373883645)));
252  CHECK(grad_old.grads_positions[0][2] == ComplexApprox(ValueType(3.8805320617146, 1.5825508129169)));
253  CHECK(grad_old.grads_positions[1][0] == ComplexApprox(ValueType(47.387717528888, -8.7703065253151e-06)));
254  CHECK(grad_old.grads_positions[1][1] == ComplexApprox(ValueType(-54.671696901113, -7.3126138879524)));
255  CHECK(grad_old.grads_positions[1][2] == ComplexApprox(ValueType(6.6288917088321, 7.3126230586018)));
256 #else
257  CHECK(grad_old.grads_positions[0][0] == Approx(14.77249702264));
258  CHECK(grad_old.grads_positions[0][1] == Approx(-20.385235323777));
259  CHECK(grad_old.grads_positions[0][2] == Approx(4.8529516184558));
260  CHECK(grad_old.grads_positions[1][0] == Approx(47.38770710732));
261  CHECK(grad_old.grads_positions[1][1] == Approx(-63.361119579044));
262  CHECK(grad_old.grads_positions[1][2] == Approx(15.318325284049));
263 #endif
264 
265  PosType delta_sign_changed(0.1, 0.1, -0.2);
266 
267  std::vector<PosType> displs{delta_sign_changed, delta_sign_changed};
268  ParticleSet::mw_makeMove(p_ref_list, moved_elec_id, displs);
269 
270  if (kind_selected != DynamicCoordinateKind::DC_POS_OFFLOAD)
271  {
272  ValueType r_0 = wf_ref_list[0].calcRatio(p_ref_list[0], moved_elec_id);
273  GradType grad_temp;
274  ValueType r_1 = wf_ref_list[1].calcRatioGrad(p_ref_list[1], moved_elec_id, grad_temp);
275 #if defined(QMC_COMPLEX)
276  CHECK(r_0 == ComplexApprox(ValueType(-0.045474407700114, -0.59956233350555)));
277  CHECK(r_1 == ComplexApprox(ValueType(-0.44602867091608, -1.8105588403509)));
278  CHECK(grad_temp[0] == ComplexApprox(ValueType(-6.6139971152489, 22.82304260002)));
279  CHECK(grad_temp[1] == ComplexApprox(ValueType(8.3367501707711, -23.362154838104)));
280  CHECK(grad_temp[2] == ComplexApprox(ValueType(-2.6347597529645, 0.67383144279783)));
281 #else
282  CHECK(r_0 == Approx(-0.4138835449));
283  CHECK(r_1 == Approx(-2.5974770159));
284  CHECK(grad_temp[0] == Approx(-17.865723259764));
285  CHECK(grad_temp[1] == Approx(19.854257889369));
286  CHECK(grad_temp[2] == Approx(-2.9669578650441));
287 #endif
288  }
289 
290  PosType delta_zero(0, 0, 0);
291  displs = {delta_zero, delta};
292  ParticleSet::mw_makeMove(p_ref_list, moved_elec_id, displs);
293 
294  std::vector<PsiValue> ratios(2);
295  TrialWaveFunction::mw_calcRatio(wf_ref_list, p_ref_list, moved_elec_id, ratios);
296  app_log() << "calcRatio " << std::setprecision(14) << ratios[0] << " " << ratios[1] << std::endl;
297 #if defined(QMC_COMPLEX)
298  CHECK(ratios[0] == ComplexApprox(PsiValue(1, 0)));
299  CHECK(ratios[1] == ComplexApprox(PsiValue(1.6538214581548, 0.54849918598717)));
300 #else
301  CHECK(ratios[0] == Approx(1));
302  CHECK(ratios[1] == Approx(2.3055913093424));
303 #endif
304 
305  std::fill(ratios.begin(), ratios.end(), 0);
306  TWFGrads<CoordsType::POS> grad_new(2);
307 
308  if (kind_selected != DynamicCoordinateKind::DC_POS_OFFLOAD)
309  {
310  ratios[0] = wf_ref_list[0].calcRatioGrad(p_ref_list[0], moved_elec_id, grad_new.grads_positions[0]);
311  ratios[1] = wf_ref_list[1].calcRatioGrad(p_ref_list[1], moved_elec_id, grad_new.grads_positions[1]);
312 
313  app_log() << "calcRatioGrad " << std::setprecision(14) << ratios[0] << " " << ratios[1] << std::endl
314  << grad_new.grads_positions[0][0] << " " << grad_new.grads_positions[0][1] << " "
315  << grad_new.grads_positions[0][2] << " " << grad_new.grads_positions[1][0] << " "
316  << grad_new.grads_positions[1][1] << " " << grad_new.grads_positions[1][2] << std::endl;
317  }
318  //Temporary as switch to std::reference_wrapper proceeds
319  // testing batched interfaces
320 
321  TrialWaveFunction::mw_calcRatioGrad(wf_ref_list, p_ref_list, moved_elec_id, ratios, grad_new);
322 #if defined(QMC_COMPLEX)
323  CHECK(ratios[0] == ComplexApprox(ValueType(1, 0)));
324  CHECK(grad_new.grads_positions[0][0] == ComplexApprox(ValueType(18.817970466022, -6.5837500306076)));
325  CHECK(grad_new.grads_positions[0][1] == ComplexApprox(ValueType(-22.840838391977, 3.9963373883645)));
326  CHECK(grad_new.grads_positions[0][2] == ComplexApprox(ValueType(3.8805320617146, 1.5825508129169)));
327  CHECK(ratios[1] == ComplexApprox(ValueType(1.6538214581548, 0.54849918598717)));
328  CHECK(grad_new.grads_positions[1][0] == ComplexApprox(ValueType(18.817970466022, -6.5837500306076)));
329  CHECK(grad_new.grads_positions[1][1] == ComplexApprox(ValueType(-22.840838391977, 3.9963373883645)));
330  CHECK(grad_new.grads_positions[1][2] == ComplexApprox(ValueType(3.8805320617146, 1.5825508129169)));
331 #else
332  CHECK(ratios[0] == Approx(1));
333  CHECK(grad_new.grads_positions[0][0] == Approx(14.77249702264));
334  CHECK(grad_new.grads_positions[0][1] == Approx(-20.385235323777));
335  CHECK(grad_new.grads_positions[0][2] == Approx(4.8529516184558));
336  CHECK(ratios[1] == Approx(2.3055913093424));
337  CHECK(grad_new.grads_positions[1][0] == Approx(14.77249702264));
338  CHECK(grad_new.grads_positions[1][1] == Approx(-20.385235323777));
339  CHECK(grad_new.grads_positions[1][2] == Approx(4.8529516184558));
340 #endif
341 
342  std::vector<bool> isAccepted(2, true);
343  TrialWaveFunction::mw_accept_rejectMove(wf_ref_list, p_ref_list, moved_elec_id, isAccepted);
344 #if defined(QMC_COMPLEX)
345  REQUIRE(std::complex<RealType>(wf_ref_list[0].getLogPsi(), wf_ref_list[0].getPhase()) ==
346  LogComplexApprox(std::complex<RealType>(0.4351202455204972, 6.665972664860828)));
347  REQUIRE(std::complex<RealType>(wf_ref_list[1].getLogPsi(), wf_ref_list[1].getPhase()) ==
348  LogComplexApprox(std::complex<RealType>(0.4351202455204972, 6.665972664860828)));
349 #else
350  REQUIRE(std::complex<RealType>(wf_ref_list[0].getLogPsi(), wf_ref_list[0].getPhase()) ==
351  LogComplexApprox(std::complex<RealType>(-0.6365029797784554, 3.141592653589793)));
352  REQUIRE(std::complex<RealType>(wf_ref_list[1].getLogPsi(), wf_ref_list[1].getPhase()) ==
353  LogComplexApprox(std::complex<RealType>(-0.6365029797784554, 3.141592653589793)));
354 #endif
355 
356  TrialWaveFunction::mw_evalGrad(wf_ref_list, p_ref_list, moved_elec_id, grad_old);
357 #if defined(QMC_COMPLEX)
358  CHECK(grad_old.grads_positions[0][0] == ComplexApprox(ValueType(18.817970466022, -6.5837500306076)));
359  CHECK(grad_old.grads_positions[0][1] == ComplexApprox(ValueType(-22.840838391977, 3.9963373883645)));
360  CHECK(grad_old.grads_positions[0][2] == ComplexApprox(ValueType(3.8805320617146, 1.5825508129169)));
361  CHECK(grad_old.grads_positions[1][0] == ComplexApprox(ValueType(18.817970466022, -6.5837500306076)));
362  CHECK(grad_old.grads_positions[1][1] == ComplexApprox(ValueType(-22.840838391977, 3.9963373883645)));
363  CHECK(grad_old.grads_positions[1][2] == ComplexApprox(ValueType(3.8805320617146, 1.5825508129169)));
364 #else
365  CHECK(grad_old.grads_positions[0][0] == Approx(14.77249702264));
366  CHECK(grad_old.grads_positions[0][1] == Approx(-20.385235323777));
367  CHECK(grad_old.grads_positions[0][2] == Approx(4.8529516184558));
368  CHECK(grad_old.grads_positions[1][0] == Approx(14.77249702264));
369  CHECK(grad_old.grads_positions[1][1] == Approx(-20.385235323777));
370  CHECK(grad_old.grads_positions[1][2] == Approx(4.8529516184558));
371 #endif
372 }
373 
374 #if defined(QMC_COMPLEX) && !defined(ENABLE_CUDA)
375 /** This test is intended to catch a bug that was found in the batched code
376  * when using spinors and jastrows. The issue came about because WFCs that don't
377  * contribute to the spin gradient end up going back to the normal mw_evalGrad
378  * In the TWF::mw_evalGrad, it uses TWFGrads to accumulate the spin gradient and normal gradients
379  * using a returned variable grads. The individual components are stored in grads_z and the update over the
380  * component loop is grads += grads_z. Internally to the WFCs, the position gradients get zeroed and computed.
381  * However, for the spins, if they weren't being touched then the spin part is left untouched. But that means that if
382  * grads += grads_z didn't account for zeroing out the spin part for that component, then it acctually accumulates the previous ones.
383  * This test fails with the buggy code, and now makes sure TWF has the right behavior.
384  }
385  */
386 TEST_CASE("TrialWaveFunction::mw_evalGrad for spinors", "[wavefunction]")
387 {
388  ProjectData test_project("test", ProjectData::DriverVersion::BATCH);
390 
392  auto wavefunction_pool =
394 
395  auto& elec = *(particle_pool).getParticleSet("e");
396  auto& psi_noJ = *(wavefunction_pool).getWaveFunction("wavefunction");
397 
398  elec.update();
399  auto logpsi = psi_noJ.evaluateLog(elec);
400  WaveFunctionComponent::ComplexType spingrad_ref(0);
401  WaveFunctionComponent::GradType grad = psi_noJ.evalGradWithSpin(elec, 0, spingrad_ref);
402 
403  // Now tack on a jastrow to make sure it is still the same since jastrows don't contribute
404  auto wavefunction_pool2 =
406  auto& psi = *(wavefunction_pool2).getWaveFunction("wavefunction");
407 
408  // make clones
409  ParticleSet elec_clone(elec);
410  std::unique_ptr<TrialWaveFunction> psi_clone(psi.makeClone(elec_clone));
411 
412  ResourceCollection elec_res("test_elec_res");
413  ResourceCollection psi_res("test_psi_res");
414  elec.createResource(elec_res);
415  psi.createResource(psi_res);
416 
417  RefVectorWithLeader<ParticleSet> elec_ref_list(elec, {elec, elec_clone});
418  RefVectorWithLeader<TrialWaveFunction> psi_ref_list(psi, {psi, *psi_clone});
419 
420  ResourceCollectionTeamLock<ParticleSet> mw_elec_lock(elec_res, elec_ref_list);
421  ResourceCollectionTeamLock<TrialWaveFunction> mw_psi_lock(psi_res, psi_ref_list);
422 
423  ParticleSet::mw_update(elec_ref_list);
424  TrialWaveFunction::mw_evaluateLog(psi_ref_list, elec_ref_list);
425  TWFGrads<CoordsType::POS_SPIN> grads(2);
426  TrialWaveFunction::mw_evalGrad(psi_ref_list, elec_ref_list, 0, grads);
427  for (size_t iw = 0; iw < 2; iw++)
428  CHECK(grads.grads_spins[iw] == ComplexApprox(spingrad_ref));
429 }
430 #endif
431 
432 } // namespace qmcplusplus
a class that defines a supercell in D-dimensional Euclean space.
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
DynamicCoordinateKind
enumerator for DynamicCoordinates kinds
void setName(const std::string &aname)
Definition: ParticleSet.h:237
WaveFunctionComponent::PsiValue PsiValue
void setSimulationCell(const SimulationCell &simulation_cell)
set simulation cell
class that handles xmlDoc
Definition: Libxml2Doc.h:76
ValueType calcRatio(ParticleSet &P, int iat, ComputeType ct=ComputeType::ALL)
compute psi(R_new) / psi(R_current) ratio It returns a complex value if the wavefunction is complex...
static void mw_makeMove(const RefVectorWithLeader< ParticleSet > &p_list, int iat, const MCCoords< CT > &displs)
batched version of makeMove
WaveFunctionComponent::PsiValue PsiValue
Definition: SlaterDet.cpp:25
int addSpecies(const std::string &aname)
When a name species does not exist, add a new species.
Definition: SpeciesSet.cpp:33
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
WaveFunctionComponent::GradType GradType
QTBase::GradType GradType
Definition: Configuration.h:62
void createResource(ResourceCollection &collection) const
initialize a shared resource and hand it to a collection
QTBase::RealType RealType
Definition: Configuration.h:58
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false)
update the state with the new data
std::ostream & app_log()
Definition: OutputManager.h:65
TEST_CASE("complex_helper", "[type_traits]")
std::unique_ptr< WaveFunctionComponent > buildComponent(xmlNodePtr cur) override
process a xml node at cur
static void mw_calcRatioGrad(const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, TWFGrads< CT > &grads)
batched version of ratioGrad
WaveFunctionComponent::LogValue LogValue
void addParticleSet(std::unique_ptr< ParticleSet > &&p)
add a ParticleSet* to the pool with its ownership transferred ParticleSet built outside the ParticleS...
xmlNodePtr getRoot()
Definition: Libxml2Doc.h:88
Builder class for einspline-based SPOSet objects.
JastrowBuilder using an analytic 1d functor Should be able to eventually handle all one and two body ...
LatticeGaussianProduct::GradType GradType
static WaveFunctionPool make_O2_spinor(const RuntimeOptions &runtime_options, Communicate *comm, ParticleSetPool &particle_pool)
ProjectData test_project("test", ProjectData::DriverVersion::BATCH)
QTBase::ComplexType ComplexType
Definition: Configuration.h:59
void update(bool skipSK=false)
update the internal data
Communicate * Controller
Global Communicator for a process.
Definition: Communicate.cpp:35
static void mw_accept_rejectMove(const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, const std::vector< bool > &isAccepted, bool safe_to_delay=false)
int addAttribute(const std::string &aname)
for a new attribute, allocate the data, !More often used to get the index of a species ...
Definition: SpeciesSet.cpp:45
const RuntimeOptions & getRuntimeOptions() const noexcept
std::unique_ptr< TrialWaveFunction > makeClone(ParticleSet &tqp) const
Catch::Detail::LogComplexApprox LogComplexApprox
RefVector< MultiSlaterDetTableMethod > findMSD() const
find MSD WFCs if exist
UniqueOptObjRefs extractOptimizableObjectRefs()
extract underlying OptimizableObject references
Wrapping information on parallelism.
Definition: Communicate.h:68
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > lattice
int addTable(const ParticleSet &psrc, DTModes modes=DTModes::ALL_OFF)
add a distance table
static ParticleSetPool make_O2_spinor(Communicate *c)
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
std::vector< QMCTraits::GradType > grads_positions
Definition: TWFGrads.hpp:31
QTBase::ValueType ValueType
Definition: Configuration.h:60
REQUIRE(std::filesystem::exists(filename))
Manage a collection of ParticleSet objects.
static void mw_calcRatio(const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, ComputeType ct=ComputeType::ALL)
batched version of calcRatio
ParticlePos R
Position.
Definition: ParticleSet.h:79
QTBase::PosType PosType
Definition: Configuration.h:61
static WaveFunctionPool make_O2_spinor_J12(const RuntimeOptions &runtime_options, Communicate *comm, ParticleSetPool &particle_pool)
static void mw_evalGrad(const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, TWFGrads< CT > &grads)
batched version of evalGrad
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
Definition: ParticleSet.h:231
void create(const std::vector< int > &agroup)
create grouped particles
DiracDeterminant< DelayedUpdate< QMCTraits::ValueType, QMCTraits::QTFull::ValueType > > DiracDet
Declaration of a TrialWaveFunction.
Class to represent a many-body trial wave function.
bool parseFromString(const std::string_view data)
Definition: Libxml2Doc.cpp:204
static void mw_update(const RefVectorWithLeader< ParticleSet > &p_list, bool skipSK=false)
batched version of update
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
handles acquire/release resource by the consumer (RefVectorWithLeader type).
LatticeGaussianProduct::ValueType ValueType
Declaration of DiracDeterminant with a S(ingle)P(article)O(rbital)Set.
void createSK()
create Structure Factor with PBCs
std::complex< double > LogValue
Custom container for set of attributes for a set of species.
Definition: SpeciesSet.h:33
const PoolType & getPool() const
get the Pool object
std::unique_ptr< SPOSet > createSPOSetFromXML(xmlNodePtr cur) override
initialize the Antisymmetric wave function for electrons
const auto & getSimulationCell() const
get simulation cell
void addComponent(std::unique_ptr< WaveFunctionComponent > &&aterm)
add a WaveFunctionComponent
static void mw_evaluateLog(const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list)
batched version of evaluateLog.
Declaration of ParticleSetPool.