QMCPACK
QMC Drivers using walker-by-walker update

Move all the particles for each walker. More...

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

Classes

class  CSVMC
 
Implements the VMC algorithm using umbrella sampling. More...
 
class  CSVMCUpdateAll
 
Implements the VMC algorithm using umbrella sampling. More...
 

Detailed Description

Move all the particles for each walker.


Class Documentation

◆ qmcplusplus::CSVMC

class qmcplusplus::CSVMC


Implements the VMC algorithm using umbrella sampling.

Energy difference method with multiple H/Psi. Consult S. Chiesa's note.

Definition at line 34 of file CSVMC.h.

+ Inheritance diagram for CSVMC:
+ Collaboration diagram for CSVMC:

Public Member Functions

 CSVMC (const ProjectData &project_data, MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, Communicate *comm)
 Constructor. More...
 
bool run () override
 Run the CSVMC algorithm. More...
 
bool put (xmlNodePtr cur) override
 allocate internal data here before run() is called More...
 
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

 CSVMC (const CSVMC &)=delete
 Copy Constructor (disabled) More...
 
CSVMCoperator= (const CSVMC &)=delete
 Copy operator (disabled). More...
 
void resetRun ()
 

Private Attributes

std::string UseDrift
 
int prevSteps
 
int prevStepsBetweenSamples
 
int equilBlocks
 blocks over which normalization factors are accumulated More...
 
CSEnergyEstimatormultiEstimator
 
CSUpdateBaseMover
 

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

◆ CSVMC() [1/2]

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

Constructor.

Definition at line 37 of file CSVMC.cpp.

References ParameterSet::add(), CSVMC::equilBlocks, QMCDriver::m_param, QMCDriver::qmc_driver_mode, QMCDriver::QMC_MULTIPLE, QMCDriver::RootName, and CSVMC::UseDrift.

42  : QMCDriver(project_data, w, psi, h, comm, "CSVMC"), UseDrift("yes"), multiEstimator(0), Mover(0)
43 {
44  RootName = "csvmc";
45  m_param.add(UseDrift, "useDrift");
46  m_param.add(UseDrift, "usedrift");
47  m_param.add(UseDrift, "use_drift");
48  equilBlocks = -1;
49  m_param.add(equilBlocks, "equilBlocks");
51 }
int equilBlocks
blocks over which normalization factors are accumulated
Definition: CSVMC.h:53
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
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
CSUpdateBase * Mover
Definition: CSVMC.h:63
CSEnergyEstimator * multiEstimator
Definition: CSVMC.h:62
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>
std::string UseDrift
Definition: CSVMC.h:49

◆ CSVMC() [2/2]

CSVMC ( const CSVMC )
privatedelete

Copy Constructor (disabled)

Member Function Documentation

◆ getRunType()

QMCRunType getRunType ( )
inlineoverridevirtual

Implements QMCDriverInterface.

Definition at line 46 of file CSVMC.h.

References qmcplusplus::CSVMC.

◆ operator=()

CSVMC& operator= ( const CSVMC )
privatedelete

Copy operator (disabled).

◆ put()

bool put ( xmlNodePtr  q)
overridevirtual

allocate internal data here before run() is called

Author
SIMONE

See QMCDriver::process

Implements QMCDriverInterface.

Definition at line 58 of file CSVMC.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, CSVMC::prevSteps, CSVMC::prevStepsBetweenSamples, ParameterSet::put(), qmcplusplus::qmc_common, QMCState::qmc_counter, Communicate::size(), QMCDriver::Tau, and QMCDriver::W.

