28 input_(
std::move(mdi)),
31 norm_nofK(1.0 /
RealType(mdi.get_samples()))
48 RealType sum_kmaxs = kmaxs[0] + kmaxs[1] + kmaxs[2];
51 bool directional = sum_kmaxs > 0.0 ? true :
false;
52 if (!sphere && !directional)
64 kgrid = int(kmax / min_Length) + 1;
67 kgrid_squared[i] = kmaxs[i] * kmaxs[i] / vec_length[i] / vec_length[i];
68 RealType kmax_squared = sphere_kmax * sphere_kmax;
69 std::vector<int> kcount0;
70 std::vector<int> kcount1;
71 std::vector<int> kcount2;
72 kcount0.resize(2 * kgrid + 1, 0);
73 kcount1.resize(2 * kgrid + 1, 0);
74 kcount2.resize(2 * kgrid + 1, 0);
75 for (
int i = -kgrid; i < (kgrid + 1); i++)
77 for (
int j = -kgrid; j < (kgrid + 1); j++)
79 for (
int k = -kgrid; k < (kgrid + 1); k++)
82 ikpt[0] = i +
twist[0];
83 ikpt[1] = j +
twist[1];
84 ikpt[2] = k +
twist[2];
87 bool not_recorded =
true;
89 if (directional && ikpt[0] * ikpt[0] <= kgrid_squared[0] && ikpt[1] * ikpt[1] <= kgrid_squared[1] &&
90 ikpt[2] * ikpt[2] <= kgrid_squared[2])
93 kcount0[kgrid + i] = 1;
94 kcount1[kgrid + j] = 1;
95 kcount2[kgrid + k] = 1;
99 if (sphere && not_recorded &&
100 kpt[0] * kpt[0] + kpt[1] * kpt[1] + kpt[2] * kpt[2] <=
109 if (sphere && !directional)
111 app_log() <<
" Using all k-space points with (kx^2+ky^2+kz^2)^0.5 < " << sphere_kmax
112 <<
" for Momentum Distribution." << std::endl;
113 app_log() <<
" Total number of k-points for Momentum Distribution is " <<
kPoints.size() << std::endl;
115 else if (directional && !sphere)
121 for (
int i = 0; i < 2 * kgrid + 1; i++)
123 sums[0] += kcount0[i];
124 sums[1] += kcount1[i];
125 sums[2] += kcount2[i];
128 <<
", " <<
input_.
get_kmax2() <<
" for Momentum Distribution." << std::endl;
129 app_log() <<
" Total number of k-points for Momentum Distribution: " <<
kPoints.size() << std::endl;
130 app_log() <<
" Number of grid points in kmax0 direction: " << sums[0] << std::endl;
131 app_log() <<
" Number of grid points in kmax1 direction: " << sums[1] << std::endl;
132 app_log() <<
" Number of grid points in kmax2 direction: " << sums[2] << std::endl;
140 for (
int i = 0; i < 2 * kgrid + 1; i++)
142 sums[0] += kcount0[i];
143 sums[1] += kcount1[i];
144 sums[2] += kcount2[i];
146 app_log() <<
" Using all k-space points with (kx^2+ky^2+kz^2)^0.5 < " << sphere_kmax <<
", and" << std::endl;
149 app_log() <<
" Total number of k-points for Momentum Distribution is " <<
kPoints.size() << std::endl;
150 app_log() <<
" The number of k-points within the cut-off region: " << sums[0] * sums[1] * sums[2] << std::endl;
151 app_log() <<
" Number of grid points in kmax0 direction: " << sums[0] << std::endl;
152 app_log() <<
" Number of grid points in kmax1 direction: " << sums[1] << std::endl;
153 app_log() <<
" Number of grid points in kmax2 direction: " << sums[2] << std::endl;
162 vPos.resize(samples);
165 for (
int im = 0; im < samples; im++)
170 size_t data_size =
nofK.size();
171 data_.resize(data_size, 0.0);
181 std::size_t data_size =
data_.size();
189 throw std::runtime_error(
"There is no memory savings implementation for MomentumDistribution");
192 auto spawn = std::make_unique<MomentumDistribution>(*
this, spawn_data_locality);
193 spawn->get_data().resize(data_size);
241 for (
int iw = 0; iw <
walkers.size(); ++iw)
248 const int np =
pset.getTotalNum();
257 for (
int s = 0;
s < samples; ++
s)
266 for (
int i = 0; i < np; ++i)
269 for (
int ik = 0; ik < nk; ++ik)
276 for (
int i = 0; i < np; ++i)
278 for (
int ik = 0; ik < nk; ++ik)
281 for (
int s = 0;
s < samples; ++
s)
284 const RealType ratio_c = one_ratio.real();
285 const RealType ratio_s = one_ratio.imag();
291 #pragma omp simd aligned(nofK_here, phases_c, phases_s, phases_vPos_c, phases_vPos_s : QMC_SIMD_ALIGNMENT) 292 for (
int ik = 0; ik < nk; ++ik)
293 nofK_here[ik] += (phases_c[ik] * phases_vPos_c[ik] - phases_s[ik] * phases_vPos_s[ik]) * ratio_c -
294 (phases_s[ik] * phases_vPos_c[ik] + phases_c[ik] * phases_vPos_s[ik]) * ratio_s;
299 for (
int ik = 0; ik <
nofK.size(); ++ik)
313 throw std::runtime_error(
"You cannot call collect on a MomentumDistribution with this DataLocality");
320 using namespace std::string_literals;
322 std::vector<int> ng(1);
328 h5o.set_dimensions(ng, 0);
329 h5o.addProperty(
const_cast<std::vector<PosType>&
>(
kPoints),
"kpoints", file);
330 h5o.addProperty(
const_cast<std::vector<int>&
>(
kWeights),
"kweights", file);
void resize(size_type n, Type_t val=Type_t())
Resize the container.
a class that defines a supercell in D-dimensional Euclean space.
const Real & get_kmax1() const
void evaluateRatiosAlltoOne(ParticleSet &P, std::vector< ValueType > &ratios)
helper functions for EinsplineSetBuilder
QMCTraits::RealType RealType
Scalar_t WignerSeitzRadius_G
Wigner-Seitz cell radius in reciprocal space.
std::vector< ObservableHelper > h5desc_
void fill_n(T *x, size_t count, const T &value)
std::unique_ptr< OperatorEstBase > spawnCrowdClone() const override
standard interface
std::vector< ValueType > psi_ratios
wavefunction ratios
Vector< RealType > kdotp
nofK internal
Class that collects momentum distribution of electrons.
void collect(const RefVector< OperatorEstBase > &operator_estimators) override
this allows the EstimatorManagerNew to reduce without needing to know the details of MomentumDistribu...
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
const std::string & get_name() const
void resize(size_type n, size_type m)
Resize the container.
const Real & get_kmax2() const
DataLocality data_locality_
locality for accumulation of estimator data.
Matrix< ValueType > psi_ratios_all
wavefunction ratios all samples
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)
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > lattice
SingleParticlePos k_cart(const SingleParticlePos &kin) const
conversion of a reciprocal-vector
Specialized paritlce class for atomistic simulations.
QMCT::FullPrecRealType walkers_weight_
const Real & get_kmax() const
void registerOperatorEstimator(hdf_archive &file) override
this allows the EstimatorManagerNew to reduce without needing to know the details of MomentumDistribu...
const RealType norm_nofK
normalization factor for n(k)
aligned_vector< RealType > nofK
nofK
Scalar_t Volume
Physical properties of a supercell.
std::vector< int > kWeights
weight of k-points (make use of symmetry)
An abstract class for gridded estimators.
std::vector< VectorSoaContainer< RealType, 2 > > phases_vPos
phases of vPos
std::vector< PosType > vPos
T * data()
return the base
Declaration of a TrialWaveFunction.
std::vector< std::reference_wrapper< T > > RefVector
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
const PosType twist
twist angle
std::vector< PosType > kPoints
list of k-points in Cartesian Coordinates
const Real & get_kmax0() const
Class to represent a many-body trial wave function.
TinyVector< SingleParticlePos, D > Gv
Reciprocal unit vectors.
const MomentumDistributionInput input_
input values
VectorSoaContainer< RealType, 2 > phases
phases
DataLocality
data locality with respect to walker buffer
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
MomentumDistribution(MomentumDistributionInput &&mdi, size_t np, const PosType &twist, const LatticeType &lattice, DataLocality dl=DataLocality::crowd)
Constructor for MomentumDistributionInput.
SingleParticlePos toCart(const TinyVector< T1, D > &c) const
Convert a unit vector to a cartesian vector.
QMCTraits::ComplexType ComplexType
void startBlock(int steps) override
This allows us to allocate the necessary data for the DataLocality::queue.
void resize(size_type n)
resize myData
const int & get_samples() const
A container class to represent a walker.
Native representation for Momentum Distribution Estimators inputs.
void eval_e2iphi(int n, const T *restrict phi, T *restrict phase_r, T *restrict phase_i)
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 MomentumDistribution samples
virtual void collect(const RefVector< OperatorEstBase > &oebs)
Reduce estimator result data from crowds to rank.
std::string my_name_
name of this object – only used for debugging and h5 output