QMCPACK
EwaldHandler3D.h
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 /** @file LRHandlerTemp.h
14  * @brief Define a LRHandler with two template parameters
15  */
16 #ifndef QMCPLUSPLUS_EWALD_HANLDER3D_H
17 #define QMCPLUSPLUS_EWALD_HANLDER3D_H
18 
20 #include "coulomb_types.h"
21 
22 namespace qmcplusplus
23 {
24 /* LR breakup for the standard Ewald method in 3D
25  *
26  */
28 {
29 public:
30  ///type of supercell
32  /// Related to the Gaussian width: \f$ v_l = v(r)erf(\sigma r)\f$
34  ///Volume of the supercell
36  ///Area of the supercell: always z is the slab direction
38 
40  ///store |k|
41  std::vector<mRealType> kMag;
42  /// Constructor
43  EwaldHandler3D(ParticleSet& ref, mRealType kc_in = -1.0) : LRHandlerBase(kc_in)
44  {
45  LRHandlerBase::ClassName = "EwaldHandler3D";
46  Sigma = LR_kc = ref.getLattice().LR_kc;
47  }
48 
49  /** "copy" constructor
50  * @param aLR LRHandlerTemp
51  * @param ref Particleset
52  *
53  * Copy the content of aLR
54  * References to ParticleSet or ParticleLayoutout_t are not copied.
55  */
56  EwaldHandler3D(const EwaldHandler3D& aLR, ParticleSet& ref);
57 
58  LRHandlerBase* makeClone(ParticleSet& ref) const override { return new EwaldHandler3D(*this, ref); }
59 
60  void initBreakup(ParticleSet& ref) override;
61 
62  void Breakup(ParticleSet& ref, mRealType rs_in) override { initBreakup(ref); }
63 
64  void resetTargetParticleSet(ParticleSet& ref) override {}
65 
66  inline mRealType evaluate(mRealType r, mRealType rinv) const override { return erfc(r * Sigma) * rinv; }
67 
68  /** evaluate the contribution from the long-range part for for spline
69  */
70  inline mRealType evaluateLR(mRealType r) const override { return erf(r * Sigma) / r; }
71 
72  inline mRealType evaluateSR_k0() const override
73  {
74  mRealType v0 = M_PI / Sigma / Sigma / Volume;
75  return v0;
76  }
77 
78  mRealType evaluate_vlr_k(mRealType k) const override;
79 
80  mRealType evaluateLR_r0() const override { return 2.0 * Sigma / std::sqrt(M_PI); }
81 
82  /** evaluate the first derivative of the short range part at r
83  *
84  * @param r radius
85  * @param rinv 1/r
86  */
87  inline mRealType srDf(mRealType r, mRealType rinv) const override
88  {
89  return -2.0 * Sigma * std::exp(-Sigma * Sigma * r * r) / (std::sqrt(M_PI) * r) - erfc(Sigma * r) * rinv * rinv;
90  }
91 
92  /** evaluate the first derivative of the long range part (in real space) at r
93  *
94  * @param r radius
95  */
96  inline mRealType lrDf(mRealType r) const override
97  {
98  mRealType rinv = 1.0 / r;
99  return 2.0 * Sigma * std::exp(-Sigma * Sigma * r * r) / (std::sqrt(M_PI) * r) - erf(Sigma * r) * rinv * rinv;
100  }
101 
102  void fillFk(const KContainer& KList);
103 
104  void fillYkgstrain(const KContainer& KList)
105  {
106  Fkgstrain.resize(KList.kpts_cart.size());
107  const std::vector<int>& kshell(KList.kshell);
108  MaxKshell = kshell.size() - 1;
109  for (int ks = 0, ki = 0; ks < MaxKshell; ks++)
110  {
111  mRealType uk = evalYkgstrain(std::sqrt(KList.ksq[ki]));
112  while (ki < KList.kshell[ks + 1] && ki < Fkgstrain.size())
113  Fkgstrain[ki++] = uk;
114  }
115  }
116 
117  void filldFk_dk(const KContainer& KList)
118  {
119  dFk_dstrain.resize(KList.kpts_cart.size());
120 
121  for (int ki = 0; ki < dFk_dstrain.size(); ki++)
122  {
123  dFk_dstrain[ki] = evaluateLR_dstrain(KList.kpts_cart[ki], std::sqrt(KList.ksq[ki]));
124  }
125  }
126 
127  //This returns the stress derivative of Fk, except for the explicit volume dependence. The explicit volume dependence is factored away into V.
129  pRealType kmag) const override
130  {
131  SymTensor<mRealType, OHMMS_DIM> deriv_tensor = 0;
132 
133  for (int dim1 = 0; dim1 < OHMMS_DIM; dim1++)
134  for (int dim2 = dim1; dim2 < OHMMS_DIM; dim2++)
135  {
136  deriv_tensor(dim1, dim2) =
137  -evaldYkgstrain(kmag) * k[dim1] * k[dim2] / kmag; //- evaldFk_dk(kmag)*k[dim1]*k[dim2]/kmag ;
138 
139  if (dim1 == dim2)
140  deriv_tensor(dim1, dim2) -= evalYkgstrain(kmag); //+ derivconst;
141  }
142 
143 
144  return deriv_tensor;
145  }
146 
147 
149  pRealType rmag) const override
150  {
151  SymTensor<mRealType, OHMMS_DIM> deriv_tensor = 0;
152 
153  mRealType Sr_r = srDf(rmag, 1.0 / mRealType(rmag)) / mRealType(rmag);
154 
155  for (int dim1 = 0; dim1 < OHMMS_DIM; dim1++)
156  {
157  for (int dim2 = dim1; dim2 < OHMMS_DIM; dim2++)
158  {
159  deriv_tensor(dim1, dim2) = r[dim1] * r[dim2] * Sr_r;
160  }
161  }
162 
163  return deriv_tensor;
164  }
165 
167  {
168  mRealType v0 = -M_PI / Sigma / Sigma / Volume;
170  for (int i = 0; i < OHMMS_DIM; i++)
171  stress(i, i) = v0;
172 
173  return stress;
174  }
175 
176  inline mRealType evaluateLR_r0_dstrain(int i, int j) const { return 0.0; }
177 
179  {
181  return stress;
182  }
183 
184 private:
186  {
187  mRealType norm = 4.0 * M_PI / Volume;
188  mRealType denom = 4.0 * Sigma * Sigma;
189  mRealType k2 = k * k;
190  return norm * std::exp(-k2 / denom) / k2;
191  }
192 
194  {
195  mRealType norm = 4.0 * M_PI / Volume;
196  mRealType denom = 4.0 * Sigma * Sigma;
197  mRealType sigma2 = Sigma * Sigma;
198  mRealType k2 = k * k;
199  return -norm * std::exp(-k2 / denom) * (denom + k2) / (k * k2 * 2.0 * sigma2);
200  }
201 };
202 } // namespace qmcplusplus
203 #endif
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
LRHandlerBase * makeClone(ParticleSet &ref) const override
make clone
std::vector< PosType > kpts_cart
K-vector in Cartesian coordinates.
Definition: KContainer.h:53
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
SymTensor< mRealType, OHMMS_DIM > evaluateSR_k0_dstrain() const override
mRealType LR_kc
Maximum k cutoff.
Definition: LRHandlerBase.h:37
DECLARE_COULOMB_TYPES int MaxKshell
Maxkimum Kshell for the given Kc.
Definition: LRHandlerBase.h:35
EwaldHandler3D::mRealType mRealType
void fillYkgstrain(const KContainer &KList)
void resetTargetParticleSet(ParticleSet &ref) override
Vector< mRealType > Fkgstrain
Vector of df_k/dk, fit as to optimize strains.
Definition: LRHandlerBase.h:47
mRealType Sigma
Related to the Gaussian width: .
mRealType Area
Area of the supercell: always z is the slab direction.
mRealType Volume
Volume of the supercell.
void filldFk_dk(const KContainer &KList)
#define OHMMS_DIM
Definition: config.h:64
void Breakup(ParticleSet &ref, mRealType rs_in) override
std::vector< SymTensor< mRealType, OHMMS_DIM > > dFk_dstrain
Fourier component of the LR part of strain tensor, by optimized breakup.
Definition: LRHandlerBase.h:45
std::vector< mRealType > kMag
store |k|
mRealType evalYkgstrain(mRealType k) const
mRealType evaluateLR_r0() const override
evaluate for the self-interaction term
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
size_type size() const
return the current size
Definition: OhmmsVector.h:162
qmcplusplus::LRHandlerBase::pRealType pRealType
double norm(const zVec &c)
Definition: VectorOps.h:118
SymTensor< mRealType, OHMMS_DIM > evaluateLR_r0_dstrain() const override
These functions return the strain derivatives of all corresponding quantities in total energy...
mRealType evaluateSR_k0() const override
evaluate
mRealType evaldYkgstrain(mRealType k) const
mRealType srDf(mRealType r, mRealType rinv) const override
evaluate the first derivative of the short range part at r
mRealType evaluate(mRealType r, mRealType rinv) const override
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
void fillFk(const KContainer &KList)
SymTensor< mRealType, OHMMS_DIM > evaluateSR_dstrain(TinyVector< pRealType, OHMMS_DIM > r, pRealType rmag) const override
mRealType evaluateLR(mRealType r) const override
evaluate the contribution from the long-range part for for spline
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 evaluateLR_r0_dstrain(int i, int j) const
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
Define LRHandlerBase and DummyLRHandler<typename Func>
EwaldHandler3D(ParticleSet &ref, mRealType kc_in=-1.0)
Constructor.
void initBreakup(ParticleSet &ref) override
mRealType lrDf(mRealType r) const override
evaluate the first derivative of the long range part (in real space) at r
SymTensor< mRealType, OHMMS_DIM > evaluateLR_dstrain(TinyVector< pRealType, OHMMS_DIM > k, pRealType kmag) const override