32 : M(40), refPsi(psi), lattice_(elns.getLattice()), norm_nofK(1), hdf5_out(false)
45 for (
int s = 0;
s <
M; ++
s)
49 newpos[i] = (*
myRNG)();
54 for (
int i = 0; i < np; ++i)
57 for (
int ik = 0; ik < nk; ++ik)
63 for (
int i = 0; i < np; ++i)
65 for (
int ik = 0; ik < nk; ++ik)
68 for (
int s = 0;
s <
M; ++
s)
71 const RealType ratio_c = one_ratio.real();
72 const RealType ratio_s = one_ratio.imag();
78 #pragma omp simd aligned(nofK_here, phases_c, phases_s, phases_vPos_c, phases_vPos_s : QMC_SIMD_ALIGNMENT) 79 for (
int ik = 0; ik < nk; ++ik)
80 nofK_here[ik] += (phases_c[ik] * phases_vPos_c[ik] - phases_s[ik] * phases_vPos_s[ik]) * ratio_c -
81 (phases_s[ik] * phases_vPos_c[ik] + phases_c[ik] * phases_vPos_s[ik]) * ratio_s;
88 for (
int ik = 0; ik <
nofK.size(); ++ik, ++j)
93 for (
int ik = 0; ik <
nofK.size(); ++ik)
105 std::vector<int> ng(1);
108 h5desc.emplace_back(
hdf_path{
"nofk"});
109 auto& h5o = h5desc.back();
111 h5o.addProperty(
const_cast<std::vector<PosType>&
>(
kPoints),
"kpoints", file);
112 h5o.addProperty(
const_cast<std::vector<int>&
>(
kWeights),
"kweights", file);
127 for (
int i = 0; i <
nofK.size(); i++)
129 std::stringstream sstr;
130 sstr <<
"nofk_" << i;
131 int id = plist.
add(sstr.str());
156 std::string hdf5_flag =
"yes";
165 pAttrib.
add(hdf5_flag,
"hdf5");
167 pAttrib.
add(kmax,
"kmax");
168 pAttrib.
add(kmax0,
"kmax0");
169 pAttrib.
add(kmax1,
"kmax1");
170 pAttrib.
add(kmax2,
"kmax2");
171 pAttrib.
add(
M,
"samples");
185 RealType sum_kmaxs = kmaxs[0] + kmaxs[1] + kmaxs[2];
187 bool sphere = kmax > 0.0 ? true :
false;
188 bool directional = sum_kmaxs > 0.0 ? true :
false;
189 if (!sphere && !directional)
201 kgrid = int(kmax / min_Length) + 1;
204 kgrid_squared[i] = kmaxs[i] * kmaxs[i] / vec_length[i] / vec_length[i];
205 RealType kmax_squared = sphere_kmax * sphere_kmax;
206 std::vector<int> kcount0;
207 std::vector<int> kcount1;
208 std::vector<int> kcount2;
209 kcount0.resize(2 * kgrid + 1, 0);
210 kcount1.resize(2 * kgrid + 1, 0);
211 kcount2.resize(2 * kgrid + 1, 0);
212 for (
int i = -kgrid; i < (kgrid + 1); i++)
214 for (
int j = -kgrid; j < (kgrid + 1); j++)
216 for (
int k = -kgrid; k < (kgrid + 1); k++)
219 ikpt[0] = i +
twist[0];
220 ikpt[1] = j +
twist[1];
221 ikpt[2] = k +
twist[2];
224 bool not_recorded =
true;
226 if (directional && ikpt[0] * ikpt[0] <= kgrid_squared[0] && ikpt[1] * ikpt[1] <= kgrid_squared[1] &&
227 ikpt[2] * ikpt[2] <= kgrid_squared[2])
230 kcount0[kgrid + i] = 1;
231 kcount1[kgrid + j] = 1;
232 kcount2[kgrid + k] = 1;
233 not_recorded =
false;
236 if (sphere && not_recorded &&
237 kpt[0] * kpt[0] + kpt[1] * kpt[1] + kpt[2] * kpt[2] <=
245 if (sphere && !directional)
247 app_log() <<
" Using all k-space points with (kx^2+ky^2+kz^2)^0.5 < " << sphere_kmax
248 <<
" for Momentum Distribution." << std::endl;
249 app_log() <<
" Total number of k-points for Momentum Distribution is " <<
kPoints.size() << std::endl;
251 else if (directional && !sphere)
257 for (
int i = 0; i < 2 * kgrid + 1; i++)
259 sums[0] += kcount0[i];
260 sums[1] += kcount1[i];
261 sums[2] += kcount2[i];
263 app_log() <<
" Using all k-space points within cut-offs " << kmax0 <<
", " << kmax1 <<
", " << kmax2
264 <<
" for Momentum Distribution." << std::endl;
265 app_log() <<
" Total number of k-points for Momentum Distribution: " <<
kPoints.size() << std::endl;
266 app_log() <<
" Number of grid points in kmax0 direction: " << sums[0] << std::endl;
267 app_log() <<
" Number of grid points in kmax1 direction: " << sums[1] << std::endl;
268 app_log() <<
" Number of grid points in kmax2 direction: " << sums[2] << std::endl;
276 for (
int i = 0; i < 2 * kgrid + 1; i++)
278 sums[0] += kcount0[i];
279 sums[1] += kcount1[i];
280 sums[2] += kcount2[i];
282 app_log() <<
" Using all k-space points with (kx^2+ky^2+kz^2)^0.5 < " << sphere_kmax <<
", and" << std::endl;
283 app_log() <<
" within the cut-offs " << kmax0 <<
", " << kmax1 <<
", " << kmax2 <<
" for Momentum Distribution." 285 app_log() <<
" Total number of k-points for Momentum Distribution is " <<
kPoints.size() << std::endl;
286 app_log() <<
" The number of k-points within the cut-off region: " << sums[0] * sums[1] * sums[2] << std::endl;
287 app_log() <<
" Number of grid points in kmax0 direction: " << sums[0] << std::endl;
288 app_log() <<
" Number of grid points in kmax1 direction: " << sums[1] << std::endl;
289 app_log() <<
" Number of grid points in kmax2 direction: " << sums[2] << std::endl;
291 app_log() <<
" Number of samples: " <<
M << std::endl;
298 RealType sum_kmaxs = kmaxs[0] + kmaxs[1];
300 bool disk = kmax > 0.0 ? true :
false;
301 bool directional = sum_kmaxs > 0.0 ? true :
false;
302 if (!disk && !directional)
314 kgrid = int(kmax / min_Length) + 1;
317 kgrid_squared[i] = kmaxs[i] * kmaxs[i] / vec_length[i] / vec_length[i];
318 RealType kmax_squared = disk_kmax * disk_kmax;
319 std::vector<int> kcount0;
320 std::vector<int> kcount1;
321 kcount0.resize(2 * kgrid + 1, 0);
322 kcount1.resize(2 * kgrid + 1, 0);
323 for (
int i = -kgrid; i < (kgrid + 1); i++)
325 for (
int j = -kgrid; j < (kgrid + 1); j++)
328 ikpt[0] = i -
twist[0];
329 ikpt[1] = j -
twist[1];
332 bool not_recorded =
true;
333 if (directional && ikpt[0] * ikpt[0] <= kgrid_squared[0] && ikpt[1] * ikpt[1] <= kgrid_squared[1])
336 kcount0[kgrid + i] = 1;
337 kcount1[kgrid + j] = 1;
338 not_recorded =
false;
340 if (disk && not_recorded &&
341 kpt[0] * kpt[0] + kpt[1] * kpt[1] <= kmax_squared)
347 if (disk && !directional)
349 app_log() <<
" Using all k-space points with (kx^2+ky^2)^0.5 < " << disk_kmax <<
" for Momentum Distribution." 351 app_log() <<
" Total number of k-points for Momentum Distribution is " <<
kPoints.size() << std::endl;
353 else if (directional && !disk)
358 for (
int i = 0; i < 2 * kgrid + 1; i++)
360 sums[0] += kcount0[i];
361 sums[1] += kcount1[i];
363 app_log() <<
" Using all k-space points within cut-offs " << kmax0 <<
", " << kmax1
364 <<
" for Momentum Distribution." << std::endl;
365 app_log() <<
" Total number of k-points for Momentum Distribution: " <<
kPoints.size() << std::endl;
366 app_log() <<
" Number of grid points in kmax0 direction: " << sums[0] << std::endl;
367 app_log() <<
" Number of grid points in kmax1 direction: " << sums[1] << std::endl;
374 for (
int i = 0; i < 2 * kgrid + 1; i++)
376 sums[0] += kcount0[i];
377 sums[1] += kcount1[i];
379 app_log() <<
" Using all k-space points with (kx^2+ky^2)^0.5 < " << disk_kmax <<
", and" << std::endl;
380 app_log() <<
" within the cut-offs " << kmax0 <<
", " << kmax1 <<
" for Momentum Distribution." << std::endl;
381 app_log() <<
" Total number of k-points for Momentum Distribution is " <<
kPoints.size() << std::endl;
382 app_log() <<
" The number of k-points within the cut-off region: " << sums[0] * sums[1] << std::endl;
383 app_log() <<
" Number of grid points in kmax0 direction: " << sums[0] << std::endl;
384 app_log() <<
" Number of grid points in kmax1 direction: " << sums[1] << std::endl;
386 app_log() <<
" Number of samples: " <<
M << std::endl;
391 std::stringstream sstr;
394 sstr <<
"_" << round(100.0 *
twist[i]);
396 std::ofstream fout(sstr.str().c_str());
397 fout.setf(std::ios::scientific, std::ios::floatfield);
400 fout <<
"k_" << i <<
" ";
402 for (
int i = 0; i <
kPoints.size(); i++)
417 for (
int im = 0; im <
M; im++)
428 std::unique_ptr<MomentumEstimator> myclone = std::make_unique<MomentumEstimator>(qp, psi);
440 nofK.resize(kin.size());
448 for (
int im = 0; im <
M; im++)
void resize(size_type n, Type_t val=Type_t())
Resize the container.
std::vector< PosType > vPos
sample positions
bool get(std::ostream &os) const override
write about the class
size_type size() const
return the size of the data
TrialWaveFunction & refPsi
reference to the trial wavefunction for ratio evaluations
void evaluateRatiosAlltoOne(ParticleSet &P, std::vector< ValueType > &ratios)
void resize(const std::vector< PosType > &kin, const int Min)
Matrix< ValueType > psi_ratios_all
wavefunction ratios all samples
helper functions for EinsplineSetBuilder
bool hdf5_out
print to hdf5 or scalar.dat
QTBase::RealType RealType
size_t getTotalNum() const
RealType norm_nofK
normalization factor for n(k)
void fill_n(T *x, size_t count, const T &value)
int my_index_
starting index of this object
bool put(xmlNodePtr cur)
assign attributes to the set
bool putSpecial(xmlNodePtr cur, ParticleSet &elns, bool rootNode)
std::unique_ptr< OperatorBase > makeClone(ParticleSet &qp, TrialWaveFunction &psi) final
std::vector< T >::iterator begin()
iterators to use std algorithms
QTBase::ComplexType ComplexType
MomentumEstimator(ParticleSet &elns, TrialWaveFunction &psi)
Vectorized record engine for scalar properties.
void resize(size_type n, size_type m)
Resize the container.
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
MakeReturn< BinaryNode< FnPow, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t, typename CreateLeaf< Vector< T2, C2 > >::Leaf_t > >::Expression_t pow(const Vector< T1, C1 > &l, const Vector< T2, C2 > &r)
SingleParticlePos k_cart(const SingleParticlePos &kin) const
conversion of a reciprocal-vector
void setObservables(PropertySetType &plist) override
Set the values evaluated by this object to plist Default implementation is to assign Value which is u...
Specialized paritlce class for atomistic simulations.
void resetTargetParticleSet(ParticleSet &P) override
Reset the data with the target ParticleSet.
std::unique_ptr< RandomBase< FullPrecRealType > > myRNG
random generator
VectorSoaContainer< RealType, 2 > phases
phases
int add(const std::string &aname)
virtual std::unique_ptr< RandomBase< T > > makeClone() const =0
class to handle a set of attributes of an xmlNode
void registerCollectables(std::vector< ObservableHelper > &h5desc, hdf_archive &file) const override
Walker_t * t_walker_
reference to the current walker
T * data()
return the base
void setRandomGenerator(RandomBase< FullPrecRealType > *rng) override
Set the Random Generator object TODO: add docs.
Buffer_t Collectables
observables in addition to those registered in Properties/PropertyList
Declaration of a TrialWaveFunction.
FullPrecRealType Return_t
type of return value of evaluate
const SingleParticlePos & getTwist() const
Define determinant operators.
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
Return_t evaluate(ParticleSet &P) override
Evaluate the local energy contribution of this component.
Class to represent a many-body trial wave function.
aligned_vector< RealType > nofK
nofK
void addObservables(PropertySetType &plist)
FullPrecRealType Weight
Weight of the walker.
const auto & getLattice() const
std::vector< int > kWeights
weight of k-points (make use of symmetry)
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
SingleParticlePos toCart(const TinyVector< T1, D > &c) const
Convert a unit vector to a cartesian vector.
const ParticleSet::ParticleLayout & lattice_
lattice vector
std::vector< VectorSoaContainer< RealType, 2 > > phases_vPos
phases of vPos
void resize(size_type n)
resize myData
void setParticlePropertyList(PropertySetType &plist, int offset) override
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
std::vector< ValueType > psi_ratios
wavefunction ratios
Vector< RealType > kdotp
nofK internal
void eval_e2iphi(int n, const T *restrict phi, T *restrict phase_r, T *restrict phase_i)
std::bitset< 8 > update_mode_
set the current update mode
void makeVirtualMoves(const SingleParticlePos &newpos)
Handles virtual moves for all the particles to a single newpos.
std::vector< PosType > kPoints
list of k-points in Cartesian Coordinates