QMCPACK
SpinDensityNew.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) 2020 QMCPACK developers.
6 //
7 // File developed by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Laboratory
8 //
9 // File refactored from: SpinDensity.h
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 #ifndef QMCPLUSPLUS_SPINDENSITYNEW_H
13 #define QMCPLUSPLUS_SPINDENSITYNEW_H
14 
15 #include "SpinDensityInput.h"
16 
17 #include <vector>
18 
19 #include "Configuration.h"
20 #include "OperatorEstBase.h"
22 
23 namespace qmcplusplus
24 {
25 class SpeciesSet;
26 namespace testing
27 {
28 class SpinDensityNewTests;
29 }
30 /** Class that collects density per species of particle
31  *
32  * commonly used for spin up and down electrons
33  *
34  */
36 {
37 public:
40  using QMCT = QMCTraits;
42 
43  /** Constructor for SpinDensityNew that contains an explicitly defined cell
44  * part of legacy input handling, Deprecated
45  */
47 
48  /** Constructor
49  *
50  * If the sdi contains a cell definition the Lattice passed will be ignored.
51  *
52  * Other wise the crystal lattice should come from the same particle set as the species set.
53  * in case you are tempted to just pass the ParticleSet don't. It clouds the data dependence of
54  * constructing the estimator and creates a strong coupling between the classes.
55  *
56  * Ideally when validating input is built up enough there would be only one constructor with
57  * signature
58  *
59  * SpinDensityNew(SpinDensityInput&& sdi,
60  * SpinDensityInput::DerivedParameters&& dev_par,
61  * SpeciesSet species,
62  * DataLocality dl);
63  */
65  const Lattice&,
66  const SpeciesSet& species,
68 
69  /** Constructor used when spawing crowd clones
70  * needs to be public so std::make_unique can call it.
71  * Do not use directly unless you've really thought it through.
72  */
74 
75  /** This allows us to allocate the necessary data for the DataLocality::queue
76  */
77  void startBlock(int steps) override;
78 
79  /** standard interface
80  */
81  std::unique_ptr<OperatorEstBase> spawnCrowdClone() const override;
82 
83  /** accumulate 1 or more walkers of SpinDensity samples
84  */
86  const RefVector<ParticleSet>& psets,
87  const RefVector<TrialWaveFunction>& wfns,
88  const RefVector<QMCHamiltonian>& hams,
89  RandomBase<FullPrecRealType>& rng) override;
90 
91  /** this allows the EstimatorManagerNew to reduce without needing to know the details
92  * of SpinDensityNew's data.
93  *
94  * can use base class default until crowd level SpinDensity
95  * estimators don't have a copy of the density grid.
96  */
97  void collect(const RefVector<OperatorEstBase>& operator_estimators) override;
98 
99  /** this allows the EstimatorManagerNew to reduce without needing to know the details
100  * of SpinDensityNew's data.
101  *
102  * can use base class default until crowd level SpinDensity estimators don't have a copy of the density grid.
103  */
104  //void collect(const OperatorEstBase& oeb);
105 
106  /** this gets us into the hdf5 file
107  *
108  * Just parroting for now don't fully understand.
109  *, needs to be unraveled and simplified the hdf5 output is another
110  * big state big coupling design.
111  */
112  void registerOperatorEstimator(hdf_archive& file) override;
113 
114 private:
115  SpinDensityNew(const SpinDensityNew& sdn) = default;
116 
117  static std::vector<int> getSpeciesSize(const SpeciesSet& species);
118  /** derived_parameters_ must be valid i.e. initialized with call to input_.calculateDerivedParameters
119  */
120  size_t getFullDataSize();
121  void accumulateToData(size_t point, QMCT::RealType weight);
122  void reset();
123  void report(const std::string& pad);
124 
125  //data members
128  // this is a bit of a mess to get from SpeciesSet
129  const std::vector<int> species_size_;
130 
131  /** @ingroup SpinDensity mutable parameters
132  *
133  * they should be limited to values that can be changed from input
134  * or are not present explicitly in the SpinDensityInput
135  * @{
136  */
137 
138  /// Lattice is always local since it is either in the input or a constructor argument.
141  /**}@*/
142 
144 };
145 
146 } // namespace qmcplusplus
147 
148 #endif /* QMCPLUSPLUS_SPINDENSITYNEW_H */
a class that defines a supercell in D-dimensional Euclean space.
void accumulate(const RefVector< MCPWalker > &walkers, const RefVector< ParticleSet > &psets, const RefVector< TrialWaveFunction > &wfns, const RefVector< QMCHamiltonian > &hams, RandomBase< FullPrecRealType > &rng) override
accumulate 1 or more walkers of SpinDensity samples
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
QTBase::RealType RealType
Definition: Configuration.h:58
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > ParticleLayout
Definition: Configuration.h:79
void collect(const RefVector< OperatorEstBase > &operator_estimators) override
this allows the EstimatorManagerNew to reduce without needing to know the details of SpinDensityNew&#39;s...
class to handle hdf file
Definition: hdf_archive.h:51
const char walkers[]
Definition: HDFVersion.h:36
class to preserve access control in MomentumDistribution
std::unique_ptr< OperatorEstBase > spawnCrowdClone() const override
standard interface
void report(const std::string &pad)
const std::vector< int > species_size_
static std::vector< int > getSpeciesSize(const SpeciesSet &species)
void accumulateToData(size_t point, QMCT::RealType weight)
SpinDensityNew(SpinDensityInput &&sdi, const SpeciesSet &species, DataLocality dl=DataLocality::crowd)
Constructor for SpinDensityNew that contains an explicitly defined cell part of legacy input handling...
size_t getFullDataSize()
derived_parameters_ must be valid i.e.
void registerOperatorEstimator(hdf_archive &file) override
this allows the EstimatorManagerNew to reduce without needing to know the details of SpinDensityNew&#39;s...
An abstract class for gridded estimators.
QMCT::FullPrecRealType FullPrecRealType
const SpeciesSet & species_
Lattice lattice_
they should be limited to values that can be changed from input or are not present explicitly in t...
Native representation for Spin Density Estimators inputs.
std::vector< std::reference_wrapper< T > > RefVector
Particle traits to use UniformGridLayout for the ParticleLayout.
Definition: Configuration.h:77
SpinDensityInput::DerivedParameters derived_parameters_
Class that collects density per species of particle.
void startBlock(int steps) override
This allows us to allocate the necessary data for the DataLocality::queue.
DataLocality
data locality with respect to walker buffer
Definition: DataLocality.h:19
const SpinDensityInput input_
QTFull::RealType FullPrecRealType
Definition: Configuration.h:66
Custom container for set of attributes for a set of species.
Definition: SpeciesSet.h:33
traits for QMC variables
Definition: Configuration.h:49
SpinDensityInput sdi(node)
SpinDensityNew sdn(std::move(sdi), lattice, species_set)