QMCPACK
LRHandlerSRCoulomb< Func, BreakupBasis > Class Template Reference
+ Inheritance diagram for LRHandlerSRCoulomb< Func, BreakupBasis >:
+ Collaboration diagram for LRHandlerSRCoulomb< Func, BreakupBasis >:

Public Types

using ParticleLayout = ParticleSet::ParticleLayout
 
using BreakupBasisType = BreakupBasis
 
using GridType = LinearGrid< mRealType >
 

Public Member Functions

 LRHandlerSRCoulomb (ParticleSet &ref, mRealType kc_in=-1.0)
 
 ~LRHandlerSRCoulomb () override
 
 LRHandlerSRCoulomb (const LRHandlerSRCoulomb &aLR, ParticleSet &ref)
 "copy" constructor More...
 
LRHandlerBasemakeClone (ParticleSet &ref) const override
 make clone More...
 
void initBreakup (ParticleSet &ref) override
 
void Breakup (ParticleSet &ref, mRealType rs_ext) override
 
void resetTargetParticleSet (ParticleSet &ref) override
 
void resetTargetParticleSet (ParticleSet &ref, mRealType rs)
 
mRealType evaluate (mRealType r, mRealType rinv) const override
 
mRealType evaluate_vlr_k (mRealType k) const override
 
mRealType srDf (mRealType r, mRealType rinv) const override
 evaluate the first derivative of the short range part at r More...
 
mRealType srDf_strain (mRealType r, mRealType rinv) const
 
mRealType lrDf (mRealType r) const override
 
mRealType evaluateLR (mRealType r) const override
 evaluate the contribution from the long-range part for for spline More...
 
mRealType evaluateSR_k0 () const override
 evaluate $ v_{s}(k=0) = \frac{4\pi}{V}\int_0^{r_c} r^2 v_s(r) dr $ More...
 
mRealType evaluateLR_r0 () const override
 evaluate $ v_s(r=0) $ for the self-interaction term More...
 
SymTensor< mRealType, OHMMS_DIMevaluateLR_dstrain (TinyVector< pRealType, OHMMS_DIM > k, pRealType kmag) const override
 
SymTensor< mRealType, OHMMS_DIMevaluateSR_dstrain (TinyVector< pRealType, OHMMS_DIM > r, pRealType rmag) const override
 
SymTensor< mRealType, OHMMS_DIMevaluateSR_k0_dstrain () const override
 
mRealType evaluateLR_r0_dstrain (int i, int j) const
 
SymTensor< mRealType, OHMMS_DIMevaluateLR_r0_dstrain () const override
 These functions return the strain derivatives of all corresponding quantities in total energy. More...
 
- Public Member Functions inherited from LRHandlerBase
 LRHandlerBase (mRealType kc)
 
virtual ~LRHandlerBase ()=default
 
mRealType get_rc () const
 
mRealType get_kc () const
 
mRealType evaluate_w_sk (const std::vector< int > &kshell, const pRealType *restrict sk) const
 
