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

Hamiltonian updates for batched estimators #5295

Merged
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
1 change: 1 addition & 0 deletions src/QMCHamiltonians/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ set(HAMSRCS
QMCHamiltonian.cpp
Hdispatcher.cpp
BareKineticEnergy.cpp
CoulombPotential.cpp
CoulombPBCAA.cpp
CoulombPBCAB.cpp
EwaldRef.cpp
Expand Down
41 changes: 39 additions & 2 deletions src/QMCHamiltonians/CoulombPBCAA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <ResourceCollection.h>
#include <Message/UniformCommunicateError.h>
#include "Numerics/OneDimCubicSplineLinearGrid.h"
#include <numeric>

namespace qmcplusplus
{
Expand Down Expand Up @@ -123,6 +124,7 @@
{
app_log() << " Check passed." << std::endl;
}

}
prefix_ = "F_AA";
app_log() << " Maximum K shell " << AA->MaxKshell << std::endl;
Expand Down Expand Up @@ -317,6 +319,30 @@

for (const ListenerVector<RealType>& listener : listeners)
listener.report(walker_index, name, v_sample);

#ifndef NDEBUG
RealType Vlrnow = cpbcaa.evalLR(pset);
RealType Vsrnow = cpbcaa.evalSR(pset);
RealType Vcnow = cpbcaa.myConst;
RealType Vcsum = std::accumulate(pp_consts.begin(), pp_consts.end(), 0.0);
RealType Vnow = Vlrnow + Vsrnow + Vcnow;
RealType Vsum = std::accumulate(v_sample.begin(), v_sample.end(), 0.0);
if (std::abs(Vsum - Vnow) > TraceManager::trace_tol)
{
app_log() << "accumtest: CoulombPBCAA::evaluate()" << std::endl;
app_log() << "accumtest: tot:" << Vnow << std::endl;
app_log() << "accumtest: sum:" << Vsum << std::endl;
throw std::runtime_error("Trace check failed");
}
if (std::abs(Vcsum - Vcnow) > TraceManager::trace_tol)
{
app_log() << "accumtest: CoulombPBCAA::evalConsts()" << std::endl;
app_log() << "accumtest: tot:" << Vcnow << std::endl;
app_log() << "accumtest: sum:" << Vcsum << std::endl;
throw std::runtime_error("Trace check failed");
}
#endif

return value;
};

Expand All @@ -327,6 +353,17 @@
}
}

void CoulombPBCAA::mw_evaluatePerParticleWithToperator(const RefVectorWithLeader<OperatorBase>& o_list,

Check warning on line 356 in src/QMCHamiltonians/CoulombPBCAA.cpp

View check run for this annotation

Codecov / codecov/patch

src/QMCHamiltonians/CoulombPBCAA.cpp#L356

Added line #L356 was not covered by tests
const RefVectorWithLeader<TrialWaveFunction>& wf_list,
const RefVectorWithLeader<ParticleSet>& p_list,
const std::vector<ListenerVector<RealType>>& listeners,
const std::vector<ListenerVector<RealType>>& ion_listeners) const

{
mw_evaluatePerParticle(o_list, wf_list, p_list, listeners, ion_listeners);

Check warning on line 363 in src/QMCHamiltonians/CoulombPBCAA.cpp

View check run for this annotation

Codecov / codecov/patch

src/QMCHamiltonians/CoulombPBCAA.cpp#L363

Added line #L363 was not covered by tests
}


void CoulombPBCAA::evaluateIonDerivs(ParticleSet& P,
ParticleSet& ions,
TrialWaveFunction& psi,
Expand Down Expand Up @@ -631,7 +668,7 @@
}


CoulombPBCAA::Return_t CoulombPBCAA::evalSR(ParticleSet& P)
CoulombPBCAA::Return_t CoulombPBCAA::evalSR(const ParticleSet& P) const
{
ScopedTimer local_timer(evalSR_timer_);
const auto& d_aa(P.getDistTableAA(d_aa_ID));
Expand Down Expand Up @@ -738,7 +775,7 @@
return values;
}

