28 : trial_wf_(trial_wf), elec_particle_set_(elecs), hamiltonian_(hamiltonian), num_ranks_(
num_ranks), rank_(this_rank)
30 const auto num_groups = elecs->
groups();
33 for (
int ig = 0; ig < num_groups; ++ig)
40 for (
int ig = 0; ig < num_groups; ++ig)
41 for (
int iat = elecs->
first(ig); iat < elecs->
last(ig); ++iat)
60 walkers_.resize(num_walkers_plus_reserve);
68 #pragma omp parallel for 69 for (
size_t iw = 0; iw < num_walkers_plus_reserve; iw++)
76 *
walkers_[iw] = *walker_configs[iw % num_existing_walkers];
94 int num_walkers_created = 0;
97 if (walker_ptr->getWalkerID() == 0)
101 walker_ptr->setWalkerID((num_walkers_created++) *
num_ranks_ +
rank_ + 1);
102 walker_ptr->setParentID(walker_ptr->getWalkerID());
112 for (
int i = 0; i < extra_walkers; ++i)
123 std::vector<WalkerElementsRef> walker_elements;
124 for (
int iw = 0; iw <
walkers_.size(); ++iw)
128 return walker_elements;
157 walkers_.back()->Multiplicity = 1.0;
163 <<
" outside of reserves, this ideally should never happened." << std::endl;
175 walkers_.back()->Multiplicity = 1.0;
212 while (it_walkers !=
walkers_.end())
214 if (&
walker == (*it_walkers).get())
232 throw std::runtime_error(
"Attempt to kill nonexistent walker in MCPopulation!");
237 std::vector<IndexType> num_local_walkers_per_rank(
comm->
size(), 0);
242 num_global_walkers_ = std::accumulate(num_local_walkers_per_rank.begin(), num_local_walkers_per_rank.end(), 0);
249 std::vector<FullPrecRealType> weight_energy_variance(3, 0.0);
254 weight_energy_variance[0] += w;
255 weight_energy_variance[1] += w *
e;
256 weight_energy_variance[2] += w *
e *
e;
260 ener = weight_energy_variance[1] / weight_energy_variance[0];
261 variance = weight_energy_variance[2] / weight_energy_variance[0] - ener * ener;
268 if (
walkers_.size() != num_local_walkers_active)
269 throw std::runtime_error(
"walkers_ has inconsistent size");
271 throw std::runtime_error(
"walker_elec_particle_sets_ has inconsistent size");
273 throw std::runtime_error(
"walker_trial_wavefunctions_ has inconsistent size");
275 throw std::runtime_error(
"walker_trial_wavefunctions_ has inconsistent size");
277 throw std::runtime_error(
"walker_hamiltonians_ has inconsistent size");
282 throw std::runtime_error(
"dead_walker_elec_particle_sets_ has inconsistent size");
284 throw std::runtime_error(
"dead_walker_trial_wavefunctions_ has inconsistent size");
286 throw std::runtime_error(
"dead_walker_trial_wavefunctions_ has inconsistent size");
288 throw std::runtime_error(
"dead_walker_hamiltonians_ has inconsistent size");
297 walker_configs[iw]->Weight =
walkers_[iw]->Weight;
std::vector< WalkerElementsRef > get_walker_elements()
As long as walker WalkerElements is used we need this for unit tests.
QMCTraits::RealType RealType
UPtrVector< TrialWaveFunction > walker_trial_wavefunctions_
WalkerElementsRef spawnWalker()
State Requirement:
void pause()
Pause the summary and log streams.
std::ostream & app_warning()
std::vector< RealType > ptcl_inv_mass_
1/Mass per particle
helper functions for EinsplineSetBuilder
QMCTraits::FullPrecRealType FullPrecRealType
int rank() const
return the rank
ParticleScalar spins
internal spin variables for dynamical spin calculations
PropertyContainer_t Properties
properties of the current walker
size_t getActiveWalkers() const
return the number of active walkers
size_t getTotalNum() const
type for returning the walker and its elements from MCPopulation
A set of light weight walkers that are carried between driver sections and restart.
UPtrVector< QMCHamiltonian > dead_walker_hamiltonians_
Collection of Local Energy Operators.
QMCHamiltonian * hamiltonian_
int first(int igroup) const
return the first index of a group i
MCPopulation(int num_ranks, int this_rank, ParticleSet *elecs, TrialWaveFunction *trial_wf, QMCHamiltonian *hamiltonian_)
Temporary constructor to deal with MCWalkerConfiguration be the only source of some information in QM...
int size() const
return the number of tasks
std::unique_ptr< TrialWaveFunction > makeClone(ParticleSet &tqp) const
OutputManagerClass outputManager(Verbosity::HIGH)
UPtrVector< QMCHamiltonian > walker_hamiltonians_
PropertySetType PropertyList
name-value map of Walker Properties
void measureGlobalEnergyVariance(Communicate &comm, FullPrecRealType &ener, FullPrecRealType &variance) const
void checkIntegrity() const
}@
Wrapping information on parallelism.
int groups() const
return the number of groups
UPtrVector< TrialWaveFunction > dead_walker_trial_wavefunctions_
void resume()
Resume the summary and log streams.
Specialized paritlce class for atomistic simulations.
std::vector< RealType > ptclgrp_inv_mass_
1/Mass per species
UPtrVector< ParticleSet > dead_walker_elec_particle_sets_
void syncWalkersPerRank(Communicate *comm)
void resize(size_t m, size_t n)
std::vector< RealType > ptclgrp_mass_
int last(int igroup) const
return the last index of a group i
QMCTraits::IndexType IndexType
void createWalkers(IndexType num_walkers, const WalkerConfigurations &walker_configs, RealType reserve=1.0)
}@
IndexType num_local_walkers_
void saveWalkerConfigurations(WalkerConfigurations &walker_configs)
save walker configurations to walker_configs_ref_
Declaration of a TrialWaveFunction.
void resize(int numWalkers, size_t numPtcls)
clean up the walker list and make a new list
Class to represent a many-body trial wave function.
ParticleScalar Mass
mass of each particle
TrialWaveFunction * trial_wf_
UPtrVector< ParticleSet > walker_elec_particle_sets_
UPtrVector< MCPWalker > walkers_
WalkerElementsRef getWalkerElementsRef(const size_t walker_index)
Non threadsafe access to walkers and their elements.
UPtrVector< MCPWalker > dead_walkers_
IndexType num_global_walkers_
std::unique_ptr< QMCHamiltonian > makeClone(ParticleSet &qp, TrialWaveFunction &psi) const
return a clone
void killWalker(MCPWalker &)
Kill a walker (just barely)
A container class to represent a walker.
void killLastWalker()
Kill last walker (just barely)
ParticleSet * elec_particle_set_
Declaration of QMCHamiltonian.