mRealType evaluate (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
 evaluate $\sum_k F_{k} \rho^1_{-{\bf k}} \rho^2_{\bf k}$ More...
 
virtual 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
 Evaluate the long-range potential with the open BC for the D-1 direction. More...
 
void evaluateGrad (const ParticleSet &A, const ParticleSet &B, int specB, std::vector< pRealType > &Zat, std::vector< TinyVector< pRealType, OHMMS_DIM >> &grad1) const
 evaluate $\sum_k F_{k} \rho^1_{-{\bf k}} \rho^2_{\bf k}$ and $\sum_k F_{k} \rho^1_{-{\bf k}} \rho^2_{\bf k}$ More...
 
SymTensor< pRealType, OHMMS_DIMevaluateStress (const std::vector< int > &kshell, const pRealType *rhokA_r, const pRealType *rhokA_i, const pRealType *rhokB_r, const pRealType *rhokB_i) const
 FIX_PRECISION. More...
 

Public Attributes

bool FirstTime
 
mRealType rs
 
BreakupBasisType Basis
 
Func myFunc
 
std::vector< mRealTypeFk_copy
 
- Public Attributes inherited from LRHandlerBase
DECLARE_COULOMB_TYPES int MaxKshell
 Maxkimum Kshell for the given Kc. More...
 
mRealType LR_kc
 Maximum k cutoff. More...
 
mRealType LR_rc
 Maximum r cutoff. More...
 
Vector< mRealTypeFk
 Fourier component for all the k-point. More...
 
Vector< mRealTypeFkg
 Fourier component of the LR part, fit to optimize the gradients. More...
 
std::vector< SymTensor< mRealType, OHMMS_DIM > > dFk_dstrain
 Fourier component of the LR part of strain tensor, by optimized breakup. More...
 
Vector< mRealTypeFkgstrain
 Vector of df_k/dk, fit as to optimize strains. More...
 
Vector< mRealTypeFk_symm
 Fourier component for each k-shell. More...
 
std::vector< mRealTypecoefs
 Fourier component for each k-shell Coefficient. More...
 
std::vector< mRealTypegcoefs
 Coefficient for gradient fit. More...
 
std::vector< mRealTypegstraincoefs
 Coefficient for strain fit. More...
 

Private Member Functions

mRealType evalYk (mRealType k) const
 
mRealType evalYkg (mRealType k) const
 
mRealType evalYkgstrain (mRealType k) const
 
mRealType evaldYkgstrain (mRealType k) const
 
void InitBreakup (const ParticleLayout &ref, int NumFunctions)
 Initialise the basis and coefficients for the long-range beakup. More...
 
void fillVk (std::vector< TinyVector< mRealType, 2 >> &KList)
 
void fillYk (KContainer &KList)
 
void fillYkg (const KContainer &KList)
 
void fillYkgstrain (KContainer &KList)
 
void filldFk_dk (KContainer &KList)
 

Additional Inherited Members

- Protected Attributes inherited from LRHandlerBase
std::string ClassName
 

Detailed Description

template<class Func, class BreakupBasis = LPQHISRCoulombBasis>
class qmcplusplus::LRHandlerSRCoulomb< Func, BreakupBasis >

Definition at line 43 of file LRHandlerSRCoulomb.h.

Member Typedef Documentation

◆ BreakupBasisType

using BreakupBasisType = BreakupBasis

Definition at line 48 of file LRHandlerSRCoulomb.h.

◆ GridType

Definition at line 49 of file LRHandlerSRCoulomb.h.

◆ ParticleLayout

Constructor & Destructor Documentation

◆ LRHandlerSRCoulomb() [1/2]

LRHandlerSRCoulomb ( ParticleSet ref,
mRealType  kc_in = -1.0 
)
inline

Definition at line 60 of file LRHandlerSRCoulomb.h.

References LRHandlerBase::ClassName, and LRHandlerSRCoulomb< Func, BreakupBasis >::myFunc.

61  : LRHandlerBase(kc_in), FirstTime(true), Basis(ref.getLRBox())
62 
63  {
64  LRHandlerBase::ClassName = "LRHandlerSRCoulomb";
65  myFunc.reset(ref);
66  }

◆ ~LRHandlerSRCoulomb()

~LRHandlerSRCoulomb ( )
inlineoverride

Definition at line 68 of file LRHandlerSRCoulomb.h.

68 {}

◆ LRHandlerSRCoulomb() [2/2]

LRHandlerSRCoulomb ( const LRHandlerSRCoulomb< Func, BreakupBasis > &  aLR,
ParticleSet ref 
)
inline

"copy" constructor

Parameters
aLRLRHandlerSRCoulomb
refParticleset

Copy the content of aLR References to ParticleSet or ParticleLayoutout_t are not copied.

Definition at line 77 of file LRHandlerSRCoulomb.h.

78  : LRHandlerBase(aLR), FirstTime(true), Basis(aLR.Basis, ref.getLRBox())
79  {}

Member Function Documentation

◆ Breakup()

void Breakup ( ParticleSet ref,
mRealType  rs_ext 
)
inlineoverridevirtual

Implements LRHandlerBase.

Definition at line 98 of file LRHandlerSRCoulomb.h.

References LRHandlerSRCoulomb< Func, BreakupBasis >::Basis, LRHandlerSRCoulomb< Func, BreakupBasis >::fillYkg(), ParticleSet::getLRBox(), ParticleSet::getSimulationCell(), LRHandlerSRCoulomb< Func, BreakupBasis >::InitBreakup(), LRHandlerBase::LR_rc, LRHandlerSRCoulomb< Func, BreakupBasis >::myFunc, and LRHandlerSRCoulomb< Func, BreakupBasis >::rs.

99  {
100  rs = rs_ext;
101  myFunc.reset(ref, rs);
102  InitBreakup(ref.getLRBox(), 1);
103  // fillYk(ref.getSimulationCell().getKLists());
104  fillYkg(ref.getSimulationCell().getKLists());
105  //This is expensive to calculate. Deprecating stresses for now.
106  //filldFk_dk(ref.getSimulationCell().getKLists());
107  LR_rc = Basis.get_rc();
108  }
mRealType LR_rc
Maximum r cutoff.
Definition: LRHandlerBase.h:39
void InitBreakup(const ParticleLayout &ref, int NumFunctions)
Initialise the basis and coefficients for the long-range beakup.
void fillYkg(const KContainer &KList)

◆ evaldYkgstrain()

mRealType evaldYkgstrain ( mRealType  k) const
inlineprivate

Definition at line 262 of file LRHandlerSRCoulomb.h.

References APP_ABORT, LRHandlerSRCoulomb< Func, BreakupBasis >::Basis, LRHandlerBase::gstraincoefs, and LRHandlerSRCoulomb< Func, BreakupBasis >::myFunc.

Referenced by LRHandlerSRCoulomb< Func, BreakupBasis >::evaluateLR_dstrain().

263  {
264  APP_ABORT("Stresses not supported yet\n");
265  mRealType dFk_dk = myFunc.dVk_dk(k) - Basis.dfk_dk(k, gstraincoefs);
266  // mRealType dFk_dk = myFunc.dVk_dk(k,Basis.get_rc()) - Basis.dfk_dk(k,coefs);
267  return dFk_dk;
268  }
EwaldHandler3D::mRealType mRealType
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
std::vector< mRealType > gstraincoefs
Coefficient for strain fit.
Definition: LRHandlerBase.h:57

◆ evaluate()

mRealType evaluate ( mRealType  r,
mRealType  rinv 
) const
inlineoverridevirtual

Implements LRHandlerBase.

Definition at line 114 of file LRHandlerSRCoulomb.h.

References LRHandlerSRCoulomb< Func, BreakupBasis >::Basis, and LRHandlerBase::gcoefs.

Referenced by LRHandlerSRCoulomb< Func, BreakupBasis >::evaluateLR(), and qmcplusplus::TEST_CASE().

115  {
116  //Right now LRHandlerSRCoulomb is the force only handler. This is why the gcoefs are used for evaluate.
117  mRealType v = Basis.f(r, gcoefs);
118  return v;
119  }
EwaldHandler3D::mRealType mRealType
std::vector< mRealType > gcoefs
Coefficient for gradient fit.
Definition: LRHandlerBase.h:55

◆ evaluate_vlr_k()

mRealType evaluate_vlr_k ( mRealType  k) const
inlineoverridevirtual

Implements LRHandlerBase.

Definition at line 121 of file LRHandlerSRCoulomb.h.

References LRHandlerSRCoulomb< Func, BreakupBasis >::evalYk().

121 { return evalYk(k); }
mRealType evalYk(mRealType k) const

◆ evaluateLR()

mRealType evaluateLR ( mRealType  r) const
inlineoverridevirtual

evaluate the contribution from the long-range part for for spline

Implements LRHandlerBase.

Definition at line 148 of file LRHandlerSRCoulomb.h.

References LRHandlerSRCoulomb< Func, BreakupBasis >::evaluate(), and LRHandlerSRCoulomb< Func, BreakupBasis >::myFunc.

Referenced by qmcplusplus::TEST_CASE().

149  {
150  mRealType v = 0.0;
151  v = myFunc(r, 1.0 / r) - evaluate(r, 1.0 / r);
152  return v;
153  }
EwaldHandler3D::mRealType mRealType
mRealType evaluate(mRealType r, mRealType rinv) const override

◆ evaluateLR_dstrain()

SymTensor<mRealType, OHMMS_DIM> evaluateLR_dstrain ( TinyVector< pRealType, OHMMS_DIM k,
pRealType  kmag 
) const
inlineoverridevirtual

Reimplemented from LRHandlerBase.

Definition at line 173 of file LRHandlerSRCoulomb.h.

References APP_ABORT, LRHandlerSRCoulomb< Func, BreakupBasis >::evaldYkgstrain(), LRHandlerSRCoulomb< Func, BreakupBasis >::evalYkgstrain(), and OHMMS_DIM.

Referenced by LRHandlerSRCoulomb< Func, BreakupBasis >::filldFk_dk().

175  {
176  APP_ABORT("Stresses not supported yet\n");
177  SymTensor<mRealType, OHMMS_DIM> deriv_tensor = 0;
178  for (int dim1 = 0; dim1 < OHMMS_DIM; dim1++)
179  for (int dim2 = dim1; dim2 < OHMMS_DIM; dim2++)
180  {
181  deriv_tensor(dim1, dim2) =
182  -evaldYkgstrain(kmag) * k[dim1] * k[dim2] / kmag; //- evaldFk_dk(kmag)*k[dim1]*k[dim2]/kmag ;
183  if (dim1 == dim2)
184  deriv_tensor(dim1, dim2) -= evalYkgstrain(kmag); //+ derivconst;
185  }
186  return deriv_tensor;
187  }
#define OHMMS_DIM
Definition: config.h:64
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
mRealType evaldYkgstrain(mRealType k) const
mRealType evalYkgstrain(mRealType k) const

◆ evaluateLR_r0()

mRealType evaluateLR_r0 ( ) const
inlineoverridevirtual

evaluate $ v_s(r=0) $ for the self-interaction term

Reimplemented from LRHandlerBase.

Definition at line 164 of file LRHandlerSRCoulomb.h.

165  {
166  //this is because the constraint v(r)=sigma(r) as r-->0.
167  // so v(r)-sigma(r)="0". Divergence prevents me from coding this.
168  mRealType v0 = 0.0;
169  return v0;
170  }
EwaldHandler3D::mRealType mRealType

◆ evaluateLR_r0_dstrain() [1/2]

mRealType evaluateLR_r0_dstrain ( int  i,
int  j 
) const
inline

Definition at line 223 of file LRHandlerSRCoulomb.h.

References APP_ABORT.

224  {
225  APP_ABORT("Stresses not supported yet\n");
226  //the t derivative for the relevant basis elements are all zero because of constraints.
227  return 0.0; //Basis.f(0,dcoefs(i,j));
228  }
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ evaluateLR_r0_dstrain() [2/2]

SymTensor<mRealType, OHMMS_DIM> evaluateLR_r0_dstrain ( ) const
inlineoverridevirtual

These functions return the strain derivatives of all corresponding quantities in total energy.

See documentation (forthcoming).

Reimplemented from LRHandlerBase.

Definition at line 230 of file LRHandlerSRCoulomb.h.

References APP_ABORT.

231  {
232  APP_ABORT("Stresses not supported yet\n");
233  SymTensor<mRealType, OHMMS_DIM> stress;
234  return stress;
235  }
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ evaluateSR_dstrain()

SymTensor<mRealType, OHMMS_DIM> evaluateSR_dstrain ( TinyVector< pRealType, OHMMS_DIM r,
pRealType  rmag 
) const
inlineoverridevirtual

Reimplemented from LRHandlerBase.

Definition at line 190 of file LRHandlerSRCoulomb.h.

References APP_ABORT, OHMMS_DIM, and LRHandlerSRCoulomb< Func, BreakupBasis >::srDf_strain().

192  {
193  APP_ABORT("Stresses not supported yet\n");
194  SymTensor<mRealType, OHMMS_DIM> deriv_tensor = 0;
195 
196  mRealType Sr_r = srDf_strain(rmag, 1.0 / mRealType(rmag)) / mRealType(rmag);
197 
198  for (int dim1 = 0; dim1 < OHMMS_DIM; dim1++)
199  {
200  for (int dim2 = dim1; dim2 < OHMMS_DIM; dim2++)
201  deriv_tensor(dim1, dim2) = r[dim1] * r[dim2] * Sr_r;
202  }
203  return deriv_tensor;
204  }
EwaldHandler3D::mRealType mRealType
#define OHMMS_DIM
Definition: config.h:64
mRealType srDf_strain(mRealType r, mRealType rinv) const
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ evaluateSR_k0()

mRealType evaluateSR_k0 ( ) const
inlineoverridevirtual

evaluate $ v_{s}(k=0) = \frac{4\pi}{V}\int_0^{r_c} r^2 v_s(r) dr $

Reimplemented from LRHandlerBase.

Definition at line 155 of file LRHandlerSRCoulomb.h.

References LRHandlerSRCoulomb< Func, BreakupBasis >::Basis, LRHandlerBase::coefs, and qmcplusplus::n.

156  {
157  mRealType v0 = 0.0;
158  for (int n = 0; n < coefs.size(); n++)
159  v0 += coefs[n] * Basis.hintr2(n);
160  return v0 * 2.0 * TWOPI / Basis.get_CellVolume();
161  }
EwaldHandler3D::mRealType mRealType
std::vector< mRealType > coefs
Fourier component for each k-shell Coefficient.
Definition: LRHandlerBase.h:53

◆ evaluateSR_k0_dstrain()

SymTensor<mRealType, OHMMS_DIM> evaluateSR_k0_dstrain ( ) const
inlineoverridevirtual

Reimplemented from LRHandlerBase.

Definition at line 206 of file LRHandlerSRCoulomb.h.

References APP_ABORT, LRHandlerSRCoulomb< Func, BreakupBasis >::Basis, LRHandlerBase::coefs, LRHandlerBase::gstraincoefs, qmcplusplus::n, norm(), and OHMMS_DIM.

207  {
208  APP_ABORT("Stresses not supported yet\n");
209  mRealType v0 = 0.0;
210  mRealType norm = 2.0 * TWOPI / Basis.get_CellVolume();
211 
212  for (int n = 0; n < coefs.size(); n++)
213  v0 += gstraincoefs[n] * Basis.hintr2(n);
214 
215  v0 *= -norm;
216  SymTensor<mRealType, OHMMS_DIM> stress;
217  for (int i = 0; i < OHMMS_DIM; i++)
218  stress(i, i) = v0;
219 
220  return stress;
221  }
EwaldHandler3D::mRealType mRealType
std::vector< mRealType > coefs
Fourier component for each k-shell Coefficient.
Definition: LRHandlerBase.h:53
#define OHMMS_DIM
Definition: config.h:64
double norm(const zVec &c)
Definition: VectorOps.h:118
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
std::vector< mRealType > gstraincoefs
Coefficient for strain fit.
Definition: LRHandlerBase.h:57

◆ evalYk()

mRealType evalYk ( mRealType  k) const
inlineprivate

Definition at line 238 of file LRHandlerSRCoulomb.h.

References LRHandlerSRCoulomb< Func, BreakupBasis >::Basis, LRHandlerBase::coefs, and LRHandlerSRCoulomb< Func, BreakupBasis >::myFunc.

Referenced by LRHandlerSRCoulomb< Func, BreakupBasis >::evaluate_vlr_k(), and LRHandlerSRCoulomb< Func, BreakupBasis >::fillYk().

239  {
240  //FatK = 4.0*M_PI/(Basis.get_CellVolume()*k*k)* std::cos(k*Basis.get_rc());
241  mRealType FatK = myFunc.Vk(k) - Basis.fk(k, coefs);
242  // for(int n=0; n<Basis.NumBasisElem(); n++)
243  // FatK -= coefs[n]*Basis.c(n,k);
244  return FatK;
245  }
EwaldHandler3D::mRealType mRealType
std::vector< mRealType > coefs
Fourier component for each k-shell Coefficient.
Definition: LRHandlerBase.h:53

◆ evalYkg()

mRealType evalYkg ( mRealType  k) const
inlineprivate

Definition at line 246 of file LRHandlerSRCoulomb.h.

References LRHandlerSRCoulomb< Func, BreakupBasis >::Basis, LRHandlerBase::gcoefs, and LRHandlerSRCoulomb< Func, BreakupBasis >::myFunc.

Referenced by LRHandlerSRCoulomb< Func, BreakupBasis >::fillYkg().

247  {
248  mRealType FatK = myFunc.Vk(k) - Basis.fk(k, gcoefs);
249  //for(int n=0; n<Basis.NumBasisElem(); n++)
250  // FatK -= gcoefs[n]*Basis.c(n,k);
251  return FatK;
252  }
EwaldHandler3D::mRealType mRealType
std::vector< mRealType > gcoefs
Coefficient for gradient fit.
Definition: LRHandlerBase.h:55

◆ evalYkgstrain()

mRealType evalYkgstrain ( mRealType  k) const
inlineprivate

Definition at line 253 of file LRHandlerSRCoulomb.h.

References APP_ABORT, LRHandlerSRCoulomb< Func, BreakupBasis >::Basis, LRHandlerBase::gstraincoefs, and LRHandlerSRCoulomb< Func, BreakupBasis >::myFunc.

Referenced by LRHandlerSRCoulomb< Func, BreakupBasis >::evaluateLR_dstrain(), and LRHandlerSRCoulomb< Func, BreakupBasis >::fillYkgstrain().

254  {
255  APP_ABORT("Stresses not supported yet\n");
256  mRealType FatK = myFunc.Vk(k) - Basis.fk(k, gstraincoefs);
257  //for(int n=0; n<Basis.NumBasisElem(); n++)
258  // FatK -= gcoefs[n]*Basis.c(n,k);
259  return FatK;
260  }
EwaldHandler3D::mRealType mRealType
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
std::vector< mRealType > gstraincoefs
Coefficient for strain fit.
Definition: LRHandlerBase.h:57

◆ filldFk_dk()

void filldFk_dk ( KContainer KList)
inlineprivate

Definition at line 458 of file LRHandlerSRCoulomb.h.

References APP_ABORT, LRHandlerBase::dFk_dstrain, LRHandlerSRCoulomb< Func, BreakupBasis >::evaluateLR_dstrain(), KContainer::kpts_cart, KContainer::ksq, and qmcplusplus::sqrt().

459  {
460  APP_ABORT("Stresses not supported yet\n");
461  dFk_dstrain.resize(KList.kpts_cart.size());
462 
463  for (int ki = 0; ki < dFk_dstrain.size(); ki++)
464  dFk_dstrain[ki] = evaluateLR_dstrain(KList.kpts_cart[ki], std::sqrt(KList.ksq[ki]));
465  }
std::vector< SymTensor< mRealType, OHMMS_DIM > > dFk_dstrain
Fourier component of the LR part of strain tensor, by optimized breakup.
Definition: LRHandlerBase.h:45
SymTensor< mRealType, OHMMS_DIM > evaluateLR_dstrain(TinyVector< pRealType, OHMMS_DIM > k, pRealType kmag) const override
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)

