QMCPACK
QMC Drivers using particle-by-particle update

Move particle by particle. More...

+ Collaboration diagram for QMC Drivers using particle-by-particle update:

Classes

class  CSVMCUpdatePbyP
 
Implements the VMC algorithm More...
 
class  CSVMCUpdatePbyPWithDriftFast
 
Implements the VMC algorithm with drift. More...
 
class  DMCBatched
 
Implements a DMC using particle-by-particle threaded and batched moves. More...
 
class  RMC
 
Implements a RMC using threaded execution. More...
 
class  RMCUpdateAllWithDrift
 
Implements the RMC algorithm using all electron moves More...
 
class  RMCUpdatePbyPWithDrift
 
Implements the RMC algorithm using all electron moves More...
 
class  SOVMCUpdateAll
 
Implements the Spin VMC algorithm using particle-by-particle move. More...
 
class  SOVMCUpdatePbyP
 
Implements the VMC algorithm using particle-by-particle move, including spin-moves More...
 
class  VMC
 
Implements a VMC using particle-by-particle move. More...
 
class  VMCBatched
 
Implements a VMC using particle-by-particle move. More...
 
class  VMCUpdateAll
 
Implements the VMC algorithm using particle-by-particle move. More...
 
class  VMCUpdatePbyP
 
Implements the VMC algorithm using particle-by-particle move. More...
 

Detailed Description

Move particle by particle.


Class Documentation

◆ qmcplusplus::CSVMCUpdatePbyP

class qmcplusplus::CSVMCUpdatePbyP


Implements the VMC algorithm

Definition at line 24 of file CSVMCUpdatePbyP.h.

+ Inheritance diagram for CSVMCUpdatePbyP:
+ Collaboration diagram for CSVMCUpdatePbyP:

Public Member Functions

 CSVMCUpdatePbyP (MCWalkerConfiguration &w, std::vector< TrialWaveFunction *> &psi, std::vector< QMCHamiltonian *> &h, RandomBase< FullPrecRealType > &rg)
 Constructor. More...
 
 ~CSVMCUpdatePbyP () override
 
void advanceWalker (Walker_t &thisWalker, bool recompute) override
 move a walker More...
 
- Public Member Functions inherited from CSUpdateBase
 CSUpdateBase (MCWalkerConfiguration &w, std::vector< TrialWaveFunction *> &psi, std::vector< QMCHamiltonian *> &h, RandomBase< FullPrecRealType > &rg)
 
 ~CSUpdateBase () override
 
void computeSumRatio (const std::vector< RealType > &logpsi, const std::vector< RealType > &avgNorm, std::vector< RealType > &sumratio)
 
void computeSumRatio (const Matrix< RealType > &ratioij, std::vector< RealType > &sumratio)
 
void computeSumRatio (const std::vector< RealType > &logpsi, const std::vector< RealType > &avgNorm, Matrix< RealType > &ratioij, std::vector< RealType > &sumratio)
 
void updateRatioMatrix (const std::vector< RealType > &ratio_pbyp, Matrix< RealType > &ratioij)
 
void resizeWorkSpace (int nw, int nptcls)
 
void updateNorms ()
 
void updateAvgWeights ()
 
void initCSWalkers (WalkerIter_t it, WalkerIter_t it_end, bool resetNorms)
 
void initCSWalkersForPbyP (WalkerIter_t it, WalkerIter_t it_end, bool resetNorms)
 
void updateCSWalkers (WalkerIter_t it, WalkerIter_t it_end)
 
- 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)
 

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 CSUpdateBase
int nPsi
 
bool useDrift
 
std::vector< RealTypelogpsi
 
std::vector< RealTypesumratio
 
std::vector< RealTypeinvsumratio
 
std::vector< RealTypeavgNorm
 
std::vector< RealTypeavgWeight
 
std::vector< RealTypelogNorm
 
std::vector< RealTypecumNorm
 
std::vector< RealTypeinstRij
 
std::vector< RealTyperatio
 
Matrix< RealTyperatioIJ
 
std::string useDriftOption
 
Matrix< RealTypeRatioIJ
 
CSEnergyEstimatormultiEstimator
 multiple estimator More...
 
std::vector< QMCHamiltonian * > H1
 a list of QMCHamiltonians for multiple method More...
 
std::vector< TrialWaveFunction * > Psi1
 a list of TrialWaveFunctions for multiple method More...
 
std::vector< ParticleSet::ParticleGradient * > G1
 
std::vector< ParticleSet::ParticleLaplacian * > L1
 
std::vector< GradTypeg1_old
 
std::vector< GradTypeg1_new
 
- 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
 

Constructor & Destructor Documentation

◆ CSVMCUpdatePbyP()

CSVMCUpdatePbyP ( MCWalkerConfiguration w,
std::vector< TrialWaveFunction *> &  psi,
std::vector< QMCHamiltonian *> &  h,
RandomBase< FullPrecRealType > &  rg 
)

Constructor.

Definition at line 30 of file CSVMCUpdatePbyP.cpp.

34  : CSUpdateBase(w, psi, h, rg)
35 {}
CSUpdateBase(MCWalkerConfiguration &w, std::vector< TrialWaveFunction *> &psi, std::vector< QMCHamiltonian *> &h, RandomBase< FullPrecRealType > &rg)

◆ ~CSVMCUpdatePbyP()

~CSVMCUpdatePbyP ( )
override

Definition at line 37 of file CSVMCUpdatePbyP.cpp.

37 {}

Member Function Documentation

◆ advanceWalker()

void advanceWalker ( Walker_t thisWalker,
bool  recompute 
)
overridevirtual

move a walker

Implements QMCUpdateBase.

Definition at line 39 of file CSVMCUpdatePbyP.cpp.

References ParticleSet::accept_rejectMove(), CSUpdateBase::avgNorm, CSUpdateBase::computeSumRatio(), CSUpdateBase::cumNorm, Walker< t_traits, p_traits >::DataSet, QMCUpdateBase::deltaR, ParticleSet::donePbyP(), ParticleSet::first(), ParticleSet::G, CSUpdateBase::G1, Walker< t_traits, p_traits >::getPropertyBase(), ParticleSet::groups(), CSUpdateBase::H1, CSUpdateBase::invsumratio, ParticleSet::L, Walker< t_traits, p_traits >::L, CSUpdateBase::L1, ParticleSet::last(), ParticleSet::loadWalker(), CSUpdateBase::logpsi, qmcplusplus::makeGaussRandomWithEngine(), ParticleSet::makeMoveAndCheck(), QMCUpdateBase::MassInvS, Walker< t_traits, p_traits >::Multiplicity, QMCUpdateBase::nAccept, QMCUpdateBase::nAllRejected, norm(), CSUpdateBase::nPsi, QMCUpdateBase::nReject, QMCUpdateBase::nSubSteps, Walker< t_traits, p_traits >::Properties, CSUpdateBase::Psi1, QMCUpdateBase::RandomGen, CSUpdateBase::ratio, CSUpdateBase::RatioIJ, ParticleSet::saveWalker(), qmcplusplus::sqrt(), CSUpdateBase::sumratio, QMCUpdateBase::Tau, CSUpdateBase::updateRatioMatrix(), and QMCUpdateBase::W.

40 {
41  W.loadWalker(thisWalker, true);
42 
43  //First step, we initialize all Psis, and read up the value of logpsi
44  //from the last run.
45  for (int ipsi = 0; ipsi < nPsi; ipsi++)
46  {
47  Psi1[ipsi]->copyFromBuffer(W, thisWalker.DataSet);
48  logpsi[ipsi] = thisWalker.Properties(ipsi, WP::LOGPSI);
49  }
50 
51  //Now we compute sumratio and more importantly, ratioij.
53  for (int iter = 0; iter < nSubSteps; ++iter)
54  {
56  bool stucked = true;
57  for (int ig = 0; ig < W.groups(); ++ig) //loop over species
58  {
59  RealType sqrttau = std::sqrt(Tau * MassInvS[ig]);
60  for (int iat = W.first(ig); iat < W.last(ig); ++iat)
61  {
62  PosType dr = sqrttau * deltaR[iat];
63  //The move proposal for particle iat.
64  if (W.makeMoveAndCheck(iat, dr))
65  {
66  for (int ipsi = 0; ipsi < nPsi; ipsi++)
67  ratio[ipsi] = std::norm(Psi1[ipsi]->calcRatio(W, iat));
68  //Compute the ratio and acceptance probability.
69  RealType prob = 0;
70  for (int ipsi = 0; ipsi < nPsi; ipsi++)
71  prob += ratio[ipsi] / sumratio[ipsi];
72 
73  bool is_accepted = false;
74  if (RandomGen() < prob)
75  {
76  is_accepted = true;
77  stucked = false;
78  ++nAccept;
79  for (int ipsi = 0; ipsi < nPsi; ipsi++)
80  Psi1[ipsi]->acceptMove(W, iat, true);
81 
82  //Now we update ratioIJ.
85  }
86  else
87  {
88  ++nReject;
89  for (int ipsi = 0; ipsi < nPsi; ipsi++)
90  Psi1[ipsi]->rejectMove(iat);
91  }
92 
93  W.accept_rejectMove(iat, is_accepted);
94  }
95  else //reject illegal moves
96  ++nReject;
97  } //iat
98  } //ig for the species
99  if (stucked)
100  {
101  ++nAllRejected;
102  }
103  for (int ipsi = 0; ipsi < nPsi; ipsi++)
104  Psi1[ipsi]->completeUpdates();
105  }
106 
107  W.donePbyP();
108 
109  for (int ipsi = 0; ipsi < nPsi; ipsi++)
110  {
111  //now recompute logpsi, gradients, and laplacians of the new R. Save them.
112  logpsi[ipsi] = Psi1[ipsi]->updateBuffer(W, thisWalker.DataSet, recompute);
113  W.saveWalker(thisWalker);
114  //Save G and L for this wavefunction in the working G1, L1 arrays.
115  *G1[ipsi] = thisWalker.G;
116  *L1[ipsi] = thisWalker.L;
117  //Set G and L for this wavefunction.
118  Psi1[ipsi]->G = W.G;
119  Psi1[ipsi]->L = W.L;
120  }
121 
123  for (int ipsi = 0; ipsi < nPsi; ipsi++)
124  {
125  invsumratio[ipsi] = sumratio[ipsi];
126  cumNorm[ipsi] += 1.0 / invsumratio[ipsi];
127  }
128 
129  for (int ipsi = 0; ipsi < nPsi; ipsi++)
130  {
131  //Now reload the G and L associated with ipsi into the walker and particle set.
132  //This is required for correct calculation of kinetic energy.
133  thisWalker.G = *G1[ipsi];
134  thisWalker.L = *L1[ipsi];
135  W.L = thisWalker.L;
136  W.G = thisWalker.G;
137  thisWalker.Properties(ipsi, WP::LOCALENERGY) = H1[ipsi]->evaluate(W);
138  thisWalker.Properties(ipsi, WP::LOGPSI) = logpsi[ipsi];
139  thisWalker.Properties(ipsi, WP::SIGN) = Psi1[ipsi]->getPhase();
140  thisWalker.Properties(ipsi, WP::UMBRELLAWEIGHT) = 1.0 / sumratio[ipsi];
141  //Use Multiplicity as a temporary container for sumratio.
142  thisWalker.Multiplicity = sumratio[0];
143  H1[ipsi]->auxHevaluate(W, thisWalker);
144  H1[ipsi]->saveProperty(thisWalker.getPropertyBase(ipsi));
145  }
146 }
std::vector< RealType > sumratio
Definition: CSUpdateBase.h:40
std::vector< RealType > cumNorm
Definition: CSUpdateBase.h:45
void computeSumRatio(const std::vector< RealType > &logpsi, const std::vector< RealType > &avgNorm, std::vector< RealType > &sumratio)
void updateRatioMatrix(const std::vector< RealType > &ratio_pbyp, Matrix< RealType > &ratioij)
int first(int igroup) const
return the first index of a group i
Definition: ParticleSet.h:514
ParticleSet::ParticlePos deltaR
temporary storage for random displacement
ParticleLaplacian L
laplacians of the particles
Definition: ParticleSet.h:85
std::vector< TrialWaveFunction * > Psi1
a list of TrialWaveFunctions for multiple method
Definition: CSUpdateBase.h:57
QMCTraits::PosType PosType
int groups() const
return the number of groups
Definition: ParticleSet.h:511
std::vector< RealType > logpsi
Definition: CSUpdateBase.h:39
double norm(const zVec &c)
Definition: VectorOps.h:118
std::vector< RealType > invsumratio
Definition: CSUpdateBase.h:41
ParticleGradient G
gradients of the particles
Definition: ParticleSet.h:83
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...
std::vector< ParticleSet::ParticleGradient * > G1
Definition: CSUpdateBase.h:59
Matrix< RealType > RatioIJ
Definition: CSUpdateBase.h:51
int last(int igroup) const
return the last index of a group i
Definition: ParticleSet.h:517
MCWalkerConfiguration & W
walker ensemble
void loadWalker(Walker_t &awalker, bool pbyp)
load a Walker_t to the current ParticleSet
int nSubSteps
number of steps per measurement
Definition: QMCUpdateBase.h:56
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
QMCTraits::RealType RealType
RandomBase< FullPrecRealType > & RandomGen
random number generator
std::vector< RealType > ratio
Definition: CSUpdateBase.h:47
std::vector< RealType > avgNorm
Definition: CSUpdateBase.h:42
bool makeMoveAndCheck(Index_t iat, const SingleParticlePos &displ)
move the iat-th particle to active_pos_
std::vector< ParticleSet::ParticleLaplacian * > L1
Definition: CSUpdateBase.h:60
IndexType nAccept
counter for number of moves accepted
Definition: QMCUpdateBase.h:63
IndexType nReject
counter for number of moves rejected
Definition: QMCUpdateBase.h:65
std::vector< RealType > MassInvS
1/Mass per species
std::vector< QMCHamiltonian * > H1
a list of QMCHamiltonians for multiple method
Definition: CSUpdateBase.h:55
void donePbyP(bool skipSK=false)
update structure factor and unmark active_ptcl_
IndexType nAllRejected
Total number of the steps when all the particle moves are rejected.
Definition: QMCUpdateBase.h:67
void makeGaussRandomWithEngine(ParticleAttrib< TinyVector< T, D >> &a, RG &rng)

◆ qmcplusplus::CSVMCUpdatePbyPWithDriftFast

class qmcplusplus::CSVMCUpdatePbyPWithDriftFast


Implements the VMC algorithm with drift.

Definition at line 43 of file CSVMCUpdatePbyP.h.

+ Inheritance diagram for CSVMCUpdatePbyPWithDriftFast:
+ Collaboration diagram for CSVMCUpdatePbyPWithDriftFast:

Public Member Functions

 CSVMCUpdatePbyPWithDriftFast (MCWalkerConfiguration &w, std::vector< TrialWaveFunction *> &psi, std::vector< QMCHamiltonian *> &h, RandomBase< FullPrecRealType > &rg)
 Constructor. More...
 
 ~CSVMCUpdatePbyPWithDriftFast () override
 
void advanceWalker (Walker_t &thisWalker, bool recompute) override
 move a walker More...
 
- Public Member Functions inherited from CSUpdateBase
 CSUpdateBase (MCWalkerConfiguration &w, std::vector< TrialWaveFunction *> &psi, std::vector< QMCHamiltonian *> &h, RandomBase< FullPrecRealType > &rg)
 
 ~CSUpdateBase () override
 
void computeSumRatio (const std::vector< RealType > &logpsi, const std::vector< RealType > &avgNorm, std::vector< RealType > &sumratio)
 
void computeSumRatio (const Matrix< RealType > &ratioij, std::vector< RealType > &sumratio)
 
void computeSumRatio (const std::vector< RealType > &logpsi, const std::vector< RealType > &avgNorm, Matrix< RealType > &ratioij, std::vector< RealType > &sumratio)
 
void updateRatioMatrix (const std::vector< RealType > &ratio_pbyp, Matrix< RealType > &ratioij)
 
void resizeWorkSpace (int nw, int nptcls)
 
void updateNorms ()
 
void updateAvgWeights ()
 
void initCSWalkers (WalkerIter_t it, WalkerIter_t it_end, bool resetNorms)
 
void initCSWalkersForPbyP (WalkerIter_t it, WalkerIter_t it_end, bool resetNorms)
 
void updateCSWalkers (WalkerIter_t it, WalkerIter_t it_end)
 
- 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)
 

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 CSUpdateBase
int nPsi
 
bool useDrift
 
std::vector< RealTypelogpsi
 
std::vector< RealTypesumratio
 
std::vector< RealTypeinvsumratio
 
std::vector< RealTypeavgNorm
 
std::vector< RealTypeavgWeight
 
std::vector< RealTypelogNorm
 
std::vector< RealTypecumNorm
 
std::vector< RealTypeinstRij
 
std::vector< RealTyperatio
 
Matrix< RealTyperatioIJ
 
std::string useDriftOption
 
Matrix< RealTypeRatioIJ
 
CSEnergyEstimatormultiEstimator
 multiple estimator More...
 
std::vector< QMCHamiltonian * > H1
 a list of QMCHamiltonians for multiple method More...
 
std::vector< TrialWaveFunction * > Psi1
 a list of TrialWaveFunctions for multiple method More...
 
std::vector< ParticleSet::ParticleGradient * > G1
 
std::vector< ParticleSet::ParticleLaplacian * > L1
 
std::vector< GradTypeg1_old
 
std::vector< GradTypeg1_new
 
- 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
 

Constructor & Destructor Documentation

◆ CSVMCUpdatePbyPWithDriftFast()

CSVMCUpdatePbyPWithDriftFast ( MCWalkerConfiguration w,
std::vector< TrialWaveFunction *> &  psi,
std::vector< QMCHamiltonian *> &  h,
RandomBase< FullPrecRealType > &  rg 
)

Constructor.

UpdatePbyP With Drift Fast.

Definition at line 150 of file CSVMCUpdatePbyP.cpp.

References APP_ABORT.

154  : CSUpdateBase(w, psi, h, rg){APP_ABORT("CSVMCUpdatePbyPWithDriftFast currently not working. Please eliminate \
155  drift option, or choose all electron moves instead.")}
CSUpdateBase(MCWalkerConfiguration &w, std::vector< TrialWaveFunction *> &psi, std::vector< QMCHamiltonian *> &h, RandomBase< FullPrecRealType > &rg)
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ ~CSVMCUpdatePbyPWithDriftFast()

Definition at line 157 of file CSVMCUpdatePbyP.cpp.

158 {}

Member Function Documentation

◆ advanceWalker()

void advanceWalker ( Walker_t thisWalker,
bool  recompute 
)
overridevirtual

move a walker

Implements QMCUpdateBase.

Definition at line 160 of file CSVMCUpdatePbyP.cpp.

160 {}

◆ qmcplusplus::DMCBatched

class qmcplusplus::DMCBatched


Implements a DMC using particle-by-particle threaded and batched moves.

Definition at line 35 of file DMCBatched.h.

+ Inheritance diagram for DMCBatched:
+ Collaboration diagram for DMCBatched:

Public Types

using Base = QMCDriverNew
 
using FullPrecRealType = QMCTraits::FullPrecRealType
 
using PosType = QMCTraits::PosType
 
using ParticlePositions = PtclOnLatticeTraits::ParticlePos
 
- Public Types inherited from QMCDriverNew
enum  { QMC_UPDATE_MODE, QMC_MULTIPLE, QMC_OPTIMIZE, QMC_WARMUP }
 separate but similar to QMCModeEnum More...
 
using RealType = QMCTraits::RealType
 
using IndexType = QMCTraits::IndexType
 
using FullPrecRealType = QMCTraits::FullPrecRealType
 
using MCPWalker = MCPopulation::MCPWalker
 
using WFBuffer = MCPopulation::WFBuffer
 
using SetNonLocalMoveHandler = std::function< void(QMCHamiltonian &)>
 
- Public Types inherited from QMCDriverInterface
using BranchEngineType = SimpleFixedNodeBranch
 
using FullPrecRealType = QMCTraits::FullPrecRealType
 
- Public Types inherited from MPIObjectBase
using mpi_comm_type = Communicate::mpi_comm_type
 

Public Member Functions

 DMCBatched (const ProjectData &project_data, QMCDriverInput &&qmcdriver_input, const std::optional< EstimatorManagerInput > &global_emi, DMCDriverInput &&input, WalkerConfigurations &wc, MCPopulation &&pop, Communicate *comm)
 Constructor. More...
 
 DMCBatched (const DMCBatched &)=delete
 Copy Constructor (disabled) More...
 
DMCBatchedoperator= (const DMCBatched &)=delete
 Copy operator (disabled). More...
 
 DMCBatched (DMCBatched &&)=default
 
 ~DMCBatched () override
 
void process (xmlNodePtr cur) override
 DMCBatched driver will eventually ignore cur. More...
 
bool run () override
 
QMCRunType getRunType () override
 
void setNonLocalMoveHandler (QMCHamiltonian &hamiltonian)
 
- Public Member Functions inherited from QMCDriverNew
 QMCDriverNew (const ProjectData &project_data, QMCDriverInput &&input, const std::optional< EstimatorManagerInput > &global_emi, WalkerConfigurations &wc, MCPopulation &&population, const std::string timer_prefix, Communicate *comm, const std::string &QMC_driver_type)
 Constructor. More...
 
 QMCDriverNew (QMCDriverNew &&)=default
 Move Constructor. More...
 
 QMCDriverNew (const QMCDriverNew &)=delete
 Copy Constructor (disabled). More...
 
QMCDriverNewoperator= (const QMCDriverNew &)=delete
 Copy operator (disabled). More...
 
 ~QMCDriverNew () override
 
bool putQMCInfo (xmlNodePtr cur)
 
void makeLocalWalkers (int nwalkers, RealType reserve)
 Adjust populations local walkers to this number. More...
 
DriftModifierBaseget_drift_modifier () const
 
void recordBlock (int block) override
 record the state of the block More...
 
bool finalize (int block, bool dumpwalkers=true)
 finalize a qmc section More...
 
IndexType current () const
 return current step More...
 
void setStatus (const std::string &aname, const std::string &h5name, bool append) override
 Set the status of the QMCDriver. More...
 
void add_H_and_Psi (QMCHamiltonian *h, TrialWaveFunction *psi) override
 
void createRngsStepContexts (int num_crowds)
 Creates Random Number generators for crowds and step contexts. More...
 
void putWalkers (std::vector< xmlNodePtr > &wset) override
 Read walker configurations from *.config.h5 files. More...
 
RefVector< RandomBase< FullPrecRealType > > getRngRefs () const
 
RandomBase< FullPrecRealType > & getRng (int i) override
 return the i-th random generator More...
 
std::string getEngineName () override
 intended for logging output and debugging you should base behavior on type preferably at compile time or if necessary at runtime using and protected by dynamic cast. More...
 
unsigned long getDriverMode () override
 
IndexType get_num_living_walkers () const
 
IndexType get_num_dead_walkers () const
 
const QMCDriverInputgetQMCDriverInput () const
 
bool put (xmlNodePtr cur) override
 
More...
 
void setUpdateMode (bool pbyp) override
 should be set in input don't see a reason to set individually More...
 
void putTraces (xmlNodePtr txml) override
 
void requestTraces (bool allow_traces) override
 
void putWalkerLogs (xmlNodePtr wlxml) override
 
void requestWalkerLogs (bool allow_walker_logs_) override
 
- Public Member Functions inherited from QMCDriverInterface
virtual ~QMCDriverInterface ()
 
virtual void setBranchEngine (std::unique_ptr< BranchEngineType > &&be)
 
virtual std::unique_ptr< BranchEngineTypegetBranchEngine ()
 
- Public Member Functions inherited from MPIObjectBase
 MPIObjectBase (Communicate *c)
 constructor with communicator More...
 
int rank () const
 return the rank of the communicator More...
 
int getGroupID () const
 return the group id of the communicator More...
 
CommunicategetCommunicator () const
 return myComm More...
 
CommunicategetCommRef () const
 return a TEMPORARY reference to Communicate More...
 
mpi_comm_type getMPI () const
 return MPI communicator if one wants to use MPI directly More...
 
bool is_manager () const
 return true if the rank == 0 More...
 
const std::string & getName () const
 return the name More...
 
void setName (const std::string &aname)
 

Static Public Member Functions

static void runDMCStep (int crowd_id, const StateForThread &sft, DriverTimers &timers, DMCTimers &dmc_timers, UPtrVector< ContextForSteps > &move_context, UPtrVector< Crowd > &crowds)
 
- Static Public Member Functions inherited from QMCDriverNew
static void initialLogEvaluation (int crowd_id, UPtrVector< Crowd > &crowds, UPtrVector< ContextForSteps > &step_context)
 
template<typename RT , CoordsType CT>
static void scaleBySqrtTau (const TauParams< RT, CT > &taus, MCCoords< CT > &coords)
 
template<typename RT , CoordsType CT>
static void computeLogGreensFunction (const MCCoords< CT > &coords, const TauParams< RT, CT > &taus, std::vector< QMCTraits::RealType > &log_gb)
 calculates Green Function from displacements stored in MCCoords [param, out] log_g More...
 

Static Private Member Functions

template<CoordsType CT>
static void advanceWalkers (const StateForThread &sft, Crowd &crowd, DriverTimers &timers, DMCTimers &dmc_timers, ContextForSteps &move_context, bool recompute, bool accumulate_this_step)
 

Private Attributes

const DMCDriverInput dmcdriver_input_
 
DMCTimers dmc_timers_
 I think its better if these have there own type and variable name. More...
 
IndexType branch_interval_
 Interval between branching. More...
 
std::unique_ptr< SFNBranchbranch_engine_
 branch engine More...
 
std::unique_ptr< WalkerControlwalker_controller_
 walker controller for load-balance More...
 

Friends

class qmcplusplus::testing::DMCBatchedTest
 

Additional Inherited Members

- Public Attributes inherited from QMCDriverNew
std::bitset< QMC_MODE_MAXqmc_driver_mode_
 bits to classify QMCDriver More...
 
bool allow_walker_logs
 whether to allow walker logs More...
 
WalkerLogInput walker_logs_input
 walker logs input More...
 
- Protected Member Functions inherited from QMCDriverNew
void initializeQMC (const AdjustedWalkerCounts &awc)
 Do common section starting tasks for VMC and DMC. More...
 
void measureImbalance (const std::string &tag) const
 inject additional barrier and measure load imbalance. More...
 
void endBlock ()
 end of a block operations. Aggregates statistics across all MPI ranks and write to disk. More...
 
const std::string & get_root_name () const override
 
- Static Protected Member Functions inherited from QMCDriverNew
static QMCDriverNew::AdjustedWalkerCounts adjustGlobalWalkerCount (Communicate &comm, const IndexType current_configs, const IndexType requested_total_walkers, const IndexType requested_walkers_per_rank, const RealType reserve_walkers, int num_crowds)
 }@ More...
 
static size_t determineStepsPerBlock (IndexType global_walkers, IndexType requested_samples, IndexType requested_steps, IndexType blocks)
 pure function calculating the actual number of steps per block More...
 
static void checkNumCrowdsLTNumThreads (const int num_crowds)
 
static void checkLogAndGL (Crowd &crowd, const std::string_view location)
 check logpsi and grad and lap against values computed from scratch More...
 
static void setWalkerOffsets (WalkerConfigurations &, Communicate *comm)
 update the global offsets of walker configurations after active walkers being touched. More...
 
- Protected Attributes inherited from QMCDriverNew
QMCDriverInput qmcdriver_input_
 
RealType max_disp_sq_
 
they should be limited to values that can be changed from input or are live state. More...
 
IndexType target_samples_
 the number of saved samples More...
 
IndexType nBlocksBetweenRecompute
 the number of blocks between recomptePsi More...
 
UPtrVector< Crowdcrowds_
 }@ More...
 
std::string h5_file_root_
 
std::unique_ptr< DriftModifierBasedrift_modifier_
 drift modifer More...
 
int k_delay
 the number to delay updates by More...
 
int walker_dump_period
 period of recording walker configurations More...
 
IndexType current_step_
 
size_t steps_per_block_ = 0
 actual number of steps per block More...
 
IndexType nAccept
 counter for number of moves accepted More...
 
IndexType nReject
 counter for number of moves /rejected More...
 
RealType m_oneover2tau
 Time-step factor $ 1/(2\tau)$. More...
 
RealType m_sqrttau
 Time-step factor $ \sqrt{\tau}$. More...
 
const std::string QMCType
 type of qmc: assigned by subclasses More...
 
MCPopulation population_
 the entire (on node) walker population it serves VMCBatch and DMCBatch right now but will be polymorphic More...
 
struct DriverWalkerResourceCollection golden_resource_
 the golden multi walker shared resource serves ParticleSet TrialWaveFunction right now but actually should be based on MCPopulation. More...
 
const MultiWalkerDispatchers dispatchers_
 multi walker dispatchers More...
 
std::unique_ptr< EstimatorManagerNewestimator_manager_
 Observables manager Has very problematic owner ship and life cycle. More...
 
std::unique_ptr< HDFWalkerOutputwOut
 record engine for walkers More...
 
UPtrVector< ContextForStepsstep_contexts_
 Per crowd move contexts, this is where the DistanceTables etc. More...
 
UPtrVector< RandomBase< FullPrecRealType > > Rng
 Random number generators. More...
 
std::vector< xmlNodePtr > mcwalkerNodePtr
 a list of mcwalkerset element More...
 
DriverTimers timers_
 period of dumping walker configurations and everything else for restart More...
 
ScopedProfiler driver_scope_profiler_
 profile the driver lifetime More...
 
const ProjectDataproject_data_
 project info for accessing global fileroot and series id More...
 
WalkerConfigurationswalker_configs_ref_
 
- Protected Attributes inherited from MPIObjectBase
CommunicatemyComm
 pointer to Communicate More...
 
std::string ClassName
 class Name More...
 
std::string myName
 name of the object More...
 

Member Typedef Documentation

◆ Base

using Base = QMCDriverNew

Definition at line 38 of file DMCBatched.h.

◆ FullPrecRealType

Definition at line 39 of file DMCBatched.h.

◆ ParticlePositions

◆ PosType

Definition at line 40 of file DMCBatched.h.

Constructor & Destructor Documentation

◆ DMCBatched() [1/3]

DMCBatched ( const ProjectData project_data,
QMCDriverInput &&  qmcdriver_input,
const std::optional< EstimatorManagerInput > &  global_emi,
DMCDriverInput &&  input,
WalkerConfigurations wc,
MCPopulation &&  pop,
Communicate comm 
)

Constructor.

Constructor maintains proper ownership of input parameters.

Note you must call the Base constructor before the derived class sets QMCType

Definition at line 44 of file DMCBatched.cpp.

51  : QMCDriverNew(project_data,
52  std::move(qmcdriver_input),
53  global_emi,
54  wc,
55  std::move(pop),
56  "DMCBatched::",
57  comm,
58  "DMCBatched"),
60  dmc_timers_("DMCBatched::")
61 {}
QMCDriverNew(const ProjectData &project_data, QMCDriverInput &&input, const std::optional< EstimatorManagerInput > &global_emi, WalkerConfigurations &wc, MCPopulation &&population, const std::string timer_prefix, Communicate *comm, const std::string &QMC_driver_type)
Constructor.
DMCTimers dmc_timers_
I think its better if these have there own type and variable name.
Definition: DMCBatched.h:136
const DMCDriverInput dmcdriver_input_
Definition: DMCBatched.h:132
testing::ValidSpinDensityInput input

◆ DMCBatched() [2/3]

DMCBatched ( const DMCBatched )
delete

Copy Constructor (disabled)

◆ DMCBatched() [3/3]

DMCBatched ( DMCBatched &&  )
default

◆ ~DMCBatched()

~DMCBatched ( )
overridedefault

Member Function Documentation

◆ advanceWalkers()

void advanceWalkers ( const StateForThread sft,
Crowd crowd,
DriverTimers timers,
DMCTimers dmc_timers,
ContextForSteps move_context,
bool  recompute,
bool  accumulate_this_step 
)
staticprivate

Definition at line 72 of file DMCBatched.cpp.

References DMCBatched::StateForThread::branch_engine, SFNBranch::branchWeight(), QMCDriverNew::DriverTimers::buffer_timer, qmcplusplus::CHECKGL_AFTER_MOVES, qmcplusplus::CHECKGL_AFTER_TMOVE, QMCDriverNew::checkLogAndGL(), QMCDriverNew::DriverTimers::collectables_timer, QMCDriverNew::computeLogGreensFunction(), qmcplusplus::crowd, qmcplusplus::dot(), DMCBatched::StateForThread::drift_modifier, QMCDriverNew::DriverTimers::estimators_timer, qmcplusplus::exp(), QMCDriverInput::get_debug_checks(), MCPopulation::get_ptclgrp_inv_mass(), ContextForSteps::get_random_gen(), QMCDriverInput::get_spin_mass(), QMCDriverInput::get_tau(), DriftModifierBase::getDrifts(), DMCBatched::StateForThread::global_step, QMCDriverNew::DriverTimers::hamiltonian_timer, qmcplusplus::isfinite(), qmcplusplus::makeGaussRandomWithEngine(), QMCDriverNew::DriverTimers::movepbyp_timer, norm(), qmcplusplus::hdf::num_walkers, SFNBranch::phaseChanged(), DMCBatched::StateForThread::population, DMCBatched::StateForThread::qmcdrv_input, QMCDriverNew::DriverTimers::resource_timer, QMCDriverNew::scaleBySqrtTau(), TimerType< CLOCK >::start(), DMCBatched::DMCTimers::step_begin_recompute_timer, TimerType< CLOCK >::stop(), DMCBatched::DMCTimers::tmove_timer, qmcplusplus::twf, qmcplusplus::walker, and qmcplusplus::hdf::walkers.

