QMCPACK
DensityMatrices1B.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) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory
8 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
9 //
10 // File created by: Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory
11 //////////////////////////////////////////////////////////////////////////////////////
12 
13 
14 #ifndef QMCPLUSPLUS_ONE_BODY_DENSITY_MATRICES_H
15 #define QMCPLUSPLUS_ONE_BODY_DENSITY_MATRICES_H
16 
20 
21 namespace qmcplusplus
22 {
24 {
25 protected:
27 
28 public:
29  enum
30  {
32  };
33 
34  using Value_t = ValueType;
35  using Grad_t = GradType;
41  using pts_t = std::vector<PosType>;
42  using dens_t = std::vector<RealType>;
43 
45  {
50  };
51 
53  {
54  loop = 0,
57  };
58 
59  enum samplings
60  {
64  };
65 
66  //data members
67  bool energy_mat;
74  bool warmed_up;
75  std::vector<PosType> rsamples;
77  std::vector<ValueType> psi_ratios;
80  int nindex;
81  int eindex;
85  const ParticleSet* Pc;
93  std::vector<Value_t> E_samp;
95 
96 
98  bool normalized;
101  int samples;
103  int nspecies;
104  std::vector<int> species_size;
105  std::vector<std::string> species_name;
106  std::vector<Vector_t*> E_N;
107  std::vector<Matrix_t*> Phi_NB, Psi_NM, Phi_Psi_NB, N_BB, E_BB;
111 
112 //#define DMCHECK
113 #ifdef DMCHECK
114  std::vector<Vector_t*> E_Ntmp;
115  std::vector<Matrix_t*> Phi_NBtmp, Psi_NMtmp, Phi_Psi_NBtmp, N_BBtmp, E_BBtmp;
116  Matrix_t Phi_MBtmp;
117 #endif
118 
122  int points;
126  bool periodic;
127  int warmup;
129  bool use_drift;
130  int nmoves;
135 
136  int ind_dims[DIM];
138 
142 
144 
145 
146  //constructor/destructor
149  ~DensityMatrices1B() override;
150 
151  bool dependsOnWaveFunction() const override { return true; }
152  std::string getClassName() const override { return "DensityMatrices1B"; }
153  //standard interface
154  std::unique_ptr<OperatorBase> makeClone(ParticleSet& P, TrialWaveFunction& psi) final;
155  bool put(xmlNodePtr cur) override;
156  Return_t evaluate(ParticleSet& P) override;
157 
158  //optional standard interface
159  void getRequiredTraces(TraceManager& tm) override;
161 
162  //required for Collectables interface
163  void addObservables(PropertySetType& plist, BufferType& olist) override;
164  void registerCollectables(std::vector<ObservableHelper>& h5desc, hdf_archive& file) const override;
165 
166  //should be empty for Collectables interface
167  void resetTargetParticleSet(ParticleSet& P) override {}
168  void setObservables(PropertySetType& plist) override {}
169  void setParticlePropertyList(PropertySetType& plist, int offset) override {}
170  void contributeScalarQuantities() override {}
172  void collectScalarQuantities() override {}
173  void deleteScalarQuantities() override {}
174 
175  //obsolete?
176  bool get(std::ostream& os) const override { return false; }
177 
178  //local functions
179  // initialization/finalization
180  void reset();
181  void set_state(xmlNodePtr cur);
182  void set_state(DensityMatrices1B& master);
183  void initialize();
184  void finalize();
185  void normalize();
186  // printing
187  void report(const std::string& pad = "");
188  // sample generation
189  void warmup_sampling();
190  void generate_samples(RealType weight, int steps = 0);
193  void generate_density_samples(bool save, int steps, RandomBase<FullPrecRealType>& rng);
194  void diffusion(RealType sqt, PosType& diff);
195  void density_only(const PosType& r, RealType& dens);
196  void density_drift(const PosType& r, RealType& dens, PosType& drift);
197  // basis & wavefunction ratio matrix construction
198  void get_energies(std::vector<Vector_t*>& E_n);
199  void generate_sample_basis(Matrix_t& Phi_mb);
200  void generate_sample_ratios(std::vector<Matrix_t*> Psi_nm);
201  void generate_particle_basis(ParticleSet& P, std::vector<Matrix_t*>& Phi_nb);
202  // basis set updates
203  void update_basis(const PosType& r);
204  void update_basis_d012(const PosType& r);
205  // testing
206  void test_overlap();
207  void test_derivatives();
208  // original loop implementation
209  void integrate(ParticleSet& P, int n);
211  // matrix implementation
214 
215 
216  bool match(Value_t e1, Value_t e2, RealType tol = 1e-12);
217  bool same(Vector_t& v1, Vector_t& v2, RealType tol = 1e-6);
218  bool same(Matrix_t& m1, Matrix_t& m2, RealType tol = 1e-6);
219  void compare(const std::string& name, Vector_t& v1, Vector_t& v2, bool write = false, bool diff_only = true);
220  void compare(const std::string& name, Matrix_t& m1, Matrix_t& m2, bool write = false, bool diff_only = true);
221 
222 private:
223 };
224 
225 } // namespace qmcplusplus
226 
227 #endif
std::vector< Matrix_t * > Phi_NB
std::vector< Value_t > E_samp
void density_drift(const PosType &r, RealType &dens, PosType &drift)
bool dependsOnWaveFunction() const override
return true if this operator depends on a wavefunction
Fixed-size array.
Definition: OhmmsTinyMeta.h:30
Return_t evaluate(ParticleSet &P) override
Evaluate the local energy contribution of this component.
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
QTBase::GradType GradType
Definition: Configuration.h:62
void contributeScalarQuantities() override
void getRequiredTraces(TraceManager &tm) override
TODO: add docs.
void resetTargetParticleSet(ParticleSet &P) override
Reset the data with the target ParticleSet.
void generate_density_samples(bool save, int steps, RandomBase< FullPrecRealType > &rng)
ParticleSet::ParticleLayout Lattice_t
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > ParticleLayout
Definition: Configuration.h:79
std::vector< Vector_t * > E_N
std::vector< Matrix_t * > Psi_NM
Declaration of OperatorBase.
void setObservables(PropertySetType &plist) override
Set the values evaluated by this object to plist Default implementation is to assign Value which is u...
Return_t evaluate_check(ParticleSet &P)
class to handle hdf file
Definition: hdf_archive.h:51
Vectorized record engine for scalar properties.
void integrate(ParticleSet &P, int n)
TraceSample< TraceReal > * w_trace
#define OHMMS_DIM
Definition: config.h:64
DensityMatrices1B::Value_t Value_t
std::vector< PosType > pts_t
void registerCollectables(std::vector< ObservableHelper > &h5desc, hdf_archive &file) const override
bool put(xmlNodePtr cur) override
Read the input parameter.
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
ParticleSet::Buffer_t BufferType
typedef for the serialized buffer
Definition: OperatorBase.h:75
void diffusion(RealType sqt, PosType &diff)
std::vector< Matrix_t * > E_BB
TraceSample< TraceComp > * T_trace
void generate_uniform_grid(RandomBase< FullPrecRealType > &rng)
QTBase::ValueType ValueType
Definition: Configuration.h:60
void setRandomGenerator(RandomBase< FullPrecRealType > *rng) override
Set the Random Generator object TODO: add docs.
void get_energies(std::vector< Vector_t *> &E_n)
OrbitalSetTraits< ValueType >::ValueVector ValueVector
Definition: SPOSet.h:49
void generate_sample_basis(Matrix_t &Phi_mb)
std::vector< std::string > species_name
void setParticlePropertyList(PropertySetType &plist, int offset) override
RandomBase< FullPrecRealType > * uniform_random
void generate_samples(RealType weight, int steps=0)
void addObservables(PropertySetType &plist, BufferType &olist) override
named values to the property list Default implementaton uses addValue(plist_)
CombinedTraceSample< TraceReal > * Vc_trace
An abstract class for Local Energy operators.
Definition: OperatorBase.h:59
void report(const std::string &pad="")
std::unique_ptr< OperatorBase > makeClone(ParticleSet &P, TrialWaveFunction &psi) final
OrbitalSetTraits< ValueType >::GradVector GradVector
Definition: SPOSet.h:51
Return_t evaluate_loop(ParticleSet &P)
Class to represent a many-body trial wave function.
CombinedTraceSample< TraceReal > * E_trace
Return_t evaluate_matrix(ParticleSet &P)
std::vector< Matrix_t * > Phi_Psi_NB
void checkoutScalarQuantities(TraceManager &tm) override
CombinedTraceSample< TraceReal > * Vq_trace
void compare(const std::string &name, Vector_t &v1, Vector_t &v2, bool write=false, bool diff_only=true)
void generate_particle_basis(ParticleSet &P, std::vector< Matrix_t *> &Phi_nb)
bool match(Value_t e1, Value_t e2, RealType tol=1e-12)
std::string getClassName() const override
return class name
CombinedTraceSample< TraceReal > * Vcc_trace
void update_basis_d012(const PosType &r)
std::vector< RealType > dens_t
void generate_sample_ratios(std::vector< Matrix_t *> Psi_nm)
void update_basis(const PosType &r)
CombinedTraceSample< TraceReal > * Vqq_trace
std::vector< ValueType > psi_ratios
DensityMatrices1B(ParticleSet &P, TrialWaveFunction &psi, ParticleSet *Pcl)
void generate_uniform_samples(RandomBase< FullPrecRealType > &rng)
void density_only(const PosType &r, RealType &dens)
std::vector< Matrix_t * > N_BB
bool same(Vector_t &v1, Vector_t &v2, RealType tol=1e-6)
std::vector< PosType > rsamples
CombinedTraceSample< TraceReal > * Vqc_trace
BareKineticEnergy::Return_t Return_t
RecordNamedProperty< FullPrecRealType > PropertySetType
define PropertyList_t
Definition: Configuration.h:69