◆ fillVk()

void fillVk ( std::vector< TinyVector< mRealType, 2 >> &  KList)
inlineprivate

Definition at line 384 of file LRHandlerSRCoulomb.h.

References LRHandlerBase::Fk, LRHandlerBase::Fkg, LRHandlerSRCoulomb< Func, BreakupBasis >::myFunc, and Vector< T, Alloc >::resize().

Referenced by LRHandlerSRCoulomb< Func, BreakupBasis >::InitBreakup().

385  {
386  Fk.resize(KList.size());
387  Fkg.resize(KList.size());
388  // Fkgstrain.resize(KList.size());
389  // Fk_copy.resize(KList.size());
390  for (int ki = 0; ki < KList.size(); ki++)
391  {
392  mRealType k = KList[ki][0];
393  // Fk[ki] = myFunc.Vk(k); //Call derived fn.
394  Fkg[ki] = myFunc.Vk(k);
395  // Fkgstrain[ki] = myFunc.dVk_dk(k);
396  // Fk_copy[ki]=myFunc.Vk(k);
397  }
398  }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
EwaldHandler3D::mRealType mRealType
Vector< mRealType > Fkg
Fourier component of the LR part, fit to optimize the gradients.
Definition: LRHandlerBase.h:43
Vector< mRealType > Fk
Fourier component for all the k-point.
Definition: LRHandlerBase.h:41

