QMCPACK
EwaldHandlerQuasi2D.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: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
9 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
10 // Yubo "Paul" Yang, yubo.paul.yang@gmail.com, CCQ @ Flatiron
11 //
12 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
13 //////////////////////////////////////////////////////////////////////////////////////
14 
16 
17 namespace qmcplusplus
18 {
19 
21  : LRHandlerBase(kc_in)
22 {
23  if (ref.getLattice().SuperCellEnum != SUPERCELL_SLAB)
24  throw std::runtime_error("Quasi2D Ewald requires ppn boundary.");
25  LR_rc = ref.getLattice().LR_rc; // CoulombPBC needs get_rc() to createSpline4RbyVs
26  LR_kc = ref.getLattice().LR_kc; // get_kc() is used in QMCFiniteSize
27  alpha = std::sqrt(LR_kc/2.0/LR_rc);
28  area = ref.getLattice().Volume/ref.getLattice().R(2,2);
29  // report
30  app_log() << " alpha = " << alpha << " area = " << area << std::endl;
31  fillFk(ref.getSimulationCell().getKLists());
32 }
33 
35 {
36  const mRealType knorm = M_PI / area;
37  mRealType kmag, uk;
38 
39  Fk.resize(KList.kpts_cart.size());
40  MaxKshell = KList.kshell.size() - 1;
42 
43  kmags.resize(MaxKshell);
44  for (int ks = 0, ki = 0; ks < Fk_symm.size(); ks++)
45  {
46  kmag = std::sqrt(KList.ksq[ki]);
47  kmags[ks] = kmag; // store k magnitutes
48  uk = knorm/kmag;
49  Fk_symm[ks] = uk;
50  while (ki < KList.kshell[ks + 1] && ki < Fk.size())
51  Fk[ki++] = uk;
52  }
53 }
54 
56  pRealType z, const std::vector<int>& kshell,
57  const pRealType* restrict rk1_r,
58  const pRealType* restrict rk1_i,
59  const pRealType* restrict rk2_r,
60  const pRealType* restrict rk2_i) const
61 {
62  mRealType zmag = std::abs(z);
63  mRealType vk = -slab_vsr_k0(zmag)/area;
64  for (int ks = 0, ki = 0; ks < MaxKshell; ks++)
65  {
66  mRealType u = 0;
67  for (; ki < kshell[ks + 1]; ki++)
68  u += (*rk1_r++) * (*rk2_r++) + (*rk1_i++) * (*rk2_i++);
69  vk += u * Fk_symm[ks] * slabFunc(zmag, kmags[ks]);
70  }
71  return vk;
72 }
73 
75 {
76  mRealType term1, term2;
77  term1 = std::exp(slabLogf( z, k));
78  term2 = std::exp(slabLogf(-z, k));
79  return term1+term2;
80 }
81 
83 {
84  mRealType z1 = alpha*z;
85  mRealType k1 = k/(2*alpha);
86  mRealType log_term = k*z + std::log(erfc(z1+k1));
87  return log_term;
88 }
89 
91 {
92  mRealType z1 = alpha*z;
93  mRealType term1 = std::exp(-z1*z1) * 2*std::sqrt(M_PI)/alpha;
94  mRealType term2 = 2*M_PI*z*erfc(z1);
95  return term1-term2;
96 }
97 
98 } // 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
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
mRealType LR_kc
Maximum k cutoff.
Definition: LRHandlerBase.h:37
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
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
mRealType slabLogf(mRealType z, mRealType k) const
mRealType evaluate_slab(pRealType z, const std::vector< int > &kshell, const pRealType *restrict rk1_r, const pRealType *restrict rk1_i, const pRealType *restrict rk2_r, const pRealType *restrict rk2_i) const override
Evaluate the long-range potential with the open BC for the D-1 direction.
mRealType slab_vsr_k0(mRealType z) const
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
void fillFk(const KContainer &KList)
qmcplusplus::LRHandlerBase::pRealType pRealType
mRealType LR_rc
Maximum r cutoff.
Definition: LRHandlerBase.h:39
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
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< FnLog, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t log(const Vector< T1, C1 > &l)
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
std::vector< mRealType > kmags
store |k|
const auto & getLattice() const
Definition: ParticleSet.h:251
base class for LRHandlerTemp<FUNC,BASIS> and DummyLRHanlder<typename Func>
Definition: LRHandlerBase.h:30
mRealType slabFunc(mRealType z, mRealType k) const
EwaldHandlerQuasi2D(ParticleSet &ref, mRealType kc_in=-1.0)
Vector< mRealType > Fk_symm
Fourier component for each k-shell.
Definition: LRHandlerBase.h:49