59 {
60  int target_min = -1;
61  ParameterSet p;
62  p.add(target_min, "minimumtargetwalkers");
63  p.add(target_min, "minimumsamples");
64  p.put(q);
65 
66  app_log() << "\n<vmc function=\"put\">"
67  << "\n qmc_counter=" << qmc_common.qmc_counter << " my_counter=" << MyCounter << std::endl;
69  {
70  nSteps = prevSteps;
72  }
73  else
74  {
75  int nw = W.getActiveWalkers();
76  //compute samples and overwrite steps for the given samples
77  int Nthreads = omp_get_max_threads();
78  int Nprocs = myComm->size();
79  //target samples set by samples or samplesperthread/dmcwalkersperthread
80  nTargetPopulation = std::max(nTargetPopulation, nSamplesPerThread * Nprocs * Nthreads);
81  nTargetSamples = static_cast<int>(std::ceil(nTargetPopulation));
82 
83  if (nTargetSamples)
84  {
85  int nwtot = nw * Nprocs; //total number of walkers used by this qmcsection
86  nTargetSamples = std::max(nwtot, nTargetSamples);
87  if (target_min > 0)
88  {
89  nTargetSamples = std::max(nTargetSamples, target_min);
90  nTargetPopulation = std::max(nTargetPopulation, static_cast<RealType>(target_min));
91  }
92  nTargetSamples = ((nTargetSamples + nwtot - 1) / nwtot) *
93  nwtot; // nTargetSamples are always multiples of total number of walkers
94  nSamplesPerThread = nTargetSamples / Nprocs / Nthreads;
95  int ns_target = nTargetSamples * nStepsBetweenSamples; //total samples to generate
96  int ns_per_step = Nprocs * nw; //total samples per step
97  nSteps = std::max(nSteps, (ns_target / ns_per_step + nBlocks - 1) / nBlocks);
99  }
100  else
101  {
102  Period4WalkerDump = nStepsBetweenSamples = (nBlocks + 1) * nSteps; //some positive number, not used
103  nSamplesPerThread = 0;
104  }
105  }
106  prevSteps = nSteps;
108 
109  app_log() << " time step = " << Tau << std::endl;
110  app_log() << " blocks = " << nBlocks << std::endl;
111  app_log() << " steps = " << nSteps << std::endl;
112  app_log() << " substeps = " << nSubSteps << std::endl;
113  app_log() << " current = " << CurrentStep << std::endl;
114  app_log() << " target samples = " << nTargetPopulation << std::endl;
115  app_log() << " walkers/mpi = " << W.getActiveWalkers() << std::endl << std::endl;
116  app_log() << " stepsbetweensamples = " << nStepsBetweenSamples << std::endl;
117 
118  m_param.get(app_log());
119 
120  if (DumpConfig)
121  {
122  app_log() << " DumpConfig==true Configurations are dumped to config.h5 with a period of " << Period4CheckPoint
123  << " blocks" << std::endl;
124  }
125  else
126  {
127  app_log() << " DumpConfig==false Nothing (configurations, state) will be saved." << std::endl;
128  }
129 
130  if (Period4WalkerDump > 0)
131  app_log() << " Walker Samples are dumped every " << Period4WalkerDump << " steps." << std::endl;
132 
133  app_log() << "</vmc>" << std::endl;
134  app_log().flush();
135 
136  return true;
137 }
size_t getActiveWalkers() const
return the number of active walkers
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: CSVMC.h:51
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

Definition at line 210 of file CSVMC.cpp.

References APP_ABORT, qmcplusplus::app_log(), WalkerConfigurations::begin(), QMCDriver::branchEngine, RandomNumberControl::Children, copy(), CloneManager::CSMovers, QMCDriver::DriftModifier, CloneManager::estimatorClones, QMCDriver::Estimators, FairDivideLow(), WalkerConfigurations::getActiveWalkers(), QMCDriver::H1, CloneManager::HPoolClones, CloneManager::makeClones(), CloneManager::Movers, QMCDriver::nSamplesPerThread, QMCDriver::nTargetSamples, CloneManager::NumThreads, QMCDriver::nWarmupSteps, QMCDriver::Psi1, CloneManager::PsiPoolClones, QMCDriver::qmc_driver_mode, QMCDriver::QMC_UPDATE_MODE, QMCDriver::qmcNode, QMCDriver::Rng, CloneManager::traceClones, QMCDriver::Traces, CSVMC::UseDrift, QMCDriver::W, CloneManager::wClones, and CloneManager::wPerRank.