79 {
80  auto& ps_dispatcher = crowd.dispatchers_.ps_dispatcher_;
81  auto& twf_dispatcher = crowd.dispatchers_.twf_dispatcher_;
82  auto& ham_dispatcher = crowd.dispatchers_.ham_dispatcher_;
83 
84  auto& walkers = crowd.get_walkers();
85  const RefVectorWithLeader<ParticleSet> walker_elecs(crowd.get_walker_elecs()[0], crowd.get_walker_elecs());
86  const RefVectorWithLeader<TrialWaveFunction> walker_twfs(crowd.get_walker_twfs()[0], crowd.get_walker_twfs());
87  const RefVectorWithLeader<QMCHamiltonian> walker_hamiltonians(crowd.get_walker_hamiltonians()[0],
88  crowd.get_walker_hamiltonians());
89 
90  timers.resource_timer.start();
91  ResourceCollectionTeamLock<ParticleSet> pset_res_lock(crowd.getSharedResource().pset_res, walker_elecs);
92  ResourceCollectionTeamLock<TrialWaveFunction> twfs_res_lock(crowd.getSharedResource().twf_res, walker_twfs);
93  ResourceCollectionTeamLock<QMCHamiltonian> hams_res_lock(crowd.getSharedResource().ham_res, walker_hamiltonians);
94  timers.resource_timer.stop();
95 
96  {
97  ScopedTimer recompute_timer(dmc_timers.step_begin_recompute_timer);
98  std::vector<bool> recompute_mask;
99  recompute_mask.reserve(walkers.size());
100  for (MCPWalker& awalker : walkers)
101  if (awalker.wasTouched)
102  {
103  recompute_mask.push_back(true);
104  awalker.wasTouched = false;
105  }
106  else
107  recompute_mask.push_back(false);
108  ps_dispatcher.flex_loadWalker(walker_elecs, walkers, recompute_mask, true);
109  twf_dispatcher.flex_recompute(walker_twfs, walker_elecs, recompute_mask);
110  }
111 
112  const int num_walkers = crowd.size();
113  auto& pset_leader = walker_elecs.getLeader();
114  const int num_particles = pset_leader.getTotalNum();
115 
116  MCCoords<CT> drifts(num_walkers), drifts_reverse(num_walkers);
117  MCCoords<CT> walker_deltas(num_walkers * num_particles), deltas(num_walkers);
118  TWFGrads<CT> grads_now(num_walkers), grads_new(num_walkers);
119 
120  //This generates an entire steps worth of deltas.
121  makeGaussRandomWithEngine(walker_deltas, step_context.get_random_gen());
122 
123  std::vector<PsiValue> ratios(num_walkers, PsiValue(0.0));
124  std::vector<RealType> log_gf(num_walkers, 0.0);
125  std::vector<RealType> log_gb(num_walkers, 0.0);
126  std::vector<RealType> prob(num_walkers, 0.0);
127 
128  // local list to handle accept/reject
129  std::vector<bool> isAccepted;
130  isAccepted.reserve(num_walkers);
131 
132  //save the old energies for branching needs.
133  std::vector<FullPrecRealType> old_energies(num_walkers);
134  for (int iw = 0; iw < num_walkers; ++iw)
135  old_energies[iw] = walkers[iw].get().Properties(WP::LOCALENERGY);
136 
137  std::vector<RealType> rr_proposed(num_walkers, 0.0);
138  std::vector<RealType> rr_accepted(num_walkers, 0.0);
139 
140  {
141  ScopedTimer pbyp_local_timer(timers.movepbyp_timer);
142  for (int ig = 0; ig < pset_leader.groups(); ++ig)
143  {
144  TauParams<RealType, CT> taus(sft.qmcdrv_input.get_tau(), sft.population.get_ptclgrp_inv_mass()[ig],
145  sft.qmcdrv_input.get_spin_mass());
146 
147  twf_dispatcher.flex_prepareGroup(walker_twfs, walker_elecs, ig);
148 
149  for (int iat = pset_leader.first(ig); iat < pset_leader.last(ig); ++iat)
150  {
151  //This is very useful thing to be able to look at in the debugger
152 #ifndef NDEBUG
153  std::vector<int> walkers_who_have_been_on_wire(num_walkers, 0);
154  for (int iw = 0; iw < walkers.size(); ++iw)
155  {
156  walkers[iw].get().get_has_been_on_wire() ? walkers_who_have_been_on_wire[iw] = 1
157  : walkers_who_have_been_on_wire[iw] = 0;
158  }
159 #endif
160  //get deltas for this particle for all walkers
161  walker_deltas.getSubset(iat * num_walkers, num_walkers, deltas);
162 
163  // only DMC does this
164  // TODO: rr needs a real name
165  std::vector<RealType> rr(num_walkers, 0.0);
166  assert(rr.size() == deltas.positions.size());
167  std::transform(deltas.positions.begin(), deltas.positions.end(), rr.begin(),
168  [t = taus.tauovermass](auto& delta_r) { return t * dot(delta_r, delta_r); });
169 
170  twf_dispatcher.flex_evalGrad(walker_twfs, walker_elecs, iat, grads_now);
171  sft.drift_modifier.getDrifts(taus, grads_now, drifts);
172 
173  scaleBySqrtTau(taus, deltas);
174  drifts += deltas;
175 
176 // in DMC this was done here, changed to match VMCBatched pending factoring to common source
177 // if (rr > m_r2max)
178 // {
179 // ++nRejectTemp;
180 // continue;
181 // }
182 #ifndef NDEBUG
183  for (int i = 0; i < rr.size(); ++i)
184  assert(qmcplusplus::isfinite(rr[i]));
185 #endif
186 
187  ps_dispatcher.flex_makeMove(walker_elecs, iat, drifts);
188 
189  twf_dispatcher.flex_calcRatioGrad(walker_twfs, walker_elecs, iat, ratios, grads_new);
190 
191  computeLogGreensFunction(deltas, taus, log_gf);
192 
193  sft.drift_modifier.getDrifts(taus, grads_new, drifts_reverse);
194 
195  drifts_reverse += drifts;
196 
197  computeLogGreensFunction(drifts_reverse, taus, log_gb);
198 
199  auto checkPhaseChanged = [&sft](const PsiValue& ratio, int& is_reject) {
200  if (ratio == PsiValue(0) || sft.branch_engine.phaseChanged(std::arg(ratio)))
201  is_reject = 1;
202  else
203  is_reject = 0;
204  };
205 
206  // Hopefully a phase change doesn't make any of these transformations fail.
207  std::vector<int> rejects(num_walkers); // instead of std::vector<bool>
208  for (int iw = 0; iw < num_walkers; ++iw)
209  {
210  checkPhaseChanged(ratios[iw], rejects[iw]);
211  //This is just convenient to do here
212  rr_proposed[iw] += rr[iw];
213  }
214 
215  for (int iw = 0; iw < num_walkers; ++iw)
216  prob[iw] = std::norm(ratios[iw]) * std::exp(log_gb[iw] - log_gf[iw]);
217 
218  isAccepted.clear();
219 
220  for (int iw = 0; iw < num_walkers; ++iw)
221  if ((!rejects[iw]) && prob[iw] >= std::numeric_limits<RealType>::epsilon() &&
222  step_context.get_random_gen()() < prob[iw])
223  {
224  crowd.incAccept();
225  isAccepted.push_back(true);
226  rr_accepted[iw] += rr[iw];
227  }
228  else
229  {
230  crowd.incReject();
231  isAccepted.push_back(false);
232  }
233 
234  twf_dispatcher.flex_accept_rejectMove(walker_twfs, walker_elecs, iat, isAccepted, true);
235 
236  ps_dispatcher.flex_accept_rejectMove<CT>(walker_elecs, iat, isAccepted);
237  }
238  }
239 
240  twf_dispatcher.flex_completeUpdates(walker_twfs);
241  ps_dispatcher.flex_donePbyP(walker_elecs);
242  }
243 
244  { // collect GL for KE.
245  ScopedTimer buffer_local(timers.buffer_timer);
246  twf_dispatcher.flex_evaluateGL(walker_twfs, walker_elecs, recompute);
247  if (sft.qmcdrv_input.get_debug_checks() & DriverDebugChecks::CHECKGL_AFTER_MOVES)
248  checkLogAndGL(crowd, "checkGL_after_moves");
249  ps_dispatcher.flex_saveWalker(walker_elecs, walkers);
250  }
251 
252  { // hamiltonian
253  ScopedTimer ham_local(timers.hamiltonian_timer);
254 
255  std::vector<QMCHamiltonian::FullPrecRealType> new_energies(
256  ham_dispatcher.flex_evaluateWithToperator(walker_hamiltonians, walker_twfs, walker_elecs));
257 
258  auto resetSigNLocalEnergy = [](MCPWalker& walker, TrialWaveFunction& twf, auto local_energy, auto rr_acc,
259  auto rr_prop) {
260  walker.resetProperty(twf.getLogPsi(), twf.getPhase(), local_energy, rr_acc, rr_prop, 1.0);
261  };
262 
263  for (int iw = 0; iw < walkers.size(); ++iw)
264  {
265  resetSigNLocalEnergy(walkers[iw], walker_twfs[iw], new_energies[iw], rr_accepted[iw], rr_proposed[iw]);
266  FullPrecRealType branch_weight = sft.branch_engine.branchWeight(new_energies[iw], old_energies[iw]);
267  walkers[iw].get().Weight *= branch_weight;
268  if (rr_proposed[iw] > 0)
269  walkers[iw].get().Age = 0;
270  else
271  walkers[iw].get().Age++;
272  }
273  }
274 
275  { // estimator collectables
276  ScopedTimer collectable_local(timers.collectables_timer);
277 
278  // evaluate non-physical hamiltonian elements
279  for (int iw = 0; iw < walkers.size(); ++iw)
280  walker_hamiltonians[iw].auxHevaluate(walker_elecs[iw], walkers[iw]);
281 
282  // save properties into walker
283  for (int iw = 0; iw < walkers.size(); ++iw)
284  walker_hamiltonians[iw].saveProperty(walkers[iw].get().getPropertyBase());
285  }
286 
287  if (accumulate_this_step)
288  {
289  ScopedTimer est_timer(timers.estimators_timer);
290  crowd.accumulate(step_context.get_random_gen());
291  }
292 
293  // collect walker logs
294  crowd.collectStepWalkerLog(sft.global_step);
295 
296  { // T-moves
297  ScopedTimer tmove_timer(dmc_timers.tmove_timer);
298 
299  const auto num_walkers = walkers.size();
300  std::vector<int> walker_non_local_moves_accepted(num_walkers, 0);
301  RefVector<MCPWalker> moved_nonlocal_walkers;
302  RefVectorWithLeader<ParticleSet> moved_nonlocal_walker_elecs(crowd.get_walker_elecs()[0]);
303  RefVectorWithLeader<TrialWaveFunction> moved_nonlocal_walker_twfs(crowd.get_walker_twfs()[0]);
304  moved_nonlocal_walkers.reserve(num_walkers);
305  moved_nonlocal_walker_elecs.reserve(num_walkers);
306  moved_nonlocal_walker_twfs.reserve(num_walkers);
307 
308  for (int iw = 0; iw < walkers.size(); ++iw)
309  {
310  walker_non_local_moves_accepted[iw] = walker_hamiltonians[iw].makeNonLocalMoves(walker_elecs[iw]);
311 
312  if (walker_non_local_moves_accepted[iw] > 0)
313  {
314  crowd.incNonlocalAccept(walker_non_local_moves_accepted[iw]);
315  moved_nonlocal_walkers.push_back(walkers[iw]);
316  moved_nonlocal_walker_elecs.push_back(walker_elecs[iw]);
317  moved_nonlocal_walker_twfs.push_back(walker_twfs[iw]);
318  }
319  }
320 
321  if (moved_nonlocal_walkers.size())
322  {
323  twf_dispatcher.flex_evaluateGL(moved_nonlocal_walker_twfs, moved_nonlocal_walker_elecs, false);
324  if (sft.qmcdrv_input.get_debug_checks() & DriverDebugChecks::CHECKGL_AFTER_TMOVE)
325  checkLogAndGL(crowd, "checkGL_after_tmove");
326  ps_dispatcher.flex_saveWalker(moved_nonlocal_walker_elecs, moved_nonlocal_walkers);
327  }
328  }
329 }
WaveFunctionComponent::PsiValue PsiValue
Definition: SlaterDet.cpp:25
const char num_walkers[]
Definition: HDFVersion.h:37
static void scaleBySqrtTau(const TauParams< RT, CT > &taus, MCCoords< CT > &coords)
Definition: QMCDriverNew.h:257
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
MCPopulation::MCPWalker MCPWalker
Definition: QMCDriverNew.h:93
const char walkers[]
Definition: HDFVersion.h:36
bool isfinite(float a)
return true if the value is finite.
Definition: math.cpp:21
double norm(const zVec &c)
Definition: VectorOps.h:118
QMCTraits::FullPrecRealType FullPrecRealType
Definition: DMCBatched.h:39
static void computeLogGreensFunction(const MCCoords< CT > &coords, const TauParams< RT, CT > &taus, std::vector< QMCTraits::RealType > &log_gb)
calculates Green Function from displacements stored in MCCoords [param, out] log_g ...
Definition: QMCDriverNew.h:270
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
static void checkLogAndGL(Crowd &crowd, const std::string_view location)
check logpsi and grad and lap against values computed from scratch
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
void makeGaussRandomWithEngine(ParticleAttrib< TinyVector< T, D >> &a, RG &rng)

◆ getRunType()

QMCRunType getRunType ( )
inlineoverridevirtual

Implements QMCDriverInterface.

Definition at line 127 of file DMCBatched.h.

References qmcplusplus::DMC_BATCH.

◆ operator=()

DMCBatched& operator= ( const DMCBatched )
delete

Copy operator (disabled).

◆ process()

void process ( xmlNodePtr  cur)
overridevirtual

DMCBatched driver will eventually ignore cur.

This is the shared entry point from QMCMain so cannot be updated yet

Contains logic that sets walkers_per_rank_ TargetWalkers trump walkers, if it is not set walkers which is by default per rank for the batched drivers from this or the previous section wins.

walkers is still badly named.

Implements QMCDriverNew.

Definition at line 375 of file DMCBatched.cpp.

References QMCDriverNew::adjustGlobalWalkerCount(), qmcplusplus::app_log(), Communicate::barrier_and_abort(), DMCBatched::branch_engine_, QMCDriverNew::determineStepsPerBlock(), DMCBatched::dmcdriver_input_, Timer::elapsed(), DMCDriverInput::get_branch_interval(), DMCDriverInput::get_feedback(), DMCDriverInput::get_max_age(), QMCDriverInput::get_max_blocks(), QMCDriverInput::get_num_crowds(), MCPopulation::get_num_global_walkers(), DMCDriverInput::get_reconfiguration(), DMCDriverInput::get_refenergy_update_scheme(), QMCDriverInput::get_requested_samples(), QMCDriverInput::get_requested_steps(), DMCDriverInput::get_reserve(), QMCDriverInput::get_tau(), QMCDriverInput::get_total_walkers(), QMCDriverInput::get_walkers_per_rank(), WalkerConfigurations::getActiveWalkers(), QMCDriverNew::AdjustedWalkerCounts::global_walkers, QMCDriverNew::initializeQMC(), MPIObjectBase::myComm, qmcplusplus::node, QMCDriverNew::population_, qmcplusplus::print_mem(), QMCDriverNew::qmcdriver_input_, Random, QMCDriverNew::steps_per_block_, qmcplusplus::UNLIMITED_HISTORY, QMCDriverNew::walker_configs_ref_, and DMCBatched::walker_controller_.

376 {
377  print_mem("DMCBatched before initialization", app_log());
378  try
379  {
380  QMCDriverNew::AdjustedWalkerCounts awc =
384 
388 
389  Base::initializeQMC(awc);
390  }
391  catch (const UniformCommunicateError& ue)
392  {
393  myComm->barrier_and_abort(ue.what());
394  }
395 
396  {
397  ReportEngine PRE("DMC", "resetUpdateEngines");
398  Timer init_timer;
399  // Here DMC loads "Ensemble of cloned MCWalkerConfigurations"
400  // I'd like to do away with this method in DMCBatched.
401 
402  app_log() << " Creating the branching engine and walker controler" << std::endl;
403  const auto refE_update_scheme = dmcdriver_input_.get_refenergy_update_scheme();
404  app_log() << " Reference energy is updated using the "
405  << (refE_update_scheme == DMCRefEnergyScheme::UNLIMITED_HISTORY ? "unlimited_history" : "limited_history")
406  << " scheme" << std::endl;
408  std::make_unique<SFNBranch>(qmcdriver_input_.get_tau(), dmcdriver_input_.get_feedback(), refE_update_scheme);
409  branch_engine_->put(node);
410 
411  walker_controller_ = std::make_unique<WalkerControl>(myComm, Random, dmcdriver_input_.get_reconfiguration());
413  walker_controller_->start();
414  walker_controller_->put(node);
415 
416  std::ostringstream o;
418  o << " Fixed population using reconfiguration method\n";
419  else
420  o << " Fluctuating population\n";
421 
422  o << " Persistent walkers are killed after " << dmcdriver_input_.get_max_age() << " MC sweeps\n";
423  o << " BranchInterval = " << dmcdriver_input_.get_branch_interval() << "\n";
424  o << " Steps per block = " << steps_per_block_ << "\n";
425  o << " Number of blocks = " << qmcdriver_input_.get_max_blocks() << "\n";
426  app_log() << o.str() << std::endl;
427 
428  app_log() << " DMC Engine Initialization = " << init_timer.elapsed() << " secs" << std::endl;
429  }
430 }
size_t steps_per_block_
actual number of steps per block
Definition: QMCDriverNew.h:407
MCPopulation population_
the entire (on node) walker population it serves VMCBatch and DMCBatch right now but will be polymorp...
Definition: QMCDriverNew.h:426
size_t getActiveWalkers() const
return the number of active walkers
if(!okay) throw std xmlNodePtr node
std::unique_ptr< WalkerControl > walker_controller_
walker controller for load-balance
Definition: DMCBatched.h:142
IndexType get_requested_steps() const
std::ostream & app_log()
Definition: OutputManager.h:65
DMCRefEnergyScheme get_refenergy_update_scheme() const
RealType get_reserve() const
#define Random
void print_mem(const std::string &title, std::ostream &log)
Definition: MemoryUsage.cpp:30
IndexType get_max_age() const
IndexType get_num_crowds() const
static size_t determineStepsPerBlock(IndexType global_walkers, IndexType requested_samples, IndexType requested_steps, IndexType blocks)
pure function calculating the actual number of steps per block
IndexType get_total_walkers() const
IndexType get_walkers_per_rank() const
WalkerConfigurations & walker_configs_ref_
Definition: QMCDriverNew.h:481
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
static QMCDriverNew::AdjustedWalkerCounts adjustGlobalWalkerCount(Communicate &comm, const IndexType current_configs, const IndexType requested_total_walkers, const IndexType requested_walkers_per_rank, const RealType reserve_walkers, int num_crowds)
}@
const DMCDriverInput dmcdriver_input_
Definition: DMCBatched.h:132
IndexType get_branch_interval() const
IndexType get_num_global_walkers() const
Definition: MCPopulation.h:168
std::unique_ptr< SFNBranch > branch_engine_
branch engine
Definition: DMCBatched.h:140
IndexType get_max_blocks() const
void barrier_and_abort(const std::string &msg) const
QMCDriverInput qmcdriver_input_
Definition: QMCDriverNew.h:372
IndexType get_requested_samples() const
void initializeQMC(const AdjustedWalkerCounts &awc)
Do common section starting tasks for VMC and DMC.

◆ run()

bool run ( )
overridevirtual

Implements QMCDriverInterface.

Definition at line 432 of file DMCBatched.cpp.

References QMCDriverNew::allow_walker_logs, qmcplusplus::app_debug_stream(), qmcplusplus::app_log(), qmcplusplus::app_summary(), Communicate::barrier(), Communicate::bcast(), DMCBatched::branch_engine_, qmcplusplus::crowd, QMCDriverNew::crowds_, DMCBatched::dmc_timers_, DMCBatched::dmcdriver_input_, QMCDriverNew::drift_modifier_, QMCDriverNew::endBlock(), QMCDriverNew::estimator_manager_, QMCDriverNew::finalize(), QMCDriverInput::get_blocks_between_recompute(), MCPopulation::get_golden_electrons(), MCPopulation::get_hamiltonians(), QMCDriverInput::get_max_blocks(), QMCDriverInput::get_measure_imbalance(), QMCDriverInput::get_recalculate_properties_period(), DMCDriverInput::get_reconfiguration(), QMCDriverNew::get_root_name(), ProjectData::getMaxCPUSeconds(), ProjectData::getTitle(), ParticleSet::getTotalNum(), Crowd::getWalkerLogCollectorRefs(), DMCBatched::StateForThread::global_step, qmcplusplus::ham, QMCDriverNew::DriverTimers::init_walkers_timer, QMCDriverNew::initialLogEvaluation(), DMCBatched::StateForThread::is_recomputing_block, WalkerLogManager::makeCollector(), MCPopulation::measureGlobalEnergyVariance(), QMCDriverNew::measureImbalance(), MPIObjectBase::myComm, qmcplusplus::hdf::num_blocks, QMCDriverNew::population_, qmcplusplus::print_mem(), QMCDriverNew::DriverTimers::production_timer, QMCDriverNew::project_data_, QMCDriverNew::qmc_driver_mode_, QMCDriverNew::QMC_UPDATE_MODE, QMCDriverNew::qmcdriver_input_, Communicate::rank(), DMCBatched::StateForThread::recalculate_properties_period, QMCDriverNew::recordBlock(), MCPopulation::redistributeWalkers(), QMCDriverNew::DriverTimers::run_steps_timer, qmcplusplus::run_time_manager, DMCBatched::runDMCStep(), DMCBatched::setNonLocalMoveHandler(), WalkerLogManager::startRun(), DMCBatched::StateForThread::step, QMCDriverNew::step_contexts_, QMCDriverNew::steps_per_block_, WalkerLogManager::stopRun(), QMCDriverNew::timers_, DMCBatched::walker_controller_, QMCDriverNew::walker_logs_input, and WalkerLogManager::writeBuffers().

433 {
435 
436  estimator_manager_->startDriverRun();
437 
438  //initialize WalkerLogManager and collectors
439  WalkerLogManager wlog_manager(walker_logs_input, allow_walker_logs, get_root_name(), myComm);
440  for (auto& crowd : crowds_)
441  crowd->setWalkerLogCollector(wlog_manager.makeCollector());
442  //register walker log collectors into the manager
443  wlog_manager.startRun(Crowd::getWalkerLogCollectorRefs(crowds_));
444 
446 
447  LoopTimer<> dmc_loop;
448  RunTimeControl<> runtimeControl(run_time_manager, project_data_.getMaxCPUSeconds(), project_data_.getTitle(),
449  myComm->rank() == 0);
450 
451  { // walker initialization
453  ParallelExecutor<> section_start_task;
454  section_start_task(crowds_.size(), initialLogEvaluation, std::ref(crowds_), std::ref(step_contexts_));
455 
456  FullPrecRealType energy, variance;
457  population_.measureGlobalEnergyVariance(*myComm, energy, variance);
458  // false indicates we do not support kill at node crossings.
459  branch_engine_->initParam(population_, energy, variance, dmcdriver_input_.get_reconfiguration(), false);
460  walker_controller_->setTrialEnergy(branch_engine_->getEtrial());
461 
462  print_mem("DMCBatched after initialLogEvaluation", app_summary());
464  measureImbalance("InitialLogEvaluation");
465  }
466 
467  // this barrier fences all previous load imbalance. Avoid block 0 timing pollution.
468  myComm->barrier();
469 
470  ScopedTimer local_timer(timers_.production_timer);
471  ParallelExecutor<> crowd_task;
472 
473  int global_step = 0;
474  for (int block = 0; block < num_blocks; ++block)
475  {
476  {
477  ScopeGuard<LoopTimer<>> dmc_local_timer(dmc_loop);
479 
480  dmc_state.recalculate_properties_period = (qmc_driver_mode_[QMC_UPDATE_MODE])
483  dmc_state.is_recomputing_block = qmcdriver_input_.get_blocks_between_recompute()
484  ? (1 + block) % qmcdriver_input_.get_blocks_between_recompute() == 0
485  : false;
486 
487  for (UPtr<Crowd>& crowd : crowds_)
488  crowd->startBlock(steps_per_block_);
489 
490  for (int step = 0; step < steps_per_block_; ++step, ++global_step)
491  {
492  ScopedTimer local_timer(timers_.run_steps_timer);
493 
494  // ensure all the live walkers carry the up-to-date T-move settings.
495  // Such info should be removed from each NLPP eventually and be kept in the driver.
496  for (UPtr<QMCHamiltonian>& ham : population_.get_hamiltonians())
498 
499  dmc_state.step = step;
500  dmc_state.global_step = global_step;
501  crowd_task(crowds_.size(), runDMCStep, dmc_state, timers_, dmc_timers_, std::ref(step_contexts_),
502  std::ref(crowds_));
503 
504  {
505  const int iter = block * steps_per_block_ + step;
506  walker_controller_->branch(iter, population_, iter == 0);
507  branch_engine_->updateParamAfterPopControl(walker_controller_->get_ensemble_property(),
509  walker_controller_->setTrialEnergy(branch_engine_->getEtrial());
510  }
511 
513  }
514  print_mem("DMCBatched after a block", app_debug_stream());
516  measureImbalance("Block " + std::to_string(block));
517  endBlock();
518  wlog_manager.writeBuffers();
519  recordBlock(block);
520  }
521 
522  bool stop_requested = false;
523  // Rank 0 decides whether the time limit was reached
524  if (!myComm->rank())
525  stop_requested = runtimeControl.checkStop(dmc_loop);
526  myComm->bcast(stop_requested);
527  // Progress messages before possibly stopping
528  if (!myComm->rank())
529  app_log() << runtimeControl.generateProgressMessage("DMCBatched", block, num_blocks);
530  if (stop_requested)
531  {
532  if (!myComm->rank())
533  app_log() << runtimeControl.generateStopMessage("DMCBatched", block);
534  run_time_manager.markStop();
535  break;
536  }
537  }
538 
539  branch_engine_->printStatus();
540 
541  print_mem("DMCBatched ends", app_log());
542 
543  wlog_manager.stopRun();
544  estimator_manager_->stopDriverRun();
545 
546  return finalize(num_blocks, true);
547 }
const std::string & getTitle() const noexcept
returns the title of the project <project id="det_qmc_short_sdbatch_vmcbatch_mwalkers" series="0"> tr...
size_t steps_per_block_
actual number of steps per block
Definition: QMCDriverNew.h:407
const ParticleSet & get_golden_electrons() const
Definition: MCPopulation.h:176
void barrier() const
MCPopulation population_
the entire (on node) walker population it serves VMCBatch and DMCBatch right now but will be polymorp...
Definition: QMCDriverNew.h:426
int rank() const
return the rank
Definition: Communicate.h:116
void recordBlock(int block) override
record the state of the block
std::unique_ptr< WalkerControl > walker_controller_
walker controller for load-balance
Definition: DMCBatched.h:142
WalkerLogInput walker_logs_input
walker logs input
Definition: QMCDriverNew.h:108
size_t getTotalNum() const
Definition: ParticleSet.h:493
std::ostream & app_log()
Definition: OutputManager.h:65
std::ostream & app_summary()
Definition: OutputManager.h:63
RunTimeManager< ChronoClock > run_time_manager
const char num_blocks[]
Definition: HDFVersion.h:44
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
UPtrVector< QMCHamiltonian > & get_hamiltonians()
Definition: MCPopulation.h:203
std::unique_ptr< EstimatorManagerNew > estimator_manager_
Observables manager Has very problematic owner ship and life cycle.
Definition: QMCDriverNew.h:443
void print_mem(const std::string &title, std::ostream &log)
Definition: MemoryUsage.cpp:30
DMCTimers dmc_timers_
I think its better if these have there own type and variable name.
Definition: DMCBatched.h:136
std::bitset< QMC_MODE_MAX > qmc_driver_mode_
bits to classify QMCDriver
Definition: QMCDriverNew.h:103
void measureGlobalEnergyVariance(Communicate &comm, FullPrecRealType &ener, FullPrecRealType &variance) const
bool finalize(int block, bool dumpwalkers=true)
finalize a qmc section
int getMaxCPUSeconds() const noexcept
const std::string & get_root_name() const override
Definition: QMCDriverNew.h:331
static RefVector< WalkerLogCollector > getWalkerLogCollectorRefs(const UPtrVector< Crowd > &crowds)
get refereces of active walker log collectors. If walker logging is disabled, the RefVector size can ...
Definition: Crowd.cpp:106
static void initialLogEvaluation(int crowd_id, UPtrVector< Crowd > &crowds, UPtrVector< ContextForSteps > &step_context)
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
void setNonLocalMoveHandler(QMCHamiltonian &hamiltonian)
Definition: DMCBatched.cpp:65
QMCTraits::FullPrecRealType FullPrecRealType
Definition: DMCBatched.h:39
QMCTraits::IndexType IndexType
Definition: QMCDriverNew.h:79
UPtrVector< ContextForSteps > step_contexts_
Per crowd move contexts, this is where the DistanceTables etc.
Definition: QMCDriverNew.h:450
const DMCDriverInput dmcdriver_input_
Definition: DMCBatched.h:132
std::unique_ptr< DriftModifierBase > drift_modifier_
drift modifer
Definition: QMCDriverNew.h:394
bool allow_walker_logs
whether to allow walker logs
Definition: QMCDriverNew.h:106
std::unique_ptr< SFNBranch > branch_engine_
branch engine
Definition: DMCBatched.h:140
IndexType get_max_blocks() const
const ProjectData & project_data_
project info for accessing global fileroot and series id
Definition: QMCDriverNew.h:478
void bcast(T &)
static void runDMCStep(int crowd_id, const StateForThread &sft, DriverTimers &timers, DMCTimers &dmc_timers, UPtrVector< ContextForSteps > &move_context, UPtrVector< Crowd > &crowds)
Definition: DMCBatched.cpp:347
IndexType get_blocks_between_recompute() const
UPtrVector< Crowd > crowds_
}@
Definition: QMCDriverNew.h:389
QMCDriverInput qmcdriver_input_
Definition: QMCDriverNew.h:372
void measureImbalance(const std::string &tag) const
inject additional barrier and measure load imbalance.
DriverTimers timers_
period of dumping walker configurations and everything else for restart
Definition: QMCDriverNew.h:472
std::ostream & app_debug_stream()
Definition: OutputManager.h:71
void redistributeWalkers(WTTV &walker_consumers)
distributes walkers and their "cloned" elements to the elements of a vector of unique_ptr to "walker_...
Definition: MCPopulation.h:131
void endBlock()
end of a block operations. Aggregates statistics across all MPI ranks and write to disk...
int get_recalculate_properties_period() const

◆ runDMCStep()

void runDMCStep ( int  crowd_id,
const StateForThread sft,
DriverTimers timers,
DMCTimers dmc_timers,
UPtrVector< ContextForSteps > &  move_context,
UPtrVector< Crowd > &  crowds 
)
static

Definition at line 347 of file DMCBatched.cpp.

References qmcplusplus::crowd, MCPopulation::get_golden_electrons(), DMCBatched::StateForThread::is_recomputing_block, ParticleSet::isSpinor(), DMCBatched::StateForThread::population, DMCBatched::StateForThread::step, and DMCBatched::StateForThread::steps_per_block.

Referenced by DMCBatched::run().

353 {
354  Crowd& crowd = *(crowds[crowd_id]);
355 
356  if (crowd.size() == 0)
357  return;
358 
359  auto& rng = context_for_steps[crowd_id]->get_random_gen();
360  crowd.setRNGForHamiltonian(rng);
361 
362  const IndexType step = sft.step;
363  // Are we entering the the last step of a block to recompute at?
364  const bool recompute_this_step = (sft.is_recomputing_block && (step + 1) == sft.steps_per_block);
365  const bool accumulate_this_step = true;
366  const bool spin_move = sft.population.get_golden_electrons().isSpinor();
367  if (spin_move)
368  advanceWalkers<CoordsType::POS_SPIN>(sft, crowd, timers, dmc_timers, *context_for_steps[crowd_id],
369  recompute_this_step, accumulate_this_step);
370  else
371  advanceWalkers<CoordsType::POS>(sft, crowd, timers, dmc_timers, *context_for_steps[crowd_id], recompute_this_step,
372  accumulate_this_step);
373 }
QMCTraits::IndexType IndexType
Definition: QMCDriverNew.h:79

◆ setNonLocalMoveHandler()

Friends And Related Function Documentation

◆ qmcplusplus::testing::DMCBatchedTest

Definition at line 153 of file DMCBatched.h.

Member Data Documentation

◆ branch_engine_

std::unique_ptr<SFNBranch> branch_engine_
private

branch engine

Definition at line 140 of file DMCBatched.h.

Referenced by DMCBatched::process(), and DMCBatched::run().

◆ branch_interval_

IndexType branch_interval_
private

Interval between branching.

Definition at line 138 of file DMCBatched.h.

◆ dmc_timers_

DMCTimers dmc_timers_
private

I think its better if these have there own type and variable name.

Definition at line 136 of file DMCBatched.h.

Referenced by DMCBatched::run().

◆ dmcdriver_input_

const DMCDriverInput dmcdriver_input_
private

◆ walker_controller_

std::unique_ptr<WalkerControl> walker_controller_
private

walker controller for load-balance

Definition at line 142 of file DMCBatched.h.

Referenced by DMCBatched::process(), and DMCBatched::run().

◆ qmcplusplus::RMC

class qmcplusplus::RMC


Implements a RMC using threaded execution.

Definition at line 25 of file RMC.h.

+ Inheritance diagram for RMC:
+ Collaboration diagram for RMC:

Public Types

using ParticlePos = ParticleSet::ParticlePos
 Constructor. More...
 
using ReptileConfig_t = Reptile::ReptileConfig_t
 
- Public Types inherited from QMCDriver
enum  { QMC_UPDATE_MODE, QMC_MULTIPLE, QMC_OPTIMIZE, QMC_WARMUP }
 enumeration coupled with QMCMode More...
 
using Walker_t = MCWalkerConfiguration::Walker_t
 
using Buffer_t = Walker_t::Buffer_t
 
using FullPrecRealType = QMCTraits::FullPrecRealType
 
- Public Types inherited from QMCDriverInterface
using BranchEngineType = SimpleFixedNodeBranch
 
using FullPrecRealType = QMCTraits::FullPrecRealType
 
- 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 Types inherited from MPIObjectBase
using mpi_comm_type = Communicate::mpi_comm_type
 

Public Member Functions

 RMC (const ProjectData &project_data, MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, Communicate *comm)
 Constructor. More...
 
bool run () override
 
bool put (xmlNodePtr cur) override
 
QMCRunType getRunType () override
 
- Public Member Functions inherited from QMCDriver
 QMCDriver (const ProjectData &project_data, MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, Communicate *comm, const std::string &QMC_driver_type, bool enable_profiling=false)
 Constructor. More...
 
 ~QMCDriver () override
 
int current () const
 return current step More...
 
void setUpdateMode (bool pbyp) override
 set the update mode More...
 
void setStatus (const std::string &aname, const std::string &h5name, bool append) override
 Set the status of the QMCDriver. More...
 
void add_H_and_Psi (QMCHamiltonian *h, TrialWaveFunction *psi) override
 add QMCHamiltonian/TrialWaveFunction pair for multiple More...
 
void process (xmlNodePtr cur) override
 initialize with xmlNode More...
 
xmlNodePtr getQMCNode ()
 return a xmlnode with update More...
 
void putWalkers (std::vector< xmlNodePtr > &wset) override
 Read walker configurations from *.config.h5 files. More...
 
void putTraces (xmlNodePtr txml) override
 
void requestTraces (bool traces) override
 
void putWalkerLogs (xmlNodePtr wlxml) override
 
void requestWalkerLogs (bool allow_walker_logs_) override
 
std::string getEngineName () override
 
template<class PDT >
void setValue (const std::string &aname, PDT x)
 
void setBranchEngine (std::unique_ptr< BranchEngineType > &&be) override
 set the BranchEngineType More...
 
std::unique_ptr< BranchEngineTypegetBranchEngine () override
 return BranchEngineType* More...
 
int addObservable (const std::string &aname)
 
RealType getObservable (int i)
 
void setTau (RealType i)
 
void setWalkerOffsets ()
 set global offsets of the walkers More...
 
RefVector< RandomBase< FullPrecRealType > > getRngRefs () const
 return the random generators More...
 
RandomBase< FullPrecRealType > & getRng (int i) override
 return the i-th random generator More...
 
unsigned long getDriverMode () override
 
- Public Member Functions inherited from QMCDriverInterface
virtual ~QMCDriverInterface ()
 
virtual void setBranchEngine (std::unique_ptr< BranchEngineType > &&be)
 
- Public Member Functions inherited from MPIObjectBase
 MPIObjectBase (Communicate *c)
 constructor with communicator More...
 
int rank () const
 return the rank of the communicator More...
 
int getGroupID () const
 return the group id of the communicator More...
 
CommunicategetCommunicator () const
 return myComm More...
 
CommunicategetCommRef () const
 return a TEMPORARY reference to Communicate More...
 
mpi_comm_type getMPI () const
 return MPI communicator if one wants to use MPI directly More...
 
bool is_manager () const
 return true if the rank == 0 More...
 
const std::string & getName () const
 return the name More...
 
void setName (const std::string &aname)
 
- Public Member Functions inherited from CloneManager
 CloneManager ()
 Constructor. More...
 
virtual ~CloneManager ()
 virtual destructor More...
 
void makeClones (MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &ham)
 
void makeClones (MCWalkerConfiguration &w, std::vector< TrialWaveFunction *> &psi, std::vector< QMCHamiltonian *> &ham)
 
void makeClones (MCWalkerConfiguration &wg, TrialWaveFunction &guide)
 
void makeClones (TrialWaveFunction &guide)
 
RealType acceptRatio () const
 

Private Member Functions

void resetVars ()
 check the run-time environments More...
 
void resetRun ()
 
void resetReptiles (int nReptiles, int nbeads, RealType tau)
 
void resetReptiles (std::vector< ReptileConfig_t > &reptile_samps, RealType tau)
 
void resetReptiles (std::vector< ParticlePos > &walker_samps, int nbeads, RealType tau)
 
 RMC (const RMC &)=delete
 copy constructor (disabled) More...
 
RMCoperator= (const RMC &)=delete
 Copy operator (disabled). More...
 

Private Attributes

int prestepsVMC
 
std::string rescaleDrift
 option to enable/disable drift equation for RMC More...
 
RealType beta
 projection time of reptile More...
 
int myPeriod4WalkerDump
 period for walker dump More...
 
int beads
 number of beads on the reptile, beta/tau More...
 
int nReptiles
 
int resizeReptile
 rescale for time step studies. some int>2 and new beads are inserted in between the old ones. More...
 
bool fromScratch
 
std::vector< int > Action
 
std::vector< int > TransProb
 

Additional Inherited Members

- Static Public Member Functions inherited from CloneManager
static void clearClones ()
 
- Public Attributes inherited from QMCDriver
std::bitset< QMC_MODE_MAXqmc_driver_mode
 bits to classify QMCDriver More...
 
bool allow_traces
 whether to allow traces More...
 
xmlNodePtr traces_xml
 traces xml More...
 
bool allow_walker_logs
 whether to allow traces More...
 
xmlNodePtr walker_logs_xml
 traces xml More...
 
EstimatorManagerBaseEstimators
 Observables manager. More...
 
std::unique_ptr< TraceManagerTraces
 Traces manager. More...
 
std::unique_ptr< WalkerLogManagerwlog_manager_
 Traces manager. More...
 
- Protected Member Functions inherited from QMCDriver
bool putQMCInfo (xmlNodePtr cur)
 Parses the xml input file for parameter definitions for a single qmc simulation. More...
 
void addWalkers (int nwalkers)
 Add walkers to the end of the ensemble of walkers. More...
 
void recordBlock (int block) override
 record the state of the block More...
 
bool finalize (int block, bool dumpwalkers=true)
 finalize a qmc section More...
 
std::string getRotationName (std::string RootName)
 
std::string getLastRotationName (std::string RootName)
 
const std::string & get_root_name () const override
 
- Protected Member Functions inherited from CloneManager
RefVector< WalkerLogCollectorgetWalkerLogCollectorRefs ()
 
- Protected Attributes inherited from QMCDriver
const ProjectDataproject_data_
 top-level project data information More...
 
std::unique_ptr< BranchEngineTypebranchEngine
 branch engine More...
 
DriftModifierBaseDriftModifier
 drift modifer More...
 
bool ResetRandom
 randomize it More...
 
bool AppendRun
 flag to append or restart the run More...
 
bool DumpConfig
 flag to turn off dumping configurations More...
 
bool IsQMCDriver
 true, if it is a real QMC engine More...
 
int MyCounter
 the number of times this QMCDriver is executed More...
 
int kDelay
 the number to delay updates by More...
 
int Period4CheckPoint
 period of dumping walker configurations and everything else for restart More...
 
int Period4CheckProperties
 period of dumping walker positions and IDs for Forward Walking More...
 
int Period4WalkerDump
 period of recording walker configurations More...
 
int Period4ConfigDump
 period of recording walker positions and IDs for forward walking afterwards More...
 
IndexType CurrentStep
 current step More...
 
IndexType nBlocks
 maximum number of blocks More...
 
IndexType nSteps
 maximum number of steps More...
 
IndexType nSubSteps
 number of steps between a step: VMCs do not evaluate energies More...
 
IndexType nWarmupSteps
 number of warmup steps More...
 
IndexType nAccept
 counter for number of moves accepted More...
 
IndexType nReject
 counter for number of moves /rejected More...
 
IndexType nBlocksBetweenRecompute
 the number of blocks between recomptePsi More...
 
IndexType nTargetWalkers
 the number of walkers More...
 
IndexType nTargetSamples
 the number of saved samples More...
 
IndexType nStepsBetweenSamples
 alternate method of setting QMC run parameters More...
 
RealType nSamplesPerThread
 samples per thread More...
 
RealType nTargetPopulation
 target population More...
 
RealType Tau
 timestep More...
 
int MaxCPUSecs
 maximum cpu in secs More...
 
RealType m_oneover2tau
 Time-step factor $ 1/(2\tau)$. More...
 
RealType m_sqrttau
 Time-step factor $ \sqrt{\tau}$. More...
 
xmlNodePtr qmcNode
 pointer to qmc node in xml file More...
 
