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

Public Member Functions

 SODMCUpdatePbyPWithRejectionFast (MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, RandomBase< FullPrecRealType > &rg)
 Constructor. More...
 
 ~SODMCUpdatePbyPWithRejectionFast () 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 19 of file SODMCUpdatePbyP.h.

Constructor & Destructor Documentation

◆ SODMCUpdatePbyPWithRejectionFast()

Constructor.

Definition at line 39 of file SODMCUpdatePbyPFast.cpp.

44 
45 {}
const TimerNameList_t< SODMCTimers > SODMCTimerNames
QMCUpdateBase(MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, RandomBase< FullPrecRealType > &rg)
Constructor.
TimerManager< NewTimer > & getGlobalTimerManager()

◆ ~SODMCUpdatePbyPWithRejectionFast()

destructor

Definition at line 48 of file SODMCUpdatePbyPFast.cpp.

48 {}

Member Function Documentation

◆ advanceWalker()

void advanceWalker ( Walker_t thisWalker,
bool  recompute 
)
overridevirtual

move a walker

Implements QMCUpdateBase.

Definition at line 50 of file SODMCUpdatePbyPFast.cpp.

References ParticleSet::accept_rejectMove(), TrialWaveFunction::acceptMove(), Walker< t_traits, p_traits >::Age, QMCHamiltonian::auxHevaluate(), QMCUpdateBase::branchEngine, SimpleFixedNodeBranch::branchWeight(), TraceManager::buffer_sample(), TrialWaveFunction::calcRatioGradWithSpin(), qmcplusplus::CHECKGL_AFTER_MOVES, QMCUpdateBase::checkLogAndGL(), TrialWaveFunction::completeUpdates(), TrialWaveFunction::copyFromBuffer(), ParticleSet::current_step, Walker< t_traits, p_traits >::DataSet, QMCUpdateBase::debug_checks_, QMCUpdateBase::deltaR, QMCUpdateBase::deltaS, ParticleSet::donePbyP(), qmcplusplus::dot(), QMCUpdateBase::DriftModifier, TrialWaveFunction::evalGradWithSpin(), QMCHamiltonian::evaluateWithToperator(), qmcplusplus::exp(), ParticleSet::first(), ParticleSet::getActivePos(), ParticleSet::getActiveSpinVal(), 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::makeMoveAndCheckWithSpin(), QMCHamiltonian::makeNonLocalMoves(), QMCUpdateBase::MassInvS, SODMCUpdatePbyPWithRejectionFast::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::SODMC_buffer, qmcplusplus::SODMC_collectables, qmcplusplus::SODMC_hamiltonian, qmcplusplus::SODMC_movePbyP, qmcplusplus::SODMC_tmoves, QMCUpdateBase::spinMass, ParticleSet::spins, qmcplusplus::sqrt(), QMCUpdateBase::Tau, QMCUpdateBase::Traces, TrialWaveFunction::updateBuffer(), QMCUpdateBase::W, and Walker< t_traits, p_traits >::Weight.