Referenced by CSVMC::run().

211 {
212  H1[0]->setPrimary(true);
213  IndexType nPsi = Psi1.size();
214  for (int ipsi = 1; ipsi < nPsi; ipsi++)
215  H1[ipsi]->setPrimary(false);
216 
217 
218  makeClones(W, Psi1, H1);
220 
221  if (NumThreads > 1)
222  APP_ABORT("OpenMP Parallelization for CSVMC not working at the moment");
223 
224  app_log() << " Initial partition of walkers ";
225  copy(wPerRank.begin(), wPerRank.end(), std::ostream_iterator<int>(app_log(), " "));
226  app_log() << std::endl;
227 
228 
229  if (Movers.empty())
230  {
231  CSMovers.resize(NumThreads);
232  estimatorClones.resize(NumThreads, nullptr);
233  traceClones.resize(NumThreads, nullptr);
234  Rng.resize(NumThreads);
235 
236  // hdf_archive::hdf_archive() is not thread-safe
237  for (int ip = 0; ip < NumThreads; ++ip)
238  estimatorClones[ip] = new EstimatorManagerBase(*Estimators);
239 
240 #pragma omp parallel for
241  for (int ip = 0; ip < NumThreads; ++ip)
242  {
243  std::ostringstream os;
244  estimatorClones[ip]->resetTargetParticleSet(*wClones[ip]);
245  estimatorClones[ip]->setCollectionMode(false);
246 #if !defined(REMOVE_TRACEMANAGER)
247  traceClones[ip] = Traces->makeClone();
248 #endif
249  Rng[ip] = RandomNumberControl::Children[ip]->makeClone();
251  {
252  if (UseDrift == "yes")
253  {
254  os << " Using particle-by-particle update with drift " << std::endl;
255  CSMovers[ip] = std::make_unique<CSVMCUpdatePbyPWithDriftFast>(*wClones[ip], PsiPoolClones[ip], HPoolClones[ip], *Rng[ip]);
256  }
257  else
258  {
259  os << " Using particle-by-particle update with no drift" << std::endl;
260  CSMovers[ip] = std::make_unique<CSVMCUpdatePbyP>(*wClones[ip], PsiPoolClones[ip], HPoolClones[ip], *Rng[ip]);
261  }
262  }
263  else
264  {
265  if (UseDrift == "yes")
266  {
267  os << " Using walker-by-walker update with Drift " << std::endl;
268  CSMovers[ip] = std::make_unique<CSVMCUpdateAllWithDrift>(*wClones[ip], PsiPoolClones[ip], HPoolClones[ip], *Rng[ip]);
269  }
270  else
271  {
272  os << " Using walker-by-walker update " << std::endl;
273  CSMovers[ip] = std::make_unique<CSVMCUpdateAll>(*wClones[ip], PsiPoolClones[ip], HPoolClones[ip], *Rng[ip]);
274  }
275  }
276  if (ip == 0)
277  app_log() << os.str() << std::endl;
278 
279  CSMovers[ip]->put(qmcNode);
280  CSMovers[ip]->resetRun(branchEngine.get(), estimatorClones[ip], traceClones[ip], DriftModifier);
281  }
282  }
283 #if !defined(REMOVE_TRACEMANAGER)
284  else
285  {
286 #pragma omp parallel for
287  for (int ip = 0; ip < NumThreads; ++ip)
288  {
289  traceClones[ip]->transfer_state_from(*Traces);
290  }
291  }
292 #endif
293 
294  app_log() << " Total Sample Size =" << nTargetSamples << std::endl;
295  app_log() << " Walker distribution on root = ";
296  copy(wPerRank.begin(), wPerRank.end(), std::ostream_iterator<int>(app_log(), " "));
297  app_log() << std::endl;
298  app_log().flush();
299 
300 #pragma omp parallel for
301  for (int ip = 0; ip < NumThreads; ++ip)
302  {
303  //int ip=omp_get_thread_num();
304  CSMovers[ip]->put(qmcNode);
305  CSMovers[ip]->resetRun(branchEngine.get(), estimatorClones[ip], traceClones[ip], DriftModifier);
307  CSMovers[ip]->initCSWalkersForPbyP(W.begin() + wPerRank[ip], W.begin() + wPerRank[ip + 1], nWarmupSteps > 0);
308  else
309  CSMovers[ip]->initCSWalkers(W.begin() + wPerRank[ip], W.begin() + wPerRank[ip + 1], nWarmupSteps > 0);
310 
311  for (int prestep = 0; prestep < nWarmupSteps; ++prestep)
312  {
313  CSMovers[ip]->advanceWalkers(W.begin() + wPerRank[ip], W.begin() + wPerRank[ip + 1], true);
314  if (prestep == nWarmupSteps - 1)
315  CSMovers[ip]->updateNorms();
316  }
317  }
318 
319  for (int ip = 0; ip < NumThreads; ++ip)
320  wClones[ip]->clearEnsemble();
321  if (nSamplesPerThread)
322  for (int ip = 0; ip < NumThreads; ++ip)
323  wClones[ip]->setNumSamples(nSamplesPerThread);
324  nWarmupSteps = 0;
325 }
std::vector< int > wPerRank
Walkers per MPI rank.
Definition: CloneManager.h:91
std::vector< TrialWaveFunction * > Psi1
a list of TrialWaveFunctions for multiple method
Definition: QMCDriver.h:335
size_t getActiveWalkers() const
return the number of active walkers
static std::vector< std::vector< TrialWaveFunction * > > PsiPoolClones
Definition: CloneManager.h:85
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
UPtrVector< CSUpdateBase > CSMovers
Definition: CloneManager.h:88
std::vector< QMCUpdateBase * > Movers
update engines
Definition: CloneManager.h:73
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
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
Definition: Blitz.h:639
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
DriftModifierBase * DriftModifier
drift modifer
Definition: QMCDriver.h:220
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
void makeClones(MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &ham)
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
static UPtrVector< RandomBase< FullPrecRealType > > Children
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65
std::vector< QMCHamiltonian * > H1
a list of QMCHamiltonians for multiple method
Definition: QMCDriver.h:338
IndexType nTargetSamples
the number of saved samples
Definition: QMCDriver.h:289
EstimatorManagerBase * Estimators
Observables manager.
Definition: QMCDriver.h:192
static std::vector< std::vector< QMCHamiltonian * > > HPoolClones
Definition: CloneManager.h:87
std::vector< TraceManager * > traceClones
trace managers
Definition: CloneManager.h:77
IndexType nWarmupSteps
number of warmup steps
Definition: QMCDriver.h:275
UPtrVector< RandomBase< FullPrecRealType > > Rng
Random number generators.
Definition: QMCDriver.h:341
std::string UseDrift
Definition: CSVMC.h:49
iterator begin()
return the first iterator