◆ fillYk()

void fillYk ( KContainer KList)
inlineprivate

Definition at line 400 of file LRHandlerSRCoulomb.h.

References LRHandlerSRCoulomb< Func, BreakupBasis >::evalYk(), LRHandlerBase::Fk, LRHandlerBase::Fk_symm, KContainer::kpts_cart, KContainer::kshell, KContainer::ksq, LRHandlerBase::MaxKshell, Vector< T, Alloc >::resize(), Vector< T, Alloc >::size(), and qmcplusplus::sqrt().

401  {
402  Fk.resize(KList.kpts_cart.size());
403  const std::vector<int>& kshell(KList.kshell);
404  if (MaxKshell >= kshell.size())
405  MaxKshell = kshell.size() - 1;
407  for (int ks = 0, ki = 0; ks < Fk_symm.size(); ks++)
408  {
409  mRealType uk = evalYk(std::sqrt(KList.ksq[ki]));
410  Fk_symm[ks] = uk;
411  while (ki < KList.kshell[ks + 1] && ki < Fk.size())
412  Fk[ki++] = uk;
413  }
414  //for(int ki=0; ki<KList.kpts_cart.size(); ki++){
415  // mRealType k=dot(KList.kpts_cart[ki],KList.kpts_cart[ki]);
416  // k=std::sqrt(k);
417  // Fk[ki] = evalFk(k); //Call derived fn.
418  //}
419  }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
DECLARE_COULOMB_TYPES int MaxKshell
Maxkimum Kshell for the given Kc.
Definition: LRHandlerBase.h:35
EwaldHandler3D::mRealType mRealType
mRealType evalYk(mRealType k) const
size_type size() const
return the current size
Definition: OhmmsVector.h:162
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)
Vector< mRealType > Fk_symm
Fourier component for each k-shell.
Definition: LRHandlerBase.h:49

