QMCPACK
EwaldHandler2D.cpp
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) 2022 QMCPACK developers.
6 //
7 // File developed by: Yubo "Paul" Yang, yubo.paul.yang@gmail.com, CCQ @ Flatiron
8 //
9 // File created by: Yubo "Paul" Yang, yubo.paul.yang@gmail.com, CCQ @ Flatiron
10 //////////////////////////////////////////////////////////////////////////////////////
11 
13 
14 namespace qmcplusplus
15 {
16 
18  : LRHandlerBase(kc_in)
19 {
20  if (ref.getLattice().ndim != 2)
21  throw std::runtime_error("2D Ewald requires 2D Lattice");
22  LR_rc = ref.getLattice().LR_rc; // CoulombPBC needs get_rc() to createSpline4RbyVs
23  LR_kc = ref.getLattice().LR_kc; // get_kc() is used in QMCFiniteSize
24  alpha = std::sqrt(LR_kc/2.0/LR_rc);
25  area = ref.getLattice().Volume/ref.getLattice().R(2,2);
26  // report
27  app_log() << " alpha = " << alpha << " area = " << area << std::endl;
28  fillFk(ref.getSimulationCell().getKLists());
29 }
30 
32 {
33  const mRealType knorm = 2.0*M_PI / area;
34  const mRealType kalpha = 1.0 / (2.0*alpha);
35  mRealType kmag, uk;
36 
37  Fk.resize(KList.kpts_cart.size());
38  MaxKshell = KList.kshell.size() - 1;
40 
41  for (int ks = 0, ki = 0; ks < Fk_symm.size(); ks++)
42  {
43  kmag = std::sqrt(KList.ksq[ki]);
44  uk = knorm * erfc(kalpha*kmag)/kmag;
45  Fk_symm[ks] = uk;
46  while (ki < KList.kshell[ks + 1] && ki < Fk.size())
47  Fk[ki++] = uk;
48  }
49 }
50 
51 } // qmcplusplus
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
std::vector< PosType > kpts_cart
K-vector in Cartesian coordinates.
Definition: KContainer.h:53
EwaldHandler2D(ParticleSet &ref, mRealType kc_in=-1.0)
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
mRealType LR_kc
Maximum k cutoff.
Definition: LRHandlerBase.h:37
std::ostream & app_log()
Definition: OutputManager.h:65
DECLARE_COULOMB_TYPES int MaxKshell
Maxkimum Kshell for the given Kc.
Definition: LRHandlerBase.h:35
EwaldHandler3D::mRealType mRealType
void fillFk(const KContainer &KList)
const auto & getSimulationCell() const
Definition: ParticleSet.h:250
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
size_type size() const
return the current size
Definition: OhmmsVector.h:162
mRealType LR_rc
Maximum r cutoff.
Definition: LRHandlerBase.h:39
Container for k-points.
Definition: KContainer.h:29
std::vector< int > kshell
kpts which belong to the ith-shell [kshell[i], kshell[i+1])
Definition: KContainer.h:61
Vector< mRealType > Fk
Fourier component for all the k-point.
Definition: LRHandlerBase.h:41
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
Definition: KContainer.h:56
const auto & getLattice() const
Definition: ParticleSet.h:251
base class for LRHandlerTemp<FUNC,BASIS> and DummyLRHanlder<typename Func>
Definition: LRHandlerBase.h:30
Vector< mRealType > Fk_symm
Fourier component for each k-shell.
Definition: LRHandlerBase.h:49