◆ run()

bool run ( )
overridevirtual

Run the CSVMC algorithm.

Similar to VMC::run

write samples to a file

Implements QMCDriverInterface.

Definition at line 143 of file CSVMC.cpp.

References qmcplusplus::app_log(), WalkerConfigurations::begin(), RandomNumberControl::Children, ParticleSet::Collectables, CloneManager::CSMovers, QMCDriver::CurrentStep, QMCDriver::DumpConfig, MCWalkerConfiguration::dumpEnsemble(), CloneManager::estimatorClones, QMCDriver::Estimators, QMCDriver::finalize(), MPIObjectBase::myComm, QMCDriver::nBlocks, QMCDriver::nSteps, CloneManager::NumThreads, omp_get_thread_num(), QMCDriver::Period4CheckProperties, QMCDriver::Period4WalkerDump, QMCDriver::qmc_driver_mode, QMCDriver::QMC_UPDATE_MODE, QMCDriver::recordBlock(), CSVMC::resetRun(), QMCDriver::Rng, PooledData< T >::size(), Communicate::size(), EstimatorManagerBase::start(), EstimatorManagerBase::stop(), EstimatorManagerBase::stopBlock(), CloneManager::traceClones, QMCDriver::Traces, QMCDriver::W, CloneManager::wClones, QMCDriver::wOut, and CloneManager::wPerRank.