const std::string QMCType
 type of QMC driver More...
 
std::string h5FileRoot
 the root of h5File More...
 
std::string RootName
 root of all the output files More...
 
ParameterSet m_param
 store any parameter that has to be read from a file More...
 
MCWalkerConfigurationW
 walker ensemble More...
 
TrialWaveFunctionPsi
 trial function More...
 
QMCHamiltonianH
 Hamiltonian. More...
 
std::unique_ptr< HDFWalkerOutputwOut
 record engine for walkers More...
 
std::vector< TrialWaveFunction * > Psi1
 a list of TrialWaveFunctions for multiple method More...
 
std::vector< QMCHamiltonian * > H1
 a list of QMCHamiltonians for multiple method More...
 
UPtrVector< RandomBase< FullPrecRealType > > Rng
 Random number generators. More...
 
std::vector< xmlNodePtr > mcwalkerNodePtr
 a list of mcwalkerset element More...
 
ParticleSet::ParticlePos drift
 temporary storage for drift More...
 
ParticleSet::ParticlePos deltaR
 temporary storage for random displacement More...
 
RealType SpinMass
 spin mass for spinor calcs More...
 
int rotation
 
- Protected Attributes inherited from MPIObjectBase
CommunicatemyComm
 pointer to Communicate More...
 
std::string ClassName
 class Name More...
 
std::string myName
 name of the object More...
 
- Protected Attributes inherited from CloneManager
const IndexType NumThreads
 number of threads More...
 
std::vector< QMCUpdateBase * > Movers
 update engines More...
 
std::vector< EstimatorManagerBase * > estimatorClones
 estimator managers More...
 
std::vector< TraceManager * > traceClones
 trace managers More...
 
UPtrVector< WalkerLogCollectorwlog_collectors
 trace collectors More...
 
UPtrVector< CSUpdateBaseCSMovers
 
std::vector< int > wPerRank
 Walkers per MPI rank. More...
 
- Static Protected Attributes inherited from CloneManager
static UPtrVector< MCWalkerConfigurationwClones_uptr
 walkers More...
 
static std::vector< MCWalkerConfiguration * > wClones
 
static UPtrVector< MCWalkerConfigurationwgClones
 
static UPtrVector< TrialWaveFunctionpsiClones_uptr
 trial wavefunctions More...
 
static std::vector< TrialWaveFunction * > psiClones
 
static UPtrVector< TrialWaveFunctionguideClones_uptr
 guide wavefunctions More...
 
static std::vector< TrialWaveFunction * > guideClones
 
static UPtrVector< QMCHamiltonianhClones_uptr
 Hamiltonians. More...
 
static std::vector< QMCHamiltonian * > hClones
 
static std::vector< UPtrVector< MCWalkerConfiguration > > WPoolClones_uptr
 
static std::vector< std::vector< MCWalkerConfiguration * > > WPoolClones
 
static std::vector< UPtrVector< TrialWaveFunction > > PsiPoolClones_uptr
 
static std::vector< std::vector< TrialWaveFunction * > > PsiPoolClones
 
static std::vector< UPtrVector< QMCHamiltonian > > HPoolClones_uptr
 
static std::vector< std::vector< QMCHamiltonian * > > HPoolClones
 

Member Typedef Documentation

◆ ParticlePos

Constructor.

Definition at line 29 of file RMC.h.

◆ ReptileConfig_t

Definition at line 30 of file RMC.h.

Constructor & Destructor Documentation

◆ RMC() [1/2]

RMC ( const ProjectData project_data,
MCWalkerConfiguration w,
TrialWaveFunction psi,
QMCHamiltonian h,
Communicate comm 
)

Constructor.

Definition at line 38 of file RMC.cpp.

References RMC::Action, ParameterSet::add(), ParticleSet::addProperty(), RMC::beads, RMC::beta, QMCDriver::m_param, RMC::prestepsVMC, QMCDriver::qmc_driver_mode, QMCDriver::QMC_UPDATE_MODE, QMCDriver::QMC_WARMUP, RMC::rescaleDrift, RMC::resizeReptile, QMCDriver::RootName, and RMC::TransProb.