◆ fillYkg()

void fillYkg ( const KContainer KList)
inlineprivate

Definition at line 420 of file LRHandlerSRCoulomb.h.

References LRHandlerSRCoulomb< Func, BreakupBasis >::evalYkg(), LRHandlerBase::Fk, LRHandlerBase::Fkg, KContainer::kpts_cart, KContainer::kshell, KContainer::ksq, LRHandlerBase::MaxKshell, Vector< T, Alloc >::resize(), Vector< T, Alloc >::size(), and qmcplusplus::sqrt().

Referenced by LRHandlerSRCoulomb< Func, BreakupBasis >::Breakup(), and LRHandlerSRCoulomb< Func, BreakupBasis >::initBreakup().

421  {
422  Fkg.resize(KList.kpts_cart.size());
423  //LRHandlerSRCoulomb is the force handler now. Only want
424  //Fourier coefficients optimized for forces being used period.
425 
426  Fk.resize(KList.kpts_cart.size());
427  const std::vector<int>& kshell(KList.kshell);
428  if (MaxKshell >= kshell.size())
429  MaxKshell = kshell.size() - 1;
430 
431  for (int ks = 0, ki = 0; ks < MaxKshell; ks++)
432  {
433  mRealType uk = evalYkg(std::sqrt(KList.ksq[ki]));
434 
435  while (ki < KList.kshell[ks + 1] && ki < Fkg.size())
436  Fkg[ki++] = uk;
437  }
438  //Have to set this, because evaluate and evaluateGrad for LR piece uses
439  //diferent fourier components. Only want to use the ones optimized for
440  //forces.
441  Fk = Fkg;
442  }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
DECLARE_COULOMB_TYPES int MaxKshell
Maxkimum Kshell for the given Kc.
Definition: LRHandlerBase.h:35
EwaldHandler3D::mRealType mRealType
size_type size() const
return the current size
Definition: OhmmsVector.h:162
Vector< mRealType > Fkg
Fourier component of the LR part, fit to optimize the gradients.
Definition: LRHandlerBase.h:43
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)
mRealType evalYkg(mRealType k) const

