33 using LogValue = std::complex<QMCTraits::QTFull::RealType>;
36 template<PlatformKind PL>
40 auto spo_init = std::make_unique<FakeSPO>();
42 spo_init->setOrbitalSetSize(norb);
43 DetType ddb(std::move(spo_init), 0, norb);
44 auto spo =
dynamic_cast<FakeSPO*
>(ddb.getPhi());
55 b(0, 0) = 0.6159749342;
56 b(0, 1) = -0.2408954682;
57 b(0, 2) = -0.1646081192;
58 b(1, 0) = 0.07923894288;
59 b(1, 1) = 0.1496231042;
60 b(1, 2) = -0.1428117337;
61 b(2, 0) = -0.2974298429;
62 b(2, 1) = -0.04586322768;
63 b(2, 2) = 0.3927890292;
66 CHECKED_ELSE(check.result) { FAIL(check.result_message); }
69 PsiValue det_ratio = ddb.ratioGrad(elec, 0, grad);
70 PsiValue det_ratio1 = 0.178276269185;
71 CHECK(det_ratio1 == ValueApprox(det_ratio));
73 ddb.acceptMove(elec, 0);
75 b(0, 0) = 3.455170657;
76 b(0, 1) = -1.35124809;
77 b(0, 2) = -0.9233316353;
78 b(1, 0) = 0.05476311768;
79 b(1, 1) = 0.1591951095;
80 b(1, 2) = -0.1362710138;
81 b(2, 0) = -2.235099338;
82 b(2, 1) = 0.7119205298;
83 b(2, 2) = 0.9105960265;
86 CHECKED_ELSE(check.result) { FAIL(check.result_message); }
93 ddb.evaluateRatiosAlltoOne(elec, ratios);
100 PsiValue ratio_0 = ddb.ratio(elec, 0);
106 std::vector<PosType> newpos2(2);
107 std::vector<ValueType> ratios2(2);
108 newpos2[0] = newpos - elec.
R[1];
109 newpos2[1] =
PosType(0.2, 0.5, 0.3) - elec.
R[1];
111 ddb.evaluateRatios(VP, ratios2);
118 PsiValue ratio_1 = ddb.ratio(elec, 1);
119 ddb.acceptMove(elec, 1);
126 TEST_CASE(
"DiracDeterminantBatched_first",
"[wavefunction][fermion]")
128 #if defined(ENABLE_OFFLOAD) && defined(ENABLE_CUDA) 129 test_DiracDeterminantBatched_first<PlatformKind::CUDA>();
131 #if defined(ENABLE_OFFLOAD) && defined(ENABLE_SYCL) 132 test_DiracDeterminantBatched_first<PlatformKind::SYCL>();
134 test_DiracDeterminantBatched_first<PlatformKind::OMPTARGET>();
139 template<PlatformKind PL>
143 auto spo_init = std::make_unique<FakeSPO>();
145 spo_init->setOrbitalSetSize(norb);
146 DetType ddb(std::move(spo_init), 0, norb);
147 auto spo =
dynamic_cast<FakeSPO*
>(ddb.getPhi());
159 for (
int i = 0; i < 3; i++)
161 for (
int j = 0; j < norb; j++)
163 orig_a(j, i) = spo->v2(i, j);
174 for (
int j = 0; j < norb; j++)
176 a_update1(j, 0) = spo->v2(0, j);
182 for (
int j = 0; j < norb; j++)
184 a_update2(j, 0) = spo->v2(0, j);
185 a_update2(j, 1) = spo->v2(1, j);
191 for (
int j = 0; j < norb; j++)
193 a_update3(j, 0) = spo->v2(0, j);
194 a_update3(j, 1) = spo->v2(1, j);
195 a_update3(j, 2) = spo->v2(2, j);
199 PsiValue det_ratio = ddb.ratioGrad(elec, 0, grad);
209 app_log() <<
"det ratio 1 = " << det_ratio1 << std::endl;
213 CHECK(det_ratio1 == ValueApprox(det_ratio));
215 ddb.acceptMove(elec, 0);
217 PsiValue det_ratio2 = ddb.ratioGrad(elec, 1, grad);
226 app_log() <<
"det ratio 2 = " << det_ratio2 << std::endl;
229 CHECK(det_ratio2 == ValueApprox(det_ratio2_val));
231 ddb.acceptMove(elec, 1);
233 PsiValue det_ratio3 = ddb.ratioGrad(elec, 2, grad);
242 app_log() <<
"det ratio 3 = " << det_ratio3 << std::endl;
244 CHECK(det_ratio3 == ValueApprox(det_ratio3_val));
247 ddb.acceptMove(elec, 2);
253 app_log() <<
"original " << std::endl;
254 app_log() << orig_a << std::endl;
255 app_log() <<
"block update " << std::endl;
256 app_log() << ddb.getPsiMinv() << std::endl;
259 auto check =
checkMatrix(orig_a, ddb.get_psiMinv());
260 CHECKED_ELSE(check.result) { FAIL(check.result_message); }
263 TEST_CASE(
"DiracDeterminantBatched_second",
"[wavefunction][fermion]")
265 #if defined(ENABLE_OFFLOAD) && defined(ENABLE_CUDA) 266 test_DiracDeterminantBatched_second<PlatformKind::CUDA>();
268 #if defined(ENABLE_OFFLOAD) && defined(ENABLE_SYCL) 269 test_DiracDeterminantBatched_second<PlatformKind::SYCL>();
271 test_DiracDeterminantBatched_second<PlatformKind::OMPTARGET>();
274 template<PlatformKind PL>
278 auto spo_init = std::make_unique<FakeSPO>();
280 spo_init->setOrbitalSetSize(norb);
281 DetType ddc(std::move(spo_init), 0, norb, delay_rank, matrix_inverter_kind);
282 auto spo =
dynamic_cast<FakeSPO*
>(ddc.getPhi());
294 for (
int i = 0; i < 3; i++)
296 for (
int j = 0; j < norb; j++)
298 orig_a(j, i) = spo->v2(i, j);
309 for (
int j = 0; j < norb; j++)
311 a_update1(j, 0) = spo->v2(0, j);
317 for (
int j = 0; j < norb; j++)
319 a_update2(j, 0) = spo->v2(0, j);
320 a_update2(j, 1) = spo->v2(1, j);
326 for (
int j = 0; j < norb; j++)
328 a_update3(j, 0) = spo->v2(0, j);
329 a_update3(j, 1) = spo->v2(1, j);
330 a_update3(j, 2) = spo->v2(2, j);
335 PsiValue det_ratio = ddc.ratioGrad(elec, 0, grad);
345 app_log() <<
"det ratio 1 = " << det_ratio1 << std::endl;
349 CHECK(det_ratio1 == ValueApprox(det_ratio));
352 ddc.acceptMove(elec, 0,
true);
354 ddc.completeUpdates();
356 auto check =
checkMatrix(a_update1, ddc.get_psiMinv());
357 CHECKED_ELSE(check.result) { FAIL(check.result_message); }
359 grad = ddc.evalGrad(elec, 1);
361 PsiValue det_ratio2 = ddc.ratioGrad(elec, 1, grad);
370 app_log() <<
"det ratio 2 = " << det_ratio2 << std::endl;
374 CHECK(det_ratio2 == ValueApprox(det_ratio2_val));
377 ddc.acceptMove(elec, 1,
true);
379 grad = ddc.evalGrad(elec, 2);
381 PsiValue det_ratio3 = ddc.ratioGrad(elec, 2, grad);
390 app_log() <<
"det ratio 3 = " << det_ratio3 << std::endl;
393 CHECK(det_ratio3 == ValueApprox(det_ratio3_val));
397 ddc.acceptMove(elec, 2,
true);
398 ddc.completeUpdates();
405 app_log() <<
"original " << std::endl;
406 app_log() << orig_a << std::endl;
407 app_log() <<
"delayed update " << std::endl;
408 app_log() << ddc.getPsiMinv() << std::endl;
413 CHECKED_ELSE(check.result) { FAIL(check.result_message); }
420 ddc.createResource(wfc_res);
424 std::unique_ptr<WaveFunctionComponent> ddc_clone(ddc.makeCopy(ddc.getPhi()->makeClone()));
425 auto& ddc_clone_ref =
dynamic_cast<DetType&
>(*ddc_clone);
434 std::vector<bool> isAccepted(2,
true);
436 ddc.mw_recompute(ddc_ref_list, p_ref_list, isAccepted);
438 std::vector<PsiValue> ratios(2);
439 std::vector<GradType> grad_new(2);
440 ddc.mw_ratioGrad(ddc_ref_list, p_ref_list, 0, ratios, grad_new);
442 CHECK(det_ratio1 == ValueApprox(ratios[0]));
443 CHECK(det_ratio1 == ValueApprox(ratios[1]));
445 ddc.mw_accept_rejectMove(ddc_ref_list, p_ref_list, 0, isAccepted,
true);
446 ddc.mw_completeUpdates(ddc_ref_list);
449 CHECKED_ELSE(check.result) { FAIL(check.result_message); }
451 check =
checkMatrix(a_update1, ddc_clone_ref.get_psiMinv());
452 CHECKED_ELSE(check.result) { FAIL(check.result_message); }
454 ddc.mw_evalGrad(ddc_ref_list, p_ref_list, 1, grad_new);
455 ddc.mw_ratioGrad(ddc_ref_list, p_ref_list, 1, ratios, grad_new);
457 CHECK(det_ratio2 == ValueApprox(ratios[0]));
458 CHECK(det_ratio2 == ValueApprox(ratios[1]));
460 ddc.mw_accept_rejectMove(ddc_ref_list, p_ref_list, 1, isAccepted,
true);
461 ddc.mw_evalGrad(ddc_ref_list, p_ref_list, 2, grad_new);
462 ddc.mw_ratioGrad(ddc_ref_list, p_ref_list, 2, ratios, grad_new);
464 CHECK(det_ratio3 == ValueApprox(ratios[0]));
465 CHECK(det_ratio3 == ValueApprox(ratios[1]));
467 ddc.mw_accept_rejectMove(ddc_ref_list, p_ref_list, 2, isAccepted,
true);
468 ddc.mw_completeUpdates(ddc_ref_list);
471 CHECKED_ELSE(check.result) { FAIL(check.result_message); }
473 check =
checkMatrix(orig_a, ddc_clone_ref.get_psiMinv());
474 CHECKED_ELSE(check.result) { FAIL(check.result_message); }
477 TEST_CASE(
"DiracDeterminantBatched_delayed_update",
"[wavefunction][fermion]")
480 #if defined(ENABLE_OFFLOAD) && defined(ENABLE_CUDA) 484 #if defined(ENABLE_OFFLOAD) && defined(ENABLE_SYCL) 494 template<PlatformKind PL>
495 void test_DiracDeterminantBatched_spinor_update(
const int delay_rank,
DetMatInvertor matrix_inverter_kind)
503 lattice.R = {5.10509515, -3.23993545, 0.00000000, 5.10509515, 3.23993545,
504 0.00000000, -6.49690625, 0.00000000, 7.08268015};
507 const SimulationCell simulation_cell(
lattice);
508 ParticleSet ions_(simulation_cell);
509 ParticleSet elec_(simulation_cell);
510 ions_.setName(
"ion");
513 ions_.R[0] = {0.00000000, 0.00000000, 1.08659253};
514 ions_.R[1] = {0.00000000, 0.00000000, -1.08659253};
516 elec_.setName(
"elec");
518 elec_.R[0] = {0.1, -0.3, 1.0};
519 elec_.R[1] = {-0.1, 0.3, 1.0};
520 elec_.R[2] = {0.1, 0.2, 0.3};
522 elec_.spins[0] = 0.0;
523 elec_.spins[1] = 0.2;
524 elec_.spins[2] = 0.4;
525 elec_.setSpinor(
true);
527 SpeciesSet& tspecies = elec_.getSpeciesSet();
528 int upIdx = tspecies.addSpecies(
"u");
529 int chargeIdx = tspecies.addAttribute(
"charge");
530 tspecies(chargeIdx, upIdx) = -1;
532 elec_.addTable(ions_);
538 const auto nelec = elec_.R.size();
542 std::vector<PosType> kup, kdn;
543 std::vector<RealType> k2up, k2dn;
548 kup[1] =
PosType(0.1, 0.2, 0.3);
549 kup[2] =
PosType(0.4, 0.5, 0.6);
553 kdn[1] =
PosType(-0.1, 0.2, -0.3);
554 kdn[2] =
PosType(0.4, -0.5, 0.6);
556 auto spo_up = std::make_unique<FreeOrbital>(
"free_orb_up", kup);
557 auto spo_dn = std::make_unique<FreeOrbital>(
"free_orb_up", kdn);
559 auto spinor_set = std::make_unique<SpinorSet>(
"free_orb_spinor");
560 spinor_set->set_spos(std::move(spo_up), std::move(spo_dn));
562 using DetType = DiracDeterminantBatched<PL, ValueType, QMCTraits::QTFull::ValueType>;
563 DetType dd(std::move(spinor_set), 0, nelec, delay_rank, matrix_inverter_kind);
564 app_log() <<
" nelec=" << nelec << std::endl;
568 ParticleAttrib<ComplexType> SG;
582 app_log() <<
" R = " << elec_.R << std::endl;
583 app_log() <<
" s = " << elec_.spins << std::endl;
588 LogValue logref = dd.evaluateLog(elec_, G, L);
590 CHECK(logref == ComplexApprox(
ValueType(-1.1619939279564413, 0.8794794652468605)));
591 CHECK(G[0][0] == ComplexApprox(
ValueType(0.13416635, 0.2468612)));
592 CHECK(G[0][1] == ComplexApprox(
ValueType(-1.1165475, 0.71497753)));
593 CHECK(G[0][2] == ComplexApprox(
ValueType(0.0178403, 0.08212244)));
594 CHECK(G[1][0] == ComplexApprox(
ValueType(1.00240841, 0.12371593)));
595 CHECK(G[1][1] == ComplexApprox(
ValueType(1.62679698, -0.41080777)));
596 CHECK(G[1][2] == ComplexApprox(
ValueType(1.81324632, 0.78589013)));
597 CHECK(G[2][0] == ComplexApprox(
ValueType(-1.10994555, 0.15525902)));
598 CHECK(G[2][1] == ComplexApprox(
ValueType(-0.46335602, -0.50809713)));
599 CHECK(G[2][2] == ComplexApprox(
ValueType(-1.751199, 0.10949589)));
602 CHECK(L[2] == ComplexApprox(
ValueType(-4.82375261, -1.97943258)));
606 for (
int iat = 0; iat < nelec; iat++)
607 dd.evalGradWithSpin(elec_, iat, SG[iat]);
609 CHECK(SG[0] == ComplexApprox(
ValueType(-1.05686704, -2.01802154)));
611 CHECK(SG[2] == ComplexApprox(
ValueType(-0.62617675, -0.51093984)));
614 g_singleeval = dd.evalGrad(elec_, 1);
616 CHECK(g_singleeval[0] == ComplexApprox(G[1][0]));
617 CHECK(g_singleeval[1] == ComplexApprox(G[1][1]));
618 CHECK(g_singleeval[2] == ComplexApprox(G[1][2]));
624 elec_.makeMoveAndCheckWithSpin(1, dr, ds);
631 ratio_new = dd.ratio(elec_, 1);
632 CHECK(ratio_new == ComplexApprox(
ValueType(1.7472917722050971, 1.1900872950904169)));
634 ratio_new = dd.ratioGrad(elec_, 1, grad_new);
635 CHECK(ratio_new == ComplexApprox(
ValueType(1.7472917722050971, 1.1900872950904169)));
636 CHECK(grad_new[0] == ComplexApprox(
ValueType(0.5496675534224996, -0.07968022499097227)));
637 CHECK(grad_new[1] == ComplexApprox(
ValueType(0.4927399293808675, -0.29971549854643653)));
638 CHECK(grad_new[2] == ComplexApprox(
ValueType(1.2792642963632226, 0.12110307514989149)));
642 ratio_new = dd.ratioGradWithSpin(elec_, 1, grad_new, spingrad_new);
643 CHECK(ratio_new == ComplexApprox(
ValueType(1.7472917722050971, 1.1900872950904169)));
644 CHECK(grad_new[0] == ComplexApprox(
ValueType(0.5496675534224996, -0.07968022499097227)));
645 CHECK(grad_new[1] == ComplexApprox(
ValueType(0.4927399293808675, -0.29971549854643653)));
646 CHECK(grad_new[2] == ComplexApprox(
ValueType(1.2792642963632226, 0.12110307514989149)));
647 CHECK(spingrad_new == ComplexApprox(
ValueType(1.164708841479661, 0.9576425115390172)));
655 g_singleeval = dd.evalGrad(elec_, 1);
656 CHECK(g_singleeval[0] == ComplexApprox(G[1][0]));
657 CHECK(g_singleeval[1] == ComplexApprox(G[1][1]));
658 CHECK(g_singleeval[2] == ComplexApprox(G[1][2]));
661 g_singleeval = dd.evalGradWithSpin(elec_, 1, spingrad_old_test);
663 CHECK(spingrad_old_test == ComplexApprox(SG[1]));
664 CHECK(g_singleeval[0] == ComplexApprox(G[1][0]));
665 CHECK(g_singleeval[1] == ComplexApprox(G[1][1]));
666 CHECK(g_singleeval[2] == ComplexApprox(G[1][2]));
669 elec_.makeMoveAndCheckWithSpin(1, dr, ds);
676 lognew = dd.evaluateLog(elec_, G, L);
678 for (
int iat = 0; iat < nelec; iat++)
679 dd.evalGradWithSpin(elec_, iat, SG[iat]);
683 CHECK(lognew == ComplexApprox(
ValueType(-0.41337396772929913, 1.4774106123071726)));
684 CHECK(G[1][0] == ComplexApprox(grad_new[0]));
685 CHECK(G[1][1] == ComplexApprox(grad_new[1]));
686 CHECK(G[1][2] == ComplexApprox(grad_new[2]));
687 CHECK(SG[1] == ComplexApprox(spingrad_new));
690 elec_.makeMoveAndCheckWithSpin(1, -dr, -ds);
692 dd.acceptMove(elec_, 1,
true);
695 ResourceCollection pset_res(
"test_pset_res");
696 ResourceCollection wfc_res(
"test_wfc_res");
698 elec_.createResource(pset_res);
699 dd.createResource(wfc_res);
701 ParticleSet elec_clone(elec_);
702 std::unique_ptr<WaveFunctionComponent> dd_clone(dd.makeCopy(dd.getPhi()->makeClone()));
703 auto& dd_clone_ref =
dynamic_cast<DetType&
>(*dd_clone);
705 RefVectorWithLeader<ParticleSet> p_ref_list(elec_, {elec_, elec_clone});
706 RefVectorWithLeader<WaveFunctionComponent> dd_ref_list(dd, {dd, *dd_clone});
708 ResourceCollectionTeamLock<ParticleSet> mw_pset_lock(pset_res, p_ref_list);
709 ResourceCollectionTeamLock<WaveFunctionComponent> mw_wfc_lock(wfc_res, dd_ref_list);
714 ParticleLaplacian L2;
719 RefVector<ParticleGradient> G_list = {G, G2};
720 RefVector<ParticleLaplacian> L_list = {L, L2};
721 dd.mw_evaluateLog(dd_ref_list, p_ref_list, G_list, L_list);
722 for (
int iw = 0; iw < dd_ref_list.size(); iw++)
724 PsiValue ref = dd_ref_list[iw].getValue();
726 CHECK(G_list[iw].
get()[0][0] == ComplexApprox(
ValueType(0.13416635, 0.2468612)));
727 CHECK(G_list[iw].
get()[0][1] == ComplexApprox(
ValueType(-1.1165475, 0.71497753)));
728 CHECK(G_list[iw].
get()[0][2] == ComplexApprox(
ValueType(0.0178403, 0.08212244)));
729 CHECK(G_list[iw].
get()[1][0] == ComplexApprox(
ValueType(1.00240841, 0.12371593)));
730 CHECK(G_list[iw].
get()[1][1] == ComplexApprox(
ValueType(1.62679698, -0.41080777)));
731 CHECK(G_list[iw].
get()[1][2] == ComplexApprox(
ValueType(1.81324632, 0.78589013)));
732 CHECK(G_list[iw].
get()[2][0] == ComplexApprox(
ValueType(-1.10994555, 0.15525902)));
733 CHECK(G_list[iw].
get()[2][1] == ComplexApprox(
ValueType(-0.46335602, -0.50809713)));
734 CHECK(G_list[iw].
get()[2][2] == ComplexApprox(
ValueType(-1.751199, 0.10949589)));
735 CHECK(L_list[iw].
get()[0] == ComplexApprox(
ValueType(-2.06554158, 1.18145239)));
736 CHECK(L_list[iw].
get()[1] == ComplexApprox(
ValueType(-5.06340536, 0.82126749)));
737 CHECK(L_list[iw].
get()[2] == ComplexApprox(
ValueType(-4.82375261, -1.97943258)));
741 MCCoords<CoordsType::POS_SPIN> displs(2);
742 displs.positions = {dr, dr};
743 displs.spins = {ds, ds};
744 elec_.mw_makeMove(p_ref_list, 1, displs);
747 std::vector<PsiValue> ratios(2);
748 std::vector<GradType> grads(2);
749 std::vector<ComplexType> spingrads(2);
750 dd.mw_ratioGrad(dd_ref_list, p_ref_list, 1, ratios, grads);
751 for (
int iw = 0; iw < grads.size(); iw++)
753 CHECK(ratios[iw] == ComplexApprox(
ValueType(1.7472917722050971, 1.1900872950904169)));
754 CHECK(grads[iw][0] == ComplexApprox(
ValueType(0.5496675534224996, -0.07968022499097227)));
755 CHECK(grads[iw][1] == ComplexApprox(
ValueType(0.4927399293808675, -0.29971549854643653)));
756 CHECK(grads[iw][2] == ComplexApprox(
ValueType(1.2792642963632226, 0.12110307514989149)));
759 std::fill(ratios.begin(), ratios.end(), 0);
760 std::fill(grads.begin(), grads.end(), 0);
761 dd.mw_ratioGradWithSpin(dd_ref_list, p_ref_list, 1, ratios, grads, spingrads);
762 for (
int iw = 0; iw < grads.size(); iw++)
764 CHECK(ratios[iw] == ComplexApprox(
ValueType(1.7472917722050971, 1.1900872950904169)));
765 CHECK(grads[iw][0] == ComplexApprox(
ValueType(0.5496675534224996, -0.07968022499097227)));
766 CHECK(grads[iw][1] == ComplexApprox(
ValueType(0.4927399293808675, -0.29971549854643653)));
767 CHECK(grads[iw][2] == ComplexApprox(
ValueType(1.2792642963632226, 0.12110307514989149)));
768 CHECK(spingrads[iw] == ComplexApprox(
ValueType(1.164708841479661, 0.9576425115390172)));
772 std::fill(grads.begin(), grads.end(), 0);
774 dd.mw_evalGrad(dd_ref_list, p_ref_list, 1, grads);
775 for (
int iw = 0; iw < grads.size(); iw++)
777 CHECK(grads[iw][0] == ComplexApprox(G_list[iw].
get()[1][0]));
778 CHECK(grads[iw][1] == ComplexApprox(G_list[iw].
get()[1][1]));
779 CHECK(grads[iw][2] == ComplexApprox(G_list[iw].
get()[1][2]));
782 std::fill(grads.begin(), grads.end(), 0);
783 std::fill(spingrads.begin(), spingrads.end(), 0);
784 dd.mw_evalGradWithSpin(dd_ref_list, p_ref_list, 1, grads, spingrads);
785 for (
int iw = 0; iw < grads.size(); iw++)
787 CHECK(grads[iw][0] == ComplexApprox(G_list[iw].
get()[1][0]));
788 CHECK(grads[iw][1] == ComplexApprox(G_list[iw].
get()[1][1]));
789 CHECK(grads[iw][2] == ComplexApprox(G_list[iw].
get()[1][2]));
790 CHECK(spingrads[iw] == ComplexApprox(
ValueType(1.18922259, 2.80414598)));
794 elec_.mw_makeMove(p_ref_list, 1, displs);
801 dd.mw_evaluateLog(dd_ref_list, p_ref_list, G_list, L_list);
802 for (
int iw = 0; iw < dd_ref_list.size(); iw++)
804 PsiValue ref = dd_ref_list[iw].getValue();
806 CHECK(G_list[iw].
get()[1][0] == ComplexApprox(
ValueType(0.5496675534224996, -0.07968022499097227)));
807 CHECK(G_list[iw].
get()[1][1] == ComplexApprox(
ValueType(0.4927399293808675, -0.29971549854643653)));
808 CHECK(G_list[iw].
get()[1][2] == ComplexApprox(
ValueType(1.2792642963632226, 0.12110307514989149)));
811 dd.mw_evalGradWithSpin(dd_ref_list, p_ref_list, 1, grads, spingrads);
812 for (
int iw = 0; iw < grads.size(); iw++)
813 CHECK(spingrads[iw] == ComplexApprox(
ValueType(1.164708841479661, 0.9576425115390172)));
816 TEST_CASE(
"DiracDeterminantBatched_spinor_update",
"[wavefunction][fermion]")
WaveFunctionComponent::PsiValue PsiValue
static T convert(const std::complex< T1 > &logpsi)
helper functions for EinsplineSetBuilder
QTBase::GradType GradType
QTBase::RealType RealType
size_t getTotalNum() const
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > ParticleLayout
TEST_CASE("complex_helper", "[type_traits]")
DetMatInvertor
determinant matrix inverter select
A ParticleSet that handles virtual moves of a selected particle of a given physical ParticleSet Virtu...
void makeMoves(const ParticleSet &refp, int jel, const std::vector< PosType > &deltaV, bool sphere=false, int iat=-1)
move virtual particles to new postions and update distance tables
CHECKED_ELSE(check_matrix_result.result)
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
LatticeGaussianProduct::GradType GradType
void createResource(ResourceCollection &collection) const
initialize a shared resource and hand it to a collection
void transpose(const T *restrict A, size_t m, size_t lda, TO *restrict B, size_t n, size_t ldb)
transpose of A(m,n) to B(n,m)
QTBase::ComplexType ComplexType
void resize(size_type n, size_type m)
Resize the container.
void test_DiracDeterminantBatched_second()
QMCTraits::PosType PosType
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > lattice
Specialized paritlce class for atomistic simulations.
QTBase::ValueType ValueType
void rejectMove(Index_t iat)
reject a proposed move in regular mode
helper class to compute matrix inversion and the log value of determinant
void test_DiracDeterminantBatched_first()
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
void create(const std::vector< int > &agroup)
create grouped particles
MakeReturn< UnaryNode< FnLog, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t log(const Vector< T1, C1 > &l)
QMCTraits::RealType RealType
Declaration of DiracDeterminantBatched with a S(ingle)P(article)O(rbital)Set.
void makeMove(Index_t iat, const SingleParticlePos &displ, bool maybe_accept=true)
move the iat-th particle to active_pos_
CheckMatrixResult checkMatrix(M1 &a_mat, M2 &b_mat, const bool check_all=false, std::optional< const double > eps=std::nullopt)
This function checks equality a_mat and b_mat elements M1, M2 need to have their element type declare...
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 }))
ParticleAttrib< SingleParticlePos > ParticlePos
TinyVector< double, 3 > PosType
QMCTraits::ComplexType ComplexType
handles acquire/release resource by the consumer (RefVectorWithLeader type).
LatticeGaussianProduct::ValueType ValueType
ParticleAttrib< QTFull::GradType > ParticleGradient
Declaration of WaveFunctionComponent.
std::complex< double > LogValue
void acceptMove(Index_t iat)
accept the move and update the particle attribute by the proposed move in regular mode ...
std::enable_if_t< std::is_same< T_FP, TMAT >::value > invert_transpose(const Matrix< TMAT, ALLOC1 > &amat, Matrix< TMAT, ALLOC2 > &invMat, std::complex< TREAL > &LogDet)
compute the inverse of the transpose of matrix A and its determinant value in log when T_FP and TMAT ...
void test_DiracDeterminantBatched_delayed_update(int delay_rank, DetMatInvertor matrix_inverter_kind)
void makeVirtualMoves(const SingleParticlePos &newpos)
Handles virtual moves for all the particles to a single newpos.