QMCPACK
DMCUpdatePbyPWithRejectionFast Class Reference
+ Inheritance diagram for DMCUpdatePbyPWithRejectionFast:
+ Collaboration diagram for DMCUpdatePbyPWithRejectionFast:

Public Member Functions

 DMCUpdatePbyPWithRejectionFast (MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, RandomBase< FullPrecRealType > &rg)
 Constructor. More...
 
 ~DMCUpdatePbyPWithRejectionFast () override
 destructor More...
 
void advanceWalker (Walker_t &thisWalker, bool recompute) override
 move a walker More...
 
- Public Member Functions inherited from QMCUpdateBase
 QMCUpdateBase (MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, RandomBase< FullPrecRealType > &rg)
 Constructor. More...
 
 QMCUpdateBase (MCWalkerConfiguration &w, TrialWaveFunction &psi, TrialWaveFunction &guide, QMCHamiltonian &h, RandomBase< FullPrecRealType > &rg)
 Alt Constructor. More...
 
virtual ~QMCUpdateBase ()
 destructor More...
 
RealType acceptRatio () const
 
void resetRun (BranchEngineType *brancher, EstimatorManagerBase *est, TraceManager *traces, const DriftModifierBase *driftmodifer)
 reset the QMCUpdateBase parameters More...
 
void resetRun2 (BranchEngineType *brancher, EstimatorManagerBase *est, TraceManager *traces, WalkerLogCollector *wlog_collector_, const DriftModifierBase *driftmodifer)
 
RealType getTau ()
 
void setTau (RealType t)
 
RealType getSpinMass ()
 
void setSpinMass (RealType m)
 
void getLogs (std::vector< RealType > &logs)
 
void set_step (int step)
 
void startRun (int blocks, bool record)
 start a run More...
 
void stopRun ()
 stop a run More...
 
void stopRun2 ()
 
void startBlock (int steps)
 prepare to start a block More...
 
void stopBlock (bool collectall=true)
 stop a block More...
 
void setMultiplicity (WalkerIter_t it, WalkerIter_t it_end)
 set the multiplicity of the walkers to branch More...
 
void setMultiplicity (Walker_t &awalker) const
 
virtual void initWalkersForPbyP (WalkerIter_t it, WalkerIter_t it_end)
 initialize Walker buffers for PbyP update More...
 
virtual void initWalkers (WalkerIter_t it, WalkerIter_t it_end)
 initialize Walker for walker update More...
 
virtual bool put (xmlNodePtr cur)
 process options More...
 
void accumulate (WalkerIter_t it, WalkerIter_t it_end)
 
virtual void advanceWalkers (WalkerIter_t it, WalkerIter_t it_end, bool recompute)
 advance walkers executed at each step More...
 
virtual RealType advanceWalkerForEE (Walker_t &w1, std::vector< PosType > &dR, std::vector< int > &iats, std::vector< int > &rs, std::vector< RealType > &ratios)
 
int RMC_checkIndex (int N, int NMax)
 
void RMC_checkWalkerBounds (WalkerIter_t &it, WalkerIter_t first, WalkerIter_t last)
 
RealType logBackwardGF (const ParticleSet::ParticlePos &displ)
 

Private Attributes

TimerList_t myTimers
 

Additional Inherited Members

- Public Types inherited from QMCUpdateBase
using Walker_t = MCWalkerConfiguration::Walker_t
 
using WalkerIter_t = MCWalkerConfiguration::iterator
 
using BranchEngineType = SimpleFixedNodeBranch
 
using mPosType = PosType
 
using mTensorType = TensorType
 
- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 
- Public Attributes inherited from QMCUpdateBase
int nSubSteps
 number of steps per measurement More...
 
DriverDebugChecks debug_checks_ = DriverDebugChecks::ALL_OFF
 determine additional checks for debugging purpose More...
 
std::string debug_checks_str_
 
IndexType MaxAge
 MaxAge>0 indicates branch is done. More...
 
IndexType nAccept
 counter for number of moves accepted More...
 
IndexType nReject
 counter for number of moves rejected More...
 
IndexType nAllRejected
 Total number of the steps when all the particle moves are rejected. More...
 
IndexType nNodeCrossing
 Total number of node crossings per block. More...
 
IndexType NonLocalMoveAccepted
 Total numer of non-local moves accepted. More...
 
RealType Tau
 timestep More...
 
RealType spinMass
 spin mass More...
 
