QMCPACK
EwaldHandler3D.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) 2020 QMCPACK developers.
6 //
7 // File developed by: Raymond Clay III, j.k.rofling@gmail.com, Lawrence Livermore National Laboratory
8 //
9 // File created by: Raymond Clay III, j.k.rofling@gmail.com, Lawrence Livermore National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "EwaldHandler3D.h"
14 
15 namespace qmcplusplus
16 {
18 {
19  SuperCellEnum = ref.getLattice().SuperCellEnum;
20  LR_rc = ref.getLattice().LR_rc;
21  LR_kc = ref.getLattice().LR_kc;
22 
23  // Sigma=3.5;
24  //We provide two means of choosing sigma here...
25  //
26  //This condition on Sigma is based on the real space cutoff of the potential at r_c for the potential.
27  //while(erfc(Sigma)/LR_rc>1e-10)
28  //
29  //This condition on Sigma is based on the magnitude of the force at r_c for the potential.
30  // while( (erfc(Sigma)+std::exp(-Sigma*Sigma)*2*Sigma/std::sqrt(M_PI))/LR_rc/LR_rc>1e-14)
31  // {
32  // Sigma+=0.1;
33  // }
34  //
35  // app_log() << " EwaldHandler3D Sigma/LR_rc = " << Sigma ;
36  // Sigma/=ref.getLattice().LR_rc;
37 
38  //This heuristic for choosing Sigma is from the 1992 Natoli Ceperley Optimized Breakup Paper.
39  Sigma = std::sqrt(LR_kc / (2.0 * LR_rc));
40  app_log() << " Sigma=" << Sigma << std::endl;
41  Volume = ref.getLattice().Volume;
42  PreFactors = 0.0;
43  fillFk(ref.getSimulationCell().getKLists());
44  fillYkgstrain(ref.getSimulationCell().getKLists());
45  filldFk_dk(ref.getSimulationCell().getKLists());
46 }
47 
49  : LRHandlerBase(aLR), Sigma(aLR.Sigma), Volume(aLR.Volume), Area(aLR.Area), PreFactors(aLR.PreFactors)
50 {
52 }
53 
55 {
56  Fk.resize(KList.kpts_cart.size());
57  Fkg.resize(KList.kpts_cart.size());
58  const std::vector<int>& kshell(KList.kshell);
59 
60  MaxKshell = kshell.size() - 1;
61 
63  kMag.resize(MaxKshell);
64  mRealType kgauss = 1.0 / (4 * Sigma * Sigma);
65  mRealType knorm = 4 * M_PI / Volume;
66  for (int ks = 0, ki = 0; ks < Fk_symm.size(); ks++)
67  {
68  mRealType t2e = KList.ksq[ki] * kgauss;
69  mRealType uk = knorm * std::exp(-t2e) / KList.ksq[ki];
70  Fk_symm[ks] = uk;
71  while (ki < KList.kshell[ks + 1] && ki < Fk.size())
72  Fk[ki++] = uk;
73  }
74 
75  for (int ki = 0; ki < Fk.size(); ki++)
76  Fkg[ki] = Fk[ki];
77 
78  PreFactors[3] = 0.0;
79  app_log().flush();
80 }
81 
83 {
84  mRealType kgauss = 1.0 / (4 * Sigma * Sigma);
85  mRealType knorm = 4 * M_PI / Volume;
86  mRealType k2 = k * k;
87  return knorm * std::exp(-k2 * kgauss) / k2;
88 }
89 
90 } // namespace 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
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 fillYkgstrain(const KContainer &KList)
mRealType Sigma
Related to the Gaussian width: .
mRealType Volume
Volume of the supercell.
void filldFk_dk(const KContainer &KList)
std::vector< mRealType > kMag
store |k|
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
Vector< mRealType > Fkg
Fourier component of the LR part, fit to optimize the gradients.
Definition: LRHandlerBase.h:43
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
int SuperCellEnum
type of supercell
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
void fillFk(const KContainer &KList)
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
TinyVector< mRealType, 4 > PreFactors
mRealType evaluate_vlr_k(mRealType k) const override
const auto & getLattice() const
Definition: ParticleSet.h:251
base class for LRHandlerTemp<FUNC,BASIS> and DummyLRHanlder<typename Func>
Definition: LRHandlerBase.h:30
EwaldHandler3D(ParticleSet &ref, mRealType kc_in=-1.0)
Constructor.
void initBreakup(ParticleSet &ref) override
Vector< mRealType > Fk_symm
Fourier component for each k-shell.
Definition: LRHandlerBase.h:49