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

Make delayed update active only by request #2180

Merged
merged 5 commits into from
Jan 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/QMCDrivers/CorrelatedSampling/CSVMCUpdatePbyP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void CSVMCUpdatePbyP::advanceWalker(Walker_t& thisWalker, bool recompute)
stucked = false;
++nAccept;
for (int ipsi = 0; ipsi < nPsi; ipsi++)
Psi1[ipsi]->acceptMove(W, iat);
Psi1[ipsi]->acceptMove(W, iat, true);

W.acceptMove(iat, true);
//Now we update ratioIJ.
Expand Down
2 changes: 1 addition & 1 deletion src/QMCDrivers/DMC/DMCBatched.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void DMCBatched::advanceWalkers(const StateForThread& sft,
}
}

TrialWaveFunction::flex_acceptMove(twf_accept_list, elec_accept_list, iat);
TrialWaveFunction::flex_acceptMove(twf_accept_list, elec_accept_list, iat, true);
TrialWaveFunction::flex_rejectMove(twf_reject_list, iat);

ParticleSet::flex_acceptMove(elec_accept_list, iat, true);
Expand Down
2 changes: 1 addition & 1 deletion src/QMCDrivers/DMC/DMCUpdatePbyPFast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void DMCUpdatePbyPWithRejectionFast::advanceWalker(Walker_t& thisWalker, bool re
if (RandomGen() < prob)
{
++nAcceptTemp;
Psi.acceptMove(W, iat);
Psi.acceptMove(W, iat, true);
W.acceptMove(iat, true);
rr_accepted += rr;
gf_acc *= prob; //accumulate the ratio
Expand Down
4 changes: 2 additions & 2 deletions src/QMCDrivers/RMC/RMCUpdatePbyP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void RMCUpdatePbyPWithDrift::advanceWalkersVMC()
if (RandomGen() < prob)
{
++nAcceptTemp;
Psi.acceptMove(W, iat);
Psi.acceptMove(W, iat, true);
W.acceptMove(iat, true);
rr_accepted += rr;
gf_acc *= prob; //accumulate the ratio
Expand Down Expand Up @@ -310,7 +310,7 @@ void RMCUpdatePbyPWithDrift::advanceWalkersRMC()
if (RandomGen() < prob)
{
++nAcceptTemp;
Psi.acceptMove(W, iat);
Psi.acceptMove(W, iat, true);
W.acceptMove(iat, true);
rr_accepted += rr;
gf_acc *= prob; //accumulate the ratio
Expand Down
2 changes: 1 addition & 1 deletion src/QMCDrivers/VMC/SOVMCUpdatePbyP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void SOVMCUpdatePbyP::advanceWalker(Walker_t& thisWalker, bool recompute)
{
moved = true;
++nAccept;
Psi.acceptMove(W, iat);
Psi.acceptMove(W, iat, true);
W.acceptMove(iat, true);
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/QMCDrivers/VMC/VMCBatched.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void VMCBatched::advanceWalkers(const StateForThread& sft,
elec_reject_list.push_back(crowd.get_walker_elecs()[i_accept]);
}

TrialWaveFunction::flex_acceptMove(twf_accept_list, elec_accept_list, iat);
TrialWaveFunction::flex_acceptMove(twf_accept_list, elec_accept_list, iat, true);
TrialWaveFunction::flex_rejectMove(twf_reject_list, iat);

ParticleSet::flex_acceptMove(elec_accept_list, iat, true);
Expand Down
2 changes: 1 addition & 1 deletion src/QMCDrivers/VMC/VMCUpdatePbyP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void VMCUpdatePbyP::advanceWalker(Walker_t& thisWalker, bool recompute)
{
moved = true;
++nAccept;
Psi.acceptMove(W, iat);
Psi.acceptMove(W, iat, true);
W.acceptMove(iat, true);
}
else
Expand Down
6 changes: 3 additions & 3 deletions src/QMCHamiltonians/NonLocalECPotential.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ int NonLocalECPotential::makeNonLocalMovesPbyP(ParticleSet& P)
{
GradType grad_iat;
Psi.calcRatioGrad(P, iat, grad_iat);
Psi.acceptMove(P, iat);
Psi.acceptMove(P, iat, true);
P.acceptMove(iat);
NonLocalMoveAccepted++;
}
Expand All @@ -371,7 +371,7 @@ int NonLocalECPotential::makeNonLocalMovesPbyP(ParticleSet& P)
if (P.makeMoveAndCheck(iat, oneTMove->Delta))
{
Psi.calcRatioGrad(P, iat, grad_iat);
Psi.acceptMove(P, iat);
Psi.acceptMove(P, iat, true);
P.acceptMove(iat);
NonLocalMoveAccepted++;
}
Expand Down Expand Up @@ -401,7 +401,7 @@ int NonLocalECPotential::makeNonLocalMovesPbyP(ParticleSet& P)
if (P.makeMoveAndCheck(iat, oneTMove->Delta))
{
Psi.calcRatioGrad(P, iat, grad_iat);
Psi.acceptMove(P, iat);
Psi.acceptMove(P, iat, true);
// mark all affected electrons
markAffectedElecs(P.getDistTable(myTableIndex), iat);
P.acceptMove(iat);
Expand Down
2 changes: 1 addition & 1 deletion src/QMCWaveFunctions/AGPDeterminant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ void AGPDeterminant::ratioDown(ParticleSet& P, int iat)

/** move was accepted, update the real container
*/
void AGPDeterminant::acceptMove(ParticleSet& P, int iat)
void AGPDeterminant::acceptMove(ParticleSet& P, int iat, bool safe_to_delay)
{
LogValue += convertValueToLog(curRatio);
//CurrentDet *= curRatio;
Expand Down
2 changes: 1 addition & 1 deletion src/QMCWaveFunctions/AGPDeterminant.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class AGPDeterminant : public WaveFunctionComponent

/** move was accepted, update the real container
*/
void acceptMove(ParticleSet& P, int iat);
void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false);

/** move was rejected. copy the real container to the temporary to move on
*/
Expand Down
2 changes: 1 addition & 1 deletion src/QMCWaveFunctions/ConstantOrbital.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ConstantOrbital : public WaveFunctionComponent
return 0.0;
}

virtual void acceptMove(ParticleSet& P, int iat) override {}
virtual void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false) override {}

virtual void restore(int iat) override {}

Expand Down
2 changes: 1 addition & 1 deletion src/QMCWaveFunctions/ExampleHeComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ExampleHeComponent : public WaveFunctionComponent
ParticleSet::ParticleGradient_t& G,
ParticleSet::ParticleLaplacian_t& L) override;

void acceptMove(ParticleSet& P, int iat) override {}
void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false) override {}

void restore(int iat) override {}

Expand Down
6 changes: 3 additions & 3 deletions src/QMCWaveFunctions/FDLRWfn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,10 @@ FDLRWfn::PsiValueType FDLRWfn::ratio(ParticleSet& P, int iat)
/// \param[in] iat the id number of the moved particle
///
///////////////////////////////////////////////////////////////////////////////////////////////
void FDLRWfn::acceptMove(ParticleSet& P, int iat)
void FDLRWfn::acceptMove(ParticleSet& P, int iat, bool safe_to_delay)
{
m_wfn_xpd->acceptMove(P, iat);
m_wfn_xmd->acceptMove(P, iat);
m_wfn_xpd->acceptMove(P, iat, safe_to_delay);
m_wfn_xmd->acceptMove(P, iat, safe_to_delay);

LogValue += convertValueToLog(curRatio);

Expand Down
2 changes: 1 addition & 1 deletion src/QMCWaveFunctions/FDLRWfn.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class FDLRWfn : public WaveFunctionComponent

PsiValueType ratio(ParticleSet& P, int iat);

void acceptMove(ParticleSet& P, int iat);
void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false);

void restore(int iat);

Expand Down
4 changes: 3 additions & 1 deletion src/QMCWaveFunctions/Fermion/DiracDeterminant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,14 @@ void DiracDeterminant<DU_TYPE>::mw_ratioGrad(const std::vector<WaveFunctionCompo
/** move was accepted, update the real container
*/
template<typename DU_TYPE>
void DiracDeterminant<DU_TYPE>::acceptMove(ParticleSet& P, int iat)
void DiracDeterminant<DU_TYPE>::acceptMove(ParticleSet& P, int iat, bool safe_to_delay)
{
const int WorkingIndex = iat - FirstIndex;
LogValue += convertValueToLog(curRatio);
UpdateTimer.start();
updateEng.acceptRow(psiM, WorkingIndex, psiV);
if (!safe_to_delay)
updateEng.updateInvMat(psiM);
// invRow becomes invalid after accepting a move
invRow_id = -1;
if (UpdateMode == ORB_PBYP_PARTIAL)
Expand Down
6 changes: 3 additions & 3 deletions src/QMCWaveFunctions/Fermion/DiracDeterminant.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ class DiracDeterminant : public DiracDeterminantBase

/** move was accepted, update the real container
*/
void acceptMove(ParticleSet& P, int iat) override;
void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false) override;

void mw_acceptMove(const std::vector<WaveFunctionComponent*>& WFC_list,
const std::vector<ParticleSet*>& P_list,
int iat) override
int iat, bool safe_to_delay = false) override
{
for (int iw = 0; iw < WFC_list.size(); iw++)
WFC_list[iw]->acceptMove(*P_list[iw], iat);
WFC_list[iw]->acceptMove(*P_list[iw], iat, safe_to_delay);
}

void completeUpdates() override;
Expand Down
2 changes: 1 addition & 1 deletion src/QMCWaveFunctions/Fermion/DiracDeterminantCUDA.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class DiracDeterminantCUDA : public DiracDeterminantBase
APP_ABORT("Calling DiracDeterminantCUDA::evaluateLog is illegal!");
}

void acceptMove(ParticleSet& P, int iat) { APP_ABORT("Calling DiracDeterminantCUDA::acceptMove is illegal!"); }
void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false) { APP_ABORT("Calling DiracDeterminantCUDA::acceptMove is illegal!"); }