bool UseDrift
 use Drift More...
 
RealType csoffset
 normalization offset for cs type runs. More...
 
TraceManagerTraces
 traces More...
 
WalkerLogCollectorwlog_collector
 
- Protected Member Functions inherited from QMCUpdateBase
RealType getNodeCorrection (const ParticleSet::ParticleGradient &g, ParticleSet::ParticlePos &gscaled)
 evaluate the ratio of scaled velocity and velocity More...
 
 QMCUpdateBase (const QMCUpdateBase &)=delete
 copy constructor (disabled) More...
 
- Static Protected Member Functions inherited from QMCUpdateBase
static void checkLogAndGL (ParticleSet &pset, TrialWaveFunction &twf, const std::string_view location)
 check logpsi and grad and lap against values computed from scratch More...
 
- Protected Attributes inherited from QMCUpdateBase
bool UpdatePbyP
 update particle-by-particle More...
 
IndexType NumPtcl
 number of particles More...
 
RealType m_oneover2tau
 Time-step factor $ 1/(2\tau)$. More...
 
RealType m_sqrttau
 Time-step factor $ \sqrt{\tau}$. More...
 
RealType m_tauovermass
 tau/mass More...
 
RealType m_r2max
 maximum displacement^2 More...
 
MCWalkerConfigurationW
 walker ensemble More...
 
TrialWaveFunctionPsi
 trial function More...
 
TrialWaveFunctionGuide
 guide function More...
 
QMCHamiltonianH
 Hamiltonian. More...
 
RandomBase< FullPrecRealType > & RandomGen
 random number generator More...
 
const BranchEngineTypebranchEngine
 branch engine, stateless reference to the one in QMCDriver More...
 
const DriftModifierBaseDriftModifier
 drift modifer, stateless reference to the one in QMCDriver More...
 
EstimatorManagerBaseEstimators
 estimator More...
 
ParameterSet myParams
 parameters More...
 
std::vector< RealTypeMassInvS
 1/Mass per species More...
 
std::vector< RealTypeMassInvP
 1/Mass per particle More...
 
std::vector< RealTypeSqrtTauOverMass
 sqrt(tau/Mass) per particle More...
 
ParticleSet::ParticlePos drift
 temporary storage for drift More...
 
ParticleSet::ParticlePos deltaR
 temporary storage for random displacement More...
 
ParticleSet::ParticleScalar deltaS
 temporart storage for spin displacement More...
 
ParticleSet::ParticleGradient G
 storage for differential gradients for PbyP update More...
 
ParticleSet::ParticleGradient dG
 
ParticleSet::ParticleLaplacian L
 storage for differential laplacians for PbyP update More...
 
ParticleSet::ParticleLaplacian dL
 

Detailed Description

Definition at line 22 of file DMCUpdatePbyP.h.

Constructor & Destructor Documentation

◆ DMCUpdatePbyPWithRejectionFast()

Constructor.

Definition at line 43 of file DMCUpdatePbyPFast.cpp.

48 {}
TimerNameList_t< DMCTimers > DMCTimerNames
QMCUpdateBase(MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, RandomBase< FullPrecRealType > &rg)
Constructor.
TimerManager< NewTimer > & getGlobalTimerManager()

◆ ~DMCUpdatePbyPWithRejectionFast()

destructor

Definition at line 51 of file DMCUpdatePbyPFast.cpp.

51 {}

Member Function Documentation

◆ advanceWalker()

void advanceWalker ( Walker_t thisWalker,
bool  recompute 
)
overridevirtual

move a walker

Implements QMCUpdateBase.

Definition at line 53 of file DMCUpdatePbyPFast.cpp.