43  : QMCDriver(project_data, w, psi, h, comm, "RMC"),
44  prestepsVMC(-1),
45  rescaleDrift("no"),
46  beta(-1),
47  beads(-1),
48  fromScratch(true)
49 {
50  RootName = "rmc";
53  m_param.add(rescaleDrift, "drift");
54  m_param.add(beta, "beta");
55  m_param.add(beads, "beads");
56  m_param.add(resizeReptile, "resize");
57  m_param.add(prestepsVMC, "vmcpresteps");
58 
59  Action.resize(3);
60  Action[0] = w.addProperty("ActionBackward");
61  Action[1] = w.addProperty("ActionForward");
62  Action[2] = w.addProperty("ActionLocal");
63  TransProb.resize(2);
64  TransProb[0] = w.addProperty("TransProbBackward");
65  TransProb[1] = w.addProperty("TransProbForward");
66 }
int prestepsVMC
Definition: RMC.h:42
QMCDriver(const ProjectData &project_data, MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, Communicate *comm, const std::string &QMC_driver_type, bool enable_profiling=false)
Constructor.
Definition: QMCDriver.cpp:44
std::string RootName
root of all the output files
Definition: QMCDriver.h:317
bool fromScratch
Definition: RMC.h:57
ParameterSet m_param
store any parameter that has to be read from a file
Definition: QMCDriver.h:320
std::bitset< QMC_MODE_MAX > qmc_driver_mode
bits to classify QMCDriver
Definition: QMCDriver.h:93
void add(PDT &aparam, const std::string &aname_in, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new parameter corresponding to an xmlNode <parameter>
int resizeReptile
rescale for time step studies. some int>2 and new beads are inserted in between the old ones...
Definition: RMC.h:54
std::vector< int > Action
Definition: RMC.h:59
RealType beta
projection time of reptile
Definition: RMC.h:46
std::vector< int > TransProb
Definition: RMC.h:60
int beads
number of beads on the reptile, beta/tau
Definition: RMC.h:50
std::string rescaleDrift
option to enable/disable drift equation for RMC
Definition: RMC.h:44

◆ RMC() [2/2]

RMC ( const RMC )
privatedelete

copy constructor (disabled)

Member Function Documentation

◆ getRunType()

QMCRunType getRunType ( )
inlineoverridevirtual

Implements QMCDriverInterface.

Definition at line 39 of file RMC.h.

References qmcplusplus::RMC.

39 { return QMCRunType::RMC; }
RMC type: rmc, rmc-ptcl.

◆ operator=()

RMC& operator= ( const RMC )
privatedelete

Copy operator (disabled).

◆ put()

bool put ( xmlNodePtr  cur)
overridevirtual

Implements QMCDriverInterface.

Definition at line 305 of file RMC.cpp.

References QMCDriver::m_param, and ParameterSet::put().

306 {
307  m_param.put(q);
308  return true;
309 }
bool put(std::istream &is) override
read from std::istream
Definition: ParameterSet.h:42
ParameterSet m_param
store any parameter that has to be read from a file
Definition: QMCDriver.h:320

◆ resetReptiles() [1/3]

void resetReptiles ( int  nReptiles,
int  nbeads,
RealType  tau 
)
private

Definition at line 312 of file RMC.cpp.

References QMCDriver::addWalkers(), WalkerConfigurations::begin(), FairDivideLow(), WalkerConfigurations::getActiveWalkers(), MCWalkerConfiguration::ReptileList, and QMCDriver::W.

Referenced by RMC::resetReptiles(), and RMC::resetRun().

313 {
314  W.ReptileList.clear();
315  // Maybe we should be more vigorous in cleaning the MCWC WalkerList?
316  std::vector<int> repWalkerSlice;
317  int nwtot = nbeads_in * nReptiles_in;
318  FairDivideLow(nwtot, nReptiles_in, repWalkerSlice);
319  if (W.getActiveWalkers() - nwtot != 0)
320  addWalkers(nwtot - W.getActiveWalkers());
321 
322  for (int i = 0; i < nReptiles_in; i++)
323  {
324  W.ReptileList.push_back(
325  std::make_unique<Reptile>(W, W.begin() + repWalkerSlice[i], W.begin() + repWalkerSlice[i + 1]));
326  W.ReptileList[i]->setTau(tau);
327  }
328 }
ReptileList_t ReptileList
a collection of reptiles contained in MCWalkerConfiguration.
size_t getActiveWalkers() const
return the number of active walkers
void FairDivideLow(int ntot, int npart, IV &adist)
partition ntot elements among npart
Definition: FairDivide.h:114
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
void addWalkers(int nwalkers)
Add walkers to the end of the ensemble of walkers.
Definition: QMCDriver.cpp:338
iterator begin()
return the first iterator

◆ resetReptiles() [2/3]

void resetReptiles ( std::vector< ReptileConfig_t > &  reptile_samps,
RealType  tau 
)
private

Definition at line 330 of file RMC.cpp.

References APP_ABORT, MCWalkerConfiguration::ReptileList, RMC::resetReptiles(), and QMCDriver::W.

331 {
332  if (reptile_samps.empty())
333  {
334  APP_ABORT("RMC::resetReptiles(std::vector< ReptileConfig_t > reptile_samps): No samples!\n");
335  }
336  else
337  {
338  IndexType nReptiles_in = reptile_samps.size();
339  IndexType nBeads_in = reptile_samps[0].size();
340  resetReptiles(nReptiles_in, nBeads_in, tau);
341 
342  for (IndexType i = 0; i < W.ReptileList.size(); i++)
343  {
344  W.ReptileList[i]->setReptileSlicePositions(reptile_samps[i]);
345  }
346  }
347 }
ReptileList_t ReptileList
a collection of reptiles contained in MCWalkerConfiguration.
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
void resetReptiles(int nReptiles, int nbeads, RealType tau)
Definition: RMC.cpp:312
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65

◆ resetReptiles() [3/3]

void resetReptiles ( std::vector< ParticlePos > &  walker_samps,
int  nbeads,
RealType  tau 
)
private

Definition at line 349 of file RMC.cpp.

References APP_ABORT, MCWalkerConfiguration::ReptileList, RMC::resetReptiles(), and QMCDriver::W.

350 {
351  if (walker_samps.empty())
352  {
353  APP_ABORT("RMC::resetReptiles(std::vector< ParticlePos > walker_samps): No samples!\n");
354  }
355  else
356  {
357  IndexType nReptiles_in = walker_samps.size();
358  resetReptiles(nReptiles_in, nBeads_in, tau);
359 
360  for (IndexType i = 0; i < W.ReptileList.size(); i++)
361  {
362  W.ReptileList[i]->setReptileSlicePositions(walker_samps[i]);
363  }
364  }
365 }
ReptileList_t ReptileList
a collection of reptiles contained in MCWalkerConfiguration.
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
void resetReptiles(int nReptiles, int nbeads, RealType tau)
Definition: RMC.cpp:312
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65

◆ resetRun()

void resetRun ( )
private

Definition at line 143 of file RMC.cpp.

References RMC::Action, qmcplusplus::app_log(), RMC::beads, WalkerConfigurations::begin(), RMC::beta, QMCDriver::branchEngine, RandomNumberControl::Children, QMCDriver::CurrentStep, QMCDriver::DriftModifier, WalkerConfigurations::end(), CloneManager::estimatorClones, QMCDriver::Estimators, RMC::fromScratch, QMCDriver::H, CloneManager::hClones, QMCDriver::m_param, CloneManager::makeClones(), CloneManager::Movers, RMC::myPeriod4WalkerDump, QMCDriver::nBlocks, RMC::nReptiles, QMCDriver::nSteps, QMCDriver::nSubSteps, CloneManager::NumThreads, QMCDriver::nWarmupSteps, QMCDriver::Period4WalkerDump, RMC::prestepsVMC, QMCDriver::Psi, CloneManager::psiClones, ParameterSet::put(), QMCDriver::qmc_driver_mode, QMCDriver::QMC_UPDATE_MODE, QMCDriver::qmcNode, MCWalkerConfiguration::ReptileList, RMC::resetReptiles(), QMCDriver::Rng, QMCDriver::Tau, CloneManager::traceClones, QMCDriver::Traces, RMC::TransProb, QMCDriver::W, CloneManager::wClones, and CloneManager::wPerRank.

Referenced by RMC::run().

144 {
146  //For now, assume that nReptiles=NumThreads;
148 
149  if (beads < 1)
150  beads = beta / Tau;
151  else
152  beta = beads * Tau;
153 
154  app_log() << "Projection time: " << beta << " Ha^-1" << std::endl;
155  //Calculate the number of VMC presteps if not given:
156  if (prestepsVMC == -1 && fromScratch == true)
157  prestepsVMC = beads + 2;
158  //Check to see if the MCWalkerConfiguration is in a state suitable for reptation
159  if (!W.ReptileList.empty())
160  {
161  fromScratch = false;
162 
163  app_log() << "Previous RMC reptiles detected...\n";
164  if (Tau == W.ReptileList[0]->getTau() && beads == W.ReptileList[0]->size())
165  app_log() << " Using current reptiles\n"; //do nothing
166  else //we need to extrapolate off of the current reptile set.
167  {
168  //pull the reptile configurations out
169  app_log() << " Previous Tau/Beta: " << W.ReptileList[0]->getTau() << "/"
170  << W.ReptileList[0]->getTau() * W.ReptileList[0]->size() << std::endl;
171  app_log() << " New Tau/Beta: " << Tau << "/" << beta << std::endl;
172  app_log() << " Linear interpolation to get new reptile.\n";
173  std::vector<ReptileConfig_t> repSamps(0);
174  for (IndexType sampid = 0; sampid < W.ReptileList.size() && sampid < nReptiles; sampid++)
175  repSamps.push_back(W.ReptileList[sampid]->getReptileSlicePositions(Tau, beta));
176 
177  //In the event of a disparity in the number of requested reptiles and the ones received.... just copy
178  //Copies cyclically. First iteration copies the first entry, second the second, and so on. So we don't replicate just one config.
179  for (IndexType copyid = 0; repSamps.size() < nReptiles; copyid++)
180  repSamps.push_back(repSamps[copyid]);
181 
182 
183  resetReptiles(repSamps, Tau);
184  }
185  }
186 
187  //Previous run was nothing, VMC, or DMC. No reptiles--so we initialize based on whatever is there.
188  else
189  {
190  //Initialize on whatever walkers are in MCWalkerConfiguration.
191  app_log() << "Using walkers from previous non-RMC run.\n";
192  std::vector<ParticlePos> wSamps(0);
193  MCWalkerConfiguration::iterator wit(W.begin()), wend(W.end());
194  for (IndexType sampid = 0; wit != wend && sampid < nReptiles; wit++)
195  wSamps.push_back((**wit).R);
196 
197  for (IndexType copyid = 0; wSamps.size() < nReptiles; copyid++)
198  wSamps.push_back(wSamps[copyid]);
199  resetReptiles(wSamps, beads, Tau);
200  }
201 
202  //Now that we know if we're starting from scratch... decide whether to force VMC warmup.
203  if (prestepsVMC == -1 && fromScratch == true)
204  prestepsVMC = beads + 2;
205  makeClones(W, Psi, H);
207 
208  if (Movers.empty())
209  {
210  Movers.resize(NumThreads, nullptr);
211  estimatorClones.resize(NumThreads, nullptr);
212  traceClones.resize(NumThreads, nullptr);
213  Rng.resize(NumThreads);
214  branchEngine->initReptile(W);
215 
216  // hdf_archive::hdf_archive() is not thread-safe
217  for (int ip = 0; ip < NumThreads; ++ip)
218  estimatorClones[ip] = new EstimatorManagerBase(*Estimators);
219 
220 #pragma omp parallel for
221  for (int ip = 0; ip < NumThreads; ++ip)
222  {
223  std::ostringstream os;
224  estimatorClones[ip]->resetTargetParticleSet(*wClones[ip]);
225  estimatorClones[ip]->setCollectionMode(false);
226  Rng[ip] = RandomNumberControl::Children[ip]->makeClone();
227 #if !defined(REMOVE_TRACEMANAGER)
228  traceClones[ip] = Traces->makeClone();
229 #endif
230  hClones[ip]->setRandomGenerator(Rng[ip].get());
232  {
233  os << " PbyP moves with drift, using RMCUpdatePbyPWithDriftFast" << std::endl;
234  Movers[ip] =
235  new RMCUpdatePbyPWithDrift(*wClones[ip], *psiClones[ip], *hClones[ip], *Rng[ip], Action, TransProb);
236  }
237  else
238  {
239  os << " walker moves with drift, using RMCUpdateAllWithDriftFast" << std::endl;
240  Movers[ip] = new RMCUpdateAllWithDrift(*wClones[ip], *psiClones[ip], *hClones[ip], *Rng[ip], Action, TransProb);
241  }
242  Movers[ip]->nSubSteps = nSubSteps;
243  if (ip == 0)
244  app_log() << os.str() << std::endl;
245  }
246  }
247 #if !defined(REMOVE_TRACEMANAGER)
248  else
249  {
250 #pragma omp parallel for
251  for (int ip = 0; ip < NumThreads; ++ip)
252  {
253  traceClones[ip]->transfer_state_from(*Traces);
254  }
255  }
256 #endif
257  app_log().flush();
258 #pragma omp parallel for
259  for (int ip = 0; ip < NumThreads; ++ip)
260  {
261  Movers[ip]->put(qmcNode);
262  Movers[ip]->resetRun(branchEngine.get(), estimatorClones[ip], traceClones[ip], DriftModifier);
263 
264  wClones[ip]->reptile = W.ReptileList[ip].get();
265  wClones[ip]->activeBead = 0;
266  wClones[ip]->direction = +1;
267 
269  {
270  // app_log () << ip << " initWalkers for pbyp...\n";
271  Movers[ip]->initWalkersForPbyP(W.ReptileList[ip]->repstart, W.ReptileList[ip]->repend);
272  }
273  else
274  {
275  Movers[ip]->initWalkers(W.begin() + wPerRank[ip], W.begin() + wPerRank[ip + 1]);
276  }
277 
278  //this will "unroll" the reptile according to forced VMC steps (no bounce). See beginning of function for logic of setting prestepVMC.
279  for (IndexType prestep = 0; prestep < prestepsVMC; prestep++)
280  {
281  Movers[ip]->advanceWalkers(W.begin(), W.begin(), true);
282  }
283 
284  //set up initial action and transprob.
285  MCWalkerConfiguration::iterator wit(W.begin() + wPerRank[ip]), wit_end(W.begin() + wPerRank[ip + 1]);
286  }
287 
288 
289  app_log() << "Finished " << prestepsVMC << " VMC presteps\n";
290  branchEngine->checkParameters(W);
291 
292 #pragma omp parallel for
293  for (int ip = 0; ip < NumThreads; ++ip)
294  {
295  for (int prestep = 0; prestep < nWarmupSteps; ++prestep)
296  {
297  Movers[ip]->advanceWalkers(W.begin() + wPerRank[ip], W.begin() + wPerRank[ip + 1], false);
298  branchEngine->collect(CurrentStep, W);
299  }
300  }
301 
302  fromScratch = false;
303 }
int prestepsVMC
Definition: RMC.h:42
static std::vector< TrialWaveFunction * > psiClones
Definition: CloneManager.h:65
ReptileList_t ReptileList
a collection of reptiles contained in MCWalkerConfiguration.
std::vector< int > wPerRank
Walkers per MPI rank.
Definition: CloneManager.h:91
static std::vector< MCWalkerConfiguration * > wClones
Definition: CloneManager.h:61
std::ostream & app_log()
Definition: OutputManager.h:65
xmlNodePtr qmcNode
pointer to qmc node in xml file
Definition: QMCDriver.h:310
bool fromScratch
Definition: RMC.h:57
IndexType CurrentStep
current step
Definition: QMCDriver.h:263
std::vector< QMCUpdateBase * > Movers
update engines
Definition: CloneManager.h:73
std::unique_ptr< TraceManager > Traces
Traces manager.
Definition: QMCDriver.h:195
bool put(std::istream &is) override
read from std::istream
Definition: ParameterSet.h:42
ParameterSet m_param
store any parameter that has to be read from a file
Definition: QMCDriver.h:320
IndexType nSubSteps
number of steps between a step: VMCs do not evaluate energies
Definition: QMCDriver.h:272
int nReptiles
Definition: RMC.h:52
IndexType nSteps
maximum number of steps
Definition: QMCDriver.h:269
WalkerList_t::iterator iterator
FIX: a type alias of iterator for an object should not be for just one of many objects it holds...
std::bitset< QMC_MODE_MAX > qmc_driver_mode
bits to classify QMCDriver
Definition: QMCDriver.h:93
int myPeriod4WalkerDump
period for walker dump
Definition: RMC.h:48
std::unique_ptr< BranchEngineType > branchEngine
branch engine
Definition: QMCDriver.h:218
std::vector< EstimatorManagerBase * > estimatorClones
estimator managers
Definition: CloneManager.h:75
const IndexType NumThreads
number of threads
Definition: CloneManager.h:54
QMCHamiltonian & H
Hamiltonian.
Definition: QMCDriver.h:329
DriftModifierBase * DriftModifier
drift modifer
Definition: QMCDriver.h:220
void makeClones(MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &ham)
void resetReptiles(int nReptiles, int nbeads, RealType tau)
Definition: RMC.cpp:312
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
static UPtrVector< RandomBase< FullPrecRealType > > Children
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65
static std::vector< QMCHamiltonian * > hClones
Definition: CloneManager.h:71
EstimatorManagerBase * Estimators
Observables manager.
Definition: QMCDriver.h:192
TrialWaveFunction & Psi
trial function
Definition: QMCDriver.h:326
RealType Tau
timestep
Definition: QMCDriver.h:299
IndexType nBlocks
maximum number of blocks
Definition: QMCDriver.h:266
std::vector< int > Action
Definition: RMC.h:59
std::vector< TraceManager * > traceClones
trace managers
Definition: CloneManager.h:77
int Period4WalkerDump
period of recording walker configurations
Definition: QMCDriver.h:255
RealType beta
projection time of reptile
Definition: RMC.h:46
IndexType nWarmupSteps
number of warmup steps
Definition: QMCDriver.h:275
UPtrVector< RandomBase< FullPrecRealType > > Rng
Random number generators.
Definition: QMCDriver.h:341
iterator end()
return the last iterator, [begin(), end())
std::vector< int > TransProb
Definition: RMC.h:60
int beads
number of beads on the reptile, beta/tau
Definition: RMC.h:50
iterator begin()
return the first iterator

◆ resetVars()

void resetVars ( )
inlineprivate

check the run-time environments

Definition at line 63 of file RMC.h.

References RMC::beads, RMC::beta, RMC::nReptiles, and RMC::prestepsVMC.

Referenced by RMC::run().

64  {
65  prestepsVMC = -1;
66  beads = -1;
67  beta = -1;
68  nReptiles = -1;
69  };
int prestepsVMC
Definition: RMC.h:42
int nReptiles
Definition: RMC.h:52
RealType beta
projection time of reptile
Definition: RMC.h:46
int beads
number of beads on the reptile, beta/tau
Definition: RMC.h:50

◆ run()

bool run ( )
overridevirtual

Implements QMCDriverInterface.

Definition at line 68 of file RMC.cpp.

References qmcplusplus::app_log(), Communicate::bcast(), WalkerConfigurations::begin(), QMCDriver::branchEngine, RandomNumberControl::Children, ParticleSet::Collectables, QMCDriver::CurrentStep, CloneManager::estimatorClones, QMCDriver::Estimators, QMCDriver::finalize(), Communicate::getName(), QMCDriver::MaxCPUSecs, CloneManager::Movers, MPIObjectBase::myComm, RMC::myPeriod4WalkerDump, QMCDriver::nBlocks, QMCDriver::nSteps, CloneManager::NumThreads, omp_get_thread_num(), QMCDriver::Period4CheckProperties, QMCDriver::Period4WalkerDump, QMCDriver::qmc_driver_mode, QMCDriver::QMC_UPDATE_MODE, Communicate::rank(), QMCDriver::recordBlock(), RMC::resetRun(), RMC::resetVars(), QMCDriver::Rng, qmcplusplus::run_time_manager, PooledData< T >::size(), LoopTimer< CLOCK >::start(), EstimatorManagerBase::start(), LoopTimer< CLOCK >::stop(), EstimatorManagerBase::stop(), EstimatorManagerBase::stopBlock(), CloneManager::traceClones, QMCDriver::Traces, QMCDriver::W, CloneManager::wClones, and CloneManager::wPerRank.

69 {
70  resetRun();
71  //start the main estimator
73  for (int ip = 0; ip < NumThreads; ++ip)
74  Movers[ip]->startRun(nBlocks, false);
75 #if !defined(REMOVE_TRACEMANAGER)
76  Traces->startRun(nBlocks, traceClones);
77 #endif
78  const bool has_collectables = W.Collectables.size();
79 
80  LoopTimer<> rmc_loop;
81  RunTimeControl<> runtimeControl(run_time_manager, MaxCPUSecs, myComm->getName(), myComm->rank() == 0);
82  for (int block = 0; block < nBlocks; ++block)
83  {
84  rmc_loop.start();
85 #pragma omp parallel
86  {
87  int ip = omp_get_thread_num();
89  //assign the iterators and resuse them
90  MCWalkerConfiguration::iterator wit(W.begin() + wPerRank[ip]), wit_end(W.begin() + wPerRank[ip + 1]);
91  Movers[ip]->startBlock(nSteps);
92  int now_loc = CurrentStep;
93 
94  RealType cnorm = 1.0; //This is because there is only one reptile per walkerset.
95 
96  for (int step = 0; step < nSteps; ++step)
97  {
98  //collectables are reset, it is accumulated while advancing walkers
99  wClones[ip]->resetCollectables();
100  Movers[ip]->advanceWalkers(wit, wit_end, false);
101  if (has_collectables)
102  wClones[ip]->Collectables *= cnorm;
103  Movers[ip]->accumulate(wit, wit_end);
104 
105  ++now_loc;
106  if (Period4WalkerDump && now_loc % myPeriod4WalkerDump == 0)
107  wClones[ip]->saveEnsemble(wit, wit_end);
108 
109  branchEngine->collect(
110  CurrentStep,
111  W); //Ray Clay: For now, collects and syncs based on first reptile. Need a better way to do this.
112  }
113  Movers[ip]->stopBlock(false);
114  } //end-of-parallel for
115  CurrentStep += nSteps;
117  recordBlock(block);
118  rmc_loop.stop();
119 
120  bool stop_requested = false;
121  // Rank 0 decides whether the time limit was reached
122  if (!myComm->rank())
123  stop_requested = runtimeControl.checkStop(rmc_loop);
124  myComm->bcast(stop_requested);
125 
126  if (stop_requested)
127  {
128  if (!myComm->rank())
129  app_log() << runtimeControl.generateStopMessage("RMC", block);
130  run_time_manager.markStop();
131  break;
132  }
133  } //block
135  //copy back the random states
136  for (int ip = 0; ip < NumThreads; ++ip)
137  RandomNumberControl::Children[ip] = Rng[ip]->makeClone();
138  //return nbeads and stuff to its original unset state;
139  resetVars();
140  return finalize(nBlocks);
141 }
size_type size() const
return the size of the data
Definition: PooledData.h:48
int MaxCPUSecs
maximum cpu in secs
Definition: QMCDriver.h:302
std::vector< int > wPerRank
Walkers per MPI rank.
Definition: CloneManager.h:91
int rank() const
return the rank
Definition: Communicate.h:116
void recordBlock(int block) override
record the state of the block
Definition: QMCDriver.cpp:307
static std::vector< MCWalkerConfiguration * > wClones
Definition: CloneManager.h:61
std::ostream & app_log()
Definition: OutputManager.h:65
RunTimeManager< ChronoClock > run_time_manager
IndexType CurrentStep
current step
Definition: QMCDriver.h:263
std::vector< QMCUpdateBase * > Movers
update engines
Definition: CloneManager.h:73
std::unique_ptr< TraceManager > Traces
Traces manager.
Definition: QMCDriver.h:195
omp_int_t omp_get_thread_num()
Definition: OpenMP.h:25
IndexType nSteps
maximum number of steps
Definition: QMCDriver.h:269
bool finalize(int block, bool dumpwalkers=true)
finalize a qmc section
Definition: QMCDriver.cpp:318
const std::string & getName() const
Definition: Communicate.h:131
WalkerList_t::iterator iterator
FIX: a type alias of iterator for an object should not be for just one of many objects it holds...
std::bitset< QMC_MODE_MAX > qmc_driver_mode
bits to classify QMCDriver
Definition: QMCDriver.h:93
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
int myPeriod4WalkerDump
period for walker dump
Definition: RMC.h:48
std::unique_ptr< BranchEngineType > branchEngine
branch engine
Definition: QMCDriver.h:218
std::vector< EstimatorManagerBase * > estimatorClones
estimator managers
Definition: CloneManager.h:75
const IndexType NumThreads
number of threads
Definition: CloneManager.h:54
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
static UPtrVector< RandomBase< FullPrecRealType > > Children
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65
Buffer_t Collectables
observables in addition to those registered in Properties/PropertyList
Definition: ParticleSet.h:126
void resetRun()
Definition: RMC.cpp:143
QMCTraits::RealType RealType
EstimatorManagerBase * Estimators
Observables manager.
Definition: QMCDriver.h:192
void stopBlock(RealType accept, bool collectall=true)
stop a block
void bcast(T &)
IndexType nBlocks
maximum number of blocks
Definition: QMCDriver.h:266
int Period4WalkerDump
period of recording walker configurations
Definition: QMCDriver.h:255
std::vector< TraceManager * > traceClones
trace managers
Definition: CloneManager.h:77
int Period4CheckProperties
period of dumping walker positions and IDs for Forward Walking
Definition: QMCDriver.h:249
UPtrVector< RandomBase< FullPrecRealType > > Rng
Random number generators.
Definition: QMCDriver.h:341
void start(int blocks, bool record=true)
start a run
void resetVars()
check the run-time environments
Definition: RMC.h:63
iterator begin()
return the first iterator

Member Data Documentation

◆ Action

std::vector<int> Action
private

Definition at line 59 of file RMC.h.

Referenced by RMC::resetRun(), and RMC::RMC().

◆ beads

int beads
private

number of beads on the reptile, beta/tau

Definition at line 50 of file RMC.h.

Referenced by RMC::resetRun(), RMC::resetVars(), and RMC::RMC().

◆ beta

RealType beta
private

projection time of reptile

Definition at line 46 of file RMC.h.

Referenced by RMC::resetRun(), RMC::resetVars(), and RMC::RMC().

◆ fromScratch

bool fromScratch
private

Definition at line 57 of file RMC.h.

Referenced by RMC::resetRun().

◆ myPeriod4WalkerDump

int myPeriod4WalkerDump
private

period for walker dump

Definition at line 48 of file RMC.h.

Referenced by RMC::resetRun(), and RMC::run().

◆ nReptiles

int nReptiles
private

Definition at line 52 of file RMC.h.

Referenced by RMC::resetRun(), and RMC::resetVars().

◆ prestepsVMC

int prestepsVMC
private

Definition at line 42 of file RMC.h.

Referenced by RMC::resetRun(), RMC::resetVars(), and RMC::RMC().

◆ rescaleDrift

std::string rescaleDrift
private

option to enable/disable drift equation for RMC

Definition at line 44 of file RMC.h.

Referenced by RMC::RMC().

◆ resizeReptile

int resizeReptile
private

rescale for time step studies. some int>2 and new beads are inserted in between the old ones.

Definition at line 54 of file RMC.h.

Referenced by RMC::RMC().

◆ TransProb

std::vector<int> TransProb
private

Definition at line 60 of file RMC.h.

Referenced by RMC::resetRun(), and RMC::RMC().

◆ qmcplusplus::RMCUpdateAllWithDrift

class qmcplusplus::RMCUpdateAllWithDrift


Implements the RMC algorithm using all electron moves

Definition at line 23 of file RMCUpdateAll.h.

+ Inheritance diagram for RMCUpdateAllWithDrift:
+ Collaboration diagram for RMCUpdateAllWithDrift:

Public Types

enum  { SYM_ACTION, DMC_ACTION }
 Constructor. More...
 
- 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 Member Functions

 RMCUpdateAllWithDrift (MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, RandomBase< FullPrecRealType > &rg, std::vector< int > act, std::vector< int > tp)
 Constructor. More...
 
 ~RMCUpdateAllWithDrift () override
 
void advanceWalker (Walker_t &thisWalker, bool recompute) override
 move a walker More...
 
void advanceWalkers (WalkerIter_t it, WalkerIter_t it_end, bool measure) override
 advance walkers executed at each step More...
 
void advanceWalkersVMC ()
 
void advanceWalkersRMC ()
 
void checkReptile (WalkerIter_t it, WalkerIter_t it_end)
 
void initWalkers (WalkerIter_t it, WalkerIter_t it_end) override
 initialize Walker for walker update More...
 
void accumulate (WalkerIter_t it, WalkerIter_t it_end)
 
bool put (xmlNodePtr cur) override
 process options 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...
 
void accumulate (WalkerIter_t it, WalkerIter_t it_end)
 
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 Member Functions

 RMCUpdateAllWithDrift (const RMCUpdateAllWithDrift &)=delete
 Copy Constructor (disabled) More...
 
RMCUpdateAllWithDriftoperator= (const RMCUpdateAllWithDrift &)=delete
 Copy operator (disabled). More...
 

Private Attributes

std::vector< int > Action
 
std::vector< int > TransProb
 
bool scaleDrift
 
IndexType actionType
 
IndexType vmcSteps
 
IndexType equilSteps
 
IndexType vmcToDoSteps
 
IndexType equilToDoSteps
 

Additional Inherited Members

- 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
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Constructor.

Enumerator
SYM_ACTION 
DMC_ACTION 

Definition at line 28 of file RMCUpdateAll.h.

Constructor & Destructor Documentation

◆ RMCUpdateAllWithDrift() [1/2]

RMCUpdateAllWithDrift ( MCWalkerConfiguration w,
TrialWaveFunction psi,
QMCHamiltonian h,
RandomBase< FullPrecRealType > &  rg,
std::vector< int >  act,
std::vector< int >  tp 
)

Constructor.

Definition at line 40 of file RMCUpdateAll.cpp.

References RMCUpdateAllWithDrift::actionType, RMCUpdateAllWithDrift::equilSteps, RMCUpdateAllWithDrift::equilToDoSteps, RMCUpdateAllWithDrift::scaleDrift, RMCUpdateAllWithDrift::SYM_ACTION, RMCUpdateAllWithDrift::vmcSteps, and RMCUpdateAllWithDrift::vmcToDoSteps.

46  : QMCUpdateBase(w, psi, h, rg), Action(act), TransProb(tp)
47 {
48  scaleDrift = false;
50  vmcToDoSteps = 0;
51  equilToDoSteps = 0;
52  vmcSteps = 0;
53  equilSteps = 0;
54 }
QMCUpdateBase(MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, RandomBase< FullPrecRealType > &rg)
Constructor.

◆ ~RMCUpdateAllWithDrift()

~RMCUpdateAllWithDrift ( )
override

Definition at line 56 of file RMCUpdateAll.cpp.

56 {}

◆ RMCUpdateAllWithDrift() [2/2]

RMCUpdateAllWithDrift ( const RMCUpdateAllWithDrift )
privatedelete

Copy Constructor (disabled)

Member Function Documentation

◆ accumulate()

void accumulate ( WalkerIter_t  it,
WalkerIter_t  it_end 
)

Definition at line 533 of file RMCUpdateAll.cpp.

References EstimatorManagerBase::accumulate(), RMCUpdateAllWithDrift::equilToDoSteps, QMCUpdateBase::Estimators, RMCUpdateAllWithDrift::vmcToDoSteps, and QMCUpdateBase::W.

534 {
535  if (vmcToDoSteps == 0 && equilToDoSteps == 0)
536  Estimators->accumulate(W, it, it_end);
537  else
538  ;
539 }
void accumulate(MCWalkerConfiguration &W)
accumulate the measurements
EstimatorManagerBase * Estimators
estimator
MCWalkerConfiguration & W
walker ensemble

◆ advanceWalker()

void advanceWalker ( Walker_t thisWalker,
bool  recompute 
)
overridevirtual

move a walker

Implements QMCUpdateBase.

Definition at line 292 of file RMCUpdateAll.cpp.

292 {}

◆ advanceWalkers()

void advanceWalkers ( WalkerIter_t  it,
WalkerIter_t  it_end,
bool  recompute 
)
overridevirtual

advance walkers executed at each step

Derived classes implement how to move walkers and accept/reject moves.

Reimplemented from QMCUpdateBase.

Definition at line 294 of file RMCUpdateAll.cpp.

References RMCUpdateAllWithDrift::advanceWalkersRMC(), RMCUpdateAllWithDrift::advanceWalkersVMC(), RMCUpdateAllWithDrift::equilToDoSteps, and RMCUpdateAllWithDrift::vmcToDoSteps.

295 {
296  if (vmcToDoSteps > 0)
297  {
299  vmcToDoSteps--;
300  }
301  else if (vmcToDoSteps == 0 && equilToDoSteps > 0)
302  {
304  equilToDoSteps--;
305  }
306  else
307  {
309  }
310 }

◆ advanceWalkersRMC()

void advanceWalkersRMC ( )

Like DMC, this filters the local energy to ignore divergences near pathological points in phase space.

RealType eest = W.reptile->eest; RealType fbet = std::max(eest - curhead.Properties(LOCALENERGY), eest - eloc);

RealType rawcutoff=100*stdsqrt(W.reptile->evar); RealType cutoffmax = 1.5*rawcutoff; RealType cutoff=1; if (fbet > rawcutoff) cutoff = 1-(fbet - rawcutoff)/(rawcutoff*0.5); if( fbet > cutoffmax ) cutoff=0;

RealType tauscale = W.reptile->tauscale; W.Properties(W.reptile->Action[2])= 0.5*Tau*eloc*cutoff*tauscale;
RealType dS_old = +(curhead.Properties(LOGPSI) + lastbead.Properties(LOGPSI) - logpsi - nextlastbead.Properties(LOGPSI))

  • curhead.Properties(W.reptile->Action[2]) + W.Properties(W.reptile->Action[2])
  • curhead.Properties(W.reptile->Action[forward]) + W.Properties(W.reptile->Action[backward])
  • (lastbead.Properties(W.reptile->Action[2]) + nextlastbead.Properties(W.reptile->Action[2]))
  • (lastbead.Properties(W.reptile->Action[forward]) + nextlastbead.Properties(W.reptile->Action[backward])); acceptProb=std::exp(-dS_0 + (nextlastbead.Properties(W.reptile->TransProb[backward]) - curhead.Properties(W.reptile->TransProb[forward])));

Definition at line 312 of file RMCUpdateAll.cpp.

References Reptile::Action, RMCUpdateAllWithDrift::actionType, Walker< t_traits, p_traits >::Age, qmcplusplus::app_log(), qmcplusplus::assignDrift(), QMCHamiltonian::auxHevaluate(), QMCUpdateBase::branchEngine, QMCUpdateBase::deltaR, Reptile::direction, SimpleFixedNodeBranch::DMCLinkAction(), qmcplusplus::Dot(), QMCUpdateBase::drift, RMCUpdateAllWithDrift::equilSteps, RMCUpdateAllWithDrift::equilToDoSteps, QMCHamiltonian::evaluate(), TrialWaveFunction::evaluateLog(), qmcplusplus::exp(), Reptile::flip(), ParticleSet::G, Reptile::getCenter(), Reptile::getHead(), Reptile::getNewHead(), Reptile::getNext(), TrialWaveFunction::getPhase(), TrialWaveFunction::getPhaseDiff(), ParticleSet::getPropertyBase(), Reptile::getTail(), Reptile::getTransProb(), QMCUpdateBase::H, ParticleSet::loadWalker(), QMCUpdateBase::m_oneover2tau, QMCUpdateBase::m_sqrttau, QMCUpdateBase::m_tauovermass, qmcplusplus::makeGaussRandomWithEngine(), ParticleSet::makeMoveAllParticlesWithDrift(), QMCUpdateBase::MaxAge, omptarget::min(), QMCUpdateBase::nAccept, QMCUpdateBase::nReject, SimpleFixedNodeBranch::phaseChanged(), ParticleSet::Properties, Walker< t_traits, p_traits >::Properties, QMCUpdateBase::Psi, ParticleSet::R, Walker< t_traits, p_traits >::R, QMCUpdateBase::RandomGen, QMCHamiltonian::rejectedMove(), MCWalkerConfiguration::reptile, QMCHamiltonian::saveProperty(), Reptile::saveTransProb(), ParticleSet::saveWalker(), RMCUpdateAllWithDrift::scaleDrift, qmcplusplus::setScaledDrift(), RMCUpdateAllWithDrift::SYM_ACTION, SimpleFixedNodeBranch::symLinkAction(), Reptile::TransProb, ParticleSet::update(), and QMCUpdateBase::W.

Referenced by RMCUpdateAllWithDrift::advanceWalkers().

313 {
314  IndexType direction = W.reptile->direction;
315  IndexType forward = (1 - direction) / 2;
316  IndexType backward = (1 + direction) / 2;
317  Walker_t& curhead = W.reptile->getHead();
318  Walker_t& centerbead = W.reptile->getCenter();
319 
320  // if(centerbead.Age>=MaxAge)
321  // {
322  // vmcToDoSteps=vmcSteps;
323  // equilToDoSteps=equilSteps;
324  // app_log()<<"MaxAge for center bead exceeded. Reequilibrating. "<<vmcSteps<<" "<<equilSteps<< std::endl;
325  // }
326 
327  //We are going to monitor the center bead's age to determine whether we force
328  //moves. This is because the ends are less likely to get pinned.
329 
330  // centerbead.Age+=1;
331 
332  W.loadWalker(curhead, false);
333  //RealType nodecorr=1;
334  if (scaleDrift == true)
335  setScaledDrift(m_tauovermass, curhead.G, drift);
336  else
337  assignDrift(m_tauovermass, curhead.G, drift);
338  //app_log()<<"Sign head = "<<curhead.Properties(SIGN)<< std::endl;
339  //app_log()<<"Old phase = "<<Psi.getPhase()<< std::endl;
341  RealType r2proposed = Dot(deltaR, deltaR);
342  RealType r2accept = 0.0;
343  // W.reptile->r2prop += r2proposed;
344  // W.reptile->r2samp++;
346  {
347  ++nReject;
348  H.rejectedMove(W, curhead);
349  curhead.Age += 1;
350  W.reptile->flip();
351  return;
352  }
353  RealType logpsi(Psi.evaluateLog(W));
354  // app_log()<<"Sign newhead = "<<W.Properties(SIGN)<< std::endl;
355  //RealType* restrict old_headProp ((*it)->getPropertyBase());
356  //old_headProp[TransProb[forward]]= 0.5*Dot(deltaR,deltaR);
357 
358  curhead.Properties(W.reptile->TransProb[forward]) = -0.5 * Dot(deltaR, deltaR);
359  curhead.Properties(W.reptile->Action[forward]) = 0.5 * 0.5 * Dot(deltaR, deltaR);
360 
361  RealType logGf = -0.5 * Dot(deltaR, deltaR);
362  //W.reptile->saveTransProb(curhead,+1,logGf);
363 
364  Walker_t::ParticlePos fromdeltaR(deltaR);
365 
366 
367  if (scaleDrift == true)
369  else
371  fromdeltaR = curhead.R - W.R - drift;
372  FullPrecRealType* restrict new_headProp(W.getPropertyBase());
373  W.Properties(W.reptile->TransProb[backward]) = -m_oneover2tau * Dot(fromdeltaR, fromdeltaR);
374  W.Properties(W.reptile->Action[backward]) = 0.5 * m_oneover2tau * Dot(fromdeltaR, fromdeltaR);
375 
376  RealType logGb = -m_oneover2tau * Dot(fromdeltaR, fromdeltaR);
377 
378  // W.reptile->saveTransProb(W,-1, logGb);
379 
380  Walker_t &lastbead(W.reptile->getTail()), nextlastbead(W.reptile->getNext());
381  //Implementing the fixed-node approximation. If phase difference is not a multiple of 2pi, bounce away from node.
382  RealType newphase = Psi.getPhase();
383  RealType phasediff = newphase - curhead.Properties(WP::SIGN);
384  //Reject & bounce if node crossed.
386  {
387  ++nReject;
388  H.rejectedMove(W, curhead);
389  curhead.Age += 1;
390  W.reptile->flip();
391  //app_log()<<"hit a node. Bouncing...\n";
392  return;
393  }
394  RealType eloc = H.evaluate(W);
395  W.Properties(WP::LOCALENERGY) = eloc;
396  //new_headProp[Action[2]]= 0.5*Tau*eloc;
397  ////////////////////////////////////////////////////////////////////////
398  /// Like DMC, this filters the local energy to ignore divergences near pathological points in phase space.
399  ////////////////////////////////////////////////////////////////////////
400  /// RealType eest = W.reptile->eest;
401  /// RealType fbet = std::max(eest - curhead.Properties(LOCALENERGY), eest - eloc);
402 
403  /// RealType rawcutoff=100*std::sqrt(W.reptile->evar);
404  /// RealType cutoffmax = 1.5*rawcutoff;
405  /// RealType cutoff=1;
406  /// if (fbet > rawcutoff)
407  /// cutoff = 1-(fbet - rawcutoff)/(rawcutoff*0.5);
408  /// if( fbet > cutoffmax )
409  /// cutoff=0;
410  //////////////////////////////////////////////////////////////////////////
411  /// RealType tauscale = W.reptile->tauscale;
412  /// W.Properties(W.reptile->Action[2])= 0.5*Tau*eloc*cutoff*tauscale;
413  RealType dS = 0;
414  RealType acceptProb = 0;
415 
416  if (actionType == SYM_ACTION)
417  {
418  RealType oldhead_logpsi = curhead.Properties(WP::LOGPSI);
419  RealType oldtail_logpsi = lastbead.Properties(WP::LOGPSI);
420  RealType newtail_logpsi = nextlastbead.Properties(WP::LOGPSI);
421 
422  RealType oldhead_e = curhead.Properties(WP::LOCALENERGY);
423  RealType oldtail_e = lastbead.Properties(WP::LOCALENERGY);
424  RealType newhead_e = W.Properties(WP::LOCALENERGY);
425  RealType newtail_e = nextlastbead.Properties(WP::LOCALENERGY);
426 
427  RealType head_forward = W.reptile->getTransProb(curhead, +1);
428  RealType head_backward = W.reptile->getTransProb(W, -1);
429  RealType tail_forward = W.reptile->getTransProb(lastbead, +1);
430  RealType tail_backward = W.reptile->getTransProb(nextlastbead, -1);
431 
432  // RealType head_forward=curhead.Properties(W.reptile->TransProb[forward]);
433  // RealType head_backward=W.Properties(W.reptile->TransProb[backward]);
434  // RealType tail_forward=lastbead.Properties(W.reptile->TransProb[forward]);
435  // RealType tail_backward=nextlastbead.Properties(W.reptile->TransProb[backward]);
436 
437 
438  // RealType dS_head=branchEngine->symLinkActionBare(head_forward, head_backward, newhead_e, oldhead_e);
439  // RealType dS_tail=branchEngine->symLinkActionBare(tail_forward, tail_backward, newtail_e, oldtail_e);
440  RealType dS_head = branchEngine->symLinkAction(head_forward, head_backward, newhead_e, oldhead_e);
441  RealType dS_tail = branchEngine->symLinkAction(tail_forward, tail_backward, newtail_e, oldtail_e);
442 
443 
444  RealType dS_0 = dS_head - dS_tail +
445  (curhead.Properties(WP::LOGPSI) + lastbead.Properties(WP::LOGPSI) - logpsi -
446  nextlastbead.Properties(WP::LOGPSI));
447 
448  /// RealType dS_old = +(curhead.Properties(LOGPSI) + lastbead.Properties(LOGPSI) - logpsi - nextlastbead.Properties(LOGPSI))
449  /// + curhead.Properties(W.reptile->Action[2]) + W.Properties(W.reptile->Action[2])
450  /// + curhead.Properties(W.reptile->Action[forward]) + W.Properties(W.reptile->Action[backward])
451  /// - (lastbead.Properties(W.reptile->Action[2]) + nextlastbead.Properties(W.reptile->Action[2]))
452  /// - (lastbead.Properties(W.reptile->Action[forward]) + nextlastbead.Properties(W.reptile->Action[backward]));
453  ///acceptProb=std::exp(-dS_0 + (nextlastbead.Properties(W.reptile->TransProb[backward]) - curhead.Properties(W.reptile->TransProb[forward])));
454 
455  // acceptProb=std::exp(-dS_0 + tail_backward - head_forward);
456  // app_log()<<"logGf (calced) = "
457  // app_log()<<"dS_old="<<dS_old<< std::endl;
458  // app_log()<<"dS_head="<<dS_head<< std::endl;
459  // app_log()<<"dS_tail="<<dS_tail<< std::endl;
460  // app_log()<<"dS' = "<<dS_0<< std::endl;
461  // app_log()<<"W.Properties(WP::LOCALENERGY)="<<W.Properties(WP::LOCALENERGY)<< std::endl;
462 
463  // app_log()<<"---------------\n";
464  acceptProb = std::exp(-dS_0 +
465  (nextlastbead.Properties(W.reptile->TransProb[backward]) -
466  curhead.Properties(W.reptile->TransProb[forward]))); //tail_backward - head_forward);
467  // acceptProb=std::min(1.0,std::exp(-dS + -(curhead.Properties(LOGPSI) + lastbead.Properties(LOGPSI) - logpsi - nextlastbead.Properties(LOGPSI)) + tail_backward - head_forward));
468  }
469  else
470  {
471  // dS = curhead.Properties(W.reptile->Action[2]) + W.Properties(W.reptile->Action[2])
472  //- (lastbead.Properties(W.reptile->Action[2]) + nextlastbead.Properties(W.reptile->Action[2]));
473  RealType dS_head = branchEngine->DMCLinkAction(eloc, curhead.Properties(WP::LOCALENERGY));
474  RealType dS_tail =
475  branchEngine->DMCLinkAction(lastbead.Properties(WP::LOCALENERGY), nextlastbead.Properties(WP::LOCALENERGY));
476  //dS=branchEngine->DMCLinkAction(eloc,curhead.Properties(WP::LOCALENERGY)) - branchEngine->DMCLinkAction(lastbead.Properties(WP::LOCALENERGY),nextlastbead.Properties(WP::LOCALENERGY));
477  dS = dS_head - dS_tail;
478  acceptProb = std::min((RealType)1.0, std::exp(-dS));
479  }
480 
481  //app_log()<<acceptProb<< std::endl;
482  // app_log()<<"r2proposed.... = "<<r2proposed<< std::endl;
483  if ((RandomGen() < acceptProb) || curhead.Age >= MaxAge)
484  {
485  r2accept = r2proposed;
486  // W.reptile->r2accept+=r2accept;
488  if (curhead.Age >= MaxAge)
489  {
490  app_log() << "\tForce Acceptance...\n";
492  }
493  W.saveWalker(overwriteWalker);
494  overwriteWalker.Properties(WP::LOCALENERGY) = eloc;
495  overwriteWalker.Properties(W.reptile->Action[forward]) = 0;
496  overwriteWalker.Properties(W.reptile->Action[backward]) = W.Properties(W.reptile->Action[backward]);
497  overwriteWalker.Properties(W.reptile->Action[2]) = W.Properties(W.reptile->Action[2]);
498  //overwriteWalker.Properties(W.reptile->TransProb[forward])=W.Properties(W.reptile->TransProb[forward]);
499  W.reptile->saveTransProb(overwriteWalker, +1, 0);
500  W.reptile->saveTransProb(overwriteWalker, -1, logGb);
501  // overwriteWalker.Properties(W.reptile->TransProb[backward])=W.Properties(W.reptile->TransProb[backward]);
502  overwriteWalker.resetProperty(logpsi, Psi.getPhase(), eloc);
503  overwriteWalker.Properties(WP::R2ACCEPTED) = r2accept;
504  overwriteWalker.Properties(WP::R2PROPOSED) = r2proposed;
505 
506  // lastbead.Properties(R2PROPOSED)=lastbead.Properties(R2ACCEPTED)=nextlastbead.Properties(R2PROPOSED);
507  H.auxHevaluate(W, overwriteWalker, true, false); //evaluate properties but not collectables.
508  H.saveProperty(overwriteWalker.getPropertyBase());
509  overwriteWalker.Age = 0;
510 
511  ++nAccept;
512  }
513  else
514  {
515  // app_log()<<"Reject\n";
516  curhead.Properties(WP::R2ACCEPTED) = 0;
517  curhead.Properties(WP::R2PROPOSED) = r2proposed;
518  lastbead.Properties(WP::R2ACCEPTED) = 0;
519  //lastbead.Properties(R2PROPOSED)=nextlastbead.Properties(R2PROPOSED);
520  //curhead.Properties(R2
521  ++nReject;
522  H.rejectedMove(W, curhead);
523  curhead.Age += 1;
524  W.reptile->flip();
525  // app_log()<<"Reject\n";
526  return;
527  }
528  W.loadWalker(centerbead, true);
529  W.update(false); //skip S(k) evaluation? False
530  H.auxHevaluate(W, centerbead, false, true); //collectables, but not properties
531 }
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
const BranchEngineType * branchEngine
branch engine, stateless reference to the one in QMCDriver
ParticleSet::ParticlePos drift
temporary storage for drift
RealType m_tauovermass
tau/mass
PropertyContainer_t Properties
properties of the current walker
Definition: ParticleSet.h:119
Walker_t & getTail()
Definition: Reptile.h:98
TrialWaveFunction & Psi
trial function
typename p_traits::ParticlePos ParticlePos
array of particles
Definition: Walker.h:64
std::ostream & app_log()
Definition: OutputManager.h:65
void saveProperty(IT first)
save the values of Hamiltonian elements to the Properties
bool phaseChanged(RealType psi0) const
RealType DMCLinkAction(RealType enew, RealType eold) const
MCWalkerConfiguration::Walker_t Walker_t
Definition: QMCUpdateBase.h:44
Walker_t & getNewHead()
Definition: Reptile.h:128
void assignDrift(T s, const ParticleAttrib< TinyVector< TG, D >> &ga, ParticleAttrib< TinyVector< T, D >> &da)
RealType m_sqrttau
Time-step factor .
void update(bool skipSK=false)
update the internal data
RealType symLinkAction(RealType logGf, RealType logGb, RealType enew, RealType eold) const
Walker_t & getCenter()
Definition: Reptile.h:100
ParticleSet::ParticlePos deltaR
temporary storage for random displacement
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
T min(T a, T b)
std::vector< IndexType > TransProb
Definition: Reptile.h:48
std::vector< IndexType > Action
Definition: Reptile.h:47
ParticleGradient G
gradients of the particles
Definition: ParticleSet.h:83
void saveWalker(Walker_t &awalker)
save this to awalker
ParticlePos R
Position.
Definition: ParticleSet.h:79
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
Walker_t & getNext()
Definition: Reptile.h:99
MCWalkerConfiguration & W
walker ensemble
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65
void loadWalker(Walker_t &awalker, bool pbyp)
load a Walker_t to the current ParticleSet
WalkerConfigurations::Walker_t Walker_t
void auxHevaluate(ParticleSet &P)
IndexType MaxAge
MaxAge>0 indicates branch is done.
Definition: QMCUpdateBase.h:61
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
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
Walker_t & getHead()
Definition: Reptile.h:97
bool makeMoveAllParticlesWithDrift(const Walker_t &awalker, const ParticlePos &drift, const ParticlePos &deltaR, RealType dt)
move all the particles including the drift
QTFull::RealType FullPrecRealType
Definition: Configuration.h:66
IndexType nAccept
counter for number of moves accepted
Definition: QMCUpdateBase.h:63
RealType m_oneover2tau
Time-step factor .
IndexType nReject
counter for number of moves rejected
Definition: QMCUpdateBase.h:65
void saveTransProb(Walker_t &walker, IndexType d, RealType val, IndexType nPsi=0)
Definition: Reptile.h:162
FullPrecRealType *restrict getPropertyBase()
return the address of the values of Hamiltonian terms
Definition: ParticleSet.h:470
QMCHamiltonian & H
Hamiltonian.
void setScaledDrift(T tau, const ParticleAttrib< TinyVector< TG, D >> &qf, ParticleAttrib< TinyVector< T, D >> &drift)
da = scaled(tau)*ga
RealType getTransProb(Walker_t &walker, IndexType d, RealType nPsi=0)
Definition: Reptile.h:175
IndexType direction
Definition: Reptile.h:59
void makeGaussRandomWithEngine(ParticleAttrib< TinyVector< T, D >> &a, RG &rng)

◆ advanceWalkersVMC()

void advanceWalkersVMC ( )

Like DMC, this filters the local energy to ignore divergences near pathological points in phase space.

Definition at line 104 of file RMCUpdateAll.cpp.

References Reptile::Action, RMCUpdateAllWithDrift::Action, RMCUpdateAllWithDrift::actionType, qmcplusplus::assignDrift(), QMCHamiltonian::auxHevaluate(), QMCUpdateBase::branchEngine, QMCUpdateBase::deltaR, Reptile::direction, SimpleFixedNodeBranch::DMCLinkAction(), qmcplusplus::Dot(), QMCUpdateBase::drift, QMCHamiltonian::evaluate(), TrialWaveFunction::evaluateLog(), qmcplusplus::exp(), ParticleSet::G, Reptile::getHead(), Reptile::getNewHead(), Reptile::getNext(), TrialWaveFunction::getPhase(), TrialWaveFunction::getPhaseDiff(), ParticleSet::getPropertyBase(), Reptile::getTail(), Reptile::getTransProb(), QMCUpdateBase::H, ParticleSet::loadWalker(), QMCUpdateBase::m_oneover2tau, QMCUpdateBase::m_sqrttau, QMCUpdateBase::m_tauovermass, qmcplusplus::makeGaussRandomWithEngine(), ParticleSet::makeMoveAllParticlesWithDrift(), QMCUpdateBase::nAccept, QMCUpdateBase::nReject, SimpleFixedNodeBranch::phaseChanged(), ParticleSet::Properties, Walker< t_traits, p_traits >::Properties, QMCUpdateBase::Psi, ParticleSet::R, Walker< t_traits, p_traits >::R, QMCUpdateBase::RandomGen, QMCHamiltonian::rejectedMove(), MCWalkerConfiguration::reptile, Reptile::saveAction(), QMCHamiltonian::saveProperty(), Reptile::saveTransProb(), ParticleSet::saveWalker(), RMCUpdateAllWithDrift::scaleDrift, qmcplusplus::setScaledDrift(), qmcplusplus::setScaledDriftPbyPandNodeCorr(), RMCUpdateAllWithDrift::SYM_ACTION, SimpleFixedNodeBranch::symLinkAction(), QMCUpdateBase::Tau, Reptile::TransProb, and QMCUpdateBase::W.

Referenced by RMCUpdateAllWithDrift::advanceWalkers(), and RMCUpdateAllWithDrift::initWalkers().

105 {
106  IndexType direction = W.reptile->direction;
107  IndexType forward = (1 - direction) / 2;
108  IndexType backward = (1 + direction) / 2;
109  Walker_t& curhead = W.reptile->getHead();
110  W.loadWalker(curhead, false);
111  if (scaleDrift == true)
113  else
114  assignDrift(m_tauovermass, curhead.G, drift);
115  //app_log()<<"Sign head = "<<curhead.Properties(SIGN)<< std::endl;
116  //app_log()<<"Old phase = "<<Psi.getPhase()<< std::endl;
118  RealType r2proposed = Dot(deltaR, deltaR);
119  // W.reptile->r2prop += r2proposed;
120  // W.reptile->r2samp++;
122  {
123  ++nReject;
124  H.rejectedMove(W, curhead);
125  // curhead.Age+=1;
126  //W.reptile->flip();
127  return;
128  }
129 
130  RealType logpsi(Psi.evaluateLog(W));
131  RealType logGf = -0.5 * Dot(deltaR, deltaR);
132  RealType Action_forward = -0.5 * logGf;
133  curhead.Properties(W.reptile->TransProb[forward]) = -0.5 * Dot(deltaR, deltaR);
134  curhead.Properties(W.reptile->Action[forward]) = 0.5 * 0.5 * Dot(deltaR, deltaR);
135 
136  W.reptile->saveTransProb(curhead, +1, logGf);
137  W.reptile->saveAction(curhead, +1, Action_forward);
138 
139  Walker_t::ParticlePos fromdeltaR(deltaR);
140 
141 
142  if (scaleDrift == true)
144  else
146  fromdeltaR = curhead.R - W.R - drift;
147  FullPrecRealType* restrict new_headProp(W.getPropertyBase());
148 
149  RealType logGb = -m_oneover2tau * Dot(fromdeltaR, fromdeltaR);
150 
151  W.reptile->saveTransProb(W, -1, logGb);
152  //W.reptile->saveAction(W,-1,Action_backward);
153 
154  W.Properties(W.reptile->TransProb[backward]) = -m_oneover2tau * Dot(fromdeltaR, fromdeltaR);
155  W.Properties(W.reptile->Action[backward]) = 0.5 * m_oneover2tau * Dot(fromdeltaR, fromdeltaR);
156 
157  Walker_t &lastbead(W.reptile->getTail()), nextlastbead(W.reptile->getNext());
158  //Implementing the fixed-node approximation. If phase difference is not a multiple of 2pi, bounce away from node.
159  RealType newphase = Psi.getPhase();
160  RealType phasediff = newphase - curhead.Properties(WP::SIGN);
161  //Reject & bounce if node crossed.
163  {
164  ++nReject;
165  H.rejectedMove(W, curhead);
166  // curhead.Age+=1;
167  // W.reptile->flip();
168  //app_log()<<"hit a node. Bouncing...\n";
169  return;
170  }
171  RealType eloc = H.evaluate(W);
172  new_headProp[Action[2]] = 0.5 * Tau * eloc;
173 
174  ////////////////////////////////////////////////////////////////////////
175  /// Like DMC, this filters the local energy to ignore divergences near pathological points in phase space.
176  ////////////////////////////////////////////////////////////////////////
177  // RealType eest = W.reptile->eest;
178 
179  // RealType fbet = std::max(eest - curhead.Properties(WP::LOCALENERGY), eest - eloc);
180  // app_log()<<"eval = "<<eest<<" estdev="<<stddev<< std::endl;
181  // RealType rawcutoff=100*std::sqrt(W.reptile->evar);
182  // RealType cutoffmax = 1.5*rawcutoff;
183  // RealType cutoff=1;
184  // if (fbet > rawcutoff)
185  // cutoff = 1-(fbet - rawcutoff)/(rawcutoff*0.5);
186  // if( fbet > cutoffmax )
187  // cutoff=0;
188  //////////////////////////////////////////////////////////////////////////
189  // RealType tauscale = W.reptile->tauscale;
190  // W.Properties(W.reptile->Action[2])= 0.5*Tau*eloc*cutoff*tauscale;
191  RealType acceptProb = 1;
192  if (actionType == SYM_ACTION)
193  {
194  RealType oldhead_logpsi = curhead.Properties(WP::LOGPSI);
195  RealType oldtail_logpsi = lastbead.Properties(WP::LOGPSI);
196  RealType newtail_logpsi = nextlastbead.Properties(WP::LOGPSI);
197 
198  RealType oldhead_e = curhead.Properties(WP::LOCALENERGY);
199  RealType oldtail_e = lastbead.Properties(WP::LOCALENERGY);
200  RealType newhead_e = W.Properties(WP::LOCALENERGY);
201  RealType newtail_e = nextlastbead.Properties(WP::LOCALENERGY);
202 
203  RealType head_forward = W.reptile->getTransProb(curhead, +1);
204  RealType head_backward = W.reptile->getTransProb(W, -1);
205  RealType tail_forward = W.reptile->getTransProb(lastbead, +1);
206  RealType tail_backward = W.reptile->getTransProb(nextlastbead, -1);
207 
208  RealType dS_head = branchEngine->symLinkAction(head_forward, head_backward, newhead_e, oldhead_e);
209  RealType dS_tail = branchEngine->symLinkAction(tail_forward, tail_backward, newtail_e, oldtail_e);
210 
211  // dS=dS_head-dS_tail;
212 
213  // RealType dS_old = +(curhead.Properties(LOGPSI) + lastbead.Properties(LOGPSI) - logpsi - nextlastbead.Properties(LOGPSI))
214  // + curhead.Properties(W.reptile->Action[2]) + W.Properties(W.reptile->Action[2])
215  // + curhead.Properties(W.reptile->Action[forward]) + W.Properties(W.reptile->Action[backward])
216  // - (lastbead.Properties(W.reptile->Action[2]) + nextlastbead.Properties(W.reptile->Action[2]))
217  // - (lastbead.Properties(W.reptile->Action[forward]) + nextlastbead.Properties(W.reptile->Action[backward]));
218  // acceptProb=std::exp(-dS_old + (nextlastbead.Properties(W.reptile->TransProb[backward]) - curhead.Properties(W.reptile->TransProb[forward])));
219  // acceptProb=std::min(1.0,std::exp(-dS + -(curhead.Properties(LOGPSI) + lastbead.Properties(LOGPSI) - logpsi - nextlastbead.Properties(LOGPSI)) + tail_backward - head_forward));
220  }
221  else
222  {
223  // dS = curhead.Properties(W.reptile->Action[2]) + W.Properties(W.reptile->Action[2])
224  //- (lastbead.Properties(W.reptile->Action[2]) + nextlastbead.Properties(W.reptile->Action[2]));
225  RealType dS_head = branchEngine->DMCLinkAction(eloc, curhead.Properties(WP::LOCALENERGY));
226  RealType dS_tail =
227  branchEngine->DMCLinkAction(lastbead.Properties(WP::LOCALENERGY), nextlastbead.Properties(WP::LOCALENERGY));
228  //dS=branchEngine->DMCLinkAction(eloc,curhead.Properties(LOCALENERGY)) - branchEngine->DMCLinkAction(lastbead.Properties(LOCALENERGY),nextlastbead.Properties(LOCALENERGY));
229  // dS=dS_head - dS_tail;
230  // acceptProb=std::min(1.0,std::exp(-dS ));
231  }
232  acceptProb = std::exp(logGb - logGf + 2.0 * (logpsi - curhead.Properties(WP::LOGPSI)));
233 
234 
235  /* RealType dS = curhead.Properties(W.reptile->Action[2]) + W.Properties(W.reptile->Action[2])
236  - (lastbead.Properties(W.reptile->Action[2]) + nextlastbead.Properties(W.reptile->Action[2]));
237  RealType acceptProb=std::min(1.0,std::exp(-dS )); */
238  if (RandomGen() < acceptProb)
239  {
240  //Assuming the VMC step is fine, we are forcing the move.
242 
243  W.saveWalker(overwriteWalker);
244  overwriteWalker.Properties(WP::LOCALENERGY) = eloc;
245  overwriteWalker.Properties(W.reptile->Action[forward]) = 0;
246  overwriteWalker.Properties(W.reptile->Action[backward]) = W.Properties(W.reptile->Action[backward]);
247  overwriteWalker.Properties(W.reptile->Action[2]) = W.Properties(W.reptile->Action[2]);
248  overwriteWalker.Properties(W.reptile->TransProb[forward]) = W.Properties(W.reptile->TransProb[forward]);
249  overwriteWalker.Properties(W.reptile->TransProb[backward]) = W.Properties(W.reptile->TransProb[backward]);
250  overwriteWalker.resetProperty(logpsi, Psi.getPhase(), eloc);
251  H.auxHevaluate(W, overwriteWalker, true, false); //properties but not collectables.
252  H.saveProperty(overwriteWalker.getPropertyBase());
253  overwriteWalker.Age = 0;
254  ++nAccept;
255  }
256  else
257  {
258  ++nReject;
259  H.rejectedMove(W, curhead);
260  // curhead.Age+=1;
261  // W.reptile->flip();
262  return;
263  }
264 }
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
const BranchEngineType * branchEngine
branch engine, stateless reference to the one in QMCDriver
ParticleSet::ParticlePos drift
temporary storage for drift
RealType m_tauovermass
tau/mass
PropertyContainer_t Properties
properties of the current walker
Definition: ParticleSet.h:119
Walker_t & getTail()
Definition: Reptile.h:98
TrialWaveFunction & Psi
trial function
typename p_traits::ParticlePos ParticlePos
array of particles
Definition: Walker.h:64
void saveProperty(IT first)
save the values of Hamiltonian elements to the Properties
bool phaseChanged(RealType psi0) const
RealType DMCLinkAction(RealType enew, RealType eold) const
MCWalkerConfiguration::Walker_t Walker_t
Definition: QMCUpdateBase.h:44
Walker_t & getNewHead()
Definition: Reptile.h:128
void assignDrift(T s, const ParticleAttrib< TinyVector< TG, D >> &ga, ParticleAttrib< TinyVector< T, D >> &da)
RealType m_sqrttau
Time-step factor .
RealType symLinkAction(RealType logGf, RealType logGb, RealType enew, RealType eold) const
ParticleSet::ParticlePos deltaR
temporary storage for random displacement
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
std::vector< IndexType > TransProb
Definition: Reptile.h:48
T setScaledDriftPbyPandNodeCorr(T tau, const ParticleAttrib< TinyVector< T1, D >> &qf, ParticleAttrib< TinyVector< T, D >> &drift)
scale drift
std::vector< IndexType > Action
Definition: Reptile.h:47
ParticleGradient G
gradients of the particles
Definition: ParticleSet.h:83
void saveWalker(Walker_t &awalker)
save this to awalker
RealType Tau
timestep
Definition: QMCUpdateBase.h:73
ParticlePos R
Position.
Definition: ParticleSet.h:79
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
Walker_t & getNext()
Definition: Reptile.h:99
MCWalkerConfiguration & W
walker ensemble
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65
void loadWalker(Walker_t &awalker, bool pbyp)
load a Walker_t to the current ParticleSet
WalkerConfigurations::Walker_t Walker_t
void auxHevaluate(ParticleSet &P)
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
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
Walker_t & getHead()
Definition: Reptile.h:97
bool makeMoveAllParticlesWithDrift(const Walker_t &awalker, const ParticlePos &drift, const ParticlePos &deltaR, RealType dt)
move all the particles including the drift
QTFull::RealType FullPrecRealType
Definition: Configuration.h:66
void saveAction(Walker_t &walker, IndexType d, RealType val, IndexType nPsi=0)
Definition: Reptile.h:135
IndexType nAccept
counter for number of moves accepted
Definition: QMCUpdateBase.h:63
RealType m_oneover2tau
Time-step factor .
IndexType nReject
counter for number of moves rejected
Definition: QMCUpdateBase.h:65
void saveTransProb(Walker_t &walker, IndexType d, RealType val, IndexType nPsi=0)
Definition: Reptile.h:162
FullPrecRealType *restrict getPropertyBase()
return the address of the values of Hamiltonian terms
Definition: ParticleSet.h:470
QMCHamiltonian & H
Hamiltonian.
void setScaledDrift(T tau, const ParticleAttrib< TinyVector< TG, D >> &qf, ParticleAttrib< TinyVector< T, D >> &drift)
da = scaled(tau)*ga
RealType getTransProb(Walker_t &walker, IndexType d, RealType nPsi=0)
Definition: Reptile.h:175
IndexType direction
Definition: Reptile.h:59
void makeGaussRandomWithEngine(ParticleAttrib< TinyVector< T, D >> &a, RG &rng)

◆ checkReptile()

void checkReptile ( WalkerIter_t  it,
WalkerIter_t  it_end 
)

◆ initWalkers()

void initWalkers ( WalkerIter_t  it,
WalkerIter_t  it_end 
)
overridevirtual

initialize Walker for walker update

Reimplemented from QMCUpdateBase.

Definition at line 267 of file RMCUpdateAll.cpp.

References RMCUpdateAllWithDrift::advanceWalkersVMC(), QMCHamiltonian::auxHevaluate(), QMCUpdateBase::drift, QMCHamiltonian::evaluate(), TrialWaveFunction::evaluateLog(), ParticleSet::G, TrialWaveFunction::getPhase(), QMCUpdateBase::H, ParticleSet::L, QMCUpdateBase::MassInvP, qmcplusplus::n, Reptile::nbeads, QMCUpdateBase::Psi, ParticleSet::R, MCWalkerConfiguration::reptile, QMCHamiltonian::saveProperty(), qmcplusplus::setScaledDriftPbyPandNodeCorr(), QMCUpdateBase::Tau, ParticleSet::update(), RMCUpdateAllWithDrift::vmcSteps, and QMCUpdateBase::W.

268 {
269  IndexType initsteps = W.reptile->nbeads * 2;
270  vmcSteps = W.reptile->nbeads + 1;
271 
272  for (; it != it_end; ++it)
273  {
274  W.R = (*it)->R;
275  W.update();
276  RealType logpsi(Psi.evaluateLog(W));
277  (*it)->G = W.G;
278  (*it)->L = W.L;
280  RealType ene = H.evaluate(W);
281  H.auxHevaluate(W);
282  (*it)->resetProperty(logpsi, Psi.getPhase(), ene, 0.0, 0.0, nodecorr);
283  (*it)->Weight = 1;
284  H.saveProperty((*it)->getPropertyBase());
285  }
286 
287 
288  for (int n = 0; n < initsteps; n++)
290 }
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
ParticleSet::ParticlePos drift
temporary storage for drift
TrialWaveFunction & Psi
trial function
void saveProperty(IT first)
save the values of Hamiltonian elements to the Properties
void update(bool skipSK=false)
update the internal data
ParticleLaplacian L
laplacians of the particles
Definition: ParticleSet.h:85
T setScaledDriftPbyPandNodeCorr(T tau, const ParticleAttrib< TinyVector< T1, D >> &qf, ParticleAttrib< TinyVector< T, D >> &drift)
scale drift
ParticleGradient G
gradients of the particles
Definition: ParticleSet.h:83
RealType Tau
timestep
Definition: QMCUpdateBase.h:73
ParticlePos R
Position.
Definition: ParticleSet.h:79
MCWalkerConfiguration & W
walker ensemble
std::vector< RealType > MassInvP
1/Mass per particle
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65
void auxHevaluate(ParticleSet &P)
QMCTraits::RealType RealType
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
IndexType nbeads
Definition: Reptile.h:59
QMCHamiltonian & H
Hamiltonian.

◆ operator=()

RMCUpdateAllWithDrift& operator= ( const RMCUpdateAllWithDrift )
privatedelete

Copy operator (disabled).

◆ put()

bool put ( xmlNodePtr  cur)
overridevirtual

process options

Reimplemented from QMCUpdateBase.

Definition at line 58 of file RMCUpdateAll.cpp.

References RMCUpdateAllWithDrift::actionType, ParameterSet::add(), qmcplusplus::app_log(), RMCUpdateAllWithDrift::DMC_ACTION, RMCUpdateAllWithDrift::equilSteps, omp_get_thread_num(), ParameterSet::put(), QMCUpdateBase::put(), and RMCUpdateAllWithDrift::scaleDrift.

59 {
60  QMCUpdateBase::put(cur);
61  ParameterSet m_param;
62  // bool usedrift=false;
63  std::string action = "SLA";
64  std::string usedrift = "no";
65  m_param.add(usedrift, "useScaledDrift");
66  m_param.add(action, "Action");
67  m_param.add(equilSteps, "equilsteps");
68  m_param.add(equilSteps, "equilSteps");
69 
70  // m_param.add(scaleDrift,"scaleDrift");
71  m_param.put(cur);
72 
73  bool driftoption = (usedrift == "yes" || usedrift == "Yes" || usedrift == "True" || usedrift == "true");
74 
75  if (driftoption)
76  {
77  scaleDrift = true;
78  if (omp_get_thread_num() == 0)
79  app_log() << " Using Umrigar scaled drift\n";
80  // H.rejectedMove(W,thisWalker);
81  }
82  else
83  {
84  if (omp_get_thread_num() == 0)
85  app_log() << " Using non-scaled drift\n";
86  }
87 
88  if (action == "DMC")
89  {
91  if (omp_get_thread_num() == 0)
92  app_log() << " Using DMC link-action\n";
93  }
94  else
95  {
96  if (omp_get_thread_num() == 0)
97  app_log() << " Using Symmetrized Link-Action\n";
98  }
99 
100  return true;
101 }
std::ostream & app_log()
Definition: OutputManager.h:65
virtual bool put(xmlNodePtr cur)
process options
bool put(std::istream &is) override
read from std::istream
Definition: ParameterSet.h:42
omp_int_t omp_get_thread_num()
Definition: OpenMP.h:25
class to handle a set of parameters
Definition: ParameterSet.h:27
void add(PDT &aparam, const std::string &aname_in, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new parameter corresponding to an xmlNode <parameter>

Member Data Documentation

◆ Action

std::vector<int> Action
private

Definition at line 58 of file RMCUpdateAll.h.

Referenced by RMCUpdateAllWithDrift::advanceWalkersVMC().

◆ actionType

◆ equilSteps

◆ equilToDoSteps

◆ scaleDrift

◆ TransProb

std::vector<int> TransProb
private

Definition at line 58 of file RMCUpdateAll.h.

◆ vmcSteps

◆ vmcToDoSteps

◆ qmcplusplus::RMCUpdatePbyPWithDrift

class qmcplusplus::RMCUpdatePbyPWithDrift


Implements the RMC algorithm using all electron moves

Definition at line 24 of file RMCUpdatePbyP.h.

+ Inheritance diagram for RMCUpdatePbyPWithDrift:
+ Collaboration diagram for RMCUpdatePbyPWithDrift:

Public Types

enum  { SYM_ACTION, DMC_ACTION }
 
- 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 Member Functions

 RMCUpdatePbyPWithDrift (MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, RandomBase< FullPrecRealType > &rg, std::vector< int > act, std::vector< int > tp)
 Constructor. More...
 
 ~RMCUpdatePbyPWithDrift () override
 
void advanceWalkersVMC ()
 
void advanceWalkersRMC ()
 
void advanceWalker (Walker_t &thisWalker, bool recompute) override
 move a walker More...
 
void advanceWalkers (WalkerIter_t it, WalkerIter_t it_end, bool measure) override
 advance walkers executed at each step More...
 
void initWalkersForPbyP (WalkerIter_t it, WalkerIter_t it_end) override
 initialize Walker buffers for PbyP update More...
 
void initWalkers (WalkerIter_t it, WalkerIter_t it_end) override
 initialize Walker for walker update More...
 
void accumulate (WalkerIter_t it, WalkerIter_t it_end)
 
bool put (xmlNodePtr cur) override
 process options 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
 
void accumulate (WalkerIter_t it, WalkerIter_t it_end)
 
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 Member Functions

 RMCUpdatePbyPWithDrift (const RMCUpdatePbyPWithDrift &)=delete
 Copy Constructor (disabled) More...
 
RMCUpdatePbyPWithDriftoperator= (const RMCUpdatePbyPWithDrift &)=delete
 Copy operator (disabled). More...
 

Private Attributes

std::vector< int > Action
 
std::vector< int > TransProb
 
bool scaleDrift
 
IndexType actionType
 
NewTimeradvance_timer_
 
NewTimermovepbyp_timer_
 
NewTimerupdate_mbo_timer_
 
NewTimerenergy_timer_
 
IndexType vmcSteps
 
IndexType equilSteps
 
IndexType vmcToDoSteps
 
IndexType equilToDoSteps
 

Additional Inherited Members

- 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
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
SYM_ACTION 
DMC_ACTION 

Definition at line 36 of file RMCUpdatePbyP.h.

Constructor & Destructor Documentation

◆ RMCUpdatePbyPWithDrift() [1/2]

RMCUpdatePbyPWithDrift ( MCWalkerConfiguration w,
TrialWaveFunction psi,
QMCHamiltonian h,
RandomBase< FullPrecRealType > &  rg,
std::vector< int >  act,
std::vector< int >  tp 
)

Constructor.

Definition at line 40 of file RMCUpdatePbyP.cpp.

References RMCUpdatePbyPWithDrift::actionType, RMCUpdatePbyPWithDrift::scaleDrift, and RMCUpdatePbyPWithDrift::SYM_ACTION.

46  : QMCUpdateBase(w, psi, h, rg),
47  Action(act),
48  TransProb(tp),
49  advance_timer_(createGlobalTimer("RMCUpdatePbyP::advance", timer_level_medium)),
50  movepbyp_timer_(createGlobalTimer("RMCUpdatePbyP::movePbyP", timer_level_medium)),
51  update_mbo_timer_(createGlobalTimer("RMCUpdatePbyP::updateMBO", timer_level_medium)),
52  energy_timer_(createGlobalTimer("RMCUpdatePbyP::energy", timer_level_medium))
53 {
54  scaleDrift = false;
56 }
NewTimer & createGlobalTimer(const std::string &myname, timer_levels mylevel)
QMCUpdateBase(MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, RandomBase< FullPrecRealType > &rg)
Constructor.

◆ ~RMCUpdatePbyPWithDrift()

~RMCUpdatePbyPWithDrift ( )
override

Definition at line 58 of file RMCUpdatePbyP.cpp.

58 {}

◆ RMCUpdatePbyPWithDrift() [2/2]

RMCUpdatePbyPWithDrift ( const RMCUpdatePbyPWithDrift )
privatedelete

Copy Constructor (disabled)

Member Function Documentation

◆ accumulate()

void accumulate ( WalkerIter_t  it,
WalkerIter_t  it_end 
)

Definition at line 382 of file RMCUpdatePbyP.cpp.

References EstimatorManagerBase::accumulate(), QMCUpdateBase::Estimators, and QMCUpdateBase::W.

382 { Estimators->accumulate(W, it, it_end); }
void accumulate(MCWalkerConfiguration &W)
accumulate the measurements
EstimatorManagerBase * Estimators
estimator
MCWalkerConfiguration & W
walker ensemble

◆ advanceWalker()

void advanceWalker ( Walker_t thisWalker,
bool  recompute 
)
overridevirtual

move a walker

Implements QMCUpdateBase.

Definition at line 369 of file RMCUpdatePbyP.cpp.

370 {
371  //empty function to
372 }

◆ advanceWalkers()

void advanceWalkers ( WalkerIter_t  it,
WalkerIter_t  it_end,
bool  recompute 
)
overridevirtual

advance walkers executed at each step

Derived classes implement how to move walkers and accept/reject moves.

Reimplemented from QMCUpdateBase.

Definition at line 374 of file RMCUpdatePbyP.cpp.

References RMCUpdatePbyPWithDrift::advanceWalkersRMC(), and RMCUpdatePbyPWithDrift::advanceWalkersVMC().

375 {
376  if (init == true)
378  else
380 }

◆ advanceWalkersRMC()

void advanceWalkersRMC ( )

Definition at line 250 of file RMCUpdatePbyP.cpp.

References ParticleSet::accept_rejectMove(), TrialWaveFunction::acceptMove(), Walker< t_traits, p_traits >::Age, qmcplusplus::app_log(), QMCHamiltonian::auxHevaluate(), QMCUpdateBase::branchEngine, TrialWaveFunction::calcRatioGrad(), TrialWaveFunction::completeUpdates(), TrialWaveFunction::copyFromBuffer(), Walker< t_traits, p_traits >::DataSet, QMCUpdateBase::deltaR, SimpleFixedNodeBranch::DMCLinkAction(), ParticleSet::donePbyP(), qmcplusplus::dot(), QMCUpdateBase::DriftModifier, TrialWaveFunction::evalGrad(), QMCHamiltonian::evaluate(), qmcplusplus::exp(), ParticleSet::first(), Reptile::flip(), ParticleSet::getActivePos(), Reptile::getCenter(), DriftModifierBase::getDrift(), Reptile::getHead(), Reptile::getNewHead(), Reptile::getNext(), TrialWaveFunction::getPhaseDiff(), Walker< t_traits, p_traits >::getPropertyBase(), Reptile::getTail(), ParticleSet::groups(), QMCUpdateBase::H, ParticleSet::last(), ParticleSet::loadWalker(), QMCUpdateBase::m_r2max, qmcplusplus::makeGaussRandomWithEngine(), ParticleSet::makeMoveAndCheck(), QMCUpdateBase::MassInvS, QMCUpdateBase::MaxAge, omptarget::min(), RMCUpdatePbyPWithDrift::movepbyp_timer_, QMCUpdateBase::nAccept, QMCUpdateBase::nNodeCrossing, norm(), QMCUpdateBase::nReject, SimpleFixedNodeBranch::phaseChanged(), Walker< t_traits, p_traits >::Properties, QMCUpdateBase::Psi, ParticleSet::R, Walker< t_traits, p_traits >::R, QMCUpdateBase::RandomGen, QMCHamiltonian::rejectedMove(), TrialWaveFunction::rejectMove(), MCWalkerConfiguration::reptile, QMCHamiltonian::saveProperty(), ParticleSet::saveWalker(), qmcplusplus::sqrt(), TimerType< CLOCK >::start(), TimerType< CLOCK >::stop(), QMCUpdateBase::Tau, ParticleSet::update(), TrialWaveFunction::updateBuffer(), and QMCUpdateBase::W.

Referenced by RMCUpdatePbyPWithDrift::advanceWalkers().

251 {
252  Walker_t& curhead = W.reptile->getHead();
253  Walker_t prophead(curhead);
254  Walker_t::WFBuffer_t& w_buffer(prophead.DataSet);
255  W.loadWalker(prophead, true);
256  Psi.copyFromBuffer(W, w_buffer);
257 
259  int nAcceptTemp(0);
260  //copy the old energy and scale factor of drift
261  RealType eold(prophead.Properties(WP::LOCALENERGY));
262  RealType vqold(prophead.Properties(WP::DRIFTSCALE));
263  RealType rr_proposed = 0.0;
264  RealType rr_accepted = 0.0;
266  for (int ig = 0; ig < W.groups(); ++ig) //loop over species
267  {
268  RealType tauovermass = Tau * MassInvS[ig];
269  RealType oneover2tau = 0.5 / (tauovermass);
270  RealType sqrttau = std::sqrt(tauovermass);
271  for (int iat = W.first(ig); iat < W.last(ig); ++iat)
272  {
273  //get the displacement
274  GradType grad_iat = Psi.evalGrad(W, iat);
275  PosType dr;
276  DriftModifier->getDrift(tauovermass, grad_iat, dr);
277  dr += sqrttau * deltaR[iat];
278  bool is_valid = W.makeMoveAndCheck(iat, dr);
279  RealType rr = tauovermass * dot(deltaR[iat], deltaR[iat]);
280  rr_proposed += rr;
281  if (!is_valid || rr > m_r2max)
282  {
283  W.accept_rejectMove(iat, false);
284  continue;
285  }
286  ValueType ratio = Psi.calcRatioGrad(W, iat, grad_iat);
287  //node is crossed reject the move
289  {
290  ++nNodeCrossing;
291  W.accept_rejectMove(iat, false);
292  Psi.rejectMove(iat);
293  }
294  else
295  {
296  RealType logGf = -0.5 * dot(deltaR[iat], deltaR[iat]);
297  //Use the force of the particle iat
298  DriftModifier->getDrift(tauovermass, grad_iat, dr);
299  dr = W.R[iat] - W.getActivePos() - dr;
300  RealType logGb = -oneover2tau * dot(dr, dr);
301  RealType prob = std::norm(ratio) * std::exp(logGb - logGf);
302  bool is_accepted = false;
303  if (RandomGen() < prob)
304  {
305  is_accepted = true;
306  ++nAcceptTemp;
307  Psi.acceptMove(W, iat, true);
308  rr_accepted += rr;
309  }
310  else
311  {
312  Psi.rejectMove(iat);
313  }
314  W.accept_rejectMove(iat, is_accepted);
315  }
316  }
317  }
320  W.donePbyP();
321  // In the rare case that all proposed moves fail, we bounce.
322  if (nAcceptTemp == 0)
323  {
324  ++nReject;
325  H.rejectedMove(W, prophead);
326  curhead.Age += 1;
327  W.reptile->flip();
328  }
329  prophead.R = W.R;
330  RealType logpsi = Psi.updateBuffer(W, w_buffer, false);
331  W.saveWalker(prophead);
332  Walker_t &lastbead(W.reptile->getTail()), nextlastbead(W.reptile->getNext());
333  RealType eloc = H.evaluate(W);
334  RealType dS = branchEngine->DMCLinkAction(eloc, curhead.Properties(WP::LOCALENERGY)) -
335  branchEngine->DMCLinkAction(lastbead.Properties(WP::LOCALENERGY), nextlastbead.Properties(WP::LOCALENERGY));
336  RealType acceptProb = std::min((RealType)1.0, std::exp(-dS));
337  if ((RandomGen() <= acceptProb) || (prophead.Age >= MaxAge || lastbead.Age >= MaxAge))
338  {
340  if (curhead.Age >= MaxAge || lastbead.Age >= MaxAge)
341  app_log() << "\tForce Acceptance...\n";
342 
343  prophead.Properties(WP::LOCALENERGY) = eloc;
344  prophead.Properties(WP::R2ACCEPTED) = rr_accepted;
345  prophead.Properties(WP::R2PROPOSED) = rr_proposed;
346  H.auxHevaluate(W, prophead, true, false); //evaluate properties? true. collectables? false.
347  H.saveProperty(prophead.getPropertyBase());
348  prophead.Age = 0;
349  overwriteWalker = prophead;
350  ++nAccept;
351  }
352  else
353  {
354  ++nReject;
355  H.rejectedMove(W, prophead);
356  curhead.Properties(WP::R2ACCEPTED) = 0;
357  curhead.Properties(WP::R2PROPOSED) = rr_proposed;
358  curhead.Age += 1;
359  W.reptile->flip();
360  // return;
361  }
362  //Collectables should be evaluated on center bead. Here we go.
363  Walker_t& centerbead = W.reptile->getCenter();
364  W.loadWalker(centerbead, true);
365  W.update(); //Called to recompute S(k) and distance tables.
366  H.auxHevaluate(W, centerbead, false, true); //evaluate properties? false. Collectables? true.
367 }
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
Walker_t & getTail()
Definition: Reptile.h:98
TrialWaveFunction & Psi
trial function
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false)
update the state with the new data
std::ostream & app_log()
Definition: OutputManager.h:65
void saveProperty(IT first)
save the values of Hamiltonian elements to the Properties
bool phaseChanged(RealType psi0) const
RealType DMCLinkAction(RealType enew, RealType eold) const
MCWalkerConfiguration::Walker_t Walker_t
Definition: QMCUpdateBase.h:44
Walker_t & getNewHead()
Definition: Reptile.h:128
int first(int igroup) const
return the first index of a group i
Definition: ParticleSet.h:514
void update(bool skipSK=false)
update the internal data
Walker_t & getCenter()
Definition: Reptile.h:100
ParticleSet::ParticlePos deltaR
temporary storage for random displacement
RealType updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false)
update all the wavefunction components in buffer.
T min(T a, T b)
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
QTBase::ValueType ValueType
Definition: Configuration.h:60
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)
Walker_t & getNext()
Definition: Reptile.h:99
MCWalkerConfiguration & W
walker ensemble
void loadWalker(Walker_t &awalker, bool pbyp)
load a Walker_t to the current ParticleSet
WalkerConfigurations::Walker_t Walker_t
void auxHevaluate(ParticleSet &P)
IndexType MaxAge
MaxAge>0 indicates branch is done.
Definition: QMCUpdateBase.h:61
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)
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
Walker_t & getHead()
Definition: Reptile.h:97
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_
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
std::vector< RealType > MassInvS
1/Mass per species
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...
const DriftModifierBase * DriftModifier
drift modifer, stateless reference to the one in QMCDriver
void makeGaussRandomWithEngine(ParticleAttrib< TinyVector< T, D >> &a, RG &rng)