◆ fillYkgstrain()

void fillYkgstrain ( KContainer KList)
inlineprivate

Definition at line 444 of file LRHandlerSRCoulomb.h.

References APP_ABORT, LRHandlerSRCoulomb< Func, BreakupBasis >::evalYkgstrain(), LRHandlerBase::Fkgstrain, KContainer::kpts_cart, KContainer::kshell, KContainer::ksq, LRHandlerBase::MaxKshell, Vector< T, Alloc >::resize(), Vector< T, Alloc >::size(), and qmcplusplus::sqrt().

445  {
446  APP_ABORT("Stresses not supported yet\n");
447  Fkgstrain.resize(KList.kpts_cart.size());
448  const std::vector<int>& kshell(KList.kshell);
449  if (MaxKshell >= kshell.size())
450  MaxKshell = kshell.size() - 1;
451  for (int ks = 0, ki = 0; ks < MaxKshell; ks++)
452  {
453  mRealType uk = evalYkgstrain(std::sqrt(KList.ksq[ki]));
454  while (ki < KList.kshell[ks + 1] && ki < Fkgstrain.size())
455  Fkgstrain[ki++] = uk;
456  }
457  }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
DECLARE_COULOMB_TYPES int MaxKshell
Maxkimum Kshell for the given Kc.
Definition: LRHandlerBase.h:35
EwaldHandler3D::mRealType mRealType
Vector< mRealType > Fkgstrain
Vector of df_k/dk, fit as to optimize strains.
Definition: LRHandlerBase.h:47
size_type size() const
return the current size
Definition: OhmmsVector.h:162
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
mRealType evalYkgstrain(mRealType k) const

◆ initBreakup()

void initBreakup ( ParticleSet ref)
inlineoverridevirtual

Implements LRHandlerBase.

Definition at line 88 of file LRHandlerSRCoulomb.h.

References LRHandlerSRCoulomb< Func, BreakupBasis >::Basis, LRHandlerSRCoulomb< Func, BreakupBasis >::fillYkg(), ParticleSet::getLRBox(), ParticleSet::getSimulationCell(), LRHandlerSRCoulomb< Func, BreakupBasis >::InitBreakup(), and LRHandlerBase::LR_rc.

Referenced by qmcplusplus::TEST_CASE().

89  {
90  InitBreakup(ref.getLRBox(), 1);
91  // fillYk(ref.getSimulationCell().getKLists());
92  fillYkg(ref.getSimulationCell().getKLists());
93  //This is expensive to calculate. Deprecating stresses for now.
94  //filldFk_dk(ref.getSimulationCell().getKLists());
95  LR_rc = Basis.get_rc();
96  }
mRealType LR_rc
Maximum r cutoff.
Definition: LRHandlerBase.h:39
void InitBreakup(const ParticleLayout &ref, int NumFunctions)
Initialise the basis and coefficients for the long-range beakup.
void fillYkg(const KContainer &KList)

◆ InitBreakup()

void InitBreakup ( const ParticleLayout ref,
int  NumFunctions 
)
inlineprivate

Initialise the basis and coefficients for the long-range beakup.

We loocally create a breakup handler and pass in the basis that has been initialised here. We then discard the handler, leaving basis and coefs in a usable state. This method can be re-called later if lattice changes shape.