References ParticleSet::accept_rejectMove(), TrialWaveFunction::acceptMove(), Walker< t_traits, p_traits >::Age, QMCHamiltonian::auxHevaluate(), QMCUpdateBase::branchEngine, SimpleFixedNodeBranch::branchWeight(), TraceManager::buffer_sample(), TrialWaveFunction::calcRatioGrad(), qmcplusplus::CHECKGL_AFTER_MOVES, QMCUpdateBase::checkLogAndGL(), WalkerLogCollector::collect(), TrialWaveFunction::completeUpdates(), TrialWaveFunction::copyFromBuffer(), ParticleSet::current_step, Walker< t_traits, p_traits >::DataSet, QMCUpdateBase::debug_checks_, QMCUpdateBase::deltaR, qmcplusplus::DMC_buffer, qmcplusplus::DMC_collectables, qmcplusplus::DMC_hamiltonian, qmcplusplus::DMC_movePbyP, qmcplusplus::DMC_tmoves, ParticleSet::donePbyP(), qmcplusplus::dot(), QMCUpdateBase::DriftModifier, TrialWaveFunction::evalGrad(), QMCHamiltonian::evaluateWithToperator(), qmcplusplus::exp(), ParticleSet::first(), ParticleSet::getActivePos(), DriftModifierBase::getDrift(), TrialWaveFunction::getPhase(), TrialWaveFunction::getPhaseDiff(), Walker< t_traits, p_traits >::getPropertyBase(), ParticleSet::groups(), QMCUpdateBase::H, ParticleSet::last(), ParticleSet::loadWalker(), QMCUpdateBase::m_r2max, qmcplusplus::makeGaussRandomWithEngine(), ParticleSet::makeMoveAndCheck(), QMCHamiltonian::makeNonLocalMoves(), QMCUpdateBase::MassInvS, DMCUpdatePbyPWithRejectionFast::myTimers, QMCUpdateBase::nAccept, QMCUpdateBase::nAllRejected, QMCUpdateBase::nNodeCrossing, QMCUpdateBase::NonLocalMoveAccepted, norm(), QMCUpdateBase::nReject, SimpleFixedNodeBranch::phaseChanged(), TrialWaveFunction::prepareGroup(), Walker< t_traits, p_traits >::Properties, QMCUpdateBase::Psi, ParticleSet::R, QMCUpdateBase::RandomGen, QMCHamiltonian::rejectedMove(), TrialWaveFunction::rejectMove(), Walker< t_traits, p_traits >::resetProperty(), QMCHamiltonian::saveProperty(), ParticleSet::saveWalker(), QMCUpdateBase::setMultiplicity(), qmcplusplus::sqrt(), QMCUpdateBase::Tau, QMCUpdateBase::Traces, TrialWaveFunction::updateBuffer(), QMCUpdateBase::W, Walker< t_traits, p_traits >::Weight, and QMCUpdateBase::wlog_collector.

