60 main_estimator_name_(
"LocalEnergy"),
61 max_output_scalar_dat_(8),
62 max_block_avg_name_(20)
68 : Options(em.Options),
72 EstimatorMap(em.EstimatorMap),
73 main_estimator_name_(em.main_estimator_name_),
74 max_output_scalar_dat_(em.max_output_scalar_dat_),
75 max_block_avg_name_(20)
103 RemoteData.push_back(std::make_unique<BufferType>());
104 RemoteData.push_back(std::make_unique<BufferType>());
143 o.setf(std::ios::scientific, std::ios::floatfield);
144 o.setf(std::ios::left, std::ios::adjustfield);
152 for (
int i = 0; i < maxobjs; i++)
157 o.setf(std::ios::right, std::ios::adjustfield);
177 for (
int i = 0; i < sources; ++i)
182 #if defined(DEBUG_ESTIMATOR_ARCHIVE) 183 if (record && !DebugArchive)
185 std::array<char, 128> fname;
186 if (std::snprintf(fname.data(), fname.size(),
"%s.p%03d.scalar.dat",
myComm->
getName().c_str(),
myComm->
rank()) < 0)
187 throw std::runtime_error(
"Error generating filename");
188 DebugArchive = std::make_unique<std::ofstream>(fname.data());
197 fname.concat(
".scalar.dat");
198 Archive = std::make_unique<std::ofstream>(fname);
215 int num_threads = est.size();
220 for (
int i = 1; i < num_threads; i++)
224 for (
int i = 1; i < num_threads; i++)
229 for (
int i = 1; i < num_threads; i++)
280 int num_threads = est.size();
283 for (
int i = 1; i < num_threads; i++)
287 for (
int i = 1; i < num_threads; i++)
291 for (
int i = 1; i < num_threads; i++)
307 BufferType::iterator cur(
RemoteData[0]->begin());
315 BufferType::iterator cur(
RemoteData[0]->begin());
334 for (
int j = 0; j < maxobjs; j++)
339 for (
int o = 0; o <
h5desc.size(); ++o)
381 var = tmp[2] / tmp[0] -
e *
e;
399 std::map<std::string, int>::iterator it =
EstimatorMap.find(a);
409 std::vector<std::string> extra;
413 std::string cname((
const char*)(cur->name));
414 if (cname ==
"estimator")
417 std::string use_hdf5(
"yes");
419 hAttrib.
add(est_name,
"name");
420 hAttrib.
add(use_hdf5,
"hdf5");
427 else if (est_name ==
"RMC")
431 hAttrib.
add(nobs,
"nobs");
436 else if (est_name ==
"CSLocalEnergy")
440 hAttrib.
add(nPsi,
"nPsi");
443 app_log() <<
" Adding a CSEnergyEstimator for the MainEstimator " << std::endl;
446 extra.push_back(est_name);
452 app_log() <<
" Adding a default LocalEnergyEstimator for the MainEstimator " << std::endl;
459 app_log() <<
" Using CollectablesEstimator for collectables, e.g. sk, gofr, density " << std::endl;
460 Collectables = std::make_unique<CollectablesEstimator>(H);
476 Estimators.push_back(std::move(newestimator));
482 app_log() <<
" EstimatorManagerBase::add replace " << aname <<
" estimator." << std::endl;
502 values.resize(entries);
503 for (
int a = 0; a < entries; a++)
void resize(size_type n, Type_t val=Type_t())
Resize the container.
int add(std::unique_ptr< EstimatorType > newestimator, const std::string &aname)
add an Estimator
ScalarEstimatorBase * MainEstimator
pointer to the primary ScalarEstimatorBase
EstimatorType * getEstimator(const std::string &a)
return a pointer to the estimator aname
int sizeOfCollectables() const
return the size of collectables
A set of walkers that are to be advanced by Metropolis Monte Carlo.
helper functions for EinsplineSetBuilder
void accumulate(MCWalkerConfiguration &W)
accumulate the measurements
int rank() const
return the rank
RealType BlockWeight
total weight accumulated in a block
size_t getActiveWalkers() const
return the number of active walkers
int weightInd
index for the block weight PropertyCache(weightInd)
int acceptInd
index for the acceptance rate PropertyCache(acceptInd)
RecordNamedProperty< RealType > BlockProperties
manager of property data
ScalarEstimatorBase::accumulator_type energyAccumulator
accumulator for the energy
QMCTraits::FullPrecRealType RealType
bool put(xmlNodePtr cur)
assign attributes to the set
void close()
close all the open groups and file
Collection of Local Energy Operators.
void getData(int i, std::vector< RealType > &values)
Vector< RealType > AverageCache
cached block averages of the values
int max_output_scalar_dat_
number of maximum data for a scalar.dat
int RecordCount
number of records in a block
ScalarEstimatorBase::accumulator_type varAccumulator
accumulator for the variance
Communicate * Controller
Global Communicator for a process.
std::unique_ptr< std::ofstream > Archive
file handler to write data
int size() const
return the number of tasks
void stop()
stop a qmc run
size_t getGlobalNumWalkers() const
return the total number of active walkers among a MPI group
void addHeader(std::ostream &o)
add header to an std::ostream
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
void write(CT &anything, bool doappend)
Wrapping information on parallelism.
std::vector< std::string > Names
void resetTargetParticleSet(ParticleSet &p)
void startBlock(int steps)
start a block
Specialized paritlce class for atomistic simulations.
std::map< std::string, int > EstimatorMap
column map
const std::string & getName() const
WalkerList_t::iterator iterator
FIX: a type alias of iterator for an object should not be for just one of many objects it holds...
size_type size() const
return the current size
double norm(const zVec &c)
virtual ~EstimatorManagerBase()
destructor
void setCollectionMode(bool collect)
set CollectSum
int add(const std::string &aname)
int BufferSize
size of the message buffer
class to handle a set of attributes of an xmlNode
define convenience functions for mpi operations.
int sizeOfObservables() const
return the size of observables
int cpuInd
index for the block cpu PropertyCache(cpuInd)
Manager class of scalar estimators.
UPtrVector< EstimatorType > Estimators
estimators of simple scalars
RecordNamedProperty< RealType > TotalAverages
block averages: name to value
Buffer_t Collectables
observables in addition to those registered in Properties/PropertyList
bool put(QMCHamiltonian &H, xmlNodePtr cur)
process xml tag associated with estimators
std::string main_estimator_name_
name of the primary estimator name
Class to manage a set of ScalarEstimators.
void setCommunicator(Communicate *c)
set the communicator
std::unique_ptr< CollectablesEstimator > Collectables
pointer to the CollectablesEstimator
void collectBlockAverages()
collect data and write
Matrix< RealType > TotalAveragesData
data accumulated over the blocks
return_type mean() const
return the mean
bool create(const std::filesystem::path &fname, unsigned flags=H5F_ACC_TRUNC)
create a file
EstimatorType * getMainEstimator()
return a pointer to the estimator
return_type result() const
return the sum
EstimatorManagerBase(Communicate *c=0)
default constructor
std::vector< ObservableHelper > h5desc
convenient descriptors for hdf5
Communicate * myComm
communicator to handle communication
std::vector< std::unique_ptr< BufferType > > RemoteData
void stopBlock(RealType accept, bool collectall=true)
stop a block
Vector< RealType > PropertyCache
cached block averages of properties, e.g. BlockCPU
RecordNamedProperty< RealType > BlockAverages
manager of scalar data
void reset()
reset the estimator
std::vector< int > Block2Total
index mapping between BlockAverages and TotalAverages
return_type count() const
return the count
declare a handler of DMC branching
size_t max_block_avg_name_
largest name in BlockAverages adding 2 characters
Abstract class for an estimator of a scalar operator.
int addObservable(const char *aname)
hdf_archive h_file
hdf5 handler
void start(int blocks, bool record=true)
start a run
iterator end()
return the last iterator, [begin(), end())
Vector< RealType > SquaredAverageCache
cached block averages of the squared values
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
void getApproximateEnergyVariance(RealType &e, RealType &var)
get the average of per-block energy and variance of all the blocks Note: this is not weighted average...
Declaration of a MCWalkerConfiguration.
Declaration of QMCHamiltonian.
iterator begin()
return the first iterator