void restore(int iat) { APP_ABORT("Calling DiracDeterminantCUDA::restore is illegal!"); }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ DiracDeterminantWithBackflow::LogValueType DiracDeterminantWithBackflow::evaluat

/** move was accepted, update the real container
*/
void DiracDeterminantWithBackflow::acceptMove(ParticleSet& P, int iat)
void DiracDeterminantWithBackflow::acceptMove(ParticleSet& P, int iat, bool safe_to_delay)
{
LogValue += convertValueToLog(curRatio);
UpdateTimer.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class DiracDeterminantWithBackflow : public DiracDeterminantBase

/** move was accepted, update the real container
*/
void acceptMove(ParticleSet& P, int iat);
void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false);

/** move was rejected. copy the real container to the temporary to move on
*/
Expand Down
2 changes: 1 addition & 1 deletion src/QMCWaveFunctions/Fermion/MultiDiracDeterminant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ void MultiDiracDeterminant::copyFromBuffer(ParticleSet& P, WFBufferType& buf)

/** move was accepted, update the real container
*/
void MultiDiracDeterminant::acceptMove(ParticleSet& P, int iat)
void MultiDiracDeterminant::acceptMove(ParticleSet& P, int iat, bool safe_to_delay)
{
WorkingIndex = iat - FirstIndex;
switch (UpdateMode)
Expand Down
2 changes: 1 addition & 1 deletion src/QMCWaveFunctions/Fermion/MultiDiracDeterminant.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class MultiDiracDeterminant : public WaveFunctionComponent

/** move was accepted, update the real container
*/
void acceptMove(ParticleSet& P, int iat);
void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false);