◆ advanceWalkersVMC()

void advanceWalkersVMC ( )

Definition at line 124 of file RMCUpdatePbyP.cpp.

References ParticleSet::accept_rejectMove(), TrialWaveFunction::acceptMove(), RMCUpdatePbyPWithDrift::advance_timer_, Walker< t_traits, p_traits >::Age, QMCHamiltonian::auxHevaluate(), QMCUpdateBase::branchEngine, TrialWaveFunction::calcRatioGrad(), TrialWaveFunction::completeUpdates(), TrialWaveFunction::copyFromBuffer(), Walker< t_traits, p_traits >::DataSet, QMCUpdateBase::deltaR, ParticleSet::donePbyP(), qmcplusplus::dot(), QMCUpdateBase::DriftModifier, RMCUpdatePbyPWithDrift::energy_timer_, TrialWaveFunction::evalGrad(), QMCHamiltonian::evaluate(), qmcplusplus::exp(), ParticleSet::first(), ParticleSet::getActivePos(), Reptile::getCenter(), DriftModifierBase::getDrift(), Reptile::getHead(), Reptile::getNewHead(), 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(), QMCUpdateBase::MassInvS, RMCUpdatePbyPWithDrift::movepbyp_timer_, QMCUpdateBase::nAccept, QMCUpdateBase::nAllRejected, QMCUpdateBase::nNodeCrossing, norm(), QMCUpdateBase::nReject, SimpleFixedNodeBranch::phaseChanged(), Walker< t_traits, p_traits >::Properties, QMCUpdateBase::Psi, ParticleSet::R, Walker< t_traits, p_traits >::R, QMCUpdateBase::RandomGen, QMCHamiltonian::rejectedMove(), TrialWaveFunction::rejectMove(), MCWalkerConfiguration::reptile, Walker< t_traits, p_traits >::resetProperty(), QMCHamiltonian::saveProperty(), ParticleSet::saveWalker(), qmcplusplus::sqrt(), TimerType< CLOCK >::start(), TimerType< CLOCK >::stop(), QMCUpdateBase::Tau, ParticleSet::update(), RMCUpdatePbyPWithDrift::update_mbo_timer_, TrialWaveFunction::updateBuffer(), QMCUpdateBase::W, and Walker< t_traits, p_traits >::Weight.

Referenced by RMCUpdatePbyPWithDrift::advanceWalkers(), and RMCUpdatePbyPWithDrift::initWalkers().

125 {
127  Walker_t& curhead = W.reptile->getHead();
128  Walker_t prophead(curhead);
129  Walker_t::WFBuffer_t& w_buffer(prophead.DataSet);
130  W.loadWalker(prophead, true);
131  Psi.copyFromBuffer(W, w_buffer);
132  //create a 3N-Dimensional Gaussian with variance=1
134  int nAcceptTemp(0);
135  //copy the old energy and scale factor of drift
136  RealType eold(prophead.Properties(WP::LOCALENERGY));
137  RealType vqold(prophead.Properties(WP::DRIFTSCALE));
138  RealType enew(eold);
139  RealType rr_proposed = 0.0;
140  RealType rr_accepted = 0.0;
142  for (int ig = 0; ig < W.groups(); ++ig) //loop over species
143  {
144  RealType tauovermass = Tau * MassInvS[ig];
145  RealType oneover2tau = 0.5 / (tauovermass);
146  RealType sqrttau = std::sqrt(tauovermass);
147  for (int iat = W.first(ig); iat < W.last(ig); ++iat)
148  {
149  //get the displacement
150  GradType grad_iat = Psi.evalGrad(W, iat);
151  PosType dr;
152  DriftModifier->getDrift(tauovermass, grad_iat, dr);
153  dr += sqrttau * deltaR[iat];
154  bool is_valid = W.makeMoveAndCheck(iat, dr);
155  RealType rr = tauovermass * dot(deltaR[iat], deltaR[iat]);
156  rr_proposed += rr;
157  if (!is_valid || rr > m_r2max)
158  {
159  W.accept_rejectMove(iat, false);
160  continue;
161  }
162  ValueType ratio = Psi.calcRatioGrad(W, iat, grad_iat);
163  //node is crossed reject the move
165  {
166  ++nNodeCrossing;
167  W.accept_rejectMove(iat, false);
168  Psi.rejectMove(iat);
169  }
170  else
171  {
172  RealType logGf = -0.5 * dot(deltaR[iat], deltaR[iat]);
173  //Use the force of the particle iat
174  DriftModifier->getDrift(tauovermass, grad_iat, dr);
175  dr = W.R[iat] - W.getActivePos() - dr;
176  RealType logGb = -oneover2tau * dot(dr, dr);
177  RealType prob = std::norm(ratio) * std::exp(logGb - logGf);
178  bool is_accepted = false;
179  if (RandomGen() < prob)
180  {
181  is_accepted = true;
182  ++nAcceptTemp;
183  Psi.acceptMove(W, iat, true);
184  rr_accepted += rr;
185  }
186  else
187  {
188  Psi.rejectMove(iat);
189  }
190  W.accept_rejectMove(iat, is_accepted);
191  }
192  }
193  }
196  W.donePbyP();
197 
198  if (nAcceptTemp > 0)
199  {
200  //need to overwrite the walker properties
203  prophead.Age = 0;
204  prophead.R = W.R;
205  RealType logpsi = Psi.updateBuffer(W, w_buffer, false);
206  W.saveWalker(prophead);
209  enew = H.evaluate(W);
211  prophead.resetProperty(logpsi, Psi.getPhase(), enew, rr_accepted, rr_proposed, 0.0);
212  prophead.Weight = 1.0;
213  H.auxHevaluate(W, prophead, true, false); //evaluate properties but not collectables.
214  H.saveProperty(prophead.getPropertyBase());
215  newhead = prophead;
216  nAccept++;
217  }
218  else
219  {
220  //all moves are rejected: does not happen normally with reasonable wavefunctions
221  curhead.Age++;
222  curhead.Properties(WP::R2ACCEPTED) = 0.0;
223  //weight is set to 0 for traces
224  // consistent w/ no evaluate/auxHevaluate
225  RealType wtmp = prophead.Weight;
226  curhead.Weight = 0.0;
227  H.rejectedMove(W, curhead);
228  curhead.Weight = wtmp;
229  ++nAllRejected;
230  nReject++;
231  }
232  Walker_t& centerbead = W.reptile->getCenter();
233  W.loadWalker(centerbead, true);
234  W.update();
235  H.auxHevaluate(W, centerbead); //evaluate collectables but not properties.
236  // Traces->buffer_sample();
237 }
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
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
MCWalkerConfiguration::Walker_t Walker_t
Definition: QMCUpdateBase.h:44
Walker_t & getNewHead()
Definition: Reptile.h:128
int first(int igroup) const
return the first index of a group i
Definition: ParticleSet.h:514
void update(bool skipSK=false)
update the internal data
Walker_t & getCenter()
Definition: Reptile.h:100
ParticleSet::ParticlePos deltaR
temporary storage for random displacement
RealType updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false)
update all the wavefunction components in buffer.
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
QTBase::ValueType ValueType
Definition: Configuration.h:60
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
void loadWalker(Walker_t &awalker, bool pbyp)
load a Walker_t to the current ParticleSet
WalkerConfigurations::Walker_t Walker_t
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)
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
Walker_t & getHead()
Definition: Reptile.h:97
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_
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
std::vector< RealType > MassInvS
1/Mass per species
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 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)

◆ initWalkers()

void initWalkers ( WalkerIter_t  it,
WalkerIter_t  it_end 
)
overridevirtual

initialize Walker for walker update

Reimplemented from QMCUpdateBase.

Definition at line 240 of file RMCUpdatePbyP.cpp.

References RMCUpdatePbyPWithDrift::advanceWalkersVMC(), qmcplusplus::n, Reptile::nbeads, MCWalkerConfiguration::reptile, RMCUpdatePbyPWithDrift::vmcSteps, and QMCUpdateBase::W.

241 {
242  IndexType initsteps = W.reptile->nbeads * 2;
243 
244  vmcSteps = W.reptile->nbeads + 1;
245 
246  for (int n = 0; n < initsteps; n++)
248 }
MCWalkerConfiguration & W
walker ensemble
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65
IndexType nbeads
Definition: Reptile.h:59

◆ initWalkersForPbyP()

void initWalkersForPbyP ( WalkerIter_t  it,
WalkerIter_t  it_end 
)
overridevirtual

initialize Walker buffers for PbyP update

Reimplemented from QMCUpdateBase.

Definition at line 61 of file RMCUpdatePbyP.cpp.

References PooledMemory< T_scalar, Alloc >::allocate(), PooledMemory< T_scalar, Alloc >::clear(), TrialWaveFunction::copyFromBuffer(), Walker< t_traits, p_traits >::DataSet, ParticleSet::donePbyP(), QMCHamiltonian::evaluate(), TrialWaveFunction::evaluateLog(), ParticleSet::G, TrialWaveFunction::getPhase(), QMCUpdateBase::H, ParticleSet::L, Walker< t_traits, p_traits >::L, QMCUpdateBase::Psi, ParticleSet::R, Walker< t_traits, p_traits >::R, TrialWaveFunction::registerData(), Walker< t_traits, p_traits >::resetProperty(), PooledMemory< T_scalar, Alloc >::rewind(), PooledMemory< T_scalar, Alloc >::size(), ParticleSet::update(), TrialWaveFunction::updateBuffer(), QMCUpdateBase::UpdatePbyP, and QMCUpdateBase::W.

62 {
63  UpdatePbyP = true;
64 
65  for (; it != it_end; ++it)
66  {
67  Walker_t& awalker = **it; //W.reptile->getHead();
68  W.R = awalker.R;
69  W.update(true);
70  W.donePbyP();
71  if (awalker.DataSet.size())
72  awalker.DataSet.clear();
73  awalker.DataSet.rewind();
74  Psi.registerData(W, awalker.DataSet);
75  awalker.DataSet.allocate();
76  Psi.copyFromBuffer(W, awalker.DataSet);
77  Psi.evaluateLog(W);
78  RealType logpsi = Psi.updateBuffer(W, awalker.DataSet, false);
79  awalker.G = W.G;
80  awalker.L = W.L;
81  RealType eloc = H.evaluate(W);
82  awalker.resetProperty(logpsi, Psi.getPhase(), eloc);
83  }
84 }
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
void copyFromBuffer(ParticleSet &P, WFBufferType &buf)
copy all the wavefunction components from buffer.
TrialWaveFunction & Psi
trial function
MCWalkerConfiguration::Walker_t Walker_t
Definition: QMCUpdateBase.h:44
void update(bool skipSK=false)
update the internal data
ParticleLaplacian L
laplacians of the particles
Definition: ParticleSet.h:85
RealType updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false)
update all the wavefunction components in buffer.
ParticleGradient G
gradients of the particles
Definition: ParticleSet.h:83
void registerData(ParticleSet &P, WFBufferType &buf)
register all the wavefunction components in buffer.
ParticlePos R
Position.
Definition: ParticleSet.h:79
MCWalkerConfiguration & W
walker ensemble
QMCTraits::RealType RealType
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
QMCHamiltonian & H
Hamiltonian.
void donePbyP(bool skipSK=false)
update structure factor and unmark active_ptcl_
bool UpdatePbyP
update particle-by-particle

◆ operator=()

RMCUpdatePbyPWithDrift& operator= ( const RMCUpdatePbyPWithDrift )
privatedelete

Copy operator (disabled).

◆ put()

bool put ( xmlNodePtr  cur)
overridevirtual

process options

Reimplemented from QMCUpdateBase.

Definition at line 86 of file RMCUpdatePbyP.cpp.

References RMCUpdatePbyPWithDrift::actionType, ParameterSet::add(), qmcplusplus::app_log(), RMCUpdatePbyPWithDrift::DMC_ACTION, RMCUpdatePbyPWithDrift::equilSteps, omp_get_thread_num(), ParameterSet::put(), and QMCUpdateBase::put().

87 {
88  QMCUpdateBase::put(cur);
89 
90  ParameterSet m_param;
91  bool usedrift = true;
92  std::string action = "SLA";
93  m_param.add(usedrift, "useDrift");
94  m_param.add(action, "Action");
95  m_param.add(equilSteps, "equilsteps");
96  m_param.add(equilSteps, "equilSteps");
97  m_param.put(cur);
98 
99  if (usedrift == true)
100  {
101  if (omp_get_thread_num() == 0)
102  app_log() << " Using Umrigar scaled drift\n";
103  }
104  else
105  {
106  if (omp_get_thread_num() == 0)
107  app_log() << " Using non-scaled drift\n";
108  }
109 
110  if (action == "DMC")
111  {
113  if (omp_get_thread_num() == 0)
114  app_log() << " Using DMC link-action\n";
115  }
116  else
117  {
118  if (omp_get_thread_num() == 0)
119  app_log() << " Using Symmetrized Link-Action\n";
120  }
121 
122  return true;
123 }
std::ostream & app_log()
Definition: OutputManager.h:65
virtual bool put(xmlNodePtr cur)
process options
bool put(std::istream &is) override
read from std::istream
Definition: ParameterSet.h:42
omp_int_t omp_get_thread_num()
Definition: OpenMP.h:25
class to handle a set of parameters
Definition: ParameterSet.h:27
void add(PDT &aparam, const std::string &aname_in, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new parameter corresponding to an xmlNode <parameter>

Member Data Documentation

◆ Action

std::vector<int> Action
private

Definition at line 58 of file RMCUpdatePbyP.h.

◆ actionType

IndexType actionType
private

◆ advance_timer_

NewTimer& advance_timer_
private

Definition at line 62 of file RMCUpdatePbyP.h.

Referenced by RMCUpdatePbyPWithDrift::advanceWalkersVMC().

◆ energy_timer_

NewTimer& energy_timer_
private

Definition at line 65 of file RMCUpdatePbyP.h.

Referenced by RMCUpdatePbyPWithDrift::advanceWalkersVMC().

◆ equilSteps

IndexType equilSteps
private

Definition at line 68 of file RMCUpdatePbyP.h.

Referenced by RMCUpdatePbyPWithDrift::put().

◆ equilToDoSteps

IndexType equilToDoSteps
private

Definition at line 70 of file RMCUpdatePbyP.h.

◆ movepbyp_timer_

NewTimer& movepbyp_timer_
private

◆ scaleDrift

bool scaleDrift
private

Definition at line 59 of file RMCUpdatePbyP.h.

Referenced by RMCUpdatePbyPWithDrift::RMCUpdatePbyPWithDrift().

◆ TransProb

std::vector<int> TransProb
private

Definition at line 58 of file RMCUpdatePbyP.h.

◆ update_mbo_timer_

NewTimer& update_mbo_timer_
private

Definition at line 64 of file RMCUpdatePbyP.h.

Referenced by RMCUpdatePbyPWithDrift::advanceWalkersVMC().

◆ vmcSteps

IndexType vmcSteps
private

Definition at line 67 of file RMCUpdatePbyP.h.

Referenced by RMCUpdatePbyPWithDrift::initWalkers().

◆ vmcToDoSteps

IndexType vmcToDoSteps
private

Definition at line 69 of file RMCUpdatePbyP.h.

◆ qmcplusplus::SOVMCUpdateAll

class qmcplusplus::SOVMCUpdateAll


Implements the Spin VMC algorithm using particle-by-particle move.

Definition at line 19 of file SOVMCUpdateAll.h.

+ Inheritance diagram for SOVMCUpdateAll:
+ Collaboration diagram for SOVMCUpdateAll:

Public Member Functions

 SOVMCUpdateAll (MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, RandomBase< FullPrecRealType > &rg)
 Constructor. More...
 
 ~SOVMCUpdateAll () override
 
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 Member Functions

 SOVMCUpdateAll (const SOVMCUpdateAll &)=delete
 Copy Constructor (disabled) More...
 
SOVMCUpdateAlloperator= (const SOVMCUpdateAll &)=delete
 Copy operator (disabled). More...
 

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
 

Constructor & Destructor Documentation

◆ SOVMCUpdateAll() [1/2]

Constructor.

Definition at line 24 of file SOVMCUpdateAll.cpp.

References QMCUpdateBase::UpdatePbyP.

28  : QMCUpdateBase(w, psi, h, rg)
29 {
30  UpdatePbyP = false;
31 }
QMCUpdateBase(MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, RandomBase< FullPrecRealType > &rg)
Constructor.
bool UpdatePbyP
update particle-by-particle

◆ ~SOVMCUpdateAll()

~SOVMCUpdateAll ( )
override

Definition at line 33 of file SOVMCUpdateAll.cpp.

33 {}

◆ SOVMCUpdateAll() [2/2]

SOVMCUpdateAll ( const SOVMCUpdateAll )
privatedelete

Copy Constructor (disabled)

Member Function Documentation

◆ advanceWalker()

void advanceWalker ( Walker_t thisWalker,
bool  recompute 
)
overridevirtual

move a walker

Implements QMCUpdateBase.

Definition at line 35 of file SOVMCUpdateAll.cpp.

References Walker< t_traits, p_traits >::Age, APP_ABORT, QMCHamiltonian::auxHevaluate(), QMCUpdateBase::deltaR, QMCUpdateBase::deltaS, QMCHamiltonian::evaluate(), TrialWaveFunction::evaluateLog(), qmcplusplus::exp(), TrialWaveFunction::getPhase(), Walker< t_traits, p_traits >::getPropertyBase(), QMCUpdateBase::H, ParticleSet::loadWalker(), qmcplusplus::makeGaussRandomWithEngine(), ParticleSet::makeMoveAllParticles(), QMCUpdateBase::nAccept, QMCUpdateBase::nReject, QMCUpdateBase::nSubSteps, Walker< t_traits, p_traits >::Properties, QMCUpdateBase::Psi, ParticleSet::R, Walker< t_traits, p_traits >::R, QMCUpdateBase::RandomGen, Walker< t_traits, p_traits >::resetProperty(), QMCHamiltonian::saveProperty(), ParticleSet::saveWalker(), QMCUpdateBase::spinMass, ParticleSet::spins, Walker< t_traits, p_traits >::spins, qmcplusplus::sqrt(), QMCUpdateBase::SqrtTauOverMass, ParticleSet::update(), QMCUpdateBase::UseDrift, and QMCUpdateBase::W.

36 {
37  /* thisWalker.R will track the last accepted configuration
38  * W.R will track the proposed configuration
39  *
40  * upon Call:
41  * thisWalker.R,G,L,Properties must be consistent
42  * recompute flag is for pbyp driver and is not used here
43  *
44  * upon Return:
45  * thisWalker.R,G,L,Properties must be kept consistent
46  * */
47  bool updated = false;
48  W.loadWalker(
49  thisWalker,
50  false); // W.R,G,L = thisWalker.R,G,L; false indicates W.DistTables & SK are not updated in this call. W.DistTables,SK are now stale.
51  RealType logpsi_old = thisWalker.Properties(WP::LOGPSI);
52 
53  RealType invSqrtSpinMass = 1.0 / std::sqrt(spinMass);
54 
55  for (int iter = 0; iter < nSubSteps; ++iter)
56  { // make a few Monte-Carlo steps to decorrelate samples without calculating observables
59  updated = false;
60  if (UseDrift)
61  {
62  APP_ABORT("All-electron spin moves with drift are not implemented\n");
63  }
64  else
65  {
66  if (W.makeMoveAllParticles(thisWalker, deltaR, SqrtTauOverMass))
67  {
68  //Assume that since the spatial move is fine, the spin move will be.
69  //Compute that now.
70  for (int iat = 0; iat < deltaR.size(); ++iat)
71  W.spins[iat] = thisWalker.spins[iat] + invSqrtSpinMass * SqrtTauOverMass[iat] * deltaS[iat];
72 
73  // W.R += dR*dt; W.DistTables,SK are updated; W.G,L are now stale
74  RealType logpsi = Psi.evaluateLog(W); // update W.G,L at changed W.R; update Psi.log_real_,PhaseValue
75  RealType g = std::exp(2.0 * (logpsi - logpsi_old));
76  if (RandomGen() <= g)
77  { // move is accepted; logpsi_old and R_old are stale
78  logpsi_old = logpsi; // update logpsi_old
79  thisWalker.R = W.R; // update R_old; side effect: thisWalker.G,L,DistTables,SK,Properties are now stale
80  thisWalker.spins =
81  W.spins; // update R_old; side effect: thisWalker.G,L,DistTables,SK,Properties are now stale
82  ++nAccept;
83  updated = true;
84  }
85  }
86  }
87 
88  if (!updated)
89  { // W.R,G,L,DistTables,SK are not updated. i.e. they are still consistent
90  thisWalker.Age++;
91  ++nReject;
92  }
93  }
94 
95  if (!updated)
96  { // W.G and W.L have to be computed because the last move was rejected
97  W.loadWalker(thisWalker, false); // move W back to last accepted configuration
98  W.update(); // update W.DistTables and SK
99  logpsi_old = Psi.evaluateLog(W); // update W.G,L
100  } // W and logpsi_old are up-to-date at this point
101 
102  RealType eloc = H.evaluate(
103  W); // calculate local energy; W.SK must be up-to-date if Coulomb interaction is used with periodic boundary. W.SK is used to calculate the long-range part of the Coulomb potential.
104  W.saveWalker(thisWalker);
105  thisWalker.resetProperty(logpsi_old, Psi.getPhase(),
106  eloc); // update thisWalker::Properties[WP::LOGPSI,WP::SIGN,WP::LOCALENERGY]
107  H.auxHevaluate(W, thisWalker); // update auxiliary observables, i.e. fill H::Observables
108  H.saveProperty(thisWalker.getPropertyBase()); // copy H::Observables to thisWalker::Properties
109 }
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
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
ParticleSet::ParticleScalar deltaS
temporart storage for spin displacement
void saveProperty(IT first)
save the values of Hamiltonian elements to the Properties
void update(bool skipSK=false)
update the internal data
ParticleSet::ParticlePos deltaR
temporary storage for random displacement
std::vector< RealType > SqrtTauOverMass
sqrt(tau/Mass) per particle
void saveWalker(Walker_t &awalker)
save this to awalker
ParticlePos R
Position.
Definition: ParticleSet.h:79
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
MCWalkerConfiguration & W
walker ensemble
void loadWalker(Walker_t &awalker, bool pbyp)
load a Walker_t to the current ParticleSet
void auxHevaluate(ParticleSet &P)
int nSubSteps
number of steps per measurement
Definition: QMCUpdateBase.h:56
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
QMCTraits::RealType RealType
RandomBase< FullPrecRealType > & RandomGen
random number generator
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
IndexType nAccept
counter for number of moves accepted
Definition: QMCUpdateBase.h:63
IndexType nReject
counter for number of moves rejected
Definition: QMCUpdateBase.h:65
bool makeMoveAllParticles(const Walker_t &awalker, const ParticlePos &deltaR, RealType dt)
move all the particles of a walker
QMCHamiltonian & H
Hamiltonian.
void makeGaussRandomWithEngine(ParticleAttrib< TinyVector< T, D >> &a, RG &rng)

◆ operator=()

SOVMCUpdateAll& operator= ( const SOVMCUpdateAll )
privatedelete

Copy operator (disabled).

◆ qmcplusplus::SOVMCUpdatePbyP

class qmcplusplus::SOVMCUpdatePbyP


Implements the VMC algorithm using particle-by-particle move, including spin-moves

Definition at line 22 of file SOVMCUpdatePbyP.h.

+ Inheritance diagram for SOVMCUpdatePbyP:
+ Collaboration diagram for SOVMCUpdatePbyP:

Public Member Functions

 SOVMCUpdatePbyP (MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, RandomBase< FullPrecRealType > &rg)
 Constructor. More...
 
 ~SOVMCUpdatePbyP () override
 
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

NewTimerbuffer_timer_
 
NewTimermovepbyp_timer_
 
NewTimerhamiltonian_timer_
 
NewTimercollectables_timer_
 

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
 

Constructor & Destructor Documentation

◆ SOVMCUpdatePbyP()

Constructor.

Definition at line 26 of file SOVMCUpdatePbyP.cpp.

30  : QMCUpdateBase(w, psi, h, rg),
31  buffer_timer_(createGlobalTimer("SOVMCUpdatePbyP::Buffer", timer_level_medium)),
32  movepbyp_timer_(createGlobalTimer("SOVMCUpdatePbyP::MovePbyP", timer_level_medium)),
33  hamiltonian_timer_(createGlobalTimer("SOVMCUpdatePbyP::Hamiltonian", timer_level_medium)),
34  collectables_timer_(createGlobalTimer("SOVMCUpdatePbyP::Collectables", timer_level_medium))
35 {}
NewTimer & createGlobalTimer(const std::string &myname, timer_levels mylevel)
QMCUpdateBase(MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, RandomBase< FullPrecRealType > &rg)
Constructor.

◆ ~SOVMCUpdatePbyP()

~SOVMCUpdatePbyP ( )
override

Definition at line 37 of file SOVMCUpdatePbyP.cpp.

37 {}

Member Function Documentation

◆ advanceWalker()

void advanceWalker ( Walker_t thisWalker,
bool  recompute 
)
overridevirtual

move a walker

Implements QMCUpdateBase.

Definition at line 39 of file SOVMCUpdatePbyP.cpp.

References ParticleSet::accept_rejectMove(), TrialWaveFunction::acceptMove(), QMCHamiltonian::auxHevaluate(), TraceManager::buffer_sample(), SOVMCUpdatePbyP::buffer_timer_, TrialWaveFunction::calcRatio(), TrialWaveFunction::calcRatioGradWithSpin(), qmcplusplus::CHECKGL_AFTER_MOVES, QMCUpdateBase::checkLogAndGL(), SOVMCUpdatePbyP::collectables_timer_, 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::evaluate(), qmcplusplus::exp(), ParticleSet::first(), ParticleSet::getActivePos(), ParticleSet::getActiveSpinVal(), DriftModifierBase::getDrift(), TrialWaveFunction::getPhase(), Walker< t_traits, p_traits >::getPropertyBase(), ParticleSet::groups(), QMCUpdateBase::H, SOVMCUpdatePbyP::hamiltonian_timer_, ParticleSet::last(), ParticleSet::loadWalker(), qmcplusplus::makeGaussRandomWithEngine(), ParticleSet::makeMoveAndCheckWithSpin(), QMCUpdateBase::MassInvS, SOVMCUpdatePbyP::movepbyp_timer_, QMCUpdateBase::nAccept, QMCUpdateBase::nAllRejected, norm(), QMCUpdateBase::nReject, QMCUpdateBase::nSubSteps, TrialWaveFunction::prepareGroup(), QMCUpdateBase::Psi, ParticleSet::R, QMCUpdateBase::RandomGen, TrialWaveFunction::rejectMove(), Walker< t_traits, p_traits >::resetProperty(), QMCHamiltonian::saveProperty(), ParticleSet::saveWalker(), QMCUpdateBase::spinMass, ParticleSet::spins, qmcplusplus::sqrt(), TimerType< CLOCK >::start(), TimerType< CLOCK >::stop(), QMCUpdateBase::Tau, QMCUpdateBase::Traces, TrialWaveFunction::updateBuffer(), QMCUpdateBase::UseDrift, and QMCUpdateBase::W.

40 {
42  W.loadWalker(thisWalker, true);
43  Walker_t::WFBuffer_t& w_buffer(thisWalker.DataSet);
44  Psi.copyFromBuffer(W, w_buffer);
46 
47  // start PbyP moves
49  bool moved = false;
50  constexpr RealType mhalf(-0.5);
51  for (int iter = 0; iter < nSubSteps; ++iter)
52  {
53  //create a 3N-Dimensional Gaussian with variance=1
56  moved = false;
57  for (int ig = 0; ig < W.groups(); ++ig) //loop over species
58  {
59  RealType tauovermass = Tau * MassInvS[ig];
60  RealType oneover2tau = 0.5 / (tauovermass);
61  RealType sqrttau = std::sqrt(tauovermass);
62  Psi.prepareGroup(W, ig);
63  for (int iat = W.first(ig); iat < W.last(ig); ++iat)
64  {
65  PosType dr;
67  if (UseDrift)
68  {
69  ComplexType spingrad_now;
70  GradType grad_now = Psi.evalGradWithSpin(W, iat, spingrad_now);
71  DriftModifier->getDrift(tauovermass, grad_now, dr);
72  DriftModifier->getDrift(tauovermass / spinMass, spingrad_now, ds);
73  dr += sqrttau * deltaR[iat];
74  ds += std::sqrt(tauovermass / spinMass) * deltaS[iat];
75  }
76  else
77  {
78  dr = sqrttau * deltaR[iat];
79  ds = std::sqrt(tauovermass / spinMass) * deltaS[iat];
80  }
81  if (!W.makeMoveAndCheckWithSpin(iat, dr, ds))
82  {
83  ++nReject;
84  W.accept_rejectMove(iat, false);
85  continue;
86  }
87  RealType prob(0);
88  if (UseDrift)
89  {
90  GradType grad_new;
91  ComplexType spingrad_new;
92  prob = std::norm(Psi.calcRatioGradWithSpin(W, iat, grad_new, spingrad_new));
93  DriftModifier->getDrift(tauovermass, grad_new, dr);
94  dr = W.R[iat] - W.getActivePos() - dr;
95  RealType logGb = -oneover2tau * dot(dr, dr);
96  RealType logGf = mhalf * dot(deltaR[iat], deltaR[iat]);
97 
98  DriftModifier->getDrift(tauovermass / spinMass, spingrad_new, ds);
99  ds = W.spins[iat] - W.getActiveSpinVal() - ds;
100  logGb += -spinMass * oneover2tau * ds * ds;
101  logGf += mhalf * deltaS[iat] * deltaS[iat];
102 
103  prob *= std::exp(logGb - logGf);
104  }
105  else
106  {
107  prob = std::norm(Psi.calcRatio(W, iat));
108  }
109 
110  bool is_accepted = false;
111  if (prob >= std::numeric_limits<RealType>::epsilon() && RandomGen() < prob)
112  {
113  is_accepted = true;
114  moved = true;
115  ++nAccept;
116  Psi.acceptMove(W, iat, true);
117  }
118  else
119  {
120  ++nReject;
121  Psi.rejectMove(iat);
122  }
123  W.accept_rejectMove(iat, is_accepted);
124  }
125  }
127  }
128  W.donePbyP();
131  RealType logpsi = Psi.updateBuffer(W, w_buffer, recompute);
133  checkLogAndGL(W, Psi, "checkGL_after_moves");
134  W.saveWalker(thisWalker);
136  // end PbyP moves
138  FullPrecRealType eloc = H.evaluate(W);
139  thisWalker.resetProperty(logpsi, Psi.getPhase(), eloc);
142  H.auxHevaluate(W, thisWalker);
143  H.saveProperty(thisWalker.getPropertyBase());
145 #if !defined(REMOVE_TRACEMANAGER)
147 #endif
148  if (!moved)
149  ++nAllRejected;
150 }
TraceManager * Traces
traces
void rejectMove(int iat)
restore to the original state
ValueType calcRatio(ParticleSet &P, int iat, ComputeType ct=ComputeType::ALL)
compute psi(R_new) / psi(R_current) ratio It returns a complex value if the wavefunction is complex...
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
void buffer_sample(int current_step)
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
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
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)
int nSubSteps
number of steps per measurement
Definition: QMCUpdateBase.h:56
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
QMCTraits::RealType RealType
RandomBase< FullPrecRealType > & RandomGen
random number generator
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
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
QMCHamiltonian & H
Hamiltonian.
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 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

