QMCPACK
PerParticleHamiltonianLogger.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2022 QMCPACK developers.
6 //
7 // File developed by: Peter W. Doak, doakpw@ornl.gov, Oak Ridge National Laboratory
8 //
9 // File created by: Peter W. Doak, doakpw@ornl.gov, Oak Ridge National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #ifndef QMCPLUSPLUS_PER_PARTICLE_HAMILTONIAN_LOGGER_H
14 #define QMCPLUSPLUS_PER_PARTICLE_HAMILTONIAN_LOGGER_H
16 #include <string>
17 #include <fstream>
18 #include <mutex>
19 #include <unordered_map>
20 #include <optional>
21 #include <StdRandom.h>
22 #include "OhmmsPETE/OhmmsVector.h"
24 
25 namespace qmcplusplus
26 {
27 
29 {
30 public:
32  using CrowdLogValues = std::unordered_map<std::string, std::vector<Vector<Real>>>;
33 
34 
37 
39  const RefVector<ParticleSet>& psets,
40  const RefVector<TrialWaveFunction>& wfns,
41  const RefVector<QMCHamiltonian>& hams,
42  RandomBase<FullPrecRealType>& rng) override;
43 
44  UPtr<OperatorEstBase> spawnCrowdClone() const override;
45  void startBlock(int steps) override;
46 
47  void registerListeners(QMCHamiltonian& ham_leader) override;
48  /** return lambda function to register as listener
49  * the purpose of this function is to factor out the production of the lambda for unit testing
50  * \param[out] values
51  */
53 
54  void collect(const RefVector<OperatorEstBase>& type_erased_operator_estimators) override;
55 
56  void write(CrowdLogValues& values, const std::vector<long>& walkers_ids);
57 
58  int get_block() { return block_; }
59 private:
60  bool crowd_clone = false;
63  int rank_;
65  std::vector<long> walker_ids_;
66  const std::string name_{"PerParticleHamiltonianLogger"};
67  std::fstream rank_fstream_;
68  std::mutex write_lock;
69  int block_ = 0;
70 };
71 
72 }
73 
74 #endif
std::unordered_map< std::string, std::vector< Vector< Real > >> CrowdLogValues
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
QTBase::RealType RealType
Definition: Configuration.h:58
UPtr< OperatorEstBase > spawnCrowdClone() const override
Collection of Local Energy Operators.
const char walkers[]
Definition: HDFVersion.h:36
PerParticleHamiltonianLogger *const rank_estimator_
PerParticleHamiltonianLogger(PerParticleHamiltonianLoggerInput &&input, int rank)
ListenerVector< Real >::ReportingFunction getLogger()
return lambda function to register as listener the purpose of this function is to factor out the prod...
A minimally functional wrapper for the since c++11 <random>
An abstract class for gridded estimators.
std::unique_ptr< T > UPtr
std::vector< std::reference_wrapper< T > > RefVector
std::function< void(const int walker_index, const std::string &name, const Vector< T > &values)> ReportingFunction
"Callback" function type for an operator to report a vector of values to a listener ...
Definition: Listener.hpp:49
Declaraton of Vector<T,Alloc> Manage memory through Alloc directly and allow referencing an existing ...
DataLocality
data locality with respect to walker buffer
Definition: DataLocality.h:19
void collect(const RefVector< OperatorEstBase > &type_erased_operator_estimators) override
Reduce estimator result data from crowds to rank.
void write(CrowdLogValues &values, const std::vector< long > &walkers_ids)
void registerListeners(QMCHamiltonian &ham_leader) override
Register 0-many listeners with a leading QMCHamiltonian instance i.e.
Listener types that allow Estimators to register with QMCHamiltonian to have "trace" values from oper...
void accumulate(const RefVector< MCPWalker > &walkers, const RefVector< ParticleSet > &psets, const RefVector< TrialWaveFunction > &wfns, const RefVector< QMCHamiltonian > &hams, RandomBase< FullPrecRealType > &rng) override
Accumulate whatever it is you are accumulating with respect to walkers.