/** move was rejected. copy the real container to the temporary to move on
*/
Expand Down
2 changes: 1 addition & 1 deletion src/QMCWaveFunctions/Fermion/MultiSlaterDeterminant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ WaveFunctionComponent::PsiValueType MultiSlaterDeterminant::ratio(ParticleSet& P
}
}

void MultiSlaterDeterminant::acceptMove(ParticleSet& P, int iat)
void MultiSlaterDeterminant::acceptMove(ParticleSet& P, int iat, bool safe_to_delay)
{
// this should depend on the type of update, ratio / ratioGrad
// for now is incorrect fot ratio(P,iat,dG,dL) updates
Expand Down
2 changes: 1 addition & 1 deletion src/QMCWaveFunctions/Fermion/MultiSlaterDeterminant.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class MultiSlaterDeterminant : public WaveFunctionComponent
virtual GradType evalGrad(ParticleSet& P, int iat);
virtual PsiValueType ratioGrad(ParticleSet& P, int iat, GradType& grad_iat);
virtual PsiValueType ratio(ParticleSet& P, int iat);
virtual void acceptMove(ParticleSet& P, int iat);
virtual void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false);
virtual void restore(int iat);

virtual void registerData(ParticleSet& P, WFBufferType& buf);
Expand Down
4 changes: 2 additions & 2 deletions src/QMCWaveFunctions/Fermion/MultiSlaterDeterminantFast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ WaveFunctionComponent::PsiValueType MultiSlaterDeterminantFast::ratio(ParticleSe
return curRatio;
}