51 {
52  Walker_t::WFBuffer_t& w_buffer(thisWalker.DataSet);
53  {
54  ScopedTimer local_timer(myTimers[SODMC_buffer]);
55  W.loadWalker(thisWalker, true);
56  Psi.copyFromBuffer(W, w_buffer);
57  }
58  //create a 3N-Dimensional Gaussian with variance=1
61  int nAcceptTemp(0);
62  int nRejectTemp(0);
63  //copy the old energy and scale factor of drift
64  FullPrecRealType eold(thisWalker.Properties(WP::LOCALENERGY));
65  FullPrecRealType enew(eold);
66  RealType rr_proposed = 0.0;
67  RealType rr_accepted = 0.0;
68  {
69  ScopedTimer local_timer(myTimers[SODMC_movePbyP]);
70  for (int ig = 0; ig < W.groups(); ++ig) //loop over species
71  {
72  RealType tauovermass = Tau * MassInvS[ig];
73  RealType oneover2tau = 0.5 / (tauovermass);
74  RealType sqrttau = std::sqrt(tauovermass);
75  Psi.prepareGroup(W, ig);
76  for (int iat = W.first(ig); iat < W.last(ig); ++iat)
77  {
78  //get the displacement
79  ComplexType spingrad_iat;
80  GradType grad_iat = Psi.evalGradWithSpin(W, iat, spingrad_iat);
81  PosType dr;
83  DriftModifier->getDrift(tauovermass, grad_iat, dr);
84  DriftModifier->getDrift(tauovermass / spinMass, spingrad_iat, ds);
85  dr += sqrttau * deltaR[iat];
86  ds += std::sqrt(tauovermass / spinMass) * deltaS[iat];
87  bool is_valid = W.makeMoveAndCheckWithSpin(iat, dr, ds);
88  RealType rr = tauovermass * dot(deltaR[iat], deltaR[iat]);
89  rr_proposed += rr;
90  if (!is_valid || rr > m_r2max)
91  {
92  ++nRejectTemp;
93  W.accept_rejectMove(iat, false);
94  continue;
95  }
96  ValueType ratio = Psi.calcRatioGradWithSpin(W, iat, grad_iat, spingrad_iat);
97  //node is crossed reject the move
99  {
100  ++nRejectTemp;
101  ++nNodeCrossing;
102  W.accept_rejectMove(iat, false);
103  Psi.rejectMove(iat);
104  }
105  else
106  {
107  FullPrecRealType logGf = -0.5 * dot(deltaR[iat], deltaR[iat]);
108  logGf += -0.5 * deltaS[iat] * deltaS[iat];
109  //Use the force of the particle iat
110  DriftModifier->getDrift(tauovermass, grad_iat, dr);
111  DriftModifier->getDrift(tauovermass / spinMass, spingrad_iat, ds);
112  dr = W.R[iat] - W.getActivePos() - dr;
113  ds = W.spins[iat] - W.getActiveSpinVal() - ds;
114  FullPrecRealType logGb = -oneover2tau * dot(dr, dr);
115  logGb += -spinMass * oneover2tau * ds * ds;
116  RealType prob = std::norm(ratio) * std::exp(logGb - logGf);
117  bool is_accepted = false;
118 
119  if (RandomGen() < prob)
120  {
121  is_accepted = true;
122 
123  ++nAcceptTemp;
124  Psi.acceptMove(W, iat, true);
125  rr_accepted += rr;
126  }
127  else
128  {
129  ++nRejectTemp;
130  Psi.rejectMove(iat);
131  }
132  W.accept_rejectMove(iat, is_accepted);
133  }
134  }
135  }
137  W.donePbyP();
138  }
139 
140  if (nAcceptTemp > 0)
141  {
142  //need to overwrite the walker properties
143  RealType logpsi(0);
144  {
145  ScopedTimer local_timer(myTimers[SODMC_buffer]);
146  thisWalker.Age = 0;
147  logpsi = Psi.updateBuffer(W, w_buffer, recompute);
149  checkLogAndGL(W, Psi, "checkGL_after_moves");
150  W.saveWalker(thisWalker);
151  }
152  {
153  ScopedTimer local_timer(myTimers[SODMC_hamiltonian]);
154  enew = H.evaluateWithToperator(W);
155  }
156  thisWalker.resetProperty(logpsi, Psi.getPhase(), enew, rr_accepted, rr_proposed, 1.0);
157  thisWalker.Weight *= branchEngine->branchWeight(enew, eold);
158  {
160  H.auxHevaluate(W, thisWalker);
161  H.saveProperty(thisWalker.getPropertyBase());
162  }
163  }
164  else
165  {
166  //all moves are rejected: does not happen normally with reasonable wavefunctions
167  thisWalker.Age++;
168  thisWalker.Properties(WP::R2ACCEPTED) = 0.0;
169  //weight is set to 0 for traces
170  // consistent w/ no evaluate/auxHevaluate
171  RealType wtmp = thisWalker.Weight;
172  thisWalker.Weight = 0.0;
173  H.rejectedMove(W, thisWalker);
174  thisWalker.Weight = wtmp;
175  ++nAllRejected;
176  enew = eold; //copy back old energy
177  thisWalker.Weight *= branchEngine->branchWeight(enew, eold);
178  }
179 #if !defined(REMOVE_TRACEMANAGER)
181 #endif
182  {
183  ScopedTimer local_timer(myTimers[SODMC_tmoves]);
184  const int NonLocalMoveAcceptedTemp = H.makeNonLocalMoves(W);
185  if (NonLocalMoveAcceptedTemp > 0)
186  {
187  RealType logpsi = Psi.updateBuffer(W, w_buffer, false);
188  W.saveWalker(thisWalker);
189  NonLocalMoveAccepted += NonLocalMoveAcceptedTemp;
190  }
191  }
192  nAccept += nAcceptTemp;
193  nReject += nRejectTemp;
194 
195  setMultiplicity(thisWalker);
196 }
TraceManager * Traces
traces
const BranchEngineType * branchEngine
branch engine, stateless reference to the one in QMCDriver
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
Scalar_t getActiveSpinVal() const
Definition: ParticleSet.h:262
ParticleScalar spins
internal spin variables for dynamical spin calculations
Definition: ParticleSet.h:81
TrialWaveFunction & Psi
trial function
RealType spinMass
spin mass
Definition: QMCUpdateBase.h:75
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false)
update the state with the new data
ParticleSet::ParticleScalar deltaS
temporart storage for spin displacement
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
QTBase::ComplexType ComplexType
Definition: Configuration.h:59
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
GradType evalGradWithSpin(ParticleSet &P, int iat, ComplexType &spingrad)
compute d/ds ln(psi) spin gradient at current particle position for iat electron
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
bool makeMoveAndCheckWithSpin(Index_t iat, const SingleParticlePos &displ, const Scalar_t &sdispl)
makeMoveAndCheck, but now includes an update to the spin variable
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 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
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)
ValueType calcRatioGradWithSpin(ParticleSet &P, int iat, GradType &grad_iat, ComplexType &spingrad_iat)
compute psi(R_new) / psi(R_current) ratio and d/ds ln(psi(R_new)) spin gradient It returns a complex ...
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.
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 33 of file SODMCUpdatePbyP.h.

Referenced by SODMCUpdatePbyPWithRejectionFast::advanceWalker().


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