From 1bd7a42efe02f47763d78eccc3236432943457f9 Mon Sep 17 00:00:00 2001 From: Cody Melton Date: Fri, 16 Dec 2022 17:15:46 -0700 Subject: [PATCH 1/9] add VP to SOECP and remove block, not used yet --- src/QMCHamiltonians/ECPotentialBuilder.cpp | 13 ++++++------- src/QMCHamiltonians/SOECPComponent.cpp | 19 ++++++++++++++++++- src/QMCHamiltonians/SOECPComponent.h | 4 +++- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/QMCHamiltonians/ECPotentialBuilder.cpp b/src/QMCHamiltonians/ECPotentialBuilder.cpp index efab963a88..a4755bc3d3 100644 --- a/src/QMCHamiltonians/ECPotentialBuilder.cpp +++ b/src/QMCHamiltonians/ECPotentialBuilder.cpp @@ -144,12 +144,7 @@ bool ECPotentialBuilder::put(xmlNodePtr cur) { nknot_max = std::max(nknot_max, nonLocalPot[i]->getNknot()); if (NLPP_algo == "batched") - { - if( !targetPtcl.isSpinor()) - nonLocalPot[i]->initVirtualParticle(targetPtcl); - else - throw std::runtime_error("Batched NLPP evaluation not validated with spinors. Use algorithm=\"non-batched\" in pseudopotential block."); - } + nonLocalPot[i]->initVirtualParticle(targetPtcl); apot->addComponent(i, std::move(nonLocalPot[i])); } } @@ -181,12 +176,16 @@ bool ECPotentialBuilder::put(xmlNodePtr cur) { nknot_max = std::max(nknot_max, soPot[i]->getNknot()); sknot_max = std::max(sknot_max, soPot[i]->getSknot()); + if (NLPP_algo == "batched") + soPot[i]->initVirtualParticle(targetPtcl); apot->addComponent(i, std::move(soPot[i])); } } app_log() << "\n Using SOECP potential \n" << " Maximum grid on a sphere for SOECPotential: " << nknot_max << std::endl; app_log() << " Maximum grid for Simpson's rule for spin integral: " << sknot_max << std::endl; + if (NLPP_algo == "batched") + app_log() << " Using batched ratio computing in SOECP potential" << std::endl; if (physicalSO == "yes") targetH.addOperator(std::move(apot), "SOECP"); //default is physical operator @@ -218,7 +217,7 @@ void ECPotentialBuilder::useXmlFormat(xmlNodePtr cur) std::string href("none"); std::string ionName("none"); std::string format("xml"); - int nrule = -1; + int nrule = -1; int llocal = -1; //RealType rc(2.0);//use 2 Bohr OhmmsAttributeSet hAttrib; diff --git a/src/QMCHamiltonians/SOECPComponent.cpp b/src/QMCHamiltonians/SOECPComponent.cpp index f25f2f1a65..1215e3ba2b 100644 --- a/src/QMCHamiltonians/SOECPComponent.cpp +++ b/src/QMCHamiltonians/SOECPComponent.cpp @@ -17,16 +17,33 @@ namespace qmcplusplus { -SOECPComponent::SOECPComponent() : lmax(0), nchannel(0), nknot(0), sknot(0), Rmax(-1) {} +SOECPComponent::SOECPComponent() : lmax(0), nchannel(0), nknot(0), sknot(0), Rmax(-1), VP(nullptr) {} SOECPComponent::~SOECPComponent() { for (int i = 0; i < sopp_m.size(); i++) delete sopp_m[i]; + if (VP) + delete VP; } void SOECPComponent::print(std::ostream& os) {} +void SOECPComponent::initVirtualParticle(const ParticleSet& qp) +{ + assert(VP == nullptr); + outputManager.pause(); + VP = new VirtualParticleSet(qp, nknot); + outputManager.resume(); +} + +void SOECPComponent::deleteVirtualParticle() +{ + if (VP) + delete VP; + VP = nullptr; +} + void SOECPComponent::add(int l, RadialPotentialType* pp) { angpp_m.push_back(l); diff --git a/src/QMCHamiltonians/SOECPComponent.h b/src/QMCHamiltonians/SOECPComponent.h index c29e7ba4d1..e9f178f8fa 100644 --- a/src/QMCHamiltonians/SOECPComponent.h +++ b/src/QMCHamiltonians/SOECPComponent.h @@ -69,6 +69,7 @@ class SOECPComponent : public QMCTraits std::vector vrad; std::vector sgridweight_m; + VirtualParticleSet* VP; public: SOECPComponent(); @@ -116,7 +117,8 @@ class SOECPComponent : public QMCTraits void print(std::ostream& os); - //void initVirtualParticle(const ParticleSet& qp){}; + void initVirtualParticle(const ParticleSet& qp); + void deleteVirtualParticle(); inline void setRmax(int rmax) { Rmax = rmax; } inline RealType getRmax() const { return Rmax; } From 11ecf2ddd2ef2f373b8b5935a3ceb03d427d515b Mon Sep 17 00:00:00 2001 From: Cody Melton Date: Mon, 19 Dec 2022 15:11:02 -0700 Subject: [PATCH 2/9] refactor and add VPs to SOECPComponent --- src/Particle/VirtualParticleSet.cpp | 25 ++++++++++++ src/Particle/VirtualParticleSet.h | 8 ++++ src/QMCHamiltonians/SOECPComponent.cpp | 53 +++++++++++++++++++------- src/QMCHamiltonians/SOECPComponent.h | 10 ++++- src/QMCHamiltonians/tests/test_ecp.cpp | 29 +++++++++----- 5 files changed, 102 insertions(+), 23 deletions(-) diff --git a/src/Particle/VirtualParticleSet.cpp b/src/Particle/VirtualParticleSet.cpp index b8fafc88ad..de541811a4 100644 --- a/src/Particle/VirtualParticleSet.cpp +++ b/src/Particle/VirtualParticleSet.cpp @@ -116,6 +116,31 @@ void VirtualParticleSet::makeMoves(int jel, update(); } +/// move virtual particles to new postions and update distance tables +void VirtualParticleSet::makeMovesWithSpin(int jel, + const PosType& ref_pos, + const std::vector& deltaV, + const RealType& ref_spin, + const std::vector& deltaS, + bool sphere, + int iat) +{ + if (sphere && iat < 0) + throw std::runtime_error( + "VirtualParticleSet::makeMoves is invoked incorrectly, the flag sphere=true requires iat specified!"); + onSphere = sphere; + refPtcl = jel; + refSourcePtcl = iat; + assert(R.size() == deltaV.size()); + assert(spins.size() == deltaS.size()); + for (size_t ivp = 0; ivp < R.size(); ivp++) + { + R[ivp] = ref_pos + deltaV[ivp]; + spins[ivp] = ref_spin + deltaS[ivp]; + } + update(); +} + void VirtualParticleSet::mw_makeMoves(const RefVectorWithLeader& vp_list, const RefVector>& deltaV_list, const RefVector>& joblist, diff --git a/src/Particle/VirtualParticleSet.h b/src/Particle/VirtualParticleSet.h index a431b8340b..0941d0c9f3 100644 --- a/src/Particle/VirtualParticleSet.h +++ b/src/Particle/VirtualParticleSet.h @@ -86,6 +86,14 @@ class VirtualParticleSet : public ParticleSet bool sphere = false, int iat = -1); + void makeMovesWithSpin(int jel, + const PosType& ref_pos, + const std::vector& deltaV, + const RealType& ref_spin, + const std::vector& deltaS, + bool sphere = false, + int iat = -1); + static void mw_makeMoves(const RefVectorWithLeader& vp_list, const RefVector>& deltaV_list, const RefVector>& joblist, diff --git a/src/QMCHamiltonians/SOECPComponent.cpp b/src/QMCHamiltonians/SOECPComponent.cpp index 1215e3ba2b..5eb346112b 100644 --- a/src/QMCHamiltonians/SOECPComponent.cpp +++ b/src/QMCHamiltonians/SOECPComponent.cpp @@ -62,6 +62,7 @@ void SOECPComponent::resize_warrays(int n, int m, int s) { psiratio.resize(n); deltaV.resize(n); + deltaS.resize(n); vrad.resize(m); rrotsgrid_m.resize(n); nchannel = sopp_m.size(); @@ -125,19 +126,32 @@ SOECPComponent::ComplexType SOECPComponent::getAngularIntegral(RealType sold, TrialWaveFunction& Psi, int iel, RealType r, - const PosType& dr) + const PosType& dr, + int iat) { - //quadrature sum for angular integral - constexpr RealType fourpi = 2.0 * TWOPI; - for (int j = 0; j < nknot; j++) + buildQuadraturePointDeltas(r, dr, deltaV, snew - sold, deltaS); + + if (VP) { - deltaV[j] = r * rrotsgrid_m[j] - dr; - W.makeMoveWithSpin(iel, deltaV[j], snew - sold); - psiratio[j] = Psi.calcRatio(W, iel) * sgridweight_m[j] * fourpi; - W.rejectMove(iel); - Psi.resetPhaseDiff(); + VP->makeMovesWithSpin(iel, W.R[iel], deltaV, W.spins[iel], deltaS, true, iat); + Psi.evaluateRatios(*VP, psiratio); + } + else + { + //quadrature sum for angular integral + for (int j = 0; j < nknot; j++) + { + W.makeMoveWithSpin(iel, deltaV[j], deltaS[j]); + psiratio[j] = Psi.calcRatio(W, iel); + W.rejectMove(iel); + Psi.resetPhaseDiff(); + } } + //Need to add appropriate weight to psiratio + std::transform(psiratio.begin(), psiratio.end(), sgridweight_m.begin(), psiratio.begin(), + [](auto& psi, auto& weight) { return psi * weight * 2.0 * TWOPI; }); + ComplexType angint(0.0); for (int j = 0; j < nknot; j++) { @@ -193,22 +207,35 @@ SOECPComponent::RealType SOECPComponent::evaluateOne(ParticleSet& W, for (int is = 1; is <= sknot - 1; is += 2) { RealType snew = smin + is * dS; - ComplexType angint = getAngularIntegral(sold, snew, W, Psi, iel, r, dr); + ComplexType angint = getAngularIntegral(sold, snew, W, Psi, iel, r, dr, iat); sint += RealType(4. / 3.) * dS * angint; } for (int is = 2; is <= sknot - 2; is += 2) { RealType snew = smin + is * dS; - ComplexType angint = getAngularIntegral(sold, snew, W, Psi, iel, r, dr); + ComplexType angint = getAngularIntegral(sold, snew, W, Psi, iel, r, dr, iat); sint += RealType(2. / 3.) * dS * angint; } - sint += RealType(1. / 3.) * dS * getAngularIntegral(sold, smin, W, Psi, iel, r, dr); - sint += RealType(1. / 3.) * dS * getAngularIntegral(sold, smax, W, Psi, iel, r, dr); + sint += RealType(1. / 3.) * dS * getAngularIntegral(sold, smin, W, Psi, iel, r, dr, iat); + sint += RealType(1. / 3.) * dS * getAngularIntegral(sold, smax, W, Psi, iel, r, dr, iat); RealType pairpot = std::real(sint) / TWOPI; return pairpot; } +void SOECPComponent::buildQuadraturePointDeltas(RealType r, + const PosType& dr, + std::vector& deltaV, + RealType ds, + std::vector& deltaS) const +{ + for (int j = 0; j < nknot; j++) + { + deltaV[j] = r * rrotsgrid_m[j] - dr; + deltaS[j] = ds; + } +} + void SOECPComponent::randomize_grid(RandomGenerator& myRNG) { RealType phi(TWOPI * myRNG()), psi(TWOPI * myRNG()), cth(myRNG() - 0.5); diff --git a/src/QMCHamiltonians/SOECPComponent.h b/src/QMCHamiltonians/SOECPComponent.h index e9f178f8fa..658f45a681 100644 --- a/src/QMCHamiltonians/SOECPComponent.h +++ b/src/QMCHamiltonians/SOECPComponent.h @@ -60,9 +60,11 @@ class SOECPComponent : public QMCTraits TrialWaveFunction& Psi, int iel, RealType r, - const PosType& dr); + const PosType& dr, + int iat); std::vector deltaV; + std::vector deltaS; SpherGridType sgridxyz_m; SpherGridType rrotsgrid_m; std::vector psiratio; @@ -71,6 +73,12 @@ class SOECPComponent : public QMCTraits VirtualParticleSet* VP; + void buildQuadraturePointDeltas(RealType r, + const PosType& dr, + std::vector& deltaV, + RealType ds, + std::vector& deltaS) const; + public: SOECPComponent(); ~SOECPComponent(); diff --git a/src/QMCHamiltonians/tests/test_ecp.cpp b/src/QMCHamiltonians/tests/test_ecp.cpp index ca0a84ece6..ad8c8c8db6 100644 --- a/src/QMCHamiltonians/tests/test_ecp.cpp +++ b/src/QMCHamiltonians/tests/test_ecp.cpp @@ -536,21 +536,32 @@ TEST_CASE("Evaluate_soecp", "[hamiltonian]") //Need to set up temporary data for this configuration in trial wavefunction. Needed for ratios. double logpsi = psi.evaluateLog(elec); - RealType Value1(0.0); - for (int jel = 0; jel < elec.getTotalNum(); jel++) - { - const auto& dist = myTable.getDistRow(jel); - const auto& displ = myTable.getDisplRow(jel); - for (int iat = 0; iat < ions.getTotalNum(); iat++) + auto test_evaluateOne = [&]() { + RealType Value1(0.0); + for (int jel = 0; jel < elec.getTotalNum(); jel++) { - if (sopp != nullptr && dist[iat] < sopp->getRmax()) + const auto& dist = myTable.getDistRow(jel); + const auto& displ = myTable.getDisplRow(jel); + for (int iat = 0; iat < ions.getTotalNum(); iat++) { - Value1 += sopp->evaluateOne(elec, iat, psi, jel, dist[iat], RealType(-1) * displ[iat]); + if (sopp != nullptr && dist[iat] < sopp->getRmax()) + { + Value1 += sopp->evaluateOne(elec, iat, psi, jel, dist[iat], RealType(-1) * displ[iat]); + } } } + REQUIRE(Value1 == Approx(-0.3214176962)); + }; + + { + //test with VPs + sopp->initVirtualParticle(elec); + test_evaluateOne(); + sopp->deleteVirtualParticle(); + //test without VPs + test_evaluateOne(); } - REQUIRE(Value1 == Approx(-0.3214176962)); } #endif From 52526361c249e62bdb3f4faed1554c3adf541679 Mon Sep 17 00:00:00 2001 From: Cody Melton Date: Tue, 20 Dec 2022 10:47:53 -0700 Subject: [PATCH 3/9] fix VP to include spin update, update tests --- src/Particle/VirtualParticleSet.cpp | 14 ++++++++------ src/Particle/VirtualParticleSet.h | 11 +++-------- src/QMCHamiltonians/ECPotentialBuilder.cpp | 4 ++-- src/QMCHamiltonians/NonLocalECPComponent.cpp | 7 +++---- src/QMCHamiltonians/NonLocalECPotential.deriv.cpp | 2 +- src/QMCHamiltonians/SOECPComponent.cpp | 2 +- .../tests/test_DiracDeterminant.cpp | 2 +- .../tests/test_DiracDeterminantBatched.cpp | 4 ++-- src/QMCWaveFunctions/tests/test_J2_bspline.cpp | 2 +- .../tests/test_multi_slater_determinant.cpp | 12 ++++++------ .../tests/test_polynomial_eeI_jastrow.cpp | 2 +- .../bccMo_2x1x1_SOREP/Mo-vmc-dmc-long.in.xml | 2 +- .../bccMo_2x1x1_SOREP/Mo-vmc-dmc-short.in.xml | 2 +- tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-long.in.xml | 2 +- tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-short.in.xml | 2 +- .../solids/bccMo_2x1x1_SOREP/det_Mo-vmc-dmc.in.xml | 2 +- tests/solids/bccMo_2x1x1_SOREP/det_Mo-vmc.in.xml | 2 +- 17 files changed, 35 insertions(+), 39 deletions(-) diff --git a/src/Particle/VirtualParticleSet.cpp b/src/Particle/VirtualParticleSet.cpp index de541811a4..e1c46fc146 100644 --- a/src/Particle/VirtualParticleSet.cpp +++ b/src/Particle/VirtualParticleSet.cpp @@ -99,7 +99,7 @@ void VirtualParticleSet::releaseResource(ResourceCollection& collection, /// move virtual particles to new postions and update distance tables void VirtualParticleSet::makeMoves(int jel, - const PosType& ref_pos, + const ParticleSet& p, const std::vector& deltaV, bool sphere, int iat) @@ -112,15 +112,17 @@ void VirtualParticleSet::makeMoves(int jel, refSourcePtcl = iat; assert(R.size() == deltaV.size()); for (size_t ivp = 0; ivp < R.size(); ivp++) - R[ivp] = ref_pos + deltaV[ivp]; + { + R[ivp] = p.R[jel] + deltaV[ivp]; + spins[ivp] = p.spins[jel]; //no spin deltas in this API + } update(); } /// move virtual particles to new postions and update distance tables void VirtualParticleSet::makeMovesWithSpin(int jel, - const PosType& ref_pos, + const ParticleSet& p, const std::vector& deltaV, - const RealType& ref_spin, const std::vector& deltaS, bool sphere, int iat) @@ -135,8 +137,8 @@ void VirtualParticleSet::makeMovesWithSpin(int jel, assert(spins.size() == deltaS.size()); for (size_t ivp = 0; ivp < R.size(); ivp++) { - R[ivp] = ref_pos + deltaV[ivp]; - spins[ivp] = ref_spin + deltaS[ivp]; + R[ivp] = p.R[jel] + deltaV[ivp]; + spins[ivp] = p.spins[jel] + deltaS[ivp]; } update(); } diff --git a/src/Particle/VirtualParticleSet.h b/src/Particle/VirtualParticleSet.h index 0941d0c9f3..fd60c7e2bf 100644 --- a/src/Particle/VirtualParticleSet.h +++ b/src/Particle/VirtualParticleSet.h @@ -75,21 +75,16 @@ class VirtualParticleSet : public ParticleSet /** move virtual particles to new postions and update distance tables * @param jel reference particle that all the VP moves from - * @param ref_pos reference particle position + * @param p reference particle set * @param deltaV Position delta for virtual moves. * @param sphere set true if VP are on a sphere around the reference source particle * @param iat reference source particle */ - void makeMoves(int jel, - const PosType& ref_pos, - const std::vector& deltaV, - bool sphere = false, - int iat = -1); + void makeMoves(int jel, const ParticleSet& p, const std::vector& deltaV, bool sphere = false, int iat = -1); void makeMovesWithSpin(int jel, - const PosType& ref_pos, + const ParticleSet& p, const std::vector& deltaV, - const RealType& ref_spin, const std::vector& deltaS, bool sphere = false, int iat = -1); diff --git a/src/QMCHamiltonians/ECPotentialBuilder.cpp b/src/QMCHamiltonians/ECPotentialBuilder.cpp index a4755bc3d3..62507678d3 100644 --- a/src/QMCHamiltonians/ECPotentialBuilder.cpp +++ b/src/QMCHamiltonians/ECPotentialBuilder.cpp @@ -176,8 +176,8 @@ bool ECPotentialBuilder::put(xmlNodePtr cur) { nknot_max = std::max(nknot_max, soPot[i]->getNknot()); sknot_max = std::max(sknot_max, soPot[i]->getSknot()); - if (NLPP_algo == "batched") - soPot[i]->initVirtualParticle(targetPtcl); + //if (NLPP_algo == "batched") + // soPot[i]->initVirtualParticle(targetPtcl); apot->addComponent(i, std::move(soPot[i])); } } diff --git a/src/QMCHamiltonians/NonLocalECPComponent.cpp b/src/QMCHamiltonians/NonLocalECPComponent.cpp index 0b05ae0a7e..9ae5870c48 100644 --- a/src/QMCHamiltonians/NonLocalECPComponent.cpp +++ b/src/QMCHamiltonians/NonLocalECPComponent.cpp @@ -135,7 +135,7 @@ NonLocalECPComponent::RealType NonLocalECPComponent::evaluateOne(ParticleSet& W, if (VP) { // Compute ratios with VP - VP->makeMoves(iel, W.R[iel], deltaV, true, iat); + VP->makeMoves(iel, W, deltaV, true, iat); if (use_DLA) psi.evaluateRatios(*VP, psiratio, TrialWaveFunction::ComputeType::FERMIONIC); else @@ -310,7 +310,7 @@ NonLocalECPComponent::RealType NonLocalECPComponent::evaluateOneWithForces(Parti { APP_ABORT("NonLocalECPComponent::evaluateOneWithForces(...): Forces not implemented with virtual particle moves\n"); // Compute ratios with VP - VP->makeMoves(iel, W.R[iel], deltaV, true, iat); + VP->makeMoves(iel, W, deltaV, true, iat); psi.evaluateRatios(*VP, psiratio); } else @@ -460,7 +460,7 @@ NonLocalECPComponent::RealType NonLocalECPComponent::evaluateOneWithForces(Parti { APP_ABORT("NonLocalECPComponent::evaluateOneWithForces(...): Forces not implemented with virtual particle moves\n"); // Compute ratios with VP - VP->makeMoves(iel, W.R[iel], deltaV, true, iat); + VP->makeMoves(iel, W, deltaV, true, iat); psi.evaluateRatios(*VP, psiratio); } else @@ -802,7 +802,6 @@ void NonLocalECPComponent::evaluateOneBodyOpMatrixdRContribution(ParticleSet& W, for (int j = 0; j < nknot; j++) { - RealType zz = dot(dr, rrotsgrid_m[j]) * rinv; PosType uminusrvec = rrotsgrid_m[j] - zz * dr * rinv; diff --git a/src/QMCHamiltonians/NonLocalECPotential.deriv.cpp b/src/QMCHamiltonians/NonLocalECPotential.deriv.cpp index 420050366d..1ff6c5da10 100644 --- a/src/QMCHamiltonians/NonLocalECPotential.deriv.cpp +++ b/src/QMCHamiltonians/NonLocalECPotential.deriv.cpp @@ -81,7 +81,7 @@ NonLocalECPComponent::RealType NonLocalECPComponent::evaluateValueAndDerivatives if (VP) { // Compute ratios with VP - VP->makeMoves(iel, W.R[iel], deltaV, true, iat); + VP->makeMoves(iel, W, deltaV, true, iat); psi.evaluateDerivRatios(*VP, optvars, psiratio, dratio); } else diff --git a/src/QMCHamiltonians/SOECPComponent.cpp b/src/QMCHamiltonians/SOECPComponent.cpp index 5eb346112b..b88a096bc0 100644 --- a/src/QMCHamiltonians/SOECPComponent.cpp +++ b/src/QMCHamiltonians/SOECPComponent.cpp @@ -133,7 +133,7 @@ SOECPComponent::ComplexType SOECPComponent::getAngularIntegral(RealType sold, if (VP) { - VP->makeMovesWithSpin(iel, W.R[iel], deltaV, W.spins[iel], deltaS, true, iat); + VP->makeMovesWithSpin(iel, W, deltaV, deltaS, true, iat); Psi.evaluateRatios(*VP, psiratio); } else diff --git a/src/QMCWaveFunctions/tests/test_DiracDeterminant.cpp b/src/QMCWaveFunctions/tests/test_DiracDeterminant.cpp index f30014ada7..3155bf8785 100644 --- a/src/QMCWaveFunctions/tests/test_DiracDeterminant.cpp +++ b/src/QMCWaveFunctions/tests/test_DiracDeterminant.cpp @@ -123,7 +123,7 @@ void test_DiracDeterminant_first(const DetMatInvertor inverter_kind) std::vector ratios2(2); newpos2[0] = newpos - elec.R[1]; newpos2[1] = PosType(0.2, 0.5, 0.3) - elec.R[1]; - VP.makeMoves(1, elec.R[1], newpos2); + VP.makeMoves(1, elec, newpos2); ddb.evaluateRatios(VP, ratios2); CHECK(std::real(ratios2[0]) == Approx(0.4880285278)); diff --git a/src/QMCWaveFunctions/tests/test_DiracDeterminantBatched.cpp b/src/QMCWaveFunctions/tests/test_DiracDeterminantBatched.cpp index 796644022f..ca234eaaed 100644 --- a/src/QMCWaveFunctions/tests/test_DiracDeterminantBatched.cpp +++ b/src/QMCWaveFunctions/tests/test_DiracDeterminantBatched.cpp @@ -109,7 +109,7 @@ void test_DiracDeterminantBatched_first() std::vector ratios2(2); newpos2[0] = newpos - elec.R[1]; newpos2[1] = PosType(0.2, 0.5, 0.3) - elec.R[1]; - VP.makeMoves(1, elec.R[1], newpos2); + VP.makeMoves(1, elec, newpos2); ddb.evaluateRatios(VP, ratios2); CHECK(std::real(ratios2[0]) == Approx(0.4880285278)); @@ -817,7 +817,7 @@ void test_DiracDeterminantBatched_spinor_update(const int delay_rank, DetMatInve TEST_CASE("DiracDeterminantBatched_spinor_update", "[wavefunction][fermion]") { -/* Uncomment when MatrixDelayedUpdateCUDA::mw_evalGradWithSpin is implemented + /* Uncomment when MatrixDelayedUpdateCUDA::mw_evalGradWithSpin is implemented #if defined(ENABLE_OFFLOAD) && defined(ENABLE_CUDA) test_DiracDeterminantBatched_spinor_update< MatrixDelayedUpdateCUDA>(1, DetMatInvertor::ACCEL); diff --git a/src/QMCWaveFunctions/tests/test_J2_bspline.cpp b/src/QMCWaveFunctions/tests/test_J2_bspline.cpp index 953a510bf3..0c4fbf8eb9 100644 --- a/src/QMCWaveFunctions/tests/test_J2_bspline.cpp +++ b/src/QMCWaveFunctions/tests/test_J2_bspline.cpp @@ -239,7 +239,7 @@ TEST_CASE("BSpline builder Jastrow J2", "[wavefunction]") std::vector ratios2(2); newpos2[0] = newpos - elec_.R[1]; newpos2[1] = PosType(0.2, 0.5, 0.3) - elec_.R[1]; - VP.makeMoves(1, elec_.R[1], newpos2); + VP.makeMoves(1, elec_, newpos2); j2->evaluateRatios(VP, ratios2); REQUIRE(std::real(ratios2[0]) == Approx(0.9871985577)); diff --git a/src/QMCWaveFunctions/tests/test_multi_slater_determinant.cpp b/src/QMCWaveFunctions/tests/test_multi_slater_determinant.cpp index 15449a26b3..ae4c1bdab8 100644 --- a/src/QMCWaveFunctions/tests/test_multi_slater_determinant.cpp +++ b/src/QMCWaveFunctions/tests/test_multi_slater_determinant.cpp @@ -98,7 +98,7 @@ void test_LiH_msd(const std::string& spo_xml_string, twf.evaluateLog(elec_); app_log() << "twf.evaluateLog logpsi " << std::setprecision(16) << twf.getLogPsi() << " " << twf.getPhase() - << std::endl; + << std::endl; CHECK(std::complex(twf.getLogPsi(), twf.getPhase()) == LogComplexApprox(std::complex(-7.646027846242066, 3.141592653589793))); CHECK(elec_.G[0][0] == ValueApprox(-2.181896934)); @@ -174,7 +174,7 @@ void test_LiH_msd(const std::string& spo_xml_string, std::vector ratios2(2); newpos2[0] = newpos - elec_.R[1]; newpos2[1] = PosType(0.2, 0.5, 0.3) - elec_.R[1]; - VP.makeMoves(1, elec_.R[1], newpos2); + VP.makeMoves(1, elec_, newpos2); twf.evaluateRatios(VP, ratios2); CHECK(std::real(ratios2[0]) == Approx(-0.8544310407)); @@ -205,7 +205,7 @@ void test_LiH_msd(const std::string& spo_xml_string, twf.evaluateLog(elec_); app_log() << "twf.evaluateLog logpsi " << std::setprecision(16) << twf.getLogPsi() << " " << twf.getPhase() - << std::endl; + << std::endl; CHECK(std::complex(twf.getLogPsi(), twf.getPhase()) == LogComplexApprox(std::complex(-7.803347327300154, 0.0))); CHECK(elec_.G[0][0] == ValueApprox(1.63020975849953)); @@ -244,9 +244,9 @@ void test_LiH_msd(const std::string& spo_xml_string, ParticleSet::mw_update(p_ref_list); TrialWaveFunction::mw_evaluateLog(wf_ref_list, p_ref_list); app_log() << "before YYY [0] getLogPsi getPhase " << std::setprecision(16) << wf_ref_list[0].getLogPsi() << " " - << wf_ref_list[0].getPhase() << std::endl; + << wf_ref_list[0].getPhase() << std::endl; app_log() << "before YYY [1] getLogPsi getPhase " << std::setprecision(16) << wf_ref_list[1].getLogPsi() << " " - << wf_ref_list[1].getPhase() << std::endl; + << wf_ref_list[1].getPhase() << std::endl; CHECK(std::complex(wf_ref_list[0].getLogPsi(), wf_ref_list[0].getPhase()) == LogComplexApprox(std::complex(-7.803347327300153, 0.0))); CHECK(std::complex(wf_ref_list[1].getLogPsi(), wf_ref_list[1].getPhase()) == @@ -450,7 +450,7 @@ void test_Bi_msd(const std::string& spo_xml_string, //Reference values from QWalk with SOC app_log() << "twf.evaluateLog logpsi " << std::setprecision(16) << twf.getLogPsi() << " " << twf.getPhase() - << std::endl; + << std::endl; CHECK(std::complex(twf.getLogPsi(), twf.getPhase()) == LogComplexApprox(std::complex(-9.653087, 3.311467))); diff --git a/src/QMCWaveFunctions/tests/test_polynomial_eeI_jastrow.cpp b/src/QMCWaveFunctions/tests/test_polynomial_eeI_jastrow.cpp index 49def8719c..fdd3eb41f7 100644 --- a/src/QMCWaveFunctions/tests/test_polynomial_eeI_jastrow.cpp +++ b/src/QMCWaveFunctions/tests/test_polynomial_eeI_jastrow.cpp @@ -188,7 +188,7 @@ void test_J3_polynomial3D(const DynamicCoordinateKind kind_selected) std::vector ratios2(2); newpos2[0] = newpos - elec_.R[1]; newpos2[1] = PosType(0.2, 0.5, 0.3) - elec_.R[1]; - VP.makeMoves(1, elec_.R[1], newpos2); + VP.makeMoves(1, elec_, newpos2); j3->evaluateRatios(VP, ratios2); REQUIRE(std::real(ratios2[0]) == Approx(1.0357541137)); diff --git a/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-dmc-long.in.xml b/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-dmc-long.in.xml index 7e95d35b86..669b243857 100644 --- a/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-dmc-long.in.xml +++ b/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-dmc-long.in.xml @@ -58,7 +58,7 @@ - + diff --git a/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-dmc-short.in.xml b/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-dmc-short.in.xml index 0cc230be60..555bb14d12 100644 --- a/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-dmc-short.in.xml +++ b/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-dmc-short.in.xml @@ -58,7 +58,7 @@ - + diff --git a/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-long.in.xml b/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-long.in.xml index 4be15f911f..c7f8a93f77 100644 --- a/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-long.in.xml +++ b/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-long.in.xml @@ -58,7 +58,7 @@ - + diff --git a/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-short.in.xml b/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-short.in.xml index 5c7378acf1..6a4c1d261e 100644 --- a/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-short.in.xml +++ b/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-short.in.xml @@ -58,7 +58,7 @@ - + diff --git a/tests/solids/bccMo_2x1x1_SOREP/det_Mo-vmc-dmc.in.xml b/tests/solids/bccMo_2x1x1_SOREP/det_Mo-vmc-dmc.in.xml index 8390de48e8..421e5a38f4 100644 --- a/tests/solids/bccMo_2x1x1_SOREP/det_Mo-vmc-dmc.in.xml +++ b/tests/solids/bccMo_2x1x1_SOREP/det_Mo-vmc-dmc.in.xml @@ -58,7 +58,7 @@ - + diff --git a/tests/solids/bccMo_2x1x1_SOREP/det_Mo-vmc.in.xml b/tests/solids/bccMo_2x1x1_SOREP/det_Mo-vmc.in.xml index 37afa759ed..39e6e6136a 100644 --- a/tests/solids/bccMo_2x1x1_SOREP/det_Mo-vmc.in.xml +++ b/tests/solids/bccMo_2x1x1_SOREP/det_Mo-vmc.in.xml @@ -58,7 +58,7 @@ - + From d4974a5c075943e75bd176222ff09b36ba92f05b Mon Sep 17 00:00:00 2001 From: Cody Melton Date: Tue, 20 Dec 2022 13:00:59 -0700 Subject: [PATCH 4/9] enable VP and fix makeClone --- src/QMCHamiltonians/ECPotentialBuilder.cpp | 4 ++-- src/QMCHamiltonians/SOECPComponent.cpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/QMCHamiltonians/ECPotentialBuilder.cpp b/src/QMCHamiltonians/ECPotentialBuilder.cpp index 62507678d3..a4755bc3d3 100644 --- a/src/QMCHamiltonians/ECPotentialBuilder.cpp +++ b/src/QMCHamiltonians/ECPotentialBuilder.cpp @@ -176,8 +176,8 @@ bool ECPotentialBuilder::put(xmlNodePtr cur) { nknot_max = std::max(nknot_max, soPot[i]->getNknot()); sknot_max = std::max(sknot_max, soPot[i]->getSknot()); - //if (NLPP_algo == "batched") - // soPot[i]->initVirtualParticle(targetPtcl); + if (NLPP_algo == "batched") + soPot[i]->initVirtualParticle(targetPtcl); apot->addComponent(i, std::move(soPot[i])); } } diff --git a/src/QMCHamiltonians/SOECPComponent.cpp b/src/QMCHamiltonians/SOECPComponent.cpp index b88a096bc0..5d46d70dcd 100644 --- a/src/QMCHamiltonians/SOECPComponent.cpp +++ b/src/QMCHamiltonians/SOECPComponent.cpp @@ -55,6 +55,8 @@ SOECPComponent* SOECPComponent::makeClone(const ParticleSet& qp) SOECPComponent* myclone = new SOECPComponent(*this); for (int i = 0; i < sopp_m.size(); i++) myclone->sopp_m[i] = sopp_m[i]->makeClone(); + if (VP) + myclone->VP = new VirtualParticleSet(qp, nknot); return myclone; } From 9d6d2956719288ef1ad685f36fd00139e86110c7 Mon Sep 17 00:00:00 2001 From: Cody Melton Date: Tue, 20 Dec 2022 14:15:55 -0700 Subject: [PATCH 5/9] remote batched algo from tests since they are default --- tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-dmc-long.in.xml | 2 +- tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-dmc-short.in.xml | 2 +- tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-long.in.xml | 2 +- tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-short.in.xml | 2 +- tests/solids/bccMo_2x1x1_SOREP/det_Mo-vmc-dmc.in.xml | 2 +- tests/solids/bccMo_2x1x1_SOREP/det_Mo-vmc.in.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-dmc-long.in.xml b/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-dmc-long.in.xml index 669b243857..299bd9dc6d 100644 --- a/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-dmc-long.in.xml +++ b/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-dmc-long.in.xml @@ -58,7 +58,7 @@ - + diff --git a/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-dmc-short.in.xml b/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-dmc-short.in.xml index 555bb14d12..a88d8a6487 100644 --- a/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-dmc-short.in.xml +++ b/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-dmc-short.in.xml @@ -58,7 +58,7 @@ - + diff --git a/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-long.in.xml b/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-long.in.xml index c7f8a93f77..c2ee05e1f4 100644 --- a/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-long.in.xml +++ b/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-long.in.xml @@ -58,7 +58,7 @@ - + diff --git a/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-short.in.xml b/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-short.in.xml index 6a4c1d261e..42f231e67e 100644 --- a/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-short.in.xml +++ b/tests/solids/bccMo_2x1x1_SOREP/Mo-vmc-short.in.xml @@ -58,7 +58,7 @@ - + diff --git a/tests/solids/bccMo_2x1x1_SOREP/det_Mo-vmc-dmc.in.xml b/tests/solids/bccMo_2x1x1_SOREP/det_Mo-vmc-dmc.in.xml index 421e5a38f4..d698f8014e 100644 --- a/tests/solids/bccMo_2x1x1_SOREP/det_Mo-vmc-dmc.in.xml +++ b/tests/solids/bccMo_2x1x1_SOREP/det_Mo-vmc-dmc.in.xml @@ -58,7 +58,7 @@ - + diff --git a/tests/solids/bccMo_2x1x1_SOREP/det_Mo-vmc.in.xml b/tests/solids/bccMo_2x1x1_SOREP/det_Mo-vmc.in.xml index 39e6e6136a..69276847c0 100644 --- a/tests/solids/bccMo_2x1x1_SOREP/det_Mo-vmc.in.xml +++ b/tests/solids/bccMo_2x1x1_SOREP/det_Mo-vmc.in.xml @@ -58,7 +58,7 @@ - + From bfa4ce6475246ec75593eada435955bca640b431 Mon Sep 17 00:00:00 2001 From: Cody Melton Date: Tue, 20 Dec 2022 14:23:59 -0700 Subject: [PATCH 6/9] update error message --- src/Particle/VirtualParticleSet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Particle/VirtualParticleSet.cpp b/src/Particle/VirtualParticleSet.cpp index e1c46fc146..fe1d321b55 100644 --- a/src/Particle/VirtualParticleSet.cpp +++ b/src/Particle/VirtualParticleSet.cpp @@ -129,7 +129,7 @@ void VirtualParticleSet::makeMovesWithSpin(int jel, { if (sphere && iat < 0) throw std::runtime_error( - "VirtualParticleSet::makeMoves is invoked incorrectly, the flag sphere=true requires iat specified!"); + "VirtualParticleSet::makeMovesWithSpin is invoked incorrectly, the flag sphere=true requires iat specified!"); onSphere = sphere; refPtcl = jel; refSourcePtcl = iat; From 745501d4ad78eb0fffbbf9c4fb0c59aa79368884 Mon Sep 17 00:00:00 2001 From: Cody Melton Date: Tue, 20 Dec 2022 14:48:51 -0700 Subject: [PATCH 7/9] missed unit test change for VP --- src/QMCWaveFunctions/tests/test_MO.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/QMCWaveFunctions/tests/test_MO.cpp b/src/QMCWaveFunctions/tests/test_MO.cpp index 030b8697e9..50e6c3d2be 100644 --- a/src/QMCWaveFunctions/tests/test_MO.cpp +++ b/src/QMCWaveFunctions/tests/test_MO.cpp @@ -263,7 +263,7 @@ void test_Ne(bool transform) std::vector ratios2(2); newpos2[0] = disp; newpos2[1] = -disp; - VP.makeMoves(0, elec.R[0], newpos2); + VP.makeMoves(0, elec, newpos2); sposet->evaluateDetRatios(VP, phi, phiinv, ratios2); CHECK(ratios2[0] == Approx(-0.504163137)); // values[0] * phiinv[0] CHECK(ratios2[1] == Approx(-0.504163137)); // symmetric move From b889478d2896e2adc6561b44455eb15881ea64bd Mon Sep 17 00:00:00 2001 From: Cody Melton Date: Tue, 20 Dec 2022 15:18:42 -0700 Subject: [PATCH 8/9] change VP.makeMoves(WithSpin) to only pass pos and spin --- src/Particle/VirtualParticleSet.cpp | 14 +++++++----- src/Particle/VirtualParticleSet.h | 22 ++++++++++++++++--- src/QMCHamiltonians/NonLocalECPComponent.cpp | 6 ++--- .../NonLocalECPotential.deriv.cpp | 2 +- src/QMCHamiltonians/SOECPComponent.cpp | 2 +- src/QMCHamiltonians/tests/test_ecp.cpp | 4 ---- .../tests/test_DiracDeterminant.cpp | 2 +- .../tests/test_DiracDeterminantBatched.cpp | 2 +- .../tests/test_J2_bspline.cpp | 2 +- src/QMCWaveFunctions/tests/test_MO.cpp | 2 +- .../tests/test_multi_slater_determinant.cpp | 2 +- .../tests/test_polynomial_eeI_jastrow.cpp | 2 +- 12 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/Particle/VirtualParticleSet.cpp b/src/Particle/VirtualParticleSet.cpp index fe1d321b55..c34a601ffb 100644 --- a/src/Particle/VirtualParticleSet.cpp +++ b/src/Particle/VirtualParticleSet.cpp @@ -99,7 +99,8 @@ void VirtualParticleSet::releaseResource(ResourceCollection& collection, /// move virtual particles to new postions and update distance tables void VirtualParticleSet::makeMoves(int jel, - const ParticleSet& p, + const PosType& ref_pos, + const RealType ref_spin, const std::vector& deltaV, bool sphere, int iat) @@ -113,15 +114,16 @@ void VirtualParticleSet::makeMoves(int jel, assert(R.size() == deltaV.size()); for (size_t ivp = 0; ivp < R.size(); ivp++) { - R[ivp] = p.R[jel] + deltaV[ivp]; - spins[ivp] = p.spins[jel]; //no spin deltas in this API + R[ivp] = ref_pos + deltaV[ivp]; + spins[ivp] = ref_spin; //no spin deltas in this API } update(); } /// move virtual particles to new postions and update distance tables void VirtualParticleSet::makeMovesWithSpin(int jel, - const ParticleSet& p, + const PosType& ref_pos, + const RealType ref_spin, const std::vector& deltaV, const std::vector& deltaS, bool sphere, @@ -137,8 +139,8 @@ void VirtualParticleSet::makeMovesWithSpin(int jel, assert(spins.size() == deltaS.size()); for (size_t ivp = 0; ivp < R.size(); ivp++) { - R[ivp] = p.R[jel] + deltaV[ivp]; - spins[ivp] = p.spins[jel] + deltaS[ivp]; + R[ivp] = ref_pos + deltaV[ivp]; + spins[ivp] = ref_spin + deltaS[ivp]; } update(); } diff --git a/src/Particle/VirtualParticleSet.h b/src/Particle/VirtualParticleSet.h index fd60c7e2bf..49b26c9bee 100644 --- a/src/Particle/VirtualParticleSet.h +++ b/src/Particle/VirtualParticleSet.h @@ -75,15 +75,31 @@ class VirtualParticleSet : public ParticleSet /** move virtual particles to new postions and update distance tables * @param jel reference particle that all the VP moves from - * @param p reference particle set + * @param ref_pos reference particle position + * @param ref_spin reference particle spin * @param deltaV Position delta for virtual moves. * @param sphere set true if VP are on a sphere around the reference source particle * @param iat reference source particle */ - void makeMoves(int jel, const ParticleSet& p, const std::vector& deltaV, bool sphere = false, int iat = -1); + void makeMoves(int jel, + const PosType& ref_pos, + const RealType ref_spin, + const std::vector& deltaV, + bool sphere = false, + int iat = -1); + /** move virtual particles to new postions and update distance tables + * @param jel reference particle that all the VP moves from + * @param ref_pos reference particle position + * @param ref_spin reference particle spin + * @param deltaV Position delta for virtual moves. + * @param deltaS Spin delta for virtual moves. + * @param sphere set true if VP are on a sphere around the reference source particle + * @param iat reference source particle + */ void makeMovesWithSpin(int jel, - const ParticleSet& p, + const PosType& ref_pos, + const RealType ref_spin, const std::vector& deltaV, const std::vector& deltaS, bool sphere = false, diff --git a/src/QMCHamiltonians/NonLocalECPComponent.cpp b/src/QMCHamiltonians/NonLocalECPComponent.cpp index 9ae5870c48..de76a2813f 100644 --- a/src/QMCHamiltonians/NonLocalECPComponent.cpp +++ b/src/QMCHamiltonians/NonLocalECPComponent.cpp @@ -135,7 +135,7 @@ NonLocalECPComponent::RealType NonLocalECPComponent::evaluateOne(ParticleSet& W, if (VP) { // Compute ratios with VP - VP->makeMoves(iel, W, deltaV, true, iat); + VP->makeMoves(iel, W.R[iel], W.spins[iel], deltaV, true, iat); if (use_DLA) psi.evaluateRatios(*VP, psiratio, TrialWaveFunction::ComputeType::FERMIONIC); else @@ -310,7 +310,7 @@ NonLocalECPComponent::RealType NonLocalECPComponent::evaluateOneWithForces(Parti { APP_ABORT("NonLocalECPComponent::evaluateOneWithForces(...): Forces not implemented with virtual particle moves\n"); // Compute ratios with VP - VP->makeMoves(iel, W, deltaV, true, iat); + VP->makeMoves(iel, W.R[iel], W.spins[iel], deltaV, true, iat); psi.evaluateRatios(*VP, psiratio); } else @@ -460,7 +460,7 @@ NonLocalECPComponent::RealType NonLocalECPComponent::evaluateOneWithForces(Parti { APP_ABORT("NonLocalECPComponent::evaluateOneWithForces(...): Forces not implemented with virtual particle moves\n"); // Compute ratios with VP - VP->makeMoves(iel, W, deltaV, true, iat); + VP->makeMoves(iel, W.R[iel], W.spins[iel], deltaV, true, iat); psi.evaluateRatios(*VP, psiratio); } else diff --git a/src/QMCHamiltonians/NonLocalECPotential.deriv.cpp b/src/QMCHamiltonians/NonLocalECPotential.deriv.cpp index 1ff6c5da10..15bb203fe5 100644 --- a/src/QMCHamiltonians/NonLocalECPotential.deriv.cpp +++ b/src/QMCHamiltonians/NonLocalECPotential.deriv.cpp @@ -81,7 +81,7 @@ NonLocalECPComponent::RealType NonLocalECPComponent::evaluateValueAndDerivatives if (VP) { // Compute ratios with VP - VP->makeMoves(iel, W, deltaV, true, iat); + VP->makeMoves(iel, W.R[iel], W.spins[iel], deltaV, true, iat); psi.evaluateDerivRatios(*VP, optvars, psiratio, dratio); } else diff --git a/src/QMCHamiltonians/SOECPComponent.cpp b/src/QMCHamiltonians/SOECPComponent.cpp index 5d46d70dcd..5a9fff96d9 100644 --- a/src/QMCHamiltonians/SOECPComponent.cpp +++ b/src/QMCHamiltonians/SOECPComponent.cpp @@ -135,7 +135,7 @@ SOECPComponent::ComplexType SOECPComponent::getAngularIntegral(RealType sold, if (VP) { - VP->makeMovesWithSpin(iel, W, deltaV, deltaS, true, iat); + VP->makeMovesWithSpin(iel, W.R[iel], W.spins[iel], deltaV, deltaS, true, iat); Psi.evaluateRatios(*VP, psiratio); } else diff --git a/src/QMCHamiltonians/tests/test_ecp.cpp b/src/QMCHamiltonians/tests/test_ecp.cpp index ad8c8c8db6..7b66c92d0e 100644 --- a/src/QMCHamiltonians/tests/test_ecp.cpp +++ b/src/QMCHamiltonians/tests/test_ecp.cpp @@ -544,12 +544,8 @@ TEST_CASE("Evaluate_soecp", "[hamiltonian]") const auto& dist = myTable.getDistRow(jel); const auto& displ = myTable.getDisplRow(jel); for (int iat = 0; iat < ions.getTotalNum(); iat++) - { if (sopp != nullptr && dist[iat] < sopp->getRmax()) - { Value1 += sopp->evaluateOne(elec, iat, psi, jel, dist[iat], RealType(-1) * displ[iat]); - } - } } REQUIRE(Value1 == Approx(-0.3214176962)); }; diff --git a/src/QMCWaveFunctions/tests/test_DiracDeterminant.cpp b/src/QMCWaveFunctions/tests/test_DiracDeterminant.cpp index 3155bf8785..7fcb642481 100644 --- a/src/QMCWaveFunctions/tests/test_DiracDeterminant.cpp +++ b/src/QMCWaveFunctions/tests/test_DiracDeterminant.cpp @@ -123,7 +123,7 @@ void test_DiracDeterminant_first(const DetMatInvertor inverter_kind) std::vector ratios2(2); newpos2[0] = newpos - elec.R[1]; newpos2[1] = PosType(0.2, 0.5, 0.3) - elec.R[1]; - VP.makeMoves(1, elec, newpos2); + VP.makeMoves(1, elec.R[1], elec.spins[1], newpos2); ddb.evaluateRatios(VP, ratios2); CHECK(std::real(ratios2[0]) == Approx(0.4880285278)); diff --git a/src/QMCWaveFunctions/tests/test_DiracDeterminantBatched.cpp b/src/QMCWaveFunctions/tests/test_DiracDeterminantBatched.cpp index ca234eaaed..214b4e081b 100644 --- a/src/QMCWaveFunctions/tests/test_DiracDeterminantBatched.cpp +++ b/src/QMCWaveFunctions/tests/test_DiracDeterminantBatched.cpp @@ -109,7 +109,7 @@ void test_DiracDeterminantBatched_first() std::vector ratios2(2); newpos2[0] = newpos - elec.R[1]; newpos2[1] = PosType(0.2, 0.5, 0.3) - elec.R[1]; - VP.makeMoves(1, elec, newpos2); + VP.makeMoves(1, elec.R[1], elec.spins[1], newpos2); ddb.evaluateRatios(VP, ratios2); CHECK(std::real(ratios2[0]) == Approx(0.4880285278)); diff --git a/src/QMCWaveFunctions/tests/test_J2_bspline.cpp b/src/QMCWaveFunctions/tests/test_J2_bspline.cpp index 0c4fbf8eb9..d9d8b6dd33 100644 --- a/src/QMCWaveFunctions/tests/test_J2_bspline.cpp +++ b/src/QMCWaveFunctions/tests/test_J2_bspline.cpp @@ -239,7 +239,7 @@ TEST_CASE("BSpline builder Jastrow J2", "[wavefunction]") std::vector ratios2(2); newpos2[0] = newpos - elec_.R[1]; newpos2[1] = PosType(0.2, 0.5, 0.3) - elec_.R[1]; - VP.makeMoves(1, elec_, newpos2); + VP.makeMoves(1, elec_.R[1], elec_.spins[1], newpos2); j2->evaluateRatios(VP, ratios2); REQUIRE(std::real(ratios2[0]) == Approx(0.9871985577)); diff --git a/src/QMCWaveFunctions/tests/test_MO.cpp b/src/QMCWaveFunctions/tests/test_MO.cpp index 50e6c3d2be..b18ada950f 100644 --- a/src/QMCWaveFunctions/tests/test_MO.cpp +++ b/src/QMCWaveFunctions/tests/test_MO.cpp @@ -263,7 +263,7 @@ void test_Ne(bool transform) std::vector ratios2(2); newpos2[0] = disp; newpos2[1] = -disp; - VP.makeMoves(0, elec, newpos2); + VP.makeMoves(0, elec.R[0], elec.spins[0], newpos2); sposet->evaluateDetRatios(VP, phi, phiinv, ratios2); CHECK(ratios2[0] == Approx(-0.504163137)); // values[0] * phiinv[0] CHECK(ratios2[1] == Approx(-0.504163137)); // symmetric move diff --git a/src/QMCWaveFunctions/tests/test_multi_slater_determinant.cpp b/src/QMCWaveFunctions/tests/test_multi_slater_determinant.cpp index ae4c1bdab8..b2a91ec88b 100644 --- a/src/QMCWaveFunctions/tests/test_multi_slater_determinant.cpp +++ b/src/QMCWaveFunctions/tests/test_multi_slater_determinant.cpp @@ -174,7 +174,7 @@ void test_LiH_msd(const std::string& spo_xml_string, std::vector ratios2(2); newpos2[0] = newpos - elec_.R[1]; newpos2[1] = PosType(0.2, 0.5, 0.3) - elec_.R[1]; - VP.makeMoves(1, elec_, newpos2); + VP.makeMoves(1, elec_.R[1], elec_.spins[1], newpos2); twf.evaluateRatios(VP, ratios2); CHECK(std::real(ratios2[0]) == Approx(-0.8544310407)); diff --git a/src/QMCWaveFunctions/tests/test_polynomial_eeI_jastrow.cpp b/src/QMCWaveFunctions/tests/test_polynomial_eeI_jastrow.cpp index fdd3eb41f7..d8db89537a 100644 --- a/src/QMCWaveFunctions/tests/test_polynomial_eeI_jastrow.cpp +++ b/src/QMCWaveFunctions/tests/test_polynomial_eeI_jastrow.cpp @@ -188,7 +188,7 @@ void test_J3_polynomial3D(const DynamicCoordinateKind kind_selected) std::vector ratios2(2); newpos2[0] = newpos - elec_.R[1]; newpos2[1] = PosType(0.2, 0.5, 0.3) - elec_.R[1]; - VP.makeMoves(1, elec_, newpos2); + VP.makeMoves(1, elec_.R[1], elec_.spins[1], newpos2); j3->evaluateRatios(VP, ratios2); REQUIRE(std::real(ratios2[0]) == Approx(1.0357541137)); From 8d5da5239ee00aca42faaaea31d646e8057568b0 Mon Sep 17 00:00:00 2001 From: Cody Melton Date: Tue, 20 Dec 2022 15:43:27 -0700 Subject: [PATCH 9/9] fix mixed type issue --- src/QMCHamiltonians/SOECPComponent.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/QMCHamiltonians/SOECPComponent.cpp b/src/QMCHamiltonians/SOECPComponent.cpp index 5a9fff96d9..237caf7417 100644 --- a/src/QMCHamiltonians/SOECPComponent.cpp +++ b/src/QMCHamiltonians/SOECPComponent.cpp @@ -152,7 +152,10 @@ SOECPComponent::ComplexType SOECPComponent::getAngularIntegral(RealType sold, //Need to add appropriate weight to psiratio std::transform(psiratio.begin(), psiratio.end(), sgridweight_m.begin(), psiratio.begin(), - [](auto& psi, auto& weight) { return psi * weight * 2.0 * TWOPI; }); + [](auto& psi, auto& weight) { + RealType fourpi = 2.0 * TWOPI; + return psi * weight * fourpi; + }); ComplexType angint(0.0); for (int j = 0; j < nknot; j++)