void MultiSlaterDeterminantFast::acceptMove(ParticleSet& P, int iat)
void MultiSlaterDeterminantFast::acceptMove(ParticleSet& P, int iat, bool safe_to_delay)
{
// this should depend on the type of update, ratio / ratioGrad
// for now is incorrect fot ratio(P,iat,dG,dL) updates
Expand All @@ -390,7 +390,7 @@ void MultiSlaterDeterminantFast::acceptMove(ParticleSet& P, int iat)
psiCurrent *= curRatio;
curRatio = 1.0;

Dets[iat >= nels_up]->acceptMove(P, iat);
Dets[iat >= nels_up]->acceptMove(P, iat, safe_to_delay);
//Dets[DetID[iat]]->acceptMove(P,iat);

AccRejTimer.stop();
Expand Down
2 changes: 1 addition & 1 deletion src/QMCWaveFunctions/Fermion/MultiSlaterDeterminantFast.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class MultiSlaterDeterminantFast : public WaveFunctionComponent
APP_ABORT(" Need to implement MultiSlaterDeterminantFast::evaluateRatiosAlltoOne. \n");
}

void acceptMove(ParticleSet& P, int iat) override;
void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false) override;
void restore(int iat) override;

void registerData(ParticleSet& P, WFBufferType& buf) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ WaveFunctionComponent::PsiValueType MultiSlaterDeterminantWithBackflow::ratio(Pa
}
}

void MultiSlaterDeterminantWithBackflow::acceptMove(ParticleSet& P, int iat)
void MultiSlaterDeterminantWithBackflow::acceptMove(ParticleSet& P, int iat, bool safe_to_delay)
{
// this should depend on the type of update, ratio / ratioGrad
// for now is incorrect fot ratio(P,iat,dG,dL) updates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class MultiSlaterDeterminantWithBackflow : public MultiSlaterDeterminant
GradType evalGrad(ParticleSet& P, int iat);
PsiValueType ratioGrad(ParticleSet& P, int iat, GradType& grad_iat);
PsiValueType ratio(ParticleSet& P, int iat);
void acceptMove(ParticleSet& P, int iat);
void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false);
void restore(int iat);

void registerData(ParticleSet& P, WFBufferType& buf);
Expand Down
8 changes: 4 additions & 4 deletions src/QMCWaveFunctions/Fermion/SlaterDet.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ class SlaterDet : public WaveFunctionComponent
Dets[det_id]->mw_restore(extract_Det_list(WFC_list, det_id), iat);
}