◆ buffer_timer_

NewTimer& buffer_timer_
private

Definition at line 36 of file SOVMCUpdatePbyP.h.

Referenced by SOVMCUpdatePbyP::advanceWalker().

◆ collectables_timer_

NewTimer& collectables_timer_
private

Definition at line 39 of file SOVMCUpdatePbyP.h.

Referenced by SOVMCUpdatePbyP::advanceWalker().

◆ hamiltonian_timer_

NewTimer& hamiltonian_timer_
private

Definition at line 38 of file SOVMCUpdatePbyP.h.

Referenced by SOVMCUpdatePbyP::advanceWalker().

◆ movepbyp_timer_

NewTimer& movepbyp_timer_
private

Definition at line 37 of file SOVMCUpdatePbyP.h.

Referenced by SOVMCUpdatePbyP::advanceWalker().

◆ qmcplusplus::VMC

class qmcplusplus::VMC


Implements a VMC using particle-by-particle move.

Threaded execution.

Definition at line 24 of file VMC.h.

+ Inheritance diagram for VMC:
+ Collaboration diagram for VMC:

Public Member Functions

 VMC (const ProjectData &project_data_, MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, UPtrVector< RandomBase< QMCTraits::FullPrecRealType >> &rngs, Communicate *comm, bool enable_profiling)
 Constructor. More...
 
bool run () override
 
bool put (xmlNodePtr cur) override
 
QMCRunType getRunType () override
 
- Public Member Functions inherited from QMCDriver
 QMCDriver (const ProjectData &project_data, MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, Communicate *comm, const std::string &QMC_driver_type, bool enable_profiling=false)
 Constructor. More...
 
 ~QMCDriver () override
 
int current () const
 return current step More...
 
void setUpdateMode (bool pbyp) override
 set the update mode More...
 
void setStatus (const std::string &aname, const std::string &h5name, bool append) override
 Set the status of the QMCDriver. More...
 
void add_H_and_Psi (QMCHamiltonian *h, TrialWaveFunction *psi) override
 add QMCHamiltonian/TrialWaveFunction pair for multiple More...
 
void process (xmlNodePtr cur) override
 initialize with xmlNode More...
 
xmlNodePtr getQMCNode ()
 return a xmlnode with update More...
 
void putWalkers (std::vector< xmlNodePtr > &wset) override
 Read walker configurations from *.config.h5 files. More...
 
void putTraces (xmlNodePtr txml) override
 
void requestTraces (bool traces) override
 
void putWalkerLogs (xmlNodePtr wlxml) override
 
void requestWalkerLogs (bool allow_walker_logs_) override
 
std::string getEngineName () override
 
template<class PDT >
void setValue (const std::string &aname, PDT x)
 
void setBranchEngine (std::unique_ptr< BranchEngineType > &&be) override
 set the BranchEngineType More...
 
std::unique_ptr< BranchEngineTypegetBranchEngine () override
 return BranchEngineType* More...
 
int addObservable (const std::string &aname)
 
RealType getObservable (int i)
 
void setTau (RealType i)
 
void setWalkerOffsets ()
 set global offsets of the walkers More...
 
RefVector< RandomBase< FullPrecRealType > > getRngRefs () const
 return the random generators More...
 
RandomBase< FullPrecRealType > & getRng (int i) override
 return the i-th random generator More...
 
unsigned long getDriverMode () override
 
- Public Member Functions inherited from QMCDriverInterface
virtual ~QMCDriverInterface ()
 
virtual void setBranchEngine (std::unique_ptr< BranchEngineType > &&be)
 
- Public Member Functions inherited from MPIObjectBase
 MPIObjectBase (Communicate *c)
 constructor with communicator More...
 
int rank () const
 return the rank of the communicator More...
 
int getGroupID () const
 return the group id of the communicator More...
 
CommunicategetCommunicator () const
 return myComm More...
 
CommunicategetCommRef () const
 return a TEMPORARY reference to Communicate More...
 
mpi_comm_type getMPI () const
 return MPI communicator if one wants to use MPI directly More...
 
bool is_manager () const
 return true if the rank == 0 More...
 
const std::string & getName () const
 return the name More...
 
void setName (const std::string &aname)
 
- Public Member Functions inherited from CloneManager
 CloneManager ()
 Constructor. More...
 
virtual ~CloneManager ()
 virtual destructor More...
 
void makeClones (MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &ham)
 
void makeClones (MCWalkerConfiguration &w, std::vector< TrialWaveFunction *> &psi, std::vector< QMCHamiltonian *> &ham)
 
void makeClones (MCWalkerConfiguration &wg, TrialWaveFunction &guide)
 
void makeClones (TrialWaveFunction &guide)
 
RealType acceptRatio () const
 

Private Member Functions

void resetRun ()
 check the run-time environments More...
 
 VMC (const VMC &)=delete
 copy constructor More...
 
VMCoperator= (const VMC &)=delete
 Copy operator (disabled). More...
 

Private Attributes

int prevSteps
 
int prevStepsBetweenSamples
 
std::string UseDrift
 option to enable/disable drift equation or RN for VMC More...
 
UPtrVector< RandomBase< QMCTraits::FullPrecRealType > > & rngs_
 

Additional Inherited Members

- Public Types inherited from QMCDriver
enum  { QMC_UPDATE_MODE, QMC_MULTIPLE, QMC_OPTIMIZE, QMC_WARMUP }
 enumeration coupled with QMCMode More...
 
using Walker_t = MCWalkerConfiguration::Walker_t
 
using Buffer_t = Walker_t::Buffer_t
 
using FullPrecRealType = QMCTraits::FullPrecRealType
 
- Public Types inherited from QMCDriverInterface
using BranchEngineType = SimpleFixedNodeBranch
 
using FullPrecRealType = QMCTraits::FullPrecRealType
 
- 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 Types inherited from MPIObjectBase
using mpi_comm_type = Communicate::mpi_comm_type
 
- Static Public Member Functions inherited from CloneManager
static void clearClones ()
 
- Public Attributes inherited from QMCDriver
std::bitset< QMC_MODE_MAXqmc_driver_mode
 bits to classify QMCDriver More...
 
bool allow_traces
 whether to allow traces More...
 
xmlNodePtr traces_xml
 traces xml More...
 
bool allow_walker_logs
 whether to allow traces More...
 
xmlNodePtr walker_logs_xml
 traces xml More...
 
EstimatorManagerBaseEstimators
 Observables manager. More...
 
std::unique_ptr< TraceManagerTraces
 Traces manager. More...
 
std::unique_ptr< WalkerLogManagerwlog_manager_
 Traces manager. More...
 
- Protected Member Functions inherited from QMCDriver
bool putQMCInfo (xmlNodePtr cur)
 Parses the xml input file for parameter definitions for a single qmc simulation. More...
 
void addWalkers (int nwalkers)
 Add walkers to the end of the ensemble of walkers. More...
 
void recordBlock (int block) override
 record the state of the block More...
 
bool finalize (int block, bool dumpwalkers=true)
 finalize a qmc section More...
 
std::string getRotationName (std::string RootName)
 
std::string getLastRotationName (std::string RootName)
 
const std::string & get_root_name () const override
 
- Protected Member Functions inherited from CloneManager
RefVector< WalkerLogCollectorgetWalkerLogCollectorRefs ()
 
- Protected Attributes inherited from QMCDriver
const ProjectDataproject_data_
 top-level project data information More...
 
std::unique_ptr< BranchEngineTypebranchEngine
 branch engine More...
 
DriftModifierBaseDriftModifier
 drift modifer More...
 
bool ResetRandom
 randomize it More...
 
bool AppendRun
 flag to append or restart the run More...
 
bool DumpConfig
 flag to turn off dumping configurations More...
 
bool IsQMCDriver
 true, if it is a real QMC engine More...
 
int MyCounter
 the number of times this QMCDriver is executed More...
 
int kDelay
 the number to delay updates by More...
 
int Period4CheckPoint
 period of dumping walker configurations and everything else for restart More...
 
int Period4CheckProperties
 period of dumping walker positions and IDs for Forward Walking More...
 
int Period4WalkerDump
 period of recording walker configurations More...
 
int Period4ConfigDump
 period of recording walker positions and IDs for forward walking afterwards More...
 
IndexType CurrentStep
 current step More...
 
IndexType nBlocks
 maximum number of blocks More...
 
IndexType nSteps
 maximum number of steps More...
 
IndexType nSubSteps
 number of steps between a step: VMCs do not evaluate energies More...
 
IndexType nWarmupSteps
 number of warmup steps More...
 
IndexType nAccept
 counter for number of moves accepted More...
 
IndexType nReject
 counter for number of moves /rejected More...
 
IndexType nBlocksBetweenRecompute
 the number of blocks between recomptePsi More...
 
IndexType nTargetWalkers
 the number of walkers More...
 
IndexType nTargetSamples
 the number of saved samples More...
 
IndexType nStepsBetweenSamples
 alternate method of setting QMC run parameters More...
 
RealType nSamplesPerThread
 samples per thread More...
 
RealType nTargetPopulation
 target population More...
 
RealType Tau
 timestep More...
 
int MaxCPUSecs
 maximum cpu in secs More...
 
RealType m_oneover2tau
 Time-step factor $ 1/(2\tau)$. More...
 
RealType m_sqrttau
 Time-step factor $ \sqrt{\tau}$. More...
 
xmlNodePtr qmcNode
 pointer to qmc node in xml file More...
 
const std::string QMCType
 type of QMC driver More...
 
std::string h5FileRoot
 the root of h5File More...
 
std::string RootName
 root of all the output files More...
 
ParameterSet m_param
 store any parameter that has to be read from a file More...
 
MCWalkerConfigurationW
 walker ensemble More...
 
TrialWaveFunctionPsi
 trial function More...
 
QMCHamiltonianH
 Hamiltonian. More...
 
std::unique_ptr< HDFWalkerOutputwOut
 record engine for walkers More...
 
std::vector< TrialWaveFunction * > Psi1
 a list of TrialWaveFunctions for multiple method More...
 
std::vector< QMCHamiltonian * > H1
 a list of QMCHamiltonians for multiple method More...
 
UPtrVector< RandomBase< FullPrecRealType > > Rng
 Random number generators. More...
 
std::vector< xmlNodePtr > mcwalkerNodePtr
 a list of mcwalkerset element More...
 
ParticleSet::ParticlePos drift
 temporary storage for drift More...
 
ParticleSet::ParticlePos deltaR
 temporary storage for random displacement More...
 
RealType SpinMass
 spin mass for spinor calcs More...
 
int rotation
 
- Protected Attributes inherited from MPIObjectBase
CommunicatemyComm
 pointer to Communicate More...
 
std::string ClassName
 class Name More...
 
std::string myName
 name of the object More...
 
- Protected Attributes inherited from CloneManager
const IndexType NumThreads
 number of threads More...
 
std::vector< QMCUpdateBase * > Movers
 update engines More...
 
std::vector< EstimatorManagerBase * > estimatorClones
 estimator managers More...
 
std::vector< TraceManager * > traceClones
 trace managers More...
 
UPtrVector< WalkerLogCollectorwlog_collectors
 trace collectors More...
 
UPtrVector< CSUpdateBaseCSMovers
 
std::vector< int > wPerRank
 Walkers per MPI rank. More...
 
- Static Protected Attributes inherited from CloneManager
static UPtrVector< MCWalkerConfigurationwClones_uptr
 walkers More...
 
static std::vector< MCWalkerConfiguration * > wClones
 
static UPtrVector< MCWalkerConfigurationwgClones
 
static UPtrVector< TrialWaveFunctionpsiClones_uptr
 trial wavefunctions More...
 
static std::vector< TrialWaveFunction * > psiClones
 
static UPtrVector< TrialWaveFunctionguideClones_uptr
 guide wavefunctions More...
 
static std::vector< TrialWaveFunction * > guideClones
 
static UPtrVector< QMCHamiltonianhClones_uptr
 Hamiltonians. More...
 
static std::vector< QMCHamiltonian * > hClones
 
static std::vector< UPtrVector< MCWalkerConfiguration > > WPoolClones_uptr
 
static std::vector< std::vector< MCWalkerConfiguration * > > WPoolClones
 
static std::vector< UPtrVector< TrialWaveFunction > > PsiPoolClones_uptr
 
static std::vector< std::vector< TrialWaveFunction * > > PsiPoolClones
 
static std::vector< UPtrVector< QMCHamiltonian > > HPoolClones_uptr
 
static std::vector< std::vector< QMCHamiltonian * > > HPoolClones
 

Constructor & Destructor Documentation

◆ VMC() [1/2]

VMC ( const ProjectData project_data_,
MCWalkerConfiguration w,
TrialWaveFunction psi,
QMCHamiltonian h,
UPtrVector< RandomBase< QMCTraits::FullPrecRealType >> &  rngs,
Communicate comm,
bool  enable_profiling 
)

Constructor.

Definition at line 40 of file VMC.cpp.

References ParameterSet::add(), QMCDriver::m_param, QMCDriver::nSteps, QMCDriver::nStepsBetweenSamples, VMC::prevSteps, VMC::prevStepsBetweenSamples, QMCDriver::qmc_driver_mode, QMCDriver::QMC_UPDATE_MODE, QMCDriver::QMC_WARMUP, QMCDriver::RootName, and VMC::UseDrift.

