33 APP_ABORT(
" Illegal cutoff for KContainer");
38 app_log() <<
" KContainer initialised with cutoff " <<
kcutoff << std::endl;
39 app_log() <<
" # of K-shell = " <<
kshell.size() << std::endl;
40 app_log() <<
" # of K points = " <<
kpts.size() << std::endl;
83 for (
int i = 0; i <
DIM; i++)
87 for (
int i = 1; i <
DIM; ++i)
93 app_log() <<
" No kspace sum perpendicular to slab " << std::endl;
98 app_log() <<
" No kspace sum along z " << std::endl;
111 std::vector<TinyVector<int, DIM>> kpts_tmp;
112 std::vector<PosType> kpts_cart_tmp;
113 std::vector<RealType> ksq_tmp;
119 for (
int i = -
mmax[0]; i <=
mmax[0]; i++)
122 for (
int j = -
mmax[1]; j <=
mmax[1]; j++)
125 for (
int k = -
mmax[2]; k <=
mmax[2]; k++)
129 if (i == 0 && j == 0 && k == 0)
132 kvec_cart =
lattice.k_cart(kvec + twist);
134 modk2 =
dot(kvec_cart, kvec_cart);
138 kpts_tmp.push_back(kvec);
139 kpts_cart_tmp.push_back(kvec_cart);
140 ksq_tmp.push_back(modk2);
142 for (
int idim = 0; idim < 3; idim++)
143 if (
std::abs(kvec[idim]) > TempActualMax[idim])
144 TempActualMax[idim] =
std::abs(kvec[idim]);
155 const int idimsize =
mmax[0] * 2;
156 const int jdimsize =
mmax[1] * 2;
157 const int kdimsize =
mmax[2] * 2;
158 for (
int i = 0; i < idimsize; i++)
161 if (kvec[0] >
mmax[0])
163 for (
int j = 0; j < jdimsize; j++)
166 if (kvec[1] >
mmax[1])
168 for (
int k = 0; k < kdimsize; k++)
171 if (kvec[2] >
mmax[2])
174 kvec_cart =
lattice.k_cart(kvec);
175 modk2 =
dot(kvec_cart, kvec_cart);
177 kpts_tmp.push_back(kvec);
178 kpts_cart_tmp.push_back(kvec_cart);
179 ksq_tmp.push_back(modk2);
184 TempActualMax[0] =
mmax[0];
185 TempActualMax[1] =
mmax[1];
186 TempActualMax[2] =
mmax[2];
190 numk = kpts_tmp.size();
191 std::map<int64_t, std::vector<int>*> kpts_sorted;
193 for (
int ik = 0; ik <
numk; ik++)
197 const int64_t k_ind =
static_cast<int64_t
>(ksq_tmp[ik] * 10000000);
198 auto it(kpts_sorted.find(k_ind));
199 if (it == kpts_sorted.end())
201 std::vector<int>* newSet =
new std::vector<int>;
202 kpts_sorted[k_ind] = newSet;
203 newSet->push_back(ik);
207 (*it).second->push_back(ik);
210 std::map<int64_t, std::vector<int>*>::iterator it(kpts_sorted.begin());
215 kshell.resize(kpts_sorted.size() + 1, 0);
217 while (it != kpts_sorted.end())
219 std::vector<int>::iterator vit((*it).second->begin());
220 while (vit != (*it).second->end())
223 kpts[ok] = kpts_tmp[ik];
226 ksq[ok] = ksq_tmp[ik];
235 it = kpts_sorted.begin();
236 std::map<int64_t, std::vector<int>*>::iterator e_it(kpts_sorted.end());
244 for (
int idim = 0; idim <
DIM; idim++)
246 mmax[idim] = TempActualMax[idim];
254 auto getHashOfVec = [](
const auto& inpv,
int hashparam) -> int64_t {
256 for (
int i = 0; i < inpv.Size; ++i)
257 hash += inpv[i] + hash * hashparam;
262 std::map<int64_t, int> hashToIndex;
263 for (
int ki = 0; ki <
numk; ki++)
265 hashToIndex[getHashOfVec(
kpts[ki],
numk)] = ki;
268 for (
int ki = 0; ki <
numk; ki++)
a class that defines a supercell in D-dimensional Euclean space.
std::vector< PosType > kpts_cart
K-vector in Cartesian coordinates.
helper functions for EinsplineSetBuilder
VectorSoaContainer< RealType, DIM, OffloadAllocator< RealType > > kpts_cart_soa_
K-vector in Cartesian coordinates in SoA layout.
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > lattice
RealType kcutoff
The cutoff up to which k-vectors are generated.
TinyVector< int, DIM+1 > mmax
maximum integer translations of reciprocal cell within kc.
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
std::vector< int > kshell
kpts which belong to the ith-shell [kshell[i], kshell[i+1])
void findApproxMMax(const ParticleLayout &lattice, unsigned ndim)
compute approximate parallelpiped that surrounds kc
std::vector< int > minusk
Given a k index, return index to -k.
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
std::vector< RealType > ksq
squre of kpts in Cartesian coordniates
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
Define a LRHandler with two template parameters.
void updateKLists(const ParticleLayout &lattice, RealType kc, unsigned ndim, const PosType &twist=PosType(), bool useSphere=true)
k points sorted by the |k| excluding |k|=0
std::vector< TinyVector< int, DIM > > kpts
K-vector in reduced coordinates.
int numk
number of k-points
static bool isQuasi2D()
return true if quasi 2D is selected
void BuildKLists(const ParticleLayout &lattice, const PosType &twist, bool useSphere)
construct the container for k-vectors
MakeReturn< UnaryNode< FnFloor, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t floor(const Vector< T1, C1 > &l)