virtual inline void acceptMove(ParticleSet& P, int iat) override
virtual inline void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false) override
{
Dets[getDetID(iat)]->acceptMove(P, iat);
Dets[getDetID(iat)]->acceptMove(P, iat, safe_to_delay);

LogValue = 0.0;
for (int i = 0; i < Dets.size(); ++i)
Expand All @@ -173,7 +173,7 @@ class SlaterDet : public WaveFunctionComponent

virtual void mw_acceptMove(const std::vector<WaveFunctionComponent*>& WFC_list,
const std::vector<ParticleSet*>& P_list,
int iat) override
int iat, bool safe_to_delay = false) override
{
constexpr RealType czero(0);

Expand All @@ -185,7 +185,7 @@ class SlaterDet : public WaveFunctionComponent
const std::vector<WaveFunctionComponent*> Det_list(extract_Det_list(WFC_list, i));

if (i == getDetID(iat))
Dets[i]->mw_acceptMove(Det_list, P_list, iat);
Dets[i]->mw_acceptMove(Det_list, P_list, iat, safe_to_delay);

for (int iw = 0; iw < WFC_list.size(); iw++)
WFC_list[iw]->LogValue += Det_list[iw]->LogValue;
Expand Down
2 changes: 1 addition & 1 deletion src/QMCWaveFunctions/Fermion/SlaterDetWithBackflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class SlaterDetWithBackflow : public SlaterDet
return GradType();
}

inline void acceptMove(ParticleSet& P, int iat)
inline void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false)
{
BFTrans->acceptMove(P, iat);
for (int i = 0; i < Dets.size(); i++)
Expand Down
2 changes: 1 addition & 1 deletion src/QMCWaveFunctions/Jastrow/CountingJastrow.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class CountingJastrow : public WaveFunctionComponent
return std::exp(static_cast<PsiValueType>(Jval_t - Jval));
}

void acceptMove(ParticleSet& P, int iat)
void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false)
{
C->acceptMove(P, iat);
// update values for C, FC to those at proposed position
Expand Down
2 changes: 1 addition & 1 deletion src/QMCWaveFunctions/Jastrow/J1OrbitalSoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ struct J1OrbitalSoA : public WaveFunctionComponent
inline void restore(int iat) {}

/** Accpted move. Update Vat[iat],Grad[iat] and Lap[iat] */
void acceptMove(ParticleSet& P, int iat)
void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false)
{
if (UpdateMode == ORB_PBYP_RATIO)
{
Expand Down
4 changes: 2 additions & 2 deletions src/QMCWaveFunctions/Jastrow/J2OrbitalSoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class J2OrbitalSoA : public WaveFunctionComponent

PsiValueType ratioGrad(ParticleSet& P, int iat, GradType& grad_iat);

void acceptMove(ParticleSet& P, int iat);
void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false);
inline void restore(int iat) {}

/** compute G and L after the sweep
Expand Down Expand Up @@ -548,7 +548,7 @@ typename J2OrbitalSoA<FT>::PsiValueType J2OrbitalSoA<FT>::ratioGrad(ParticleSet&
}

template<typename FT>
void J2OrbitalSoA<FT>::acceptMove(ParticleSet& P, int iat)
void J2OrbitalSoA<FT>::acceptMove(ParticleSet& P, int iat, bool safe_to_delay)
{
// get the old u, du, d2u
const auto& d_table = P.getDistTable(my_table_ID_);
Expand Down
2 changes: 1 addition & 1 deletion src/QMCWaveFunctions/Jastrow/JeeIOrbitalSoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ class JeeIOrbitalSoA : public WaveFunctionComponent

inline void restore(int iat) {}

void acceptMove(ParticleSet& P, int iat)
void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false)
{
const DistanceTableData& eI_table = P.getDistTable(ei_Table_ID_);
const DistanceTableData& ee_table = P.getDistTable(ee_Table_ID_);
Expand Down
2 changes: 1 addition & 1 deletion src/QMCWaveFunctions/Jastrow/OneBodyJastrowOrbital.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class OneBodyJastrowOrbital : public WaveFunctionComponent

inline void restore(int iat) {}

void acceptMove(ParticleSet& P, int iat)
void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false)
{
LogValue += U[iat] - curVal;
U[iat] = curVal;
Expand Down
Loading