CoulombPBCAA::Return_t CoulombPBCAA::evalLR(ParticleSet& P)
CoulombPBCAA::Return_t CoulombPBCAA::evalLR(const ParticleSet& P) const
{
ScopedTimer local_timer(evalLR_timer_);
mRealType res = 0.0;
Expand Down
9 changes: 7 additions & 2 deletions src/QMCHamiltonians/CoulombPBCAA.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ struct CoulombPBCAA : public OperatorBase, public ForceBase
const std::vector<ListenerVector<RealType>>& listeners,
const std::vector<ListenerVector<RealType>>& ion_listeners) const override;

void mw_evaluatePerParticleWithToperator(const RefVectorWithLeader<OperatorBase>& o_list,
const RefVectorWithLeader<TrialWaveFunction>& wf_list,
const RefVectorWithLeader<ParticleSet>& p_list,
const std::vector<ListenerVector<RealType>>& listeners,
const std::vector<ListenerVector<RealType>>& ion_listeners) const override;

void evaluateIonDerivs(ParticleSet& P,
ParticleSet& ions,
Expand Down Expand Up @@ -144,12 +149,12 @@ struct CoulombPBCAA : public OperatorBase, public ForceBase
void deleteParticleQuantities() override;
#endif

Return_t evalSR(ParticleSet& P);
Return_t evalSR(const ParticleSet& P) const;

static std::vector<Return_t> mw_evalSR_offload(const RefVectorWithLeader<OperatorBase>& o_list,
const RefVectorWithLeader<ParticleSet>& p_list);

Return_t evalLR(ParticleSet& P);
Return_t evalLR(const ParticleSet& P) const;
Return_t evalSRwithForces(ParticleSet& P);
Return_t evalLRwithForces(ParticleSet& P);
Return_t evalConsts(bool report = true);
Expand Down
10 changes: 10 additions & 0 deletions src/QMCHamiltonians/CoulombPBCAB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,16 @@
}
}

void CoulombPBCAB::mw_evaluatePerParticleWithToperator(const RefVectorWithLeader<OperatorBase>& o_list,

Check warning on line 382 in src/QMCHamiltonians/CoulombPBCAB.cpp

View check run for this annotation

Codecov / codecov/patch

src/QMCHamiltonians/CoulombPBCAB.cpp#L382

Added line #L382 was not covered by tests
const RefVectorWithLeader<TrialWaveFunction>& wf_list,
const RefVectorWithLeader<ParticleSet>& p_list,
const std::vector<ListenerVector<RealType>>& listeners,
const std::vector<ListenerVector<RealType>>& ion_listeners) const

{
mw_evaluatePerParticle(o_list, wf_list, p_list, listeners, ion_listeners);

Check warning on line 389 in src/QMCHamiltonians/CoulombPBCAB.cpp

View check run for this annotation

Codecov / codecov/patch

src/QMCHamiltonians/CoulombPBCAB.cpp#L389

Added line #L389 was not covered by tests
}

/** Evaluate the background term. Other constants are handled by AA potentials.
*
* \f$V_{bg}^{AB}=-\sum_{\alpha}\sum_{\beta} N^{\alpha} N^{\beta} q^{\alpha} q^{\beta} v_s(k=0) \f$
Expand Down
6 changes: 6 additions & 0 deletions src/QMCHamiltonians/CoulombPBCAB.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ class CoulombPBCAB : public OperatorBase, public ForceBase
const std::vector<ListenerVector<RealType>>& ion_listeners) const override;


void mw_evaluatePerParticleWithToperator(const RefVectorWithLeader<OperatorBase>& o_list,
const RefVectorWithLeader<TrialWaveFunction>& wf_list,
const RefVectorWithLeader<ParticleSet>& p_list,
const std::vector<ListenerVector<RealType>>& listeners,
const std::vector<ListenerVector<RealType>>& ion_listeners) const override;

void evaluateIonDerivs(ParticleSet& P,
ParticleSet& ions,
TrialWaveFunction& psi,
Expand Down
Loading
Loading