54 {
55  Walker_t::WFBuffer_t& w_buffer(thisWalker.DataSet);
56  {
57  ScopedTimer local_timer(myTimers[DMC_buffer]);
58  W.loadWalker(thisWalker, true);
59  Psi.copyFromBuffer(W, w_buffer);
60  }
61  //create a 3N-Dimensional Gaussian with variance=1
63  int nAcceptTemp(0);
64  int nRejectTemp(0);
65  //copy the old energy and scale factor of drift
66  FullPrecRealType eold(thisWalker.Properties(WP::LOCALENERGY));
67  FullPrecRealType enew(eold);
68  RealType rr_proposed = 0.0;
69  RealType rr_accepted = 0.0;
70  {
71  ScopedTimer local_timer(myTimers[DMC_movePbyP]);
72  for (int ig = 0; ig < W.groups(); ++ig) //loop over species
73  {
74  RealType tauovermass = Tau * MassInvS[ig];
75  RealType oneover2tau = 0.5 / (tauovermass);
76  RealType sqrttau = std::sqrt(tauovermass);
77  Psi.prepareGroup(W, ig);
78  for (int iat = W.first(ig); iat < W.last(ig); ++iat)
79  {
80  //get the displacement
81  GradType grad_iat = Psi.evalGrad(W, iat);
82  PosType dr;
83  DriftModifier->getDrift(tauovermass, grad_iat, dr);
84  dr += sqrttau * deltaR[iat];
85  bool is_valid = W.makeMoveAndCheck(iat, dr);
86  RealType rr = tauovermass * dot(deltaR[iat], deltaR[iat]);
87  rr_proposed += rr;
88  if (!is_valid || rr > m_r2max)
89  {
90  ++nRejectTemp;
91  W.accept_rejectMove(iat, false);
92  continue;
93  }
94  ValueType ratio = Psi.calcRatioGrad(W, iat, grad_iat);
95  //node is crossed reject the move
97  {
98  ++nRejectTemp;
99  ++nNodeCrossing;
100  W.accept_rejectMove(iat, false);
101  Psi.rejectMove(iat);
102  }
103  else
104  {
105  FullPrecRealType logGf = -0.5 * dot(deltaR[iat], deltaR[iat]);
106  //Use the force of the particle iat
107  DriftModifier->getDrift(tauovermass, grad_iat, dr);
108  dr = W.R[iat] - W.getActivePos() - dr;
109  FullPrecRealType logGb = -oneover2tau * dot(dr, dr);
110  RealType prob = std::norm(ratio) * std::exp(logGb - logGf);
111  bool is_accepted = false;
112  if (RandomGen() < prob)
113  {
114  is_accepted = true;
115  ++nAcceptTemp;
116  Psi.acceptMove(W, iat, true);
117  rr_accepted += rr;
118  }
119  else
120  {
121  ++nRejectTemp;
122  Psi.rejectMove(iat);
123  }
124  W.accept_rejectMove(iat, is_accepted);
125  }
126  }
127  }
129  W.donePbyP();
130  }
131 
132  if (nAcceptTemp > 0)
133  {
134  //need to overwrite the walker properties
135  RealType logpsi(0);
136  {
137  ScopedTimer local_timer(myTimers[DMC_buffer]);
138  thisWalker.Age = 0;
139  logpsi = Psi.updateBuffer(W, w_buffer, recompute);
141  checkLogAndGL(W, Psi, "checkGL_after_moves");
142  W.saveWalker(thisWalker);
143  }
144  {
145  ScopedTimer local_timer(myTimers[DMC_hamiltonian]);
146  enew = H.evaluateWithToperator(W);
147  }
148  thisWalker.resetProperty(logpsi, Psi.getPhase(), enew, rr_accepted, rr_proposed, 1.0);
149  thisWalker.Weight *= branchEngine->branchWeight(enew, eold);
150  {
151  ScopedTimer local_timer(myTimers[DMC_collectables]);
152  H.auxHevaluate(W, thisWalker);
153  H.saveProperty(thisWalker.getPropertyBase());
154  }
155  }
156  else
157  {
158  //all moves are rejected: does not happen normally with reasonable wavefunctions
159  thisWalker.Age++;
160  thisWalker.Properties(WP::R2ACCEPTED) = 0.0;
161  //weight is set to 0 for traces
162  // consistent w/ no evaluate/auxHevaluate
163  RealType wtmp = thisWalker.Weight;
164  thisWalker.Weight = 0.0;
165  H.rejectedMove(W, thisWalker);
166  thisWalker.Weight = wtmp;
167  ++nAllRejected;
168  enew = eold; //copy back old energy
169  thisWalker.Weight *= branchEngine->branchWeight(enew, eold);
170  }
171 #if !defined(REMOVE_TRACEMANAGER)
173 #endif
174  if(wlog_collector)
175  wlog_collector->collect(thisWalker,W,Psi,H);
176  {
177  ScopedTimer local_timer(myTimers[DMC_tmoves]);
178  const int NonLocalMoveAcceptedTemp = H.makeNonLocalMoves(W);
179  if (NonLocalMoveAcceptedTemp > 0)
180  {
181  RealType logpsi = Psi.updateBuffer(W, w_buffer, false);
182  // debugging lines
183  //W.update(true);
184  //RealType logpsi2 = Psi.evaluateLog(W);
185  //if(logpsi!=logpsi2) std::cout << " logpsi " << logpsi << " logps2i " << logpsi2 << " diff " << logpsi2-logpsi << std::endl;
186  W.saveWalker(thisWalker);
187  NonLocalMoveAccepted += NonLocalMoveAcceptedTemp;
188  }
189  }
190  nAccept += nAcceptTemp;
191  nReject += nRejectTemp;
192 
193  setMultiplicity(thisWalker);
194 }
TraceManager * Traces
traces
const BranchEngineType * branchEngine
branch engine, stateless reference to the one in QMCDriver
WalkerLogCollector * wlog_collector
void rejectMove(int iat)
restore to the original state
void copyFromBuffer(ParticleSet &P, WFBufferType &buf)
copy all the wavefunction components from buffer.
QTBase::GradType GradType
Definition: Configuration.h:62
TrialWaveFunction & Psi
trial function
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false)
update the state with the new data
void saveProperty(IT first)
save the values of Hamiltonian elements to the Properties
bool phaseChanged(RealType psi0) const
void buffer_sample(int current_step)
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
int first(int igroup) const
return the first index of a group i
Definition: ParticleSet.h:514
int current_step
current MC step
Definition: ParticleSet.h:134
ParticleSet::ParticlePos deltaR
temporary storage for random displacement
RealType updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false)
update all the wavefunction components in buffer.
DriverDebugChecks debug_checks_
determine additional checks for debugging purpose
Definition: QMCUpdateBase.h:58
IndexType nNodeCrossing
Total number of node crossings per block.
Definition: QMCUpdateBase.h:69
QMCTraits::PosType PosType
int groups() const
return the number of groups
Definition: ParticleSet.h:511
PooledMemory< FullPrecRealType > WFBuffer_t
Definition: Walker.h:80
const PosType & getActivePos() const
Definition: ParticleSet.h:261
double norm(const zVec &c)
Definition: VectorOps.h:118
FullPrecRealType evaluateWithToperator(ParticleSet &P)
evaluate Local energy with Toperators updated.
QTBase::ValueType ValueType
Definition: Configuration.h:60
RealType branchWeight(FullPrecRealType enew, FullPrecRealType eold) const
return the bare branch weight with a filtering using an energy window
void saveWalker(Walker_t &awalker)
save this to awalker
RealType Tau
timestep
Definition: QMCUpdateBase.h:73
void accept_rejectMove(Index_t iat, bool accepted, bool forward_mode=true)
accept or reject a proposed move Two operation modes: The using and updating distance tables via Part...
ParticlePos R
Position.
Definition: ParticleSet.h:79
int last(int igroup) const
return the last index of a group i
Definition: ParticleSet.h:517
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
MCWalkerConfiguration & W
walker ensemble
static void checkLogAndGL(ParticleSet &pset, TrialWaveFunction &twf, const std::string_view location)
check logpsi and grad and lap against values computed from scratch
void loadWalker(Walker_t &awalker, bool pbyp)
load a Walker_t to the current ParticleSet
void collect(const MCPWalker &walker, const ParticleSet &pset, const TrialWaveFunction &wfn, const QMCHamiltonian &ham, int step=-1)
collect all data for one walker into the data buffers
void auxHevaluate(ParticleSet &P)
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
QMCTraits::RealType RealType
void rejectedMove(ParticleSet &P, Walker_t &ThisWalker)
Looks like a hack see DMCBatched.cpp and DMC.cpp weight is used like temporary flag from DMC...
RandomBase< FullPrecRealType > & RandomGen
random number generator
GradType evalGrad(ParticleSet &P, int iat)
int makeNonLocalMoves(ParticleSet &P)
make non local moves
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
bool makeMoveAndCheck(Index_t iat, const SingleParticlePos &displ)
move the iat-th particle to active_pos_
QTFull::RealType FullPrecRealType
Definition: Configuration.h:66
IndexType nAccept
counter for number of moves accepted
Definition: QMCUpdateBase.h:63
IndexType nReject
counter for number of moves rejected
Definition: QMCUpdateBase.h:65
virtual void getDrift(RealType tau, const GradType &qf, PosType &drift) const =0
evaluate a drift with a real force
void prepareGroup(ParticleSet &P, int ig)
Prepare internal data for updating WFC correspond to a particle group Particle groups usually corresp...
std::vector< RealType > MassInvS
1/Mass per species
void setMultiplicity(WalkerIter_t it, WalkerIter_t it_end)
set the multiplicity of the walkers to branch
QMCHamiltonian & H
Hamiltonian.
ValueType calcRatioGrad(ParticleSet &P, int iat, GradType &grad_iat)
compute psi(R_new) / psi(R_current) ratio and ln(psi(R_new)) gradients It returns a complex value if...
RealType m_r2max
maximum displacement^2
void donePbyP(bool skipSK=false)
update structure factor and unmark active_ptcl_
void completeUpdates()
complete all the delayed or asynchronous operations before leaving the p-by-p move region...
IndexType NonLocalMoveAccepted
Total numer of non-local moves accepted.
Definition: QMCUpdateBase.h:71
IndexType nAllRejected
Total number of the steps when all the particle moves are rejected.
Definition: QMCUpdateBase.h:67
const DriftModifierBase * DriftModifier
drift modifer, stateless reference to the one in QMCDriver
void makeGaussRandomWithEngine(ParticleAttrib< TinyVector< T, D >> &a, RG &rng)

Member Data Documentation

◆ myTimers

TimerList_t myTimers
private

Definition at line 36 of file DMCUpdatePbyP.h.

Referenced by DMCUpdatePbyPWithRejectionFast::advanceWalker().


The documentation for this class was generated from the following files: