QMCPACK
StructFact.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: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
9 //
10 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
11 //////////////////////////////////////////////////////////////////////////////////////
12 
13 
14 #ifndef QMCPLUSPLUS_STRUCTFACT_H
15 #define QMCPLUSPLUS_STRUCTFACT_H
16 
17 #include "OhmmsPETE/OhmmsVector.h"
18 #include "OhmmsPETE/OhmmsMatrix.h"
19 #include "Configuration.h"
20 #include <Resource.h>
21 #include <NewTimer.h>
24 
25 namespace qmcplusplus
26 {
27 class ParticleSet;
28 class KContainer;
29 struct SKMultiWalkerMem;
30 
31 /** @ingroup longrange
32  *\brief Calculates the structure-factor for a particle set
33  *
34  * Structure factor per species
35  * Rhok[alpha][k] \f$ \equiv \rho_{k}^{\alpha} = \sum_{i} e^{i{\bf k}\cdot{\bf r_i}}\f$
36  * Structure factor per particle
37  * eikr[i][k]
38  */
39 class StructFact : public QMCTraits
40 {
41 public:
42  //Typedef for the lattice-type
44 
45  /** enumeration for the methods to handle mixed bconds
46  *
47  * Allow overwriting lattice::SuperCellEnum to use D-dim k-point sets with mixed BC
48  */
50  ///2-D container for the phase
53  /** Constructor - copy ParticleSet and init. k-shells
54  * @param lattice long range box
55  * @param kc cutoff for k
56  *
57  * At least in the batched version Structure factor is _NOT_ valid
58  * after construction.
59  */
60  StructFact(const ParticleLayout& lattice, const KContainer& k_lists);
61  /// desructor
62  ~StructFact();
63 
64  /** Update Rhok if all particles moved
65  */
66  void updateAllPart(const ParticleSet& P);
67 
68  /** Update RhoK for all particles for multiple walkers particles.
69  *
70  * In batched context until this is called StructFact is invalid and will cause a crash if any Hamiltonian using StructFact
71  * indirectly through ParticleSet is evaluated.
72  */
73  static void mw_updateAllPart(const RefVectorWithLeader<StructFact>& sk_list,
75  SKMultiWalkerMem& mw_mem);
76 
77  /** @brief switch on the storage per particle
78  * if StorePerParticle was false, this function allocates memory and precompute data
79  * if StorePerParticle was true, this function is no-op
80  */
81  void turnOnStorePerParticle(const ParticleSet& P);
82 
83  /// accessor of StorePerParticle
84  bool isStorePerParticle() const { return StorePerParticle; }
85 
86  /// accessor of k_lists_
87  const KContainer& getKLists() const { return k_lists_; }
88 
89 private:
90  /// Compute all rhok elements from the start
91  void computeRhok(const ParticleSet& P);
92  /** resize the internal data
93  * @param nkpts
94  * @param num_species number of species
95  * @param num_ptcls number of particles
96  */
97  void resize(int nkpts, int num_species, int num_ptcls);
98 
99  /// K-Vector List.
101  /** Whether intermediate data is stored per particle. default false
102  * storing data per particle needs significant amount of memory but some calculation may request it.
103  * storing data per particle specie is more cost-effective
104  */
106  /// timer for updateAllPart
108 };
109 
110 ///multi walker shared memory buffer
111 struct SKMultiWalkerMem : public Resource
112 {
114 
115  ///dist displ for temporary and old pairs
117 
118  SKMultiWalkerMem() : Resource("SKMultiWalkerMem") {}
119 
121 
122  std::unique_ptr<Resource> makeClone() const override { return std::make_unique<SKMultiWalkerMem>(*this); }
123 };
124 
125 } // namespace qmcplusplus
126 
127 #endif
multi walker shared memory buffer
Definition: StructFact.h:111
a class that defines a supercell in D-dimensional Euclean space.
Matrix< RealType > rhok_r
2-D container for the phase
Definition: StructFact.h:51
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
QTBase::RealType RealType
Definition: Configuration.h:58
Matrix< RealType > eikr_i
Definition: StructFact.h:52
const KContainer & k_lists_
K-Vector List.
Definition: StructFact.h:100
Matrix< RealType > rhok_i
Definition: StructFact.h:51
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > ParticleLayout
Definition: Configuration.h:79
Timer accumulates time and call counts.
Definition: NewTimer.h:135
Calculates the structure-factor for a particle set.
Definition: StructFact.h:39
static void mw_updateAllPart(const RefVectorWithLeader< StructFact > &sk_list, const RefVectorWithLeader< ParticleSet > &p_list, SKMultiWalkerMem &mw_mem)
Update RhoK for all particles for multiple walkers particles.
Definition: StructFact.cpp:63
StructFact(const ParticleLayout &lattice, const KContainer &k_lists)
Constructor - copy ParticleSet and init.
Definition: StructFact.cpp:29
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > lattice
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
void computeRhok(const ParticleSet &P)
Compute all rhok elements from the start.
Definition: StructFact.cpp:138
const KContainer & getKLists() const
accessor of k_lists_
Definition: StructFact.h:87
Container for k-points.
Definition: KContainer.h:29
bool isStorePerParticle() const
accessor of StorePerParticle
Definition: StructFact.h:84
bool StorePerParticle
Whether intermediate data is stored per particle.
Definition: StructFact.h:105
Declaraton of Vector<T,Alloc> Manage memory through Alloc directly and allow referencing an existing ...
SKMultiWalkerMem(const SKMultiWalkerMem &)
Definition: StructFact.h:120
Matrix< RealType, OffloadPinnedAllocator< RealType > > nw_rhok
dist displ for temporary and old pairs
Definition: StructFact.h:116
int SuperCellEnum
enumeration for the methods to handle mixed bconds
Definition: StructFact.h:49
Matrix< RealType > eikr_r
Definition: StructFact.h:52
void updateAllPart(const ParticleSet &P)
Update Rhok if all particles moved.
Definition: StructFact.cpp:57
traits for QMC variables
Definition: Configuration.h:49
StructFact::RealType RealType
Definition: StructFact.h:113
NewTimer & update_all_timer_
timer for updateAllPart
Definition: StructFact.h:107
void turnOnStorePerParticle(const ParticleSet &P)
switch on the storage per particle if StorePerParticle was false, this function allocates memory and ...
Definition: StructFact.cpp:207
NewTimer class various high-resolution timers.
void resize(int nkpts, int num_species, int num_ptcls)
resize the internal data
Definition: StructFact.cpp:45
std::unique_ptr< Resource > makeClone() const override
Definition: StructFact.h:122