47  : QMCDriver(project_data, w, psi, h, comm, "VMC", enable_profiling), UseDrift("yes"), rngs_(rngs)
48 {
49  RootName = "vmc";
52  m_param.add(UseDrift, "useDrift");
53  m_param.add(UseDrift, "usedrift");
54  m_param.add(UseDrift, "use_drift");
55 
56  prevSteps = nSteps;
58 }
QMCDriver(const ProjectData &project_data, MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, Communicate *comm, const std::string &QMC_driver_type, bool enable_profiling=false)
Constructor.
Definition: QMCDriver.cpp:44
int prevSteps
Definition: VMC.h:40
std::string RootName
root of all the output files
Definition: QMCDriver.h:317
int prevStepsBetweenSamples
Definition: VMC.h:41
UPtrVector< RandomBase< QMCTraits::FullPrecRealType > > & rngs_
Definition: VMC.h:46
ParameterSet m_param
store any parameter that has to be read from a file
Definition: QMCDriver.h:320
IndexType nSteps
maximum number of steps
Definition: QMCDriver.h:269
std::bitset< QMC_MODE_MAX > qmc_driver_mode
bits to classify QMCDriver
Definition: QMCDriver.h:93
void add(PDT &aparam, const std::string &aname_in, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new parameter corresponding to an xmlNode <parameter>
IndexType nStepsBetweenSamples
alternate method of setting QMC run parameters
Definition: QMCDriver.h:291
std::string UseDrift
option to enable/disable drift equation or RN for VMC
Definition: VMC.h:44

◆ VMC() [2/2]

VMC ( const VMC )
privatedelete

copy constructor

Member Function Documentation

◆ getRunType()

QMCRunType getRunType ( )
inlineoverridevirtual

Implements QMCDriverInterface.

Definition at line 37 of file VMC.h.

References qmcplusplus::VMC.

37 { return QMCRunType::VMC; }
VMC type: vmc, vmc-ptcl, vmc-multiple, vmc-ptcl-multiple.

◆ operator=()

VMC& operator= ( const VMC )
privatedelete

Copy operator (disabled).

◆ put()

bool put ( xmlNodePtr  cur)
overridevirtual

Implements QMCDriverInterface.

Definition at line 298 of file VMC.cpp.

References ParameterSet::add(), qmcplusplus::app_log(), qmcplusplus::ceil(), QMCDriver::CurrentStep, QMCDriver::DumpConfig, ParameterSet::get(), WalkerConfigurations::getActiveWalkers(), QMCDriver::m_param, MPIObjectBase::myComm, QMCDriver::MyCounter, QMCDriver::nBlocks, QMCDriver::nSamplesPerThread, QMCDriver::nSteps, QMCDriver::nStepsBetweenSamples, QMCDriver::nSubSteps, QMCDriver::nTargetPopulation, QMCDriver::nTargetSamples, omp_get_max_threads(), QMCDriver::Period4CheckPoint, QMCDriver::Period4WalkerDump, VMC::prevSteps, VMC::prevStepsBetweenSamples, ParameterSet::put(), qmcplusplus::qmc_common, QMCState::qmc_counter, Communicate::size(), QMCDriver::Tau, and QMCDriver::W.

299 {
300  //grep minimumTargetWalker
301  int target_min = -1;
302  ParameterSet p;
303  p.add(target_min, "minimumtargetwalkers"); //p.add(target_min,"minimumTargetWalkers");
304  p.add(target_min, "minimumsamples"); //p.add(target_min,"minimumSamples");
305  p.put(q);
306 
307  app_log() << "\n<vmc function=\"put\">"
308  << "\n qmc_counter=" << qmc_common.qmc_counter << " my_counter=" << MyCounter << std::endl;
309 
310 
312  {
313  nSteps = prevSteps;
315  }
316  else
317  {
318  int nw = W.getActiveWalkers();
319  //compute samples and overwrite steps for the given samples
320  int Nthreads = omp_get_max_threads();
321  int Nprocs = myComm->size();
322 
323 
324  //target samples set by samples or samplesperthread/dmcwalkersperthread
325  nTargetPopulation = std::max(nTargetPopulation, nSamplesPerThread * Nprocs * Nthreads);
326  nTargetSamples = static_cast<int>(std::ceil(nTargetPopulation));
327 
328  if (nTargetSamples)
329  {
330  int nwtot = nw * Nprocs; //total number of walkers used by this qmcsection
331  nTargetSamples = std::max(nwtot, nTargetSamples);
332  if (target_min > 0)
333  {
334  nTargetSamples = std::max(nTargetSamples, target_min);
335  nTargetPopulation = std::max(nTargetPopulation, static_cast<RealType>(target_min));
336  }
337  nTargetSamples = ((nTargetSamples + nwtot - 1) / nwtot) *
338  nwtot; // nTargetSamples are always multiples of total number of walkers
339  nSamplesPerThread = nTargetSamples / Nprocs / Nthreads;
340  int ns_target = nTargetSamples * nStepsBetweenSamples; //total samples to generate
341  int ns_per_step = Nprocs * nw; //total samples per step
342  nSteps = std::max(nSteps, (ns_target / ns_per_step + nBlocks - 1) / nBlocks);
344  }
345  else
346  {
347  Period4WalkerDump = nStepsBetweenSamples = (nBlocks + 1) * nSteps; //some positive number, not used
348  nSamplesPerThread = 0;
349  }
350  }
351  prevSteps = nSteps;
353 
354  app_log() << " time step = " << Tau << std::endl;
355  app_log() << " blocks = " << nBlocks << std::endl;
356  app_log() << " steps = " << nSteps << std::endl;
357  app_log() << " substeps = " << nSubSteps << std::endl;
358  app_log() << " current = " << CurrentStep << std::endl;
359  app_log() << " target samples = " << nTargetPopulation << std::endl;
360  app_log() << " walkers/mpi = " << W.getActiveWalkers() << std::endl << std::endl;
361  app_log() << " stepsbetweensamples = " << nStepsBetweenSamples << std::endl;
362 
363  m_param.get(app_log());
364 
365  if (DumpConfig)
366  {
367  app_log() << " DumpConfig==true Configurations are dumped to config.h5 with a period of " << Period4CheckPoint
368  << " blocks" << std::endl;
369  }
370  else
371  {
372  app_log() << " DumpConfig==false Nothing (configurations, state) will be saved." << std::endl;
373  }
374 
375  if (Period4WalkerDump > 0)
376  app_log() << " Walker Samples are dumped every " << Period4WalkerDump << " steps." << std::endl;
377 
378  app_log() << "</vmc>" << std::endl;
379  app_log().flush();
380 
381  return true;
382 }
size_t getActiveWalkers() const
return the number of active walkers
int prevSteps
Definition: VMC.h:40
bool DumpConfig
flag to turn off dumping configurations
Definition: QMCDriver.h:226
std::ostream & app_log()
Definition: OutputManager.h:65
RealType nSamplesPerThread
samples per thread
Definition: QMCDriver.h:293
int prevStepsBetweenSamples
Definition: VMC.h:41
IndexType CurrentStep
current step
Definition: QMCDriver.h:263
int size() const
return the number of tasks
Definition: Communicate.h:118
bool put(std::istream &is) override
read from std::istream
Definition: ParameterSet.h:42
ParameterSet m_param
store any parameter that has to be read from a file
Definition: QMCDriver.h:320
IndexType nSubSteps
number of steps between a step: VMCs do not evaluate energies
Definition: QMCDriver.h:272
IndexType nSteps
maximum number of steps
Definition: QMCDriver.h:269
class to handle a set of parameters
Definition: ParameterSet.h:27
MakeReturn< UnaryNode< FnCeil, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t ceil(const Vector< T1, C1 > &l)
omp_int_t omp_get_max_threads()
Definition: OpenMP.h:26
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
bool get(std::ostream &os) const override
write to a std::ostream
Definition: ParameterSet.h:35
int qmc_counter
init for <qmc> section
Definition: qmc_common.h:31
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
void add(PDT &aparam, const std::string &aname_in, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new parameter corresponding to an xmlNode <parameter>
IndexType nTargetSamples
the number of saved samples
Definition: QMCDriver.h:289
int Period4CheckPoint
period of dumping walker configurations and everything else for restart
Definition: QMCDriver.h:242
RealType nTargetPopulation
target population
Definition: QMCDriver.h:295
RealType Tau
timestep
Definition: QMCDriver.h:299
IndexType nStepsBetweenSamples
alternate method of setting QMC run parameters
Definition: QMCDriver.h:291
IndexType nBlocks
maximum number of blocks
Definition: QMCDriver.h:266
int Period4WalkerDump
period of recording walker configurations
Definition: QMCDriver.h:255
QMCState qmc_common
a unique QMCState during a run
Definition: qmc_common.cpp:111
int MyCounter
the number of times this QMCDriver is executed
Definition: QMCDriver.h:235

◆ resetRun()

void resetRun ( )
private

check the run-time environments

Definition at line 153 of file VMC.cpp.

References qmcplusplus::app_log(), SimpleFixedNodeBranch::B_TARGETWALKERS, WalkerConfigurations::begin(), QMCDriver::branchEngine, qmcplusplus::ceil(), copy(), QMCDriver::DriftModifier, CloneManager::estimatorClones, QMCDriver::Estimators, FairDivideLow(), WalkerConfigurations::getActiveWalkers(), QMCDriver::H, CloneManager::hClones, ParticleSet::isSpinor(), CloneManager::makeClones(), QMCState::memory_allocated, CloneManager::Movers, QMCDriver::nSamplesPerThread, QMCDriver::nSubSteps, QMCDriver::nTargetPopulation, QMCDriver::nTargetSamples, CloneManager::NumThreads, QMCDriver::nWarmupSteps, QMCState::print_memory_change(), QMCDriver::Psi, CloneManager::psiClones, qmcplusplus::qmc_common, QMCDriver::qmc_driver_mode, QMCDriver::QMC_UPDATE_MODE, QMCDriver::qmcNode, QMCDriver::Rng, VMC::rngs_, QMCDriver::SpinMass, CloneManager::traceClones, QMCDriver::Traces, VMC::UseDrift, QMCDriver::W, CloneManager::wClones, CloneManager::wlog_collectors, QMCDriver::wlog_manager_, and CloneManager::wPerRank.

Referenced by VMC::run().

154 {
155  ////only VMC can overwrite this
156  if (nTargetPopulation > 0)
158  makeClones(W, Psi, H);
160  app_log() << " Initial partition of walkers ";
161  copy(wPerRank.begin(), wPerRank.end(), std::ostream_iterator<int>(app_log(), " "));
162  app_log() << std::endl;
163 
164  bool movers_created = false;
165  bool spinors = false;
166  if (Movers.empty())
167  {
168  movers_created = true;
169  Movers.resize(NumThreads, nullptr);
170  estimatorClones.resize(NumThreads, nullptr);
171  traceClones.resize(NumThreads, nullptr);
172  wlog_collectors.resize(NumThreads);
173  Rng.resize(NumThreads);
174 
175  // hdf_archive::hdf_archive() is not thread-safe
176  for (int ip = 0; ip < NumThreads; ++ip)
177  estimatorClones[ip] = new EstimatorManagerBase(*Estimators);
178 
179 #pragma omp parallel for
180  for (int ip = 0; ip < NumThreads; ++ip)
181  {
182  std::ostringstream os;
183  estimatorClones[ip]->resetTargetParticleSet(*wClones[ip]);
184  estimatorClones[ip]->setCollectionMode(false);
185 #if !defined(REMOVE_TRACEMANAGER)
186  traceClones[ip] = Traces->makeClone();
187 #endif
188  wlog_collectors[ip] = wlog_manager_->makeCollector();
189  Rng[ip] = rngs_[ip]->makeClone();
190  hClones[ip]->setRandomGenerator(Rng[ip].get());
191  if (W.isSpinor())
192  {
193  spinors = true;
195  {
196  Movers[ip] = new SOVMCUpdatePbyP(*wClones[ip], *psiClones[ip], *hClones[ip], *Rng[ip]);
197  }
198  else
199  {
200  Movers[ip] = new SOVMCUpdateAll(*wClones[ip], *psiClones[ip], *hClones[ip], *Rng[ip]);
201  }
202  }
203  else
204  {
206  {
207  Movers[ip] = new VMCUpdatePbyP(*wClones[ip], *psiClones[ip], *hClones[ip], *Rng[ip]);
208  }
209  else
210  {
211  Movers[ip] = new VMCUpdateAll(*wClones[ip], *psiClones[ip], *hClones[ip], *Rng[ip]);
212  }
213  }
214  Movers[ip]->nSubSteps = nSubSteps;
215  if (ip == 0)
216  app_log() << os.str() << std::endl;
217  }
218  }
219 #if !defined(REMOVE_TRACEMANAGER)
220  else
221  {
222 #pragma omp parallel for
223  for (int ip = 0; ip < NumThreads; ++ip)
224  traceClones[ip]->transfer_state_from(*Traces);
225  }
226 #endif
228  {
229  app_log() << " Using Particle by Particle moves" << std::endl;
230  }
231  else
232  {
233  app_log() << " Using All Particle moves" << std::endl;
234  }
235 
236  if (UseDrift == "yes")
237  {
238  app_log() << " Walker moves with drift" << std::endl;
239  for (int i = 0; i < Movers.size(); i++)
240  Movers[i]->UseDrift = true;
241  }
242  else
243  {
244  app_log() << " Walker moves without drift" << std::endl;
245  for (int i = 0; i < Movers.size(); i++)
246  Movers[i]->UseDrift = false;
247  }
248 
249  if (spinors)
250  {
251  app_log() << " Spins treated as dynamic variable with SpinMass: " << SpinMass << std::endl;
252  for (int i = 0; i < Movers.size(); i++)
253  Movers[i]->setSpinMass(SpinMass);
254  }
255 
256  app_log() << " Total Sample Size =" << nTargetSamples << std::endl;
257  app_log() << " Walker distribution on root = ";
258  copy(wPerRank.begin(), wPerRank.end(), std::ostream_iterator<int>(app_log(), " "));
259  app_log() << std::endl;
260  //app_log() << " Sample Size per node=" << samples_this_node << std::endl;
261  //for (int ip=0; ip<NumThreads; ++ip)
262  // app_log() << " Sample size for thread " <<ip<<" = " << samples_th[ip] << std::endl;
263  app_log().flush();
264 #pragma omp parallel for
265  for (int ip = 0; ip < NumThreads; ++ip)
266  {
267  //int ip=omp_get_thread_num();
268  Movers[ip]->put(qmcNode);
269  //Movers[ip]->resetRun(branchEngine.get(), estimatorClones[ip], traceClones[ip], DriftModifier);
270  Movers[ip]->resetRun2(branchEngine.get(), estimatorClones[ip], traceClones[ip], wlog_collectors[ip].get(), DriftModifier);
272  Movers[ip]->initWalkersForPbyP(W.begin() + wPerRank[ip], W.begin() + wPerRank[ip + 1]);
273  else
274  Movers[ip]->initWalkers(W.begin() + wPerRank[ip], W.begin() + wPerRank[ip + 1]);
275  // if (UseDrift != "rn")
276  // {
277  for (int prestep = 0; prestep < nWarmupSteps; ++prestep)
278  Movers[ip]->advanceWalkers(W.begin() + wPerRank[ip], W.begin() + wPerRank[ip + 1], false);
279  // }
280  }
281 
282  if (movers_created)
283  {
284  size_t before = qmc_common.memory_allocated;
285  app_log() << " Anonymous Buffer size per walker : " << W[0]->DataSet.byteSize() << " Bytes." << std::endl;
286  qmc_common.memory_allocated += W.getActiveWalkers() * W[0]->DataSet.byteSize();
287  qmc_common.print_memory_change("VMC::resetRun", before);
288  }
289 
290  for (int ip = 0; ip < NumThreads; ++ip)
291  wClones[ip]->clearEnsemble();
292  if (nSamplesPerThread)
293  for (int ip = 0; ip < NumThreads; ++ip)
294  wClones[ip]->setNumSamples(nSamplesPerThread);
295  nWarmupSteps = 0;
296 }
UPtrVector< WalkerLogCollector > wlog_collectors
trace collectors
Definition: CloneManager.h:79
static std::vector< TrialWaveFunction * > psiClones
Definition: CloneManager.h:65
std::vector< int > wPerRank
Walkers per MPI rank.
Definition: CloneManager.h:91
size_t getActiveWalkers() const
return the number of active walkers
static std::vector< MCWalkerConfiguration * > wClones
Definition: CloneManager.h:61
std::ostream & app_log()
Definition: OutputManager.h:65
RealType nSamplesPerThread
samples per thread
Definition: QMCDriver.h:293
xmlNodePtr qmcNode
pointer to qmc node in xml file
Definition: QMCDriver.h:310
std::vector< QMCUpdateBase * > Movers
update engines
Definition: CloneManager.h:73
RealType SpinMass
spin mass for spinor calcs
Definition: QMCDriver.h:353
UPtrVector< RandomBase< QMCTraits::FullPrecRealType > > & rngs_
Definition: VMC.h:46
std::unique_ptr< TraceManager > Traces
Traces manager.
Definition: QMCDriver.h:195
void FairDivideLow(int ntot, int npart, IV &adist)
partition ntot elements among npart
Definition: FairDivide.h:114
IndexType nSubSteps
number of steps between a step: VMCs do not evaluate energies
Definition: QMCDriver.h:272
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
Definition: Blitz.h:639
MakeReturn< UnaryNode< FnCeil, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t ceil(const Vector< T1, C1 > &l)
std::bitset< QMC_MODE_MAX > qmc_driver_mode
bits to classify QMCDriver
Definition: QMCDriver.h:93
std::unique_ptr< BranchEngineType > branchEngine
branch engine
Definition: QMCDriver.h:218
std::vector< EstimatorManagerBase * > estimatorClones
estimator managers
Definition: CloneManager.h:75
const IndexType NumThreads
number of threads
Definition: CloneManager.h:54
QMCHamiltonian & H
Hamiltonian.
Definition: QMCDriver.h:329
DriftModifierBase * DriftModifier
drift modifer
Definition: QMCDriver.h:220
void makeClones(MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &ham)
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
static std::vector< QMCHamiltonian * > hClones
Definition: CloneManager.h:71
IndexType nTargetSamples
the number of saved samples
Definition: QMCDriver.h:289
EstimatorManagerBase * Estimators
Observables manager.
Definition: QMCDriver.h:192
RealType nTargetPopulation
target population
Definition: QMCDriver.h:295
TrialWaveFunction & Psi
trial function
Definition: QMCDriver.h:326
size_t memory_allocated
size of memory allocated in byte per MPI
Definition: qmc_common.h:29
void print_memory_change(const std::string &who, size_t before)
print memory increase
Definition: qmc_common.cpp:93
std::vector< TraceManager * > traceClones
trace managers
Definition: CloneManager.h:77
QMCState qmc_common
a unique QMCState during a run
Definition: qmc_common.cpp:111
IndexType nWarmupSteps
number of warmup steps
Definition: QMCDriver.h:275
UPtrVector< RandomBase< FullPrecRealType > > Rng
Random number generators.
Definition: QMCDriver.h:341
std::unique_ptr< WalkerLogManager > wlog_manager_
Traces manager.
Definition: QMCDriver.h:198
target total number of walkers per mpi group
std::string UseDrift
option to enable/disable drift equation or RN for VMC
Definition: VMC.h:44
iterator begin()
return the first iterator

◆ run()

bool run ( )
overridevirtual

write samples to a file

Implements QMCDriverInterface.

Definition at line 60 of file VMC.cpp.

References qmcplusplus::app_log(), Communicate::bcast(), WalkerConfigurations::begin(), ParticleSet::Collectables, QMCDriver::CurrentStep, QMCDriver::DumpConfig, MCWalkerConfiguration::dumpEnsemble(), CloneManager::estimatorClones, QMCDriver::Estimators, QMCDriver::finalize(), Communicate::getName(), CloneManager::getWalkerLogCollectorRefs(), QMCDriver::MaxCPUSecs, CloneManager::Movers, MPIObjectBase::myComm, QMCDriver::nBlocks, QMCDriver::nBlocksBetweenRecompute, QMCDriver::nSteps, CloneManager::NumThreads, omp_get_thread_num(), QMCDriver::Period4CheckProperties, QMCDriver::Period4WalkerDump, QMCDriver::qmc_driver_mode, QMCDriver::QMC_UPDATE_MODE, Communicate::rank(), QMCDriver::recordBlock(), VMC::resetRun(), QMCDriver::Rng, VMC::rngs_, qmcplusplus::run_time_manager, PooledData< T >::size(), Communicate::size(), LoopTimer< CLOCK >::start(), EstimatorManagerBase::start(), LoopTimer< CLOCK >::stop(), EstimatorManagerBase::stop(), EstimatorManagerBase::stopBlock(), CloneManager::traceClones, QMCDriver::Traces, QMCDriver::W, CloneManager::wClones, QMCDriver::wlog_manager_, QMCDriver::wOut, and CloneManager::wPerRank.

Referenced by qmcplusplus::TEST_CASE().

61 {
62  resetRun();
63  //start the main estimator
65  for (int ip = 0; ip < NumThreads; ++ip)
66  Movers[ip]->startRun(nBlocks, false);
67 #if !defined(REMOVE_TRACEMANAGER)
68  Traces->startRun(nBlocks, traceClones);
69 #endif
71 
72  LoopTimer<> vmc_loop;
73  RunTimeControl<> runtimeControl(run_time_manager, MaxCPUSecs, myComm->getName(), myComm->rank() == 0);
74 
75  const bool has_collectables = W.Collectables.size();
76  for (int block = 0; block < nBlocks; ++block)
77  {
78  vmc_loop.start();
79 #pragma omp parallel
80  {
81  int ip = omp_get_thread_num();
82  //IndexType updatePeriod=(qmc_driver_mode[QMC_UPDATE_MODE])?Period4CheckProperties:(nBlocks+1)*nSteps;
84  //assign the iterators and resuse them
85  MCWalkerConfiguration::iterator wit(W.begin() + wPerRank[ip]), wit_end(W.begin() + wPerRank[ip + 1]);
86  Movers[ip]->startBlock(nSteps);
87  int now_loc = CurrentStep;
88  RealType cnorm = 1.0 / static_cast<RealType>(wPerRank[ip + 1] - wPerRank[ip]);
89  for (int step = 0; step < nSteps; ++step)
90  {
91  Movers[ip]->set_step(now_loc);
92  //collectables are reset, it is accumulated while advancing walkers
93  wClones[ip]->resetCollectables();
94  bool recompute = (nBlocksBetweenRecompute && (step + 1) == nSteps &&
96  Movers[ip]->advanceWalkers(wit, wit_end, recompute);
97  if (has_collectables)
98  wClones[ip]->Collectables *= cnorm;
99  Movers[ip]->accumulate(wit, wit_end);
100  ++now_loc;
101  if (Period4WalkerDump && now_loc % Period4WalkerDump == 0)
102  wClones[ip]->saveEnsemble(wit, wit_end);
103  // if(storeConfigs && (now_loc%storeConfigs == 0))
104  // ForwardWalkingHistory.storeConfigsForForwardWalking(*wClones[ip]);
105  }
106  Movers[ip]->stopBlock(false);
107  } //end-of-parallel for
108  //Estimators->accumulateCollectables(wClones,nSteps);
109  CurrentStep += nSteps;
111 #if !defined(REMOVE_TRACEMANAGER)
112  Traces->write_buffers(traceClones, block);
113 #endif
114  wlog_manager_->writeBuffers();
115  recordBlock(block);
116  vmc_loop.stop();
117 
118  bool stop_requested = false;
119  // Rank 0 decides whether the time limit was reached
120  if (!myComm->rank())
121  stop_requested = runtimeControl.checkStop(vmc_loop);
122  myComm->bcast(stop_requested);
123  if (stop_requested)
124  {
125  if (!myComm->rank())
126  app_log() << runtimeControl.generateStopMessage("VMC", block);
127  run_time_manager.markStop();
128  break;
129  }
130  } //block
132  for (int ip = 0; ip < NumThreads; ++ip)
133  Movers[ip]->stopRun2();
134 #if !defined(REMOVE_TRACEMANAGER)
135  Traces->stopRun();
136 #endif
137  wlog_manager_->stopRun();
138  //copy back the random states
139  for (int ip = 0; ip < NumThreads; ++ip)
140  rngs_[ip] = Rng[ip]->makeClone();
141  ///write samples to a file
142  bool wrotesamples = DumpConfig;
143  if (DumpConfig)
144  {
146  if (wrotesamples)
147  app_log() << " samples are written to the config.h5" << std::endl;
148  }
149  //finalize a qmc section
150  return finalize(nBlocks, !wrotesamples);
151 }
size_type size() const
return the size of the data
Definition: PooledData.h:48
int MaxCPUSecs
maximum cpu in secs
Definition: QMCDriver.h:302
std::vector< int > wPerRank
Walkers per MPI rank.
Definition: CloneManager.h:91
int rank() const
return the rank
Definition: Communicate.h:116
void recordBlock(int block) override
record the state of the block
Definition: QMCDriver.cpp:307
bool DumpConfig
flag to turn off dumping configurations
Definition: QMCDriver.h:226
static std::vector< MCWalkerConfiguration * > wClones
Definition: CloneManager.h:61
std::ostream & app_log()
Definition: OutputManager.h:65
RunTimeManager< ChronoClock > run_time_manager
IndexType CurrentStep
current step
Definition: QMCDriver.h:263
std::vector< QMCUpdateBase * > Movers
update engines
Definition: CloneManager.h:73
int size() const
return the number of tasks
Definition: Communicate.h:118
UPtrVector< RandomBase< QMCTraits::FullPrecRealType > > & rngs_
Definition: VMC.h:46
std::unique_ptr< TraceManager > Traces
Traces manager.
Definition: QMCDriver.h:195
omp_int_t omp_get_thread_num()
Definition: OpenMP.h:25
IndexType nSteps
maximum number of steps
Definition: QMCDriver.h:269
std::unique_ptr< HDFWalkerOutput > wOut
record engine for walkers
Definition: QMCDriver.h:332
bool finalize(int block, bool dumpwalkers=true)
finalize a qmc section
Definition: QMCDriver.cpp:318
const std::string & getName() const
Definition: Communicate.h:131
WalkerList_t::iterator iterator
FIX: a type alias of iterator for an object should not be for just one of many objects it holds...
std::bitset< QMC_MODE_MAX > qmc_driver_mode
bits to classify QMCDriver
Definition: QMCDriver.h:93
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
std::vector< EstimatorManagerBase * > estimatorClones
estimator managers
Definition: CloneManager.h:75
const IndexType NumThreads
number of threads
Definition: CloneManager.h:54
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65
Buffer_t Collectables
observables in addition to those registered in Properties/PropertyList
Definition: ParticleSet.h:126
static bool dumpEnsemble(std::vector< MCWalkerConfiguration *> &others, HDFWalkerOutput &out, int np, int nBlock)
dump Samples to a file
void resetRun()
check the run-time environments
Definition: VMC.cpp:153
QMCTraits::RealType RealType
EstimatorManagerBase * Estimators
Observables manager.
Definition: QMCDriver.h:192
void stopBlock(RealType accept, bool collectall=true)
stop a block
void bcast(T &)
IndexType nBlocks
maximum number of blocks
Definition: QMCDriver.h:266
int Period4WalkerDump
period of recording walker configurations
Definition: QMCDriver.h:255
std::vector< TraceManager * > traceClones
trace managers
Definition: CloneManager.h:77
int Period4CheckProperties
period of dumping walker positions and IDs for Forward Walking
Definition: QMCDriver.h:249
RefVector< WalkerLogCollector > getWalkerLogCollectorRefs()
UPtrVector< RandomBase< FullPrecRealType > > Rng
Random number generators.
Definition: QMCDriver.h:341
std::unique_ptr< WalkerLogManager > wlog_manager_
Traces manager.
Definition: QMCDriver.h:198
IndexType nBlocksBetweenRecompute
the number of blocks between recomptePsi
Definition: QMCDriver.h:284
void start(int blocks, bool record=true)
start a run
iterator begin()
return the first iterator

Member Data Documentation

◆ prevSteps

int prevSteps
private

Definition at line 40 of file VMC.h.

Referenced by VMC::put(), and VMC::VMC().

◆ prevStepsBetweenSamples

int prevStepsBetweenSamples
private

Definition at line 41 of file VMC.h.

Referenced by VMC::put(), and VMC::VMC().

◆ rngs_

Definition at line 46 of file VMC.h.

Referenced by VMC::resetRun(), and VMC::run().

◆ UseDrift

std::string UseDrift
private

option to enable/disable drift equation or RN for VMC

Definition at line 44 of file VMC.h.

Referenced by VMC::resetRun(), and VMC::VMC().

◆ qmcplusplus::VMCBatched

class qmcplusplus::VMCBatched


Implements a VMC using particle-by-particle move.

Threaded execution.

Definition at line 34 of file VMCBatched.h.

+ Inheritance diagram for VMCBatched:
+ Collaboration diagram for VMCBatched:

Public Types

using Base = QMCDriverNew
 
using FullPrecRealType = QMCTraits::FullPrecRealType
 
using PosType = QMCTraits::PosType
 
using ParticlePositions = PtclOnLatticeTraits::ParticlePos
 
- Public Types inherited from QMCDriverNew
enum  { QMC_UPDATE_MODE, QMC_MULTIPLE, QMC_OPTIMIZE, QMC_WARMUP }
 separate but similar to QMCModeEnum More...
 
using RealType = QMCTraits::RealType
 
using IndexType = QMCTraits::IndexType
 
using FullPrecRealType = QMCTraits::FullPrecRealType
 
using MCPWalker = MCPopulation::MCPWalker
 
using WFBuffer = MCPopulation::WFBuffer
 
using SetNonLocalMoveHandler = std::function< void(QMCHamiltonian &)>
 
- Public Types inherited from QMCDriverInterface
using BranchEngineType = SimpleFixedNodeBranch
 
using FullPrecRealType = QMCTraits::FullPrecRealType
 
- Public Types inherited from MPIObjectBase
using mpi_comm_type = Communicate::mpi_comm_type
 

Public Member Functions

 VMCBatched (const ProjectData &project_data, QMCDriverInput &&qmcdriver_input, const std::optional< EstimatorManagerInput > &global_emi, VMCDriverInput &&input, WalkerConfigurations &wc, MCPopulation &&pop, SampleStack &samples_, Communicate *comm)
 Constructor. More...
 
void process (xmlNodePtr node) override
 QMCDriverNew driver second (3rd, 4th...) stage of constructing a valid driver. More...
 
bool run () override
 Runs the actual VMC section. More...
 
auto getCDLW ()
 transitional interface on the way to better walker count adjustment handling. More...
 
void enable_sample_collection ()
 Enable collecting samples during the VMC run. More...
 
- Public Member Functions inherited from QMCDriverNew
 QMCDriverNew (const ProjectData &project_data, QMCDriverInput &&input, const std::optional< EstimatorManagerInput > &global_emi, WalkerConfigurations &wc, MCPopulation &&population, const std::string timer_prefix, Communicate *comm, const std::string &QMC_driver_type)
 Constructor. More...
 
 QMCDriverNew (QMCDriverNew &&)=default
 Move Constructor. More...
 
 QMCDriverNew (const QMCDriverNew &)=delete
 Copy Constructor (disabled). More...
 
QMCDriverNewoperator= (const QMCDriverNew &)=delete
 Copy operator (disabled). More...
 
 ~QMCDriverNew () override
 
bool putQMCInfo (xmlNodePtr cur)
 
void makeLocalWalkers (int nwalkers, RealType reserve)
 Adjust populations local walkers to this number. More...
 
DriftModifierBaseget_drift_modifier () const
 
void recordBlock (int block) override
 record the state of the block More...
 
bool finalize (int block, bool dumpwalkers=true)
 finalize a qmc section More...
 
IndexType current () const
 return current step More...
 
void setStatus (const std::string &aname, const std::string &h5name, bool append) override
 Set the status of the QMCDriver. More...
 
void add_H_and_Psi (QMCHamiltonian *h, TrialWaveFunction *psi) override
 
void createRngsStepContexts (int num_crowds)
 Creates Random Number generators for crowds and step contexts. More...
 
void putWalkers (std::vector< xmlNodePtr > &wset) override
 Read walker configurations from *.config.h5 files. More...
 
RefVector< RandomBase< FullPrecRealType > > getRngRefs () const
 
RandomBase< FullPrecRealType > & getRng (int i) override
 return the i-th random generator More...
 
std::string getEngineName () override
 intended for logging output and debugging you should base behavior on type preferably at compile time or if necessary at runtime using and protected by dynamic cast. More...
 
unsigned long getDriverMode () override
 
IndexType get_num_living_walkers () const
 
IndexType get_num_dead_walkers () const
 
const QMCDriverInputgetQMCDriverInput () const
 
bool put (xmlNodePtr cur) override
 
More...
 
void setUpdateMode (bool pbyp) override
 should be set in input don't see a reason to set individually More...
 
void putTraces (xmlNodePtr txml) override
 
void requestTraces (bool allow_traces) override
 
void putWalkerLogs (xmlNodePtr wlxml) override
 
void requestWalkerLogs (bool allow_walker_logs_) override
 
- Public Member Functions inherited from QMCDriverInterface
virtual ~QMCDriverInterface ()
 
virtual void setBranchEngine (std::unique_ptr< BranchEngineType > &&be)
 
virtual std::unique_ptr< BranchEngineTypegetBranchEngine ()
 
- Public Member Functions inherited from MPIObjectBase
 MPIObjectBase (Communicate *c)
 constructor with communicator More...
 
int rank () const
 return the rank of the communicator More...
 
int getGroupID () const
 return the group id of the communicator More...
 
CommunicategetCommunicator () const
 return myComm More...
 
CommunicategetCommRef () const
 return a TEMPORARY reference to Communicate More...
 
mpi_comm_type getMPI () const
 return MPI communicator if one wants to use MPI directly More...
 
bool is_manager () const
 return true if the rank == 0 More...
 
const std::string & getName () const
 return the name More...
 
void setName (const std::string &aname)
 

Static Public Member Functions

template<CoordsType CT>
static void advanceWalkers (const StateForThread &sft, Crowd &crowd, DriverTimers &timers, ContextForSteps &move_context, bool recompute, bool accumulate_this_step)
 Refactor of VMCUpdatePbyP in crowd context. More...
 
static void runVMCStep (int crowd_id, const StateForThread &sft, DriverTimers &timers, UPtrVector< ContextForSteps > &context_for_steps, UPtrVector< Crowd > &crowds)
 Thread body for VMC step. More...
 
- Static Public Member Functions inherited from QMCDriverNew
static void initialLogEvaluation (int crowd_id, UPtrVector< Crowd > &crowds, UPtrVector< ContextForSteps > &step_context)
 
template<typename RT , CoordsType CT>
static void scaleBySqrtTau (const TauParams< RT, CT > &taus, MCCoords< CT > &coords)
 
template<typename RT , CoordsType CT>
static void computeLogGreensFunction (const MCCoords< CT > &coords, const TauParams< RT, CT > &taus, std::vector< QMCTraits::RealType > &log_gb)
 calculates Green Function from displacements stored in MCCoords [param, out] log_g More...
 

Private Member Functions

QMCRunType getRunType () override
 
 VMCBatched (const VMCBatched &)=delete
 Copy constructor. More...
 
VMCBatchedoperator= (const VMCBatched &)=delete
 Copy operator (disabled). More...
 

Static Private Member Functions

static size_t compute_samples_per_rank (const size_t num_blocks, const size_t samples_per_block, const size_t local_walkers)
 function to calculate samples per MPI rank More...
 

Private Attributes

int prevSteps
 
int prevStepsBetweenSamples
 
VMCDriverInput vmcdriver_input_
 
SampleStacksamples_
 Storage for samples (later used in optimizer) More...
 
bool collect_samples_
 Sample collection flag. More...
 

Friends

class qmcplusplus::testing::VMCBatchedTest
 

Additional Inherited Members

- Public Attributes inherited from QMCDriverNew
std::bitset< QMC_MODE_MAXqmc_driver_mode_
 bits to classify QMCDriver More...
 
bool allow_walker_logs
 whether to allow walker logs More...
 
WalkerLogInput walker_logs_input
 walker logs input More...
 
- Protected Member Functions inherited from QMCDriverNew
void initializeQMC (const AdjustedWalkerCounts &awc)
 Do common section starting tasks for VMC and DMC. More...
 
void measureImbalance (const std::string &tag) const
 inject additional barrier and measure load imbalance. More...
 
void endBlock ()
 end of a block operations. Aggregates statistics across all MPI ranks and write to disk. More...
 
const std::string & get_root_name () const override
 
- Static Protected Member Functions inherited from QMCDriverNew
static QMCDriverNew::AdjustedWalkerCounts adjustGlobalWalkerCount (Communicate &comm, const IndexType current_configs, const IndexType requested_total_walkers, const IndexType requested_walkers_per_rank, const RealType reserve_walkers, int num_crowds)
 }@ More...
 
static size_t determineStepsPerBlock (IndexType global_walkers, IndexType requested_samples, IndexType requested_steps, IndexType blocks)
 pure function calculating the actual number of steps per block More...
 
static void checkNumCrowdsLTNumThreads (const int num_crowds)
 
static void checkLogAndGL (Crowd &crowd, const std::string_view location)
 check logpsi and grad and lap against values computed from scratch More...
 
static void setWalkerOffsets (WalkerConfigurations &, Communicate *comm)
 update the global offsets of walker configurations after active walkers being touched. More...
 
- Protected Attributes inherited from QMCDriverNew
QMCDriverInput qmcdriver_input_
 
RealType max_disp_sq_
 
they should be limited to values that can be changed from input or are live state. More...
 
IndexType target_samples_
 the number of saved samples More...
 
IndexType nBlocksBetweenRecompute
 the number of blocks between recomptePsi More...
 
UPtrVector< Crowdcrowds_
 }@ More...
 
std::string h5_file_root_
 
std::unique_ptr< DriftModifierBasedrift_modifier_
 drift modifer More...
 
int k_delay
 the number to delay updates by More...
 
int walker_dump_period
 period of recording walker configurations More...
 
IndexType current_step_
 
size_t steps_per_block_ = 0
 actual number of steps per block More...
 
IndexType nAccept
 counter for number of moves accepted More...
 
IndexType nReject
 counter for number of moves /rejected More...
 
RealType m_oneover2tau
 Time-step factor $ 1/(2\tau)$. More...
 
RealType m_sqrttau
 Time-step factor $ \sqrt{\tau}$. More...
 
const std::string QMCType
 type of qmc: assigned by subclasses More...
 
MCPopulation population_
 the entire (on node) walker population it serves VMCBatch and DMCBatch right now but will be polymorphic More...
 
struct DriverWalkerResourceCollection golden_resource_
 the golden multi walker shared resource serves ParticleSet TrialWaveFunction right now but actually should be based on MCPopulation. More...
 
const MultiWalkerDispatchers dispatchers_
 multi walker dispatchers More...
 
std::unique_ptr< EstimatorManagerNewestimator_manager_
 Observables manager Has very problematic owner ship and life cycle. More...
 
std::unique_ptr< HDFWalkerOutputwOut
 record engine for walkers More...
 
UPtrVector< ContextForStepsstep_contexts_
 Per crowd move contexts, this is where the DistanceTables etc. More...
 
UPtrVector< RandomBase< FullPrecRealType > > Rng
 Random number generators. More...
 
std::vector< xmlNodePtr > mcwalkerNodePtr
 a list of mcwalkerset element More...
 
DriverTimers timers_
 period of dumping walker configurations and everything else for restart More...
 
ScopedProfiler driver_scope_profiler_
 profile the driver lifetime More...
 
const ProjectDataproject_data_
 project info for accessing global fileroot and series id More...
 
WalkerConfigurationswalker_configs_ref_
 
- Protected Attributes inherited from MPIObjectBase
CommunicatemyComm
 pointer to Communicate More...
 
std::string ClassName
 class Name More...
 
std::string myName
 name of the object More...
 

Member Typedef Documentation

◆ Base

using Base = QMCDriverNew

Definition at line 37 of file VMCBatched.h.

◆ FullPrecRealType

Definition at line 38 of file VMCBatched.h.

◆ ParticlePositions

◆ PosType

Definition at line 39 of file VMCBatched.h.

Constructor & Destructor Documentation

◆ VMCBatched() [1/2]

VMCBatched ( const ProjectData project_data,
QMCDriverInput &&  qmcdriver_input,
const std::optional< EstimatorManagerInput > &  global_emi,
VMCDriverInput &&  input,
WalkerConfigurations wc,
MCPopulation &&  pop,
SampleStack samples_,
Communicate comm 
)

Constructor.

Constructor maintains proper ownership of input parameters.

Definition at line 30 of file VMCBatched.cpp.

38  : QMCDriverNew(project_data,
39  std::move(qmcdriver_input),
40  global_emi,
41  wc,
42  std::move(pop),
43  "VMCBatched::",
44  comm,
45  "VMCBatched"),
47  samples_(samples),
48  collect_samples_(false)
49 {}
QMCDriverNew(const ProjectData &project_data, QMCDriverInput &&input, const std::optional< EstimatorManagerInput > &global_emi, WalkerConfigurations &wc, MCPopulation &&population, const std::string timer_prefix, Communicate *comm, const std::string &QMC_driver_type)
Constructor.
bool collect_samples_
Sample collection flag.
Definition: VMCBatched.h:135
SampleStack & samples_
Storage for samples (later used in optimizer)
Definition: VMCBatched.h:133
VMCDriverInput vmcdriver_input_
Definition: VMCBatched.h:124
testing::ValidSpinDensityInput input

◆ VMCBatched() [2/2]

VMCBatched ( const VMCBatched )
privatedelete

Copy constructor.

Member Function Documentation

◆ advanceWalkers()

void advanceWalkers ( const StateForThread sft,
Crowd crowd,
QMCDriverNew::DriverTimers timers,
ContextForSteps move_context,
bool  recompute,
bool  accumulate_this_step 
)
static

Refactor of VMCUpdatePbyP in crowd context.

MCWalkerConfiguration layer removed. Obfuscation of state changes via buffer and MCWalkerconfiguration require this be tested well

Definition at line 52 of file VMCBatched.cpp.

References QMCHamiltonian::auxHevaluate(), QMCDriverNew::DriverTimers::buffer_timer, qmcplusplus::CHECKGL_AFTER_LOAD, qmcplusplus::CHECKGL_AFTER_MOVES, QMCDriverNew::checkLogAndGL(), QMCDriverNew::DriverTimers::collectables_timer, QMCDriverNew::computeLogGreensFunction(), qmcplusplus::crowd, VMCBatched::StateForThread::drift_modifier, QMCDriverNew::DriverTimers::estimators_timer, qmcplusplus::exp(), QMCDriverInput::get_debug_checks(), MCPopulation::get_ptclgrp_inv_mass(), ContextForSteps::get_random_gen(), QMCDriverInput::get_spin_mass(), QMCDriverInput::get_sub_steps(), QMCDriverInput::get_tau(), VMCDriverInput::get_use_drift(), DriftModifierBase::getDrifts(), VMCBatched::StateForThread::global_step, qmcplusplus::ham, QMCDriverNew::DriverTimers::hamiltonian_timer, qmcplusplus::makeGaussRandomWithEngine(), QMCDriverNew::DriverTimers::movepbyp_timer, norm(), qmcplusplus::hdf::num_walkers, VMCBatched::StateForThread::population, qmcplusplus::pset, VMCBatched::StateForThread::qmcdrv_input, QMCDriverNew::DriverTimers::resource_timer, QMCHamiltonian::saveProperty(), QMCDriverNew::scaleBySqrtTau(), TimerType< CLOCK >::start(), TimerType< CLOCK >::stop(), qmcplusplus::twf, VMCBatched::StateForThread::vmcdrv_input, qmcplusplus::walker, and qmcplusplus::hdf::walkers.

58 {
59  if (crowd.size() == 0)
60  return;
61  auto& ps_dispatcher = crowd.dispatchers_.ps_dispatcher_;
62  auto& twf_dispatcher = crowd.dispatchers_.twf_dispatcher_;
63  auto& ham_dispatcher = crowd.dispatchers_.ham_dispatcher_;
64  auto& walkers = crowd.get_walkers();
65  const RefVectorWithLeader<ParticleSet> walker_elecs(crowd.get_walker_elecs()[0], crowd.get_walker_elecs());
66  const RefVectorWithLeader<TrialWaveFunction> walker_twfs(crowd.get_walker_twfs()[0], crowd.get_walker_twfs());
67 
68  // This is really a waste the resources can be acquired outside of the run steps loop in VMCD!
69  // I don't see an easy way to measure the release without putting the weight of tons of timer_manager calls in
70  // ResourceCollectionTeamLock's constructor.
71  timers.resource_timer.start();
72  ResourceCollectionTeamLock<ParticleSet> pset_res_lock(crowd.getSharedResource().pset_res, walker_elecs);
73  ResourceCollectionTeamLock<TrialWaveFunction> twfs_res_lock(crowd.getSharedResource().twf_res, walker_twfs);
74  timers.resource_timer.stop();
75  if (sft.qmcdrv_input.get_debug_checks() & DriverDebugChecks::CHECKGL_AFTER_LOAD)
76  checkLogAndGL(crowd, "checkGL_after_load");
77 
78  {
79  ScopedTimer pbyp_local_timer(timers.movepbyp_timer);
80  const int num_walkers = crowd.size();
81  auto& walker_leader = walker_elecs.getLeader();
82  const int num_particles = walker_leader.getTotalNum();
83  // Note std::vector<bool> is not like the rest of stl.
84  std::vector<bool> moved(num_walkers, false);
85  constexpr RealType mhalf(-0.5);
86  const bool use_drift = sft.vmcdrv_input.get_use_drift();
87 
88  std::vector<TrialWaveFunction::PsiValue> ratios(num_walkers);
89  std::vector<RealType> log_gf(num_walkers);
90  std::vector<RealType> log_gb(num_walkers);
91  std::vector<RealType> prob(num_walkers);
92 
93  // local list to handle accept/reject
94  std::vector<bool> isAccepted;
95  std::vector<std::reference_wrapper<TrialWaveFunction>> twf_accept_list, twf_reject_list;
96  isAccepted.reserve(num_walkers);
97 
98  MCCoords<CT> drifts(num_walkers), drifts_reverse(num_walkers);
99  MCCoords<CT> walker_deltas(num_walkers * num_particles), deltas(num_walkers);
100  TWFGrads<CT> grads_now(num_walkers), grads_new(num_walkers);
101 
102  for (int sub_step = 0; sub_step < sft.qmcdrv_input.get_sub_steps(); sub_step++)
103  {
104  //This generates an entire steps worth of deltas.
105  makeGaussRandomWithEngine(walker_deltas, step_context.get_random_gen());
106 
107  // up and down electrons are "species" within qmpack
108  for (int ig = 0; ig < walker_leader.groups(); ++ig) //loop over species
109  {
110  TauParams<RealType, CT> taus(sft.qmcdrv_input.get_tau(), sft.population.get_ptclgrp_inv_mass()[ig],
111  sft.qmcdrv_input.get_spin_mass());
112 
113  twf_dispatcher.flex_prepareGroup(walker_twfs, walker_elecs, ig);
114 
115  for (int iat = walker_leader.first(ig); iat < walker_leader.last(ig); ++iat)
116  {
117  //get deltas for this particle (iat) for all walkers
118  walker_deltas.getSubset(iat * num_walkers, num_walkers, deltas);
119  scaleBySqrtTau(taus, deltas);
120 
121  if (use_drift)
122  {
123  twf_dispatcher.flex_evalGrad(walker_twfs, walker_elecs, iat, grads_now);
124  sft.drift_modifier.getDrifts(taus, grads_now, drifts);
125  drifts += deltas;
126  }
127  else
128  drifts = deltas;
129 
130  ps_dispatcher.flex_makeMove(walker_elecs, iat, drifts);
131 
132  // This is inelegant
133  if (use_drift)
134  {
135  twf_dispatcher.flex_calcRatioGrad(walker_twfs, walker_elecs, iat, ratios, grads_new);
136 
137  computeLogGreensFunction(deltas, taus, log_gf);
138 
139  sft.drift_modifier.getDrifts(taus, grads_new, drifts_reverse);
140 
141  drifts_reverse += drifts;
142 
143  computeLogGreensFunction(drifts_reverse, taus, log_gb);
144  }
145  else
146  twf_dispatcher.flex_calcRatio(walker_twfs, walker_elecs, iat, ratios);
147 
148  std::transform(ratios.begin(), ratios.end(), prob.begin(), [](auto ratio) { return std::norm(ratio); });
149 
150  isAccepted.clear();
151 
152  for (int i_accept = 0; i_accept < num_walkers; ++i_accept)
153  if (prob[i_accept] >= std::numeric_limits<RealType>::epsilon() &&
154  step_context.get_random_gen()() < prob[i_accept] * std::exp(log_gb[i_accept] - log_gf[i_accept]))
155  {
156  crowd.incAccept();
157  isAccepted.push_back(true);
158  }
159  else
160  {
161  crowd.incReject();
162  isAccepted.push_back(false);
163  }
164 
165  twf_dispatcher.flex_accept_rejectMove(walker_twfs, walker_elecs, iat, isAccepted, true);
166 
167  ps_dispatcher.flex_accept_rejectMove<CT>(walker_elecs, iat, isAccepted);
168  }
169  }
170  twf_dispatcher.flex_completeUpdates(walker_twfs);
171  }
172 
173  ps_dispatcher.flex_donePbyP(walker_elecs);
174  }
175 
176  {
177  ScopedTimer buffer_local_timer(timers.buffer_timer);
178  twf_dispatcher.flex_evaluateGL(walker_twfs, walker_elecs, recompute);
179  if (sft.qmcdrv_input.get_debug_checks() & DriverDebugChecks::CHECKGL_AFTER_MOVES)
180  checkLogAndGL(crowd, "checkGL_after_moves");
181  }
182 
183  const RefVectorWithLeader<QMCHamiltonian> walker_hamiltonians(crowd.get_walker_hamiltonians()[0],
184  crowd.get_walker_hamiltonians());
185  {
186  ScopedTimer hamiltonian_local_timer(timers.hamiltonian_timer);
187  ResourceCollectionTeamLock<QMCHamiltonian> hams_res_lock(crowd.getSharedResource().ham_res, walker_hamiltonians);
188  std::vector<QMCHamiltonian::FullPrecRealType> local_energies(
189  ham_dispatcher.flex_evaluate(walker_hamiltonians, walker_twfs, walker_elecs));
190 
191  auto resetSigNLocalEnergy = [](MCPWalker& walker, TrialWaveFunction& twf, auto& local_energy) {
192  walker.resetProperty(twf.getLogPsi(), twf.getPhase(), local_energy);
193  };
194  for (int iw = 0; iw < crowd.size(); ++iw)
195  resetSigNLocalEnergy(walkers[iw], walker_twfs[iw], local_energies[iw]);
196  }
197 
198  {
199  ScopedTimer collectables_local_timer(timers.collectables_timer);
200  auto evaluateNonPhysicalHamiltonianElements = [](QMCHamiltonian& ham, ParticleSet& pset, MCPWalker& walker) {
202  };
203  for (int iw = 0; iw < crowd.size(); ++iw)
204  evaluateNonPhysicalHamiltonianElements(walker_hamiltonians[iw], walker_elecs[iw], walkers[iw]);
205 
206  auto savePropertiesIntoWalker = [](QMCHamiltonian& ham, MCPWalker& walker) {
207  ham.saveProperty(walker.getPropertyBase());
208  };
209  for (int iw = 0; iw < crowd.size(); ++iw)
210  savePropertiesIntoWalker(walker_hamiltonians[iw], walkers[iw]);
211  }
212 
213  if (accumulate_this_step)
214  {
215  ScopedTimer est_timer(timers.estimators_timer);
216  crowd.accumulate(step_context.get_random_gen());
217  }
218 
219  // collect walker logs
220  crowd.collectStepWalkerLog(sft.global_step);
221 
222  // TODO:
223  // check if all moves failed
224 }
void saveProperty(IT first)
save the values of Hamiltonian elements to the Properties
const char num_walkers[]
Definition: HDFVersion.h:37
static void scaleBySqrtTau(const TauParams< RT, CT > &taus, MCCoords< CT > &coords)
Definition: QMCDriverNew.h:257
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
MCPopulation::MCPWalker MCPWalker
Definition: QMCDriverNew.h:93
const char walkers[]
Definition: HDFVersion.h:36
double norm(const zVec &c)
Definition: VectorOps.h:118
static void computeLogGreensFunction(const MCCoords< CT > &coords, const TauParams< RT, CT > &taus, std::vector< QMCTraits::RealType > &log_gb)
calculates Green Function from displacements stored in MCCoords [param, out] log_g ...
Definition: QMCDriverNew.h:270
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
static void checkLogAndGL(Crowd &crowd, const std::string_view location)
check logpsi and grad and lap against values computed from scratch
void auxHevaluate(ParticleSet &P)
QMCTraits::RealType RealType
void makeGaussRandomWithEngine(ParticleAttrib< TinyVector< T, D >> &a, RG &rng)

◆ compute_samples_per_rank()

size_t compute_samples_per_rank ( const size_t  num_blocks,
const size_t  samples_per_block,
const size_t  local_walkers 
)
staticprivate

function to calculate samples per MPI rank

Definition at line 287 of file VMCBatched.cpp.

References qmcplusplus::hdf::num_blocks.

Referenced by VMCBatched::enable_sample_collection().

290 {
291  return num_blocks * samples_per_block * local_walkers;
292 }
const char num_blocks[]
Definition: HDFVersion.h:44

◆ enable_sample_collection()

void enable_sample_collection ( )

Enable collecting samples during the VMC run.

strong assumption that VMCBatched driver has passed through process phase of initialization. A side effect of VMCBatched::process is that MCPopulation has created local walkers.

Definition at line 463 of file VMCBatched.cpp.

References qmcplusplus::app_log(), VMCBatched::collect_samples_, VMCBatched::compute_samples_per_rank(), QMCDriverInput::get_max_blocks(), MCPopulation::get_num_local_walkers(), MCPopulation::get_num_ranks(), QMCDriverNew::population_, QMCDriverNew::qmcdriver_input_, VMCBatched::samples_, SampleStack::setMaxSamples(), and QMCDriverNew::steps_per_block_.

464 {
465  assert(steps_per_block_ > 0 && "VMCBatched::enable_sample_collection steps_per_block_ must be positive!");
469  collect_samples_ = true;
470 
471  auto total_samples = samples * population_.get_num_ranks();
472  app_log() << "VMCBatched Driver collecting samples, samples per rank = " << samples << std::endl
473  << " total samples = " << total_samples << std::endl
474  << std::endl;
475 }
size_t steps_per_block_
actual number of steps per block
Definition: QMCDriverNew.h:407
MCPopulation population_
the entire (on node) walker population it serves VMCBatch and DMCBatch right now but will be polymorp...
Definition: QMCDriverNew.h:426
std::ostream & app_log()
Definition: OutputManager.h:65
int get_num_ranks() const
The number of cases in which this and get_num_local_walkers is so few that I strongly suspect it is a...
Definition: MCPopulation.h:166
bool collect_samples_
Sample collection flag.
Definition: VMCBatched.h:135
void setMaxSamples(size_t n, size_t number_of_ranks=1)
set the number of max samples per rank.
Definition: SampleStack.cpp:23
SampleStack & samples_
Storage for samples (later used in optimizer)
Definition: VMCBatched.h:133
IndexType get_max_blocks() const
QMCDriverInput qmcdriver_input_
Definition: QMCDriverNew.h:372
IndexType get_num_local_walkers() const
Definition: MCPopulation.h:169
static size_t compute_samples_per_rank(const size_t num_blocks, const size_t samples_per_block, const size_t local_walkers)
function to calculate samples per MPI rank
Definition: VMCBatched.cpp:287

◆ getCDLW()

auto getCDLW ( )

transitional interface on the way to better walker count adjustment handling.

returns a closure taking walkers per rank and accomplishing what calc_default_local_walkers does.

◆ getRunType()

QMCRunType getRunType ( )
inlineoverrideprivatevirtual

Implements QMCDriverInterface.

Definition at line 125 of file VMCBatched.h.

References qmcplusplus::VMC_BATCH.

◆ operator=()

VMCBatched& operator= ( const VMCBatched )
privatedelete

Copy operator (disabled).

◆ process()

void process ( xmlNodePtr  cur)
overridevirtual

QMCDriverNew driver second (3rd, 4th...) stage of constructing a valid driver.

This is the shared entry point with legacy, from QMCMain so the API cannot be updated yet

Todo:
remove cur, the driver and all its child nodes should be completely processed before this stage of driver initialization is hit.

Implements QMCDriverNew.

Definition at line 265 of file VMCBatched.cpp.

References QMCDriverNew::adjustGlobalWalkerCount(), qmcplusplus::app_log(), Communicate::barrier_and_abort(), QMCDriverNew::determineStepsPerBlock(), QMCDriverInput::get_max_blocks(), QMCDriverInput::get_num_crowds(), QMCDriverInput::get_requested_samples(), QMCDriverInput::get_requested_steps(), QMCDriverInput::get_total_walkers(), QMCDriverInput::get_walkers_per_rank(), WalkerConfigurations::getActiveWalkers(), QMCDriverNew::AdjustedWalkerCounts::global_walkers, QMCDriverNew::initializeQMC(), MPIObjectBase::myComm, qmcplusplus::print_mem(), QMCDriverNew::qmcdriver_input_, QMCDriverNew::steps_per_block_, and QMCDriverNew::walker_configs_ref_.

266 {
267  print_mem("VMCBatched before initialization", app_log());
268  // \todo get total walkers should be coming from VMCDriverInpu
269  try
270  {
271  QMCDriverNew::AdjustedWalkerCounts awc =
274 
278 
279  Base::initializeQMC(awc);
280  }
281  catch (const UniformCommunicateError& ue)
282  {
283  myComm->barrier_and_abort(ue.what());
284  }
285 }
size_t steps_per_block_
actual number of steps per block
Definition: QMCDriverNew.h:407
size_t getActiveWalkers() const
return the number of active walkers
IndexType get_requested_steps() const
std::ostream & app_log()
Definition: OutputManager.h:65
void print_mem(const std::string &title, std::ostream &log)
Definition: MemoryUsage.cpp:30
IndexType get_num_crowds() const
static size_t determineStepsPerBlock(IndexType global_walkers, IndexType requested_samples, IndexType requested_steps, IndexType blocks)
pure function calculating the actual number of steps per block
IndexType get_total_walkers() const
IndexType get_walkers_per_rank() const
WalkerConfigurations & walker_configs_ref_
Definition: QMCDriverNew.h:481
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
static QMCDriverNew::AdjustedWalkerCounts adjustGlobalWalkerCount(Communicate &comm, const IndexType current_configs, const IndexType requested_total_walkers, const IndexType requested_walkers_per_rank, const RealType reserve_walkers, int num_crowds)
}@
IndexType get_max_blocks() const
void barrier_and_abort(const std::string &msg) const
QMCDriverInput qmcdriver_input_
Definition: QMCDriverNew.h:372
IndexType get_requested_samples() const
void initializeQMC(const AdjustedWalkerCounts &awc)
Do common section starting tasks for VMC and DMC.