This is to make sure there's no cusp in the LR part.

Definition at line 277 of file LRHandlerSRCoulomb.h.

References qmcplusplus::app_log(), LRHandlerSRCoulomb< Func, BreakupBasis >::Basis, Vector< T, Alloc >::data(), LRBreakup< BreakupBasis >::DoGradBreakup(), LRHandlerSRCoulomb< Func, BreakupBasis >::fillVk(), LRHandlerSRCoulomb< Func, BreakupBasis >::FirstTime, LRHandlerBase::Fkg, LRHandlerBase::gcoefs, LRBreakup< BreakupBasis >::KList, LRHandlerBase::LR_kc, LRHandlerBase::MaxKshell, qmcplusplus::pow(), Vector< T, Alloc >::resize(), and LRBreakup< BreakupBasis >::SetupKVecs().

Referenced by LRHandlerSRCoulomb< Func, BreakupBasis >::Breakup(), and LRHandlerSRCoulomb< Func, BreakupBasis >::initBreakup().

278  {
279  //First we send the new Lattice to the Basis, in case it has been updated.
280  Basis.set_Lattice(ref);
281  //Compute RC from box-size - in constructor?
282  //No here...need update if box changes
283  int NumKnots(17);
284  Basis.set_NumKnots(NumKnots);
285  Basis.set_rc(ref.LR_rc);
286  //Initialise the breakup - pass in basis.
287  LRBreakup<BreakupBasis> breakuphandler(Basis);
288  //Find size of basis from cutoffs
289  mRealType kc = (LR_kc < 0) ? ref.LR_kc : LR_kc;
290  LR_kc = kc; // set internal kc
291  //mRealType kc(ref.LR_kc); //User cutoff parameter...
292  //kcut is the cutoff for switching to approximate k-point degeneracies for
293  //better performance in making the breakup. A good bet is 30*K-spacing so that
294  //there are 30 "boxes" in each direction that are treated with exact degeneracies.
295  //Assume orthorhombic cell just for deriving this cutoff - should be insensitive.
296  //K-Spacing = (kpt_vol)**1/3 = 2*pi/(cellvol**1/3)
297  mRealType kcut = 60 * M_PI * std::pow(Basis.get_CellVolume(), -1.0 / 3.0);
298  //Use 3000/LMax here...==6000/rc for non-ortho cells
299  mRealType kmax(6000.0 / ref.LR_rc);
300  MaxKshell = static_cast<int>(breakuphandler.SetupKVecs(kc, kcut, kmax));
301  if (FirstTime)
302  {
303  app_log() << "\nPerforming Optimized Breakup with Short Range Coulomb Basis\n";
304  app_log() << " finding kc: " << ref.LR_kc << " , " << LR_kc << std::endl;
305  app_log() << " LRBreakp parameter Kc =" << kc << std::endl;
306  app_log() << " Continuum approximation in k = [" << kcut << "," << kmax << ")" << std::endl;
307  FirstTime = false;
308  }
309  //Set up x_k
310  //This is the FT of -V(r) from r_c to infinity.
311  //This is the only data that the breakup handler needs to do the breakup.
312  //We temporarily store it in Fk, which is replaced with the full FT (0->inf)
313  //of V_l(r) after the breakup has been done.
314  fillVk(breakuphandler.KList);
315  //Allocate the space for the coefficients.
316  int Nbasis = Basis.NumBasisElem();
317  // coefs.resize(Nbasis); //This must be after SetupKVecs.
318  gcoefs.resize(Nbasis);
319  // gstraincoefs.resize(Nbasis);
320 
321  //Going to implement a smooth real space cutoff. This means that alpha=0,1,2 for the LPQHI basis at knot r_c
322  //all equal the 0, 1st, and 2nd derivatives of our bare function.
323  //These three functions are the last three basis elements in our set.
324 
325 
326  Vector<mRealType> constraints;
327 
328  constraints.resize(Nbasis);
329  for (int i = 0; i < Nbasis; i++)
330  constraints[i] = 1;
331 
332 
333  ///This is to make sure there's no cusp in the LR part.
334  // gstraincoefs[0]=gcoefs[0]=coefs[0] = 1.0;
335  gcoefs[0] = 1.0;
336  constraints[0] = 0;
337 
338  //gstraincoefs[1]=gcoefs[1] = coefs[1] = 0.0;
339  gcoefs[1] = 0.0;
340  constraints[1] = 0;
341 
342  //gstraincoefs[2]=gcoefs[2] = coefs[2] = 0.0;
343  gcoefs[2] = 0.0;
344  constraints[2] = 0.0;
345 
346  //Boundary conditions at r=rc
347  //
348  //2nd derivative continuity.
349  //gstraincoefs[Nbasis-1]= gcoefs[Nbasis-1]=coefs[Nbasis-1]=0.0;
350  gcoefs[Nbasis - 1] = 0.0;
351  constraints[Nbasis - 1] = 0;
352 
353  //1st derivative continuity
354 
355  //gstraincoefs[Nbasis-2]=gcoefs[Nbasis-2]=coefs[Nbasis-2]=0.0;
356  gcoefs[Nbasis - 2] = 0.0;
357  constraints[Nbasis - 2] = 0;
358 
359  //Function value continuity
360  //gstraincoefs[Nbasis-3]=gcoefs[Nbasis-3]=coefs[Nbasis-3]=0.0;
361  gcoefs[Nbasis - 3] = 0.0;
362  constraints[Nbasis - 3] = 0;
363  //And now to impose the constraints
364 
365 
366  Vector<mRealType> chisqr(3);
367  // breakuphandler.DoAllBreakup(chisqr.data(), Fk.data(), Fkgstrain.data(), coefs.data(), gcoefs.data(), gstraincoefs.data(), constraints.data());
368  mRealType chisqr_force = 0;
369  chisqr_force = breakuphandler.DoGradBreakup(Fkg.data(), gcoefs.data(), constraints.data());
370  //I want this in scientific notation, but I don't want to mess up formatting flags elsewhere.
371  //Save stream state.
372  std::ios_base::fmtflags app_log_flags(app_log().flags());
373  app_log() << std::scientific;
374  app_log().precision(5);
375 
376  // app_log()<<" LR function chi^2 = "<<chisqr[0]<< std::endl;
377  app_log() << " LR grad function chi^2 = " << chisqr_force << std::endl;
378  // app_log()<<" LR strain function chi^2 = "<<chisqr[2]<< std::endl;
379 
380  app_log().flags(app_log_flags);
381  }
void fillVk(std::vector< TinyVector< mRealType, 2 >> &KList)
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
MakeReturn< BinaryNode< FnPow, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t, typename CreateLeaf< Vector< T2, C2 > >::Leaf_t > >::Expression_t pow(const Vector< T1, C1 > &l, const Vector< T2, C2 > &r)
Vector< mRealType > Fkg
Fourier component of the LR part, fit to optimize the gradients.
Definition: LRHandlerBase.h:43
std::vector< mRealType > gcoefs
Coefficient for gradient fit.
Definition: LRHandlerBase.h:55