144 {
145  resetRun();
146  //start the main estimator
148  for (int ip = 0; ip < NumThreads; ++ip)
149  CSMovers[ip]->startRun(nBlocks, false);
150 
151 #if !defined(REMOVE_TRACEMANAGER)
152  Traces->startRun(nBlocks, traceClones);
153 #endif
154  const bool has_collectables = W.Collectables.size();
155  for (int block = 0; block < nBlocks; ++block)
156  {
157 #pragma omp parallel
158  {
159  int ip = omp_get_thread_num();
161  //assign the iterators and resuse them
162  MCWalkerConfiguration::iterator wit(W.begin() + wPerRank[ip]), wit_end(W.begin() + wPerRank[ip + 1]);
163  CSMovers[ip]->startBlock(nSteps);
164  int now_loc = CurrentStep;
165  RealType cnorm = 1.0 / static_cast<RealType>(wPerRank[ip + 1] - wPerRank[ip]);
166  for (int step = 0; step < nSteps; ++step)
167  {
168  CSMovers[ip]->set_step(now_loc);
169  //collectables are reset, it is accumulated while advancing walkers
170  wClones[ip]->resetCollectables();
171  CSMovers[ip]->advanceWalkers(wit, wit_end, false);
172  if (has_collectables)
173  wClones[ip]->Collectables *= cnorm;
174  CSMovers[ip]->accumulate(wit, wit_end);
175  ++now_loc;
176  if (Period4WalkerDump && now_loc % Period4WalkerDump == 0)
177  wClones[ip]->saveEnsemble(wit, wit_end);
178  }
179  CSMovers[ip]->stopBlock(false);
180 
181  } //end-of-parallel for
182  CurrentStep += nSteps;
184 #if !defined(REMOVE_TRACEMANAGER)
185  Traces->write_buffers(traceClones, block);
186 #endif
187  recordBlock(block);
188  } //block
190  for (int ip = 0; ip < NumThreads; ++ip)
191  CSMovers[ip]->stopRun2();
192 #if !defined(REMOVE_TRACEMANAGER)
193  Traces->stopRun();
194 #endif
195  //copy back the random states
196  for (int ip = 0; ip < NumThreads; ++ip)
197  RandomNumberControl::Children[ip] = Rng[ip]->makeClone();
198  ///write samples to a file
199  bool wrotesamples = DumpConfig;
200  if (DumpConfig)
201  {
203  if (wrotesamples)
204  app_log() << " samples are written to the config.h5" << std::endl;
205  }
206  //finalize a qmc section
207  return finalize(nBlocks, !wrotesamples);
208 }
size_type size() const
return the size of the data
Definition: PooledData.h:48
std::vector< int > wPerRank
Walkers per MPI rank.
Definition: CloneManager.h:91
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
IndexType CurrentStep
current step
Definition: QMCDriver.h:263
UPtrVector< CSUpdateBase > CSMovers
Definition: CloneManager.h:88
int size() const
return the number of tasks
Definition: Communicate.h:118
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
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
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
static bool dumpEnsemble(std::vector< MCWalkerConfiguration *> &others, HDFWalkerOutput &out, int np, int nBlock)
dump Samples to a file
QMCTraits::RealType RealType
EstimatorManagerBase * Estimators
Observables manager.
Definition: QMCDriver.h:192
void stopBlock(RealType accept, bool collectall=true)
stop a block
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
iterator begin()
return the first iterator

Member Data Documentation

◆ equilBlocks

int equilBlocks
private

blocks over which normalization factors are accumulated

Definition at line 53 of file CSVMC.h.

Referenced by CSVMC::CSVMC().

◆ Mover

