Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement evaluateDerivRatios in J1 and J2 #3785

Merged
merged 8 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add QP batching in NonLocalECPotential.deriv
  • Loading branch information
ye-luo committed Jan 30, 2022
commit 2b831ae5108ea080b4fd4d7a7954b8789d92e55c
46 changes: 28 additions & 18 deletions src/QMCHamiltonians/NonLocalECPotential.deriv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,39 @@ NonLocalECPComponent::RealType NonLocalECPComponent::evaluateValueAndDerivatives
dratio.resize(optvars.num_active_vars, nknot);
dlogpsi_vp.resize(dlogpsi.size());

ValueType pairpot;
ParticleSet::ParticlePos deltarV(nknot);
deltaV.resize(nknot);

//displacements wrt W.R[iel]
for (int j = 0; j < nknot; j++)
deltarV[j] = r * rrotsgrid_m[j] - dr;
deltaV[j] = r * rrotsgrid_m[j] - dr;

for (int j = 0; j < nknot; j++)
if (VP)
{
// Compute ratios with VP
VP->makeMoves(iel, W.R[iel], deltaV, true, iat);
psi.evaluateDerivRatios(*VP, optvars, psiratio, dratio);
}
else
{
PosType pos_now = W.R[iel];
W.makeMove(iel, deltarV[j]);
psiratio[j] = psi.calcRatio(W, iel);
psi.acceptMove(W, iel);
W.acceptMove(iel);
for (int j = 0; j < nknot; j++)
{
PosType pos_now = W.R[iel];
W.makeMove(iel, deltaV[j]);
psiratio[j] = psi.calcRatio(W, iel);
psi.acceptMove(W, iel);
W.acceptMove(iel);

//use existing methods
std::fill(dlogpsi_vp.begin(), dlogpsi_vp.end(), 0.0);
psi.evaluateDerivativesWF(W, optvars, dlogpsi_vp);
for (int v = 0; v < dlogpsi_vp.size(); ++v)
dratio(v, j) = (dlogpsi_vp[v] - dlogpsi[v]);
//use existing methods
std::fill(dlogpsi_vp.begin(), dlogpsi_vp.end(), 0.0);
psi.evaluateDerivativesWF(W, optvars, dlogpsi_vp);
for (int v = 0; v < dlogpsi_vp.size(); ++v)
dratio(v, j) = dlogpsi_vp[v] - dlogpsi[v];

W.makeMove(iel, -deltarV[j]);
psi.calcRatio(W, iel);
psi.acceptMove(W, iel);
W.acceptMove(iel);
W.makeMove(iel, -deltaV[j]);
psi.calcRatio(W, iel);
psi.acceptMove(W, iel);
W.acceptMove(iel);
}
}

for (int j = 0; j < nknot; ++j)
Expand All @@ -115,6 +123,8 @@ NonLocalECPComponent::RealType NonLocalECPComponent::evaluateValueAndDerivatives
for (int l = 0; l < nchannel; l++, jl++)
Amat[jl] = lpol[angpp_m[l]];
}

ValueType pairpot;
if (nchannel == 1)
{
pairpot = vrad[0] * BLAS::dot(nknot, &Amat[0], &psiratio[0]);
Expand Down
4 changes: 2 additions & 2 deletions src/QMCHamiltonians/tests/test_ecp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,10 @@ TEST_CASE("Evaluate_ecp", "[hamiltonian]")
};

{
test_evaluateOne();
nlpp->initVirtualParticle(elec);
test_evaluateOne();
nlpp->deleteVirtualParticle();
test_evaluateOne();
}

opt_variables_type optvars;
Expand Down Expand Up @@ -367,10 +367,10 @@ TEST_CASE("Evaluate_ecp", "[hamiltonian]")
};

{
test_evaluateValueAndDerivatives();
nlpp->initVirtualParticle(elec);
test_evaluateValueAndDerivatives();
nlpp->deleteVirtualParticle();
test_evaluateValueAndDerivatives();
}

double Value2(0.0);
Expand Down
5 changes: 1 addition & 4 deletions src/QMCWaveFunctions/TrialWaveFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1124,18 +1124,15 @@ void TrialWaveFunction::evaluateDerivRatios(VirtualParticleSet& VP,
std::vector<ValueType>& ratios,
Matrix<ValueType>& dratio)
{
#if defined(QMC_COMPLEX)
APP_ABORT("TrialWaveFunction::evaluateDerivRatios not available for complex wavefunctions");
#else
std::fill(ratios.begin(), ratios.end(), 1.0);
std::fill(dratio.begin(), dratio.end(), 0.0);
std::vector<ValueType> t(ratios.size());
for (int i = 0; i < Z.size(); ++i)
{
Z[i]->evaluateDerivRatios(VP, optvars, t, dratio);
for (int j = 0; j < ratios.size(); ++j)
ratios[j] *= t[j];
}
#endif
}

bool TrialWaveFunction::put(xmlNodePtr cur) { return true; }
Expand Down