◆ run()

bool run ( )
overridevirtual

Runs the actual VMC section.

Dependent on base class state machine Assumes state already updated from the following calls:

  1. QMCDriverNew::setStatus
  2. QMCDriverNew::putWalkers
  3. QMCDriverNew::process

At the moment I don't care about 1st touch, prove it matters If does consider giving more to the thread by value that should end up thread local. (I think)

Implements QMCDriverInterface.

Definition at line 307 of file VMCBatched.cpp.

References QMCDriverNew::allow_walker_logs, qmcplusplus::app_debug_stream(), qmcplusplus::app_log(), qmcplusplus::app_summary(), SampleStack::appendSample(), Communicate::barrier(), Communicate::bcast(), VMCBatched::collect_samples_, qmcplusplus::crowd, QMCDriverNew::crowds_, QMCDriverNew::drift_modifier_, Timer::elapsed(), QMCDriverNew::endBlock(), QMCDriverNew::estimator_manager_, QMCDriverNew::finalize(), QMCDriverInput::get_blocks_between_recompute(), MCPopulation::get_elec_particle_sets(), QMCDriverInput::get_max_blocks(), QMCDriverInput::get_measure_imbalance(), QMCDriverInput::get_recalculate_properties_period(), QMCDriverNew::get_root_name(), QMCDriverInput::get_tau(), QMCDriverInput::get_warmup_steps(), ProjectData::getMaxCPUSeconds(), ProjectData::getSeriesIndex(), ProjectData::getTitle(), Crowd::getWalkerLogCollectorRefs(), VMCBatched::StateForThread::global_step, QMCDriverNew::DriverTimers::init_walkers_timer, QMCDriverNew::initialLogEvaluation(), VMCBatched::StateForThread::is_recomputing_block, WalkerLogManager::makeCollector(), QMCDriverNew::measureImbalance(), MPIObjectBase::myComm, qmcplusplus::hdf::num_blocks, QMCDriverNew::population_, qmcplusplus::print_mem(), QMCDriverNew::DriverTimers::production_timer, QMCDriverNew::project_data_, QMCDriverNew::qmc_driver_mode_, QMCDriverNew::QMC_UPDATE_MODE, QMCDriverNew::qmcdriver_input_, Communicate::rank(), VMCBatched::StateForThread::recalculate_properties_period, QMCDriverNew::recordBlock(), QMCDriverNew::DriverTimers::run_steps_timer, qmcplusplus::run_time_manager, VMCBatched::runVMCStep(), VMCBatched::samples_, WalkerLogManager::startRun(), VMCBatched::StateForThread::step, QMCDriverNew::step_contexts_, QMCDriverNew::steps_per_block_, WalkerLogManager::stopRun(), QMCDriverNew::timers_, VMCBatched::vmcdriver_input_, qmcplusplus::walker, QMCDriverNew::walker_logs_input, and WalkerLogManager::writeBuffers().

308 {
310  //start the main estimator
311  estimator_manager_->startDriverRun();
312 
313  //initialize WalkerLogManager and collectors
314  WalkerLogManager wlog_manager(walker_logs_input, allow_walker_logs, get_root_name(), myComm);
315  for (auto& crowd : crowds_)
316  crowd->setWalkerLogCollector(wlog_manager.makeCollector());
317  //register walker log collectors into the manager
318  wlog_manager.startRun(Crowd::getWalkerLogCollectorRefs(crowds_));
319 
321 
322  LoopTimer<> vmc_loop;
323  RunTimeControl<> runtimeControl(run_time_manager, project_data_.getMaxCPUSeconds(), project_data_.getTitle(),
324  myComm->rank() == 0);
325 
326  { // walker initialization
328  ParallelExecutor<> section_start_task;
329  section_start_task(crowds_.size(), initialLogEvaluation, std::ref(crowds_), std::ref(step_contexts_));
330  print_mem("VMCBatched after initialLogEvaluation", app_summary());
332  measureImbalance("InitialLogEvaluation");
333  }
334 
335  ScopedTimer local_timer(timers_.production_timer);
336  ParallelExecutor<> crowd_task;
337 
339  {
340  // Run warm-up steps
341  Timer warmup_timer;
342  auto runWarmupStep = [](int crowd_id, StateForThread& sft, DriverTimers& timers,
343  UPtrVector<ContextForSteps>& context_for_steps, UPtrVector<Crowd>& crowds) {
344  Crowd& crowd = *(crowds[crowd_id]);
345  const bool recompute = false;
346  const bool accumulate_this_step = false;
347  const bool spin_move = sft.population.get_golden_electrons().isSpinor();
348  if (spin_move)
349  advanceWalkers<CoordsType::POS_SPIN>(sft, crowd, timers, *context_for_steps[crowd_id], recompute,
350  accumulate_this_step);
351  else
352  advanceWalkers<CoordsType::POS>(sft, crowd, timers, *context_for_steps[crowd_id], recompute,
353  accumulate_this_step);
354  };
355 
356  for (int step = 0; step < qmcdriver_input_.get_warmup_steps(); ++step)
357  {
358  ScopedTimer local_timer(timers_.run_steps_timer);
359  crowd_task(crowds_.size(), runWarmupStep, vmc_state, std::ref(timers_), std::ref(step_contexts_),
360  std::ref(crowds_));
361  }
362 
363  app_log() << "VMC Warmup completed in " << std::setprecision(4) << warmup_timer.elapsed() << " secs" << std::endl;
364  print_mem("VMCBatched after Warmup", app_log());
366  measureImbalance("Warmup");
367  }
368 
369  // this barrier fences all previous load imbalance. Avoid block 0 timing pollution.
370  myComm->barrier();
371 
372  int global_step = 0;
373  for (int block = 0; block < num_blocks; ++block)
374  {
375  {
376  ScopeGuard<LoopTimer<>> vmc_local_timer(vmc_loop);
377  vmc_state.recalculate_properties_period =
379  vmc_state.is_recomputing_block = qmcdriver_input_.get_blocks_between_recompute()
380  ? (1 + block) % qmcdriver_input_.get_blocks_between_recompute() == 0
381  : false;
382 
384 
385  for (auto& crowd : crowds_)
386  crowd->startBlock(steps_per_block_);
387 
388  for (int step = 0; step < steps_per_block_; ++step, ++global_step)
389  {
390  ScopedTimer local_timer(timers_.run_steps_timer);
391  vmc_state.step = step;
392  vmc_state.global_step = global_step;
393  crowd_task(crowds_.size(), runVMCStep, vmc_state, timers_, std::ref(step_contexts_), std::ref(crowds_));
394 
395  if (collect_samples_)
396  {
397  const auto& elec_psets = population_.get_elec_particle_sets();
398  for (const auto& walker : elec_psets)
399  {
400  samples_.appendSample(MCSample(*walker));
401  }
402  }
403  }
404 
405  print_mem("VMCBatched after a block", app_debug_stream());
407  measureImbalance("Block " + std::to_string(block));
408  endBlock();
409  wlog_manager.writeBuffers();
410  recordBlock(block);
411  }
412 
413  bool stop_requested = false;
414  // Rank 0 decides whether the time limit was reached
415  if (!myComm->rank())
416  stop_requested = runtimeControl.checkStop(vmc_loop);
417  myComm->bcast(stop_requested);
418  // Progress messages before possibly stopping
419  if (!myComm->rank())
420  app_log() << runtimeControl.generateProgressMessage("VMCBatched", block, num_blocks);
421  if (stop_requested)
422  {
423  if (!myComm->rank())
424  app_log() << runtimeControl.generateStopMessage("VMCBatched", block);
425  run_time_manager.markStop();
426  break;
427  }
428  }
429  // This is confusing logic from VMC.cpp want this functionality write documentation of this
430  // and clean it up
431  // bool wrotesamples = qmcdriver_input_.get_dump_config();
432  // if (qmcdriver_input_.get_dump_config())
433  // {
434  //wrotesamples = W.dumpEnsemble(wClones, wOut, myComm->size(), nBlocks);
435  //if (wrotesamples)
436  // app_log() << " samples are written to the config.h5" << std::endl;
437  // }
438 
439  // second argument was !wrotesample so if W.dumpEnsemble returns false or
440  // dump_config is false from input then dump_walkers
441  {
442  std::ostringstream o;
443  FullPrecRealType ene, var;
444  estimator_manager_->getApproximateEnergyVariance(ene, var);
445  o << "====================================================";
446  o << "\n End of a VMC section";
447  o << "\n QMC counter = " << project_data_.getSeriesIndex();
448  o << "\n time step = " << qmcdriver_input_.get_tau();
449  o << "\n reference energy = " << ene;
450  o << "\n reference variance = " << var;
451  o << "\n====================================================";
452  app_log() << o.str() << std::endl;
453  }
454 
455  print_mem("VMCBatched ends", app_log());
456 
457  wlog_manager.stopRun();
458  estimator_manager_->stopDriverRun();
459 
460  return finalize(num_blocks, true);
461 }
const std::string & getTitle() const noexcept
returns the title of the project <project id="det_qmc_short_sdbatch_vmcbatch_mwalkers" series="0"> tr...
size_t steps_per_block_
actual number of steps per block
Definition: QMCDriverNew.h:407
void barrier() const
MCPopulation population_
the entire (on node) walker population it serves VMCBatch and DMCBatch right now but will be polymorp...
Definition: QMCDriverNew.h:426
int rank() const
return the rank
Definition: Communicate.h:116
void recordBlock(int block) override
record the state of the block
WalkerLogInput walker_logs_input
walker logs input
Definition: QMCDriverNew.h:108
std::ostream & app_log()
Definition: OutputManager.h:65
std::ostream & app_summary()
Definition: OutputManager.h:63
RunTimeManager< ChronoClock > run_time_manager
const char num_blocks[]
Definition: HDFVersion.h:44
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::unique_ptr< EstimatorManagerNew > estimator_manager_
Observables manager Has very problematic owner ship and life cycle.
Definition: QMCDriverNew.h:443
void print_mem(const std::string &title, std::ostream &log)
Definition: MemoryUsage.cpp:30
std::bitset< QMC_MODE_MAX > qmc_driver_mode_
bits to classify QMCDriver
Definition: QMCDriverNew.h:103
bool collect_samples_
Sample collection flag.
Definition: VMCBatched.h:135
bool finalize(int block, bool dumpwalkers=true)
finalize a qmc section
int getMaxCPUSeconds() const noexcept
const std::string & get_root_name() const override
Definition: QMCDriverNew.h:331
static RefVector< WalkerLogCollector > getWalkerLogCollectorRefs(const UPtrVector< Crowd > &crowds)
get refereces of active walker log collectors. If walker logging is disabled, the RefVector size can ...
Definition: Crowd.cpp:106
static void initialLogEvaluation(int crowd_id, UPtrVector< Crowd > &crowds, UPtrVector< ContextForSteps > &step_context)
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
QMCTraits::FullPrecRealType FullPrecRealType
Definition: VMCBatched.h:38
QMCTraits::IndexType IndexType
Definition: QMCDriverNew.h:79
UPtrVector< ContextForSteps > step_contexts_
Per crowd move contexts, this is where the DistanceTables etc.
Definition: QMCDriverNew.h:450
std::unique_ptr< DriftModifierBase > drift_modifier_
drift modifer
Definition: QMCDriverNew.h:394
static void runVMCStep(int crowd_id, const StateForThread &sft, DriverTimers &timers, UPtrVector< ContextForSteps > &context_for_steps, UPtrVector< Crowd > &crowds)
Thread body for VMC step.
Definition: VMCBatched.cpp:243
bool allow_walker_logs
whether to allow walker logs
Definition: QMCDriverNew.h:106
SampleStack & samples_
Storage for samples (later used in optimizer)
Definition: VMCBatched.h:133
void appendSample(MCSample &&sample)
Definition: SampleStack.cpp:33
IndexType get_warmup_steps() const
IndexType get_max_blocks() const
const ProjectData & project_data_
project info for accessing global fileroot and series id
Definition: QMCDriverNew.h:478
void bcast(T &)
int getSeriesIndex() const noexcept
VMCDriverInput vmcdriver_input_
Definition: VMCBatched.h:124
IndexType get_blocks_between_recompute() const
UPtrVector< Crowd > crowds_
}@
Definition: QMCDriverNew.h:389
QMCDriverInput qmcdriver_input_
Definition: QMCDriverNew.h:372
void measureImbalance(const std::string &tag) const
inject additional barrier and measure load imbalance.
DriverTimers timers_
period of dumping walker configurations and everything else for restart
Definition: QMCDriverNew.h:472
UPtrVector< ParticleSet > & get_elec_particle_sets()
Definition: MCPopulation.h:198
std::ostream & app_debug_stream()
Definition: OutputManager.h:71
void endBlock()
end of a block operations. Aggregates statistics across all MPI ranks and write to disk...
int get_recalculate_properties_period() const

◆ runVMCStep()

void runVMCStep ( int  crowd_id,
const StateForThread sft,
DriverTimers timers,
UPtrVector< ContextForSteps > &  context_for_steps,
UPtrVector< Crowd > &  crowds 
)
static

Thread body for VMC step.

Definition at line 243 of file VMCBatched.cpp.

References qmcplusplus::crowd, MCPopulation::get_golden_electrons(), VMCBatched::StateForThread::is_recomputing_block, ParticleSet::isSpinor(), VMCBatched::StateForThread::population, VMCBatched::StateForThread::step, and VMCBatched::StateForThread::steps_per_block.

Referenced by VMCBatched::run().

248 {
249  Crowd& crowd = *(crowds[crowd_id]);
250  crowd.setRNGForHamiltonian(context_for_steps[crowd_id]->get_random_gen());
251  const IndexType step = sft.step;
252  // Are we entering the the last step of a block to recompute at?
253  const bool recompute_this_step = (sft.is_recomputing_block && (step + 1) == sft.steps_per_block);
254  // For VMC we don't call this method for warmup steps.
255  const bool accumulate_this_step = true;
256  const bool spin_move = sft.population.get_golden_electrons().isSpinor();
257  if (spin_move)
258  advanceWalkers<CoordsType::POS_SPIN>(sft, crowd, timers, *context_for_steps[crowd_id], recompute_this_step,
259  accumulate_this_step);
260  else
261  advanceWalkers<CoordsType::POS>(sft, crowd, timers, *context_for_steps[crowd_id], recompute_this_step,
262  accumulate_this_step);
263 }
QMCTraits::IndexType IndexType
Definition: QMCDriverNew.h:79

Friends And Related Function Documentation

◆ qmcplusplus::testing::VMCBatchedTest

Definition at line 142 of file VMCBatched.h.

Member Data Documentation

◆ collect_samples_

bool collect_samples_
private

Sample collection flag.

Definition at line 135 of file VMCBatched.h.

Referenced by VMCBatched::enable_sample_collection(), and VMCBatched::run().

◆ prevSteps

int prevSteps
private

Definition at line 122 of file VMCBatched.h.

◆ prevStepsBetweenSamples

int prevStepsBetweenSamples
private

Definition at line 123 of file VMCBatched.h.

◆ samples_

SampleStack& samples_
private

Storage for samples (later used in optimizer)

Definition at line 133 of file VMCBatched.h.

Referenced by VMCBatched::enable_sample_collection(), and VMCBatched::run().

◆ vmcdriver_input_

VMCDriverInput vmcdriver_input_
private

Definition at line 124 of file VMCBatched.h.

Referenced by VMCBatched::run().

◆ qmcplusplus::VMCUpdateAll

class qmcplusplus::VMCUpdateAll


Implements the VMC algorithm using particle-by-particle move.

Definition at line 24 of file VMCUpdateAll.h.

+ Inheritance diagram for VMCUpdateAll:
+ Collaboration diagram for VMCUpdateAll:

Public Member Functions

 VMCUpdateAll (MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, RandomBase< FullPrecRealType > &rg)
 Constructor. More...
 
 ~VMCUpdateAll () override
 
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 Member Functions

 VMCUpdateAll (const VMCUpdateAll &)=delete
 Copy Constructor (disabled) More...
 
VMCUpdateAlloperator= (const VMCUpdateAll &)=delete
 Copy operator (disabled). More...
 

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
 

Constructor & Destructor Documentation

◆ VMCUpdateAll() [1/2]

Constructor.

Definition at line 24 of file VMCUpdateAll.cpp.

References QMCUpdateBase::UpdatePbyP.

28  : QMCUpdateBase(w, psi, h, rg)
29 {
30  UpdatePbyP = false;
31 }
QMCUpdateBase(MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, RandomBase< FullPrecRealType > &rg)
Constructor.
bool UpdatePbyP
update particle-by-particle

◆ ~VMCUpdateAll()

~VMCUpdateAll ( )
override

Definition at line 33 of file VMCUpdateAll.cpp.

33 {}

◆ VMCUpdateAll() [2/2]

VMCUpdateAll ( const VMCUpdateAll )
privatedelete

Copy Constructor (disabled)

Member Function Documentation

◆ advanceWalker()

void advanceWalker ( Walker_t thisWalker,
bool  recompute 
)
overridevirtual

move a walker

Implements QMCUpdateBase.

Definition at line 35 of file VMCUpdateAll.cpp.

References Walker< t_traits, p_traits >::Age, qmcplusplus::assignDrift(), QMCHamiltonian::auxHevaluate(), QMCUpdateBase::deltaR, qmcplusplus::Dot(), QMCUpdateBase::drift, QMCHamiltonian::evaluate(), TrialWaveFunction::evaluateLog(), qmcplusplus::exp(), ParticleSet::G, TrialWaveFunction::getPhase(), Walker< t_traits, p_traits >::getPropertyBase(), QMCUpdateBase::H, ParticleSet::loadWalker(), QMCUpdateBase::logBackwardGF(), qmcplusplus::makeGaussRandomWithEngine(), ParticleSet::makeMoveAllParticles(), ParticleSet::makeMoveAllParticlesWithDrift(), QMCUpdateBase::MassInvP, QMCUpdateBase::nAccept, QMCUpdateBase::nReject, QMCUpdateBase::nSubSteps, Walker< t_traits, p_traits >::Properties, QMCUpdateBase::Psi, ParticleSet::R, Walker< t_traits, p_traits >::R, QMCUpdateBase::RandomGen, Walker< t_traits, p_traits >::resetProperty(), QMCHamiltonian::saveProperty(), ParticleSet::saveWalker(), QMCUpdateBase::SqrtTauOverMass, QMCUpdateBase::Tau, ParticleSet::update(), QMCUpdateBase::UseDrift, and QMCUpdateBase::W.

36 {
37  /* thisWalker.R will track the last accepted configuration
38  * W.R will track the proposed configuration
39  *
40  * upon Call:
41  * thisWalker.R,G,L,Properties must be consistent
42  * recompute flag is for pbyp driver and is not used here
43  *
44  * upon Return:
45  * thisWalker.R,G,L,Properties must be kept consistent
46  * */
47  bool updated = false;
48  W.loadWalker(
49  thisWalker,
50  false); // W.R,G,L = thisWalker.R,G,L; false indicates W.DistTables & SK are not updated in this call. W.DistTables,SK are now stale.
51  RealType logpsi_old = thisWalker.Properties(WP::LOGPSI);
52  for (int iter = 0; iter < nSubSteps; ++iter)
53  { // make a few Monte-Carlo steps to decorrelate samples without calculating observables
55  updated = false;
56  if (UseDrift)
57  {
58  assignDrift(Tau, MassInvP, thisWalker.G, drift); // fill variable drift
60  { // W.R = thisWalker.R + drift + deltaR; W.DistTables,SK are updated; W.G,L are now stale
61  RealType logpsi = Psi.evaluateLog(W); // update W.G,L; update Psi.PhaseValue,log_real_
62  RealType logGf = -0.5 * Dot(deltaR, deltaR);
63  assignDrift(Tau, MassInvP, W.G, drift); // update drift at proposed configuration
64  deltaR = thisWalker.R - W.R - drift; // hijack deltaR to hold reverse move
65  RealType logGb = logBackwardGF(deltaR);
66 
67  RealType g = std::exp(logGb - logGf + 2.0 * (logpsi - logpsi_old));
68  // accept or reject
69  if (RandomGen() <= g)
70  {
71  thisWalker.R = W.R;
72  thisWalker.G = W.G;
73  ++nAccept;
74  logpsi_old = logpsi;
75  updated = true;
76  }
77  }
78  }
79  else
80  {
81  if (W.makeMoveAllParticles(thisWalker, deltaR, SqrtTauOverMass))
82  { // W.R += dR*dt; W.DistTables,SK are updated; W.G,L are now stale
83  RealType logpsi = Psi.evaluateLog(W); // update W.G,L at changed W.R; update Psi.log_real_,PhaseValue
84  RealType g = std::exp(2.0 * (logpsi - logpsi_old));
85  if (RandomGen() <= g)
86  { // move is accepted; logpsi_old and R_old are stale
87  logpsi_old = logpsi; // update logpsi_old
88  thisWalker.R = W.R; // update R_old; side effect: thisWalker.G,L,DistTables,SK,Properties are now stale
89  ++nAccept;
90  updated = true;
91  }
92  }
93  }
94 
95  if (!updated)
96  { // W.R,G,L,DistTables,SK are not updated. i.e. they are still consistent
97  thisWalker.Age++;
98  ++nReject;
99  }
100  }
101 
102  if (!updated)
103  { // W.G and W.L have to be computed because the last move was rejected
104  W.loadWalker(thisWalker, false); // move W back to last accepted configuration
105  W.update(); // update W.DistTables and SK
106  logpsi_old = Psi.evaluateLog(W); // update W.G,L
107  } // W and logpsi_old are up-to-date at this point
108 
109  RealType eloc = H.evaluate(
110  W); // calculate local energy; W.SK must be up-to-date if Coulomb interaction is used with periodic boundary. W.SK is used to calculate the long-range part of the Coulomb potential.
111  W.saveWalker(thisWalker);
112  thisWalker.resetProperty(logpsi_old, Psi.getPhase(),
113  eloc); // update thisWalker::Properties[WP::LOGPSI,WP::SIGN,WP::LOCALENERGY]
114  H.auxHevaluate(W, thisWalker); // update auxiliary observables, i.e. fill H::Observables
115  H.saveProperty(thisWalker.getPropertyBase()); // copy H::Observables to thisWalker::Properties
116 }
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
ParticleSet::ParticlePos drift
temporary storage for drift
TrialWaveFunction & Psi
trial function
void saveProperty(IT first)
save the values of Hamiltonian elements to the Properties
void assignDrift(T s, const ParticleAttrib< TinyVector< TG, D >> &ga, ParticleAttrib< TinyVector< T, D >> &da)
void update(bool skipSK=false)
update the internal data
ParticleSet::ParticlePos deltaR
temporary storage for random displacement
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
std::vector< RealType > SqrtTauOverMass
sqrt(tau/Mass) per particle
ParticleGradient G
gradients of the particles
Definition: ParticleSet.h:83
void saveWalker(Walker_t &awalker)
save this to awalker
RealType Tau
timestep
Definition: QMCUpdateBase.h:73
RealType logBackwardGF(const ParticleSet::ParticlePos &displ)
ParticlePos R
Position.
Definition: ParticleSet.h:79
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
MCWalkerConfiguration & W
walker ensemble
std::vector< RealType > MassInvP
1/Mass per particle
void loadWalker(Walker_t &awalker, bool pbyp)
load a Walker_t to the current ParticleSet
void auxHevaluate(ParticleSet &P)
int nSubSteps
number of steps per measurement
Definition: QMCUpdateBase.h:56
QMCTraits::RealType RealType
RandomBase< FullPrecRealType > & RandomGen
random number generator
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
bool makeMoveAllParticlesWithDrift(const Walker_t &awalker, const ParticlePos &drift, const ParticlePos &deltaR, RealType dt)
move all the particles including the drift
IndexType nAccept
counter for number of moves accepted
Definition: QMCUpdateBase.h:63
IndexType nReject
counter for number of moves rejected
Definition: QMCUpdateBase.h:65
bool makeMoveAllParticles(const Walker_t &awalker, const ParticlePos &deltaR, RealType dt)
move all the particles of a walker
QMCHamiltonian & H
Hamiltonian.
void makeGaussRandomWithEngine(ParticleAttrib< TinyVector< T, D >> &a, RG &rng)

◆ operator=()

VMCUpdateAll& operator= ( const VMCUpdateAll )
privatedelete

Copy operator (disabled).

◆ qmcplusplus::VMCUpdatePbyP

class qmcplusplus::VMCUpdatePbyP


Implements the VMC algorithm using particle-by-particle move.

Definition at line 25 of file VMCUpdatePbyP.h.

+ Inheritance diagram for VMCUpdatePbyP:
+ Collaboration diagram for VMCUpdatePbyP:

Public Member Functions

 VMCUpdatePbyP (MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, RandomBase< FullPrecRealType > &rg)
 Constructor. More...
 
 ~VMCUpdatePbyP () override
 
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

NewTimerbuffer_timer_
 
NewTimermovepbyp_timer_
 
NewTimerhamiltonian_timer_
 
NewTimercollectables_timer_
 

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
 

Constructor & Destructor Documentation

◆ VMCUpdatePbyP()

Constructor.

Definition at line 30 of file VMCUpdatePbyP.cpp.

34  : QMCUpdateBase(w, psi, h, rg),
35  buffer_timer_(createGlobalTimer("VMCUpdatePbyP::Buffer", timer_level_medium)),
36  movepbyp_timer_(createGlobalTimer("VMCUpdatePbyP::MovePbyP", timer_level_medium)),
37  hamiltonian_timer_(createGlobalTimer("VMCUpdatePbyP::Hamiltonian", timer_level_medium)),
38  collectables_timer_(createGlobalTimer("VMCUpdatePbyP::Collectables", timer_level_medium))
39 {}
NewTimer & createGlobalTimer(const std::string &myname, timer_levels mylevel)
QMCUpdateBase(MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, RandomBase< FullPrecRealType > &rg)
Constructor.

◆ ~VMCUpdatePbyP()

~VMCUpdatePbyP ( )
override

Definition at line 41 of file VMCUpdatePbyP.cpp.

41 {}

Member Function Documentation

◆ advanceWalker()

void advanceWalker ( Walker_t thisWalker,
bool  recompute 
)
overridevirtual

move a walker

Implements QMCUpdateBase.

Definition at line 43 of file VMCUpdatePbyP.cpp.

References ParticleSet::accept_rejectMove(), TrialWaveFunction::acceptMove(), QMCHamiltonian::auxHevaluate(), TraceManager::buffer_sample(), VMCUpdatePbyP::buffer_timer_, TrialWaveFunction::calcRatio(), TrialWaveFunction::calcRatioGrad(), qmcplusplus::CHECKGL_AFTER_MOVES, QMCUpdateBase::checkLogAndGL(), WalkerLogCollector::collect(), VMCUpdatePbyP::collectables_timer_, TrialWaveFunction::completeUpdates(), TrialWaveFunction::copyFromBuffer(), ParticleSet::current_step, Walker< t_traits, p_traits >::DataSet, QMCUpdateBase::debug_checks_, QMCUpdateBase::deltaR, ParticleSet::donePbyP(), qmcplusplus::dot(), QMCUpdateBase::DriftModifier, TrialWaveFunction::evalGrad(), QMCHamiltonian::evaluate(), qmcplusplus::exp(), ParticleSet::first(), ParticleSet::getActivePos(), DriftModifierBase::getDrift(), TrialWaveFunction::getPhase(), Walker< t_traits, p_traits >::getPropertyBase(), ParticleSet::groups(), QMCUpdateBase::H, VMCUpdatePbyP::hamiltonian_timer_, ParticleSet::last(), ParticleSet::loadWalker(), qmcplusplus::makeGaussRandomWithEngine(), ParticleSet::makeMoveAndCheck(), QMCUpdateBase::MassInvS, VMCUpdatePbyP::movepbyp_timer_, QMCUpdateBase::nAccept, QMCUpdateBase::nAllRejected, norm(), QMCUpdateBase::nReject, QMCUpdateBase::nSubSteps, TrialWaveFunction::prepareGroup(), QMCUpdateBase::Psi, ParticleSet::R, QMCUpdateBase::RandomGen, TrialWaveFunction::rejectMove(), Walker< t_traits, p_traits >::resetProperty(), QMCHamiltonian::saveProperty(), ParticleSet::saveWalker(), qmcplusplus::sqrt(), TimerType< CLOCK >::start(), TimerType< CLOCK >::stop(), QMCUpdateBase::Tau, QMCUpdateBase::Traces, TrialWaveFunction::updateBuffer(), QMCUpdateBase::UseDrift, QMCUpdateBase::W, and QMCUpdateBase::wlog_collector.

44 {
46  W.loadWalker(thisWalker, true);
47  Walker_t::WFBuffer_t& w_buffer(thisWalker.DataSet);
48  Psi.copyFromBuffer(W, w_buffer);
50 
51  // start PbyP moves
53  bool moved = false;
54  constexpr RealType mhalf(-0.5);
55  for (int iter = 0; iter < nSubSteps; ++iter)
56  {
57  //create a 3N-Dimensional Gaussian with variance=1
59  moved = false;
60  for (int ig = 0; ig < W.groups(); ++ig) //loop over species
61  {
62  RealType tauovermass = Tau * MassInvS[ig];
63  RealType oneover2tau = 0.5 / (tauovermass);
64  RealType sqrttau = std::sqrt(tauovermass);
65  Psi.prepareGroup(W, ig);
66  for (int iat = W.first(ig); iat < W.last(ig); ++iat)
67  {
68  PosType dr;
69  if (UseDrift)
70  {
71  GradType grad_now = Psi.evalGrad(W, iat);
72  DriftModifier->getDrift(tauovermass, grad_now, dr);
73  dr += sqrttau * deltaR[iat];
74  }
75  else
76  dr = sqrttau * deltaR[iat];
77 
78  if (!W.makeMoveAndCheck(iat, dr))
79  {
80  ++nReject;
81  W.accept_rejectMove(iat, false);
82  continue;
83  }
84 
85  RealType prob(0);
86  if (UseDrift)
87  {
88  GradType grad_new;
89  prob = std::norm(Psi.calcRatioGrad(W, iat, grad_new));
90  DriftModifier->getDrift(tauovermass, grad_new, dr);
91  dr = W.R[iat] - W.getActivePos() - dr;
92  RealType logGb = -oneover2tau * dot(dr, dr);
93  RealType logGf = mhalf * dot(deltaR[iat], deltaR[iat]);
94  prob *= std::exp(logGb - logGf);
95  }
96  else
97  prob = std::norm(Psi.calcRatio(W, iat));
98 
99  bool is_accepted = false;
100  if (prob >= std::numeric_limits<RealType>::epsilon() && RandomGen() < prob)
101  {
102  is_accepted = true;
103  moved = true;
104  ++nAccept;
105  Psi.acceptMove(W, iat, true);
106  }
107  else
108  {
109  ++nReject;
110  Psi.rejectMove(iat);
111  }
112  W.accept_rejectMove(iat, is_accepted);
113  }
114  }
116  }
117  W.donePbyP();
120  RealType logpsi = Psi.updateBuffer(W, w_buffer, recompute);
122  checkLogAndGL(W, Psi, "checkGL_after_moves");
123  W.saveWalker(thisWalker);
125  // end PbyP moves
127  FullPrecRealType eloc = H.evaluate(W);
128  thisWalker.resetProperty(logpsi, Psi.getPhase(), eloc);
131  H.auxHevaluate(W, thisWalker);
132  H.saveProperty(thisWalker.getPropertyBase());
134 #if !defined(REMOVE_TRACEMANAGER)
136 #endif
137  if(wlog_collector)
138  wlog_collector->collect(thisWalker,W,Psi,H);
139  if (!moved)
140  ++nAllRejected;
141 }
TraceManager * Traces
traces
WalkerLogCollector * wlog_collector
void rejectMove(int iat)
restore to the original state
ValueType calcRatio(ParticleSet &P, int iat, ComputeType ct=ComputeType::ALL)
compute psi(R_new) / psi(R_current) ratio It returns a complex value if the wavefunction is complex...
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
void buffer_sample(int current_step)
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
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
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)
int nSubSteps
number of steps per measurement
Definition: QMCUpdateBase.h:56
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
QMCTraits::RealType RealType
RandomBase< FullPrecRealType > & RandomGen
random number generator
GradType evalGrad(ParticleSet &P, int iat)
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
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
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...
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 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

◆ buffer_timer_

NewTimer& buffer_timer_
private

Definition at line 36 of file VMCUpdatePbyP.h.

Referenced by VMCUpdatePbyP::advanceWalker().

◆ collectables_timer_

NewTimer& collectables_timer_
private

Definition at line 39 of file VMCUpdatePbyP.h.

Referenced by VMCUpdatePbyP::advanceWalker().

◆ hamiltonian_timer_

NewTimer& hamiltonian_timer_
private

Definition at line 38 of file VMCUpdatePbyP.h.

Referenced by VMCUpdatePbyP::advanceWalker().

◆ movepbyp_timer_

NewTimer& movepbyp_timer_
private

Definition at line 37 of file VMCUpdatePbyP.h.

Referenced by VMCUpdatePbyP::advanceWalker().