CSUpdateBase* Mover
private

Definition at line 63 of file CSVMC.h.

◆ multiEstimator

CSEnergyEstimator* multiEstimator
private

Definition at line 62 of file CSVMC.h.

◆ prevSteps

int prevSteps
private

Definition at line 50 of file CSVMC.h.

Referenced by CSVMC::put().

◆ prevStepsBetweenSamples

int prevStepsBetweenSamples
private

Definition at line 51 of file CSVMC.h.

Referenced by CSVMC::put().

◆ UseDrift

std::string UseDrift
private

Definition at line 49 of file CSVMC.h.

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

◆ qmcplusplus::CSVMCUpdateAll

class qmcplusplus::CSVMCUpdateAll


Implements the VMC algorithm using umbrella sampling.

Energy difference method with multiple H/Psi. Consult S. Chiesa's note.

Definition at line 32 of file CSVMCUpdateAll.h.

+ Inheritance diagram for CSVMCUpdateAll:
+ Collaboration diagram for CSVMCUpdateAll:

Public Member Functions

 CSVMCUpdateAll (MCWalkerConfiguration &w, std::vector< TrialWaveFunction *> &psi, std::vector< QMCHamiltonian *> &h, RandomBase< FullPrecRealType > &rg)
 Constructor. More...
 
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

◆ CSVMCUpdateAll()

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

Constructor.

Definition at line 33 of file CSVMCUpdateAll.cpp.

References QMCUpdateBase::UpdatePbyP.

37  : CSUpdateBase(w, psi, h, rg)
38 {
39  UpdatePbyP = false;
40 }
CSUpdateBase(MCWalkerConfiguration &w, std::vector< TrialWaveFunction *> &psi, std::vector< QMCHamiltonian *> &h, RandomBase< FullPrecRealType > &rg)
bool UpdatePbyP
update particle-by-particle

Member Function Documentation

◆ advanceWalker()

void advanceWalker ( Walker_t thisWalker,
bool  recompute 
)
overridevirtual

move a walker

Implements QMCUpdateBase.

Definition at line 42 of file CSVMCUpdateAll.cpp.

References Walker< t_traits, p_traits >::Age, CSUpdateBase::avgNorm, CSUpdateBase::cumNorm, QMCUpdateBase::deltaR, qmcplusplus::exp(), ParticleSet::G, CSUpdateBase::G1, Walker< t_traits, p_traits >::getPropertyBase(), CSUpdateBase::H1, CSUpdateBase::invsumratio, ParticleSet::L, CSUpdateBase::L1, CSUpdateBase::logpsi, qmcplusplus::makeGaussRandomWithEngine(), ParticleSet::makeMoveAllParticles(), QMCUpdateBase::MassInvS, Walker< t_traits, p_traits >::Multiplicity, QMCUpdateBase::nAccept, CSUpdateBase::nPsi, QMCUpdateBase::nReject, Walker< t_traits, p_traits >::Properties, CSUpdateBase::Psi1, ParticleSet::R, Walker< t_traits, p_traits >::R, Random, QMCUpdateBase::RandomGen, qmcplusplus::sqrt(), CSUpdateBase::sumratio, QMCUpdateBase::Tau, and QMCUpdateBase::W.