◆ lrDf()

mRealType lrDf ( mRealType  r) const
inlineoverridevirtual

Reimplemented from LRHandlerBase.

Definition at line 141 of file LRHandlerSRCoulomb.h.

References LRHandlerSRCoulomb< Func, BreakupBasis >::myFunc, and LRHandlerSRCoulomb< Func, BreakupBasis >::srDf().

Referenced by qmcplusplus::TEST_CASE().

142  {
143  mRealType lr = myFunc.df(r) - srDf(r, 1.0 / r);
144  return lr;
145  }
EwaldHandler3D::mRealType mRealType
mRealType srDf(mRealType r, mRealType rinv) const override
evaluate the first derivative of the short range part at r

◆ makeClone()

LRHandlerBase* makeClone ( ParticleSet ref) const
inlineoverridevirtual

make clone

Implements LRHandlerBase.

Definition at line 81 of file LRHandlerSRCoulomb.h.

82  {
83  LRHandlerSRCoulomb* tmp = new LRHandlerSRCoulomb<Func, BreakupBasis>(*this, ref);
84  // tmp->makeSplines(1001);
85  return tmp;
86  }
LRHandlerSRCoulomb(ParticleSet &ref, mRealType kc_in=-1.0)

◆ resetTargetParticleSet() [1/2]

void resetTargetParticleSet ( ParticleSet ref)
inlineoverridevirtual

Implements LRHandlerBase.

Definition at line 110 of file LRHandlerSRCoulomb.h.

References LRHandlerSRCoulomb< Func, BreakupBasis >::myFunc.

110 { myFunc.reset(ref); }

◆ resetTargetParticleSet() [2/2]

void resetTargetParticleSet ( ParticleSet ref,
mRealType  rs 
)
inline

◆ srDf()

mRealType srDf ( mRealType  r,
mRealType  rinv 
) const
inlineoverridevirtual

evaluate the first derivative of the short range part at r

Parameters
rradius
rinv1/r

Implements LRHandlerBase.

Definition at line 128 of file LRHandlerSRCoulomb.h.

References LRHandlerSRCoulomb< Func, BreakupBasis >::Basis, and LRHandlerBase::gcoefs.

Referenced by LRHandlerSRCoulomb< Func, BreakupBasis >::lrDf(), and qmcplusplus::TEST_CASE().

129  {
130  mRealType df = Basis.df_dr(r, gcoefs);
131  return df;
132  }
EwaldHandler3D::mRealType mRealType
std::vector< mRealType > gcoefs
Coefficient for gradient fit.
Definition: LRHandlerBase.h:55

◆ srDf_strain()

mRealType srDf_strain ( mRealType  r,
mRealType  rinv 
) const
inline

Definition at line 134 of file LRHandlerSRCoulomb.h.

References APP_ABORT, LRHandlerSRCoulomb< Func, BreakupBasis >::Basis, and LRHandlerBase::gstraincoefs.

Referenced by LRHandlerSRCoulomb< Func, BreakupBasis >::evaluateSR_dstrain().

135  {
136  APP_ABORT("Stresses not supported yet\n");
137  mRealType df = Basis.df_dr(r, gstraincoefs);
138  return df;
139  }
EwaldHandler3D::mRealType mRealType
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
std::vector< mRealType > gstraincoefs
Coefficient for strain fit.
Definition: LRHandlerBase.h:57

Member Data Documentation

◆ Basis

◆ FirstTime

bool FirstTime

◆ Fk_copy

std::vector<mRealType> Fk_copy

Definition at line 56 of file LRHandlerSRCoulomb.h.

◆ myFunc

◆ rs


The documentation for this class was generated from the following file: