QMCPACK
WalkerLogCollector.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) 2024 QMCPACK developers.
6 //
7 // File developed by: Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory
8 //
9 // File created by: Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #ifndef QMCPLUSPLUS_WALKERLOGCOLLECTOR_H
14 #define QMCPLUSPLUS_WALKERLOGCOLLECTOR_H
15 
16 #include "WalkerLogBuffer.h"
17 
18 
19 namespace qmcplusplus
20 {
21 
22 template<class QT, class PT>
23 class Walker;
24 class ParticleSet;
25 class TrialWaveFunction;
26 class QMCHamiltonian;
27 using MCPWalker = Walker<QMCTraits, PtclOnLatticeTraits>;
28 
29 
30 /// Helper struct holding data transferred from WalkerLogManager to WalkerLogCollector following input read
32 {
33  /// whether logs are active in the current driver
34  bool logs_active = false;
35  /// period between MC steps for data collection
36  int step_period = 1;
37  /// controls verbosity of log file writes
38  bool verbose = false;
39 };
40 
41 
42 /** Crowd-level resource for walker log collection.
43  *
44  * Contains data buffers for walker properties and walker particle data.
45  * Data buffers are resized to zero at the start of an MC block.
46  * Data for all walkers is collected into the buffers each MC step in an MC block.
47  * This class is not responsible for I/O.
48  */
50 {
51 public:
52  /// MC step information for each walker throughout the MC block
53  std::vector<size_t> steps;
54  /// LocalEnergy information for each walker throughout the MC block
55  std::vector<WLog::Real> energies;
56  /// buffer containing integer walker properties
58  /// buffer containing real-valued walker properties
60  /// buffer containing per-particle walker data
62 
63  /// ParticleSet::PropertyList quantities to include
64  std::unordered_set<std::string> properties_include;
65  /// indices in ParticleSet::PropertyList for included quantities
66  std::vector<size_t> property_indices;
67  /// location of LocalEnergy in ParticleSet::PropertyList
69 
70 private:
71  // temporary (contiguous) storage for awful ParticleAttrib<> quantities
72  /// tmp storage for walker positions
74  /// tmp storage for walker spins
76  /// tmp storage for walker wavefunction gradients
78  /// tmp storage for walker wavefunciton laplacians
80  /// state data set by WalkerLogManager
82 
83 public:
84  /// constructor. The state should be given by the manager.
85  WalkerLogCollector(const WalkerLogState& state);
86 
87  /// resize buffers to zero rows at beginning of each MC block
88  void startBlock();
89 
90  /// collect all data for one walker into the data buffers
91  void collect(const MCPWalker& walker,
92  const ParticleSet& pset,
93  const TrialWaveFunction& wfn,
94  const QMCHamiltonian& ham,
95  int step = -1);
96 
97  /** Check that all buffers have the same number of rows.
98  * This ensures that the full data for a given walker can be reconstructed due to enforced data alignment in the buffers.
99  */
100  void checkBuffers();
101 
102 private:
103  /// shared variable setting in constructors
104  void init();
105 
106  /// resize buffers to zero rows
107  void resetBuffers();
108 };
109 
110 
111 } // namespace qmcplusplus
112 
113 #endif
Array< WLog::PsiVal, 2 > Gtmp
tmp storage for walker wavefunction gradients
Array< WLog::Real, 2 > Rtmp
tmp storage for walker positions
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
Array< WLog::PsiVal, 1 > Ltmp
tmp storage for walker wavefunciton laplacians
int energy_index
location of LocalEnergy in ParticleSet::PropertyList
bool verbose
controls verbosity of log file writes
int step_period
period between MC steps for data collection
WalkerLogBuffer< WLog::Int > walker_property_int_buffer
buffer containing integer walker properties
void checkBuffers()
Check that all buffers have the same number of rows.
std::vector< size_t > property_indices
indices in ParticleSet::PropertyList for included quantities
WalkerLogBuffer< WLog::Real > walker_property_real_buffer
buffer containing real-valued walker properties
Collection of Local Energy Operators.
std::unordered_set< std::string > properties_include
ParticleSet::PropertyList quantities to include.
Crowd-level resource for walker log collection.
const WalkerLogState & state_
state data set by WalkerLogManager
void resetBuffers()
resize buffers to zero rows
Array< WLog::Real, 1 > Stmp
tmp storage for walker spins
bool logs_active
whether logs are active in the current driver
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
WalkerLogBuffer< WLog::Real > walker_particle_real_buffer
buffer containing per-particle walker data
void init()
shared variable setting in constructors
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
Class to represent a many-body trial wave function.
std::vector< WLog::Real > energies
LocalEnergy information for each walker throughout the MC block.
Walker< QMCTraits, PtclOnLatticeTraits > MCPWalker
Definition: test_walker.cpp:31
void startBlock()
resize buffers to zero rows at beginning of each MC block
Helper struct holding data transferred from WalkerLogManager to WalkerLogCollector following input re...
std::vector< size_t > steps
MC step information for each walker throughout the MC block.
A container class to represent a walker.
Definition: Walker.h:49
WalkerLogCollector(const WalkerLogState &state)
constructor. The state should be given by the manager.