43 {
45  //create a 3N-Dimensional Gaussian with variance=1
47 
48  RealType tau_over_mass = std::sqrt(Tau * MassInvS[0]);
49 
50  if (!W.makeMoveAllParticles(thisWalker, deltaR, tau_over_mass))
51  {
52  for (int ipsi = 0; ipsi < nPsi; ipsi++)
53  H1[ipsi]->rejectedMove(W, thisWalker);
54  return;
55  }
56 
57  //Evaluate Psi and graidients and laplacians
58  //\f$\sum_i \ln(|psi_i|)\f$ and catching the sign separately
59  for (int ipsi = 0; ipsi < nPsi; ipsi++)
60  {
61  logpsi[ipsi] = Psi1[ipsi]->evaluateLog(W);
62  Psi1[ipsi]->L = W.L;
63  Psi1[ipsi]->G = W.G;
64 
65  *G1[ipsi] = W.G;
66  *L1[ipsi] = W.L;
67  sumratio[ipsi] = 1.0;
68  }
69  // Compute the sum over j of Psi^2[j]/Psi^2[i] for each i
70  for (int ipsi = 0; ipsi < nPsi - 1; ipsi++)
71  {
72  for (int jpsi = ipsi + 1; jpsi < nPsi; jpsi++)
73  {
74  RealType ratioij = avgNorm[ipsi] / avgNorm[jpsi] * std::exp(2.0 * (logpsi[jpsi] - logpsi[ipsi]));
75  sumratio[ipsi] += ratioij;
76  sumratio[jpsi] += 1.0 / ratioij;
77  }
78  }
79  for (int ipsi = 0; ipsi < nPsi; ipsi++)
80  {
81  invsumratio[ipsi] = 1.0 / sumratio[ipsi];
82  cumNorm[ipsi] += invsumratio[ipsi];
83  }
84 
85  for (int ipsi = 0; ipsi < nPsi; ipsi++)
86  cumNorm[ipsi] += invsumratio[ipsi];
87 
88  RealType g = sumratio[0] / thisWalker.Multiplicity * std::exp(2.0 * (logpsi[0] - thisWalker.Properties(WP::LOGPSI)));
89 
90  if (Random() > g)
91  {
92  thisWalker.Age++;
93  ++nReject;
94  for (int ipsi = 0; ipsi < nPsi; ipsi++)
95  H1[ipsi]->rejectedMove(W, thisWalker);
96  }
97  else
98  {
99  thisWalker.Age = 0;
100  thisWalker.Multiplicity = sumratio[0];
101  thisWalker.R = W.R;
102  for (int ipsi = 0; ipsi < nPsi; ipsi++)
103  {
104  W.L = *L1[ipsi];
105  W.G = *G1[ipsi];
106 
107  RealType et = H1[ipsi]->evaluate(W);
108  thisWalker.Properties(ipsi, WP::LOGPSI) = logpsi[ipsi];
109  thisWalker.Properties(ipsi, WP::SIGN) = Psi1[ipsi]->getPhase();
110  thisWalker.Properties(ipsi, WP::UMBRELLAWEIGHT) = invsumratio[ipsi];
111  thisWalker.Properties(ipsi, WP::LOCALENERGY) = et;
112  H1[ipsi]->auxHevaluate(W, thisWalker);
113  H1[ipsi]->saveProperty(thisWalker.getPropertyBase(ipsi));
114  }
115  ++nAccept;
116  }
117 }
std::vector< RealType > sumratio
Definition: CSUpdateBase.h:40
std::vector< RealType > cumNorm
Definition: CSUpdateBase.h:45
#define Random
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
std::vector< RealType > logpsi
Definition: CSUpdateBase.h:39
WalkerProperties::Indexes WP
Definition: ParticleSet.cpp:34
std::vector< RealType > invsumratio
Definition: CSUpdateBase.h:41
ParticleGradient G
gradients of the particles
Definition: ParticleSet.h:83
RealType Tau
timestep
Definition: QMCUpdateBase.h:73
ParticlePos R
Position.
Definition: ParticleSet.h:79
std::vector< ParticleSet::ParticleGradient * > G1
Definition: CSUpdateBase.h:59
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
MCWalkerConfiguration & W
walker ensemble
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
Indexes
an enum denoting index of physical properties
std::vector< RealType > avgNorm
Definition: CSUpdateBase.h:42
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
bool makeMoveAllParticles(const Walker_t &awalker, const ParticlePos &deltaR, RealType dt)
move all the particles of a walker
std::vector< QMCHamiltonian * > H1
a list of QMCHamiltonians for multiple method
Definition: CSUpdateBase.h:55
void makeGaussRandomWithEngine(ParticleAttrib< TinyVector< T, D >> &a, RG &rng)