Skip to content

Commit b08b191

Browse files
authored
Merge pull request #2329 from camelto2/qmcFScorr
adding qmcfinitesize tool
2 parents 472cc3d + 2113d4c commit b08b191

29 files changed

Lines changed: 10511 additions & 40 deletions

src/.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ CheckOptions: [ { key: readability-identifier-naming.NamespaceCase, value: lower
77
{ key: readability-identifier-naming.VariableCase, value: lower_case },
88
{ key: readability-identifier-naming.ClassMethodCase, value: camelBack },
99
{ key: readability-identifier-naming.PrivateMemberPostfix, value: _ }]
10+

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ else() #{{{
320320
SUBDIRS(OpenMP/tests)
321321
SUBDIRS(Optimize/tests)
322322
SUBDIRS(MinimalContainers/tests)
323+
SUBDIRS(QMCTools/tests)
323324
endif() #}
324325

325326
endif() #}}}

src/LongRange/EwaldHandler.cpp

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// This file is distributed under the University of Illinois/NCSA Open Source License.
33
// See LICENSE file in top directory for details.
44
//
5-
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
5+
// Copyright (c) 2020 QMCPACK developers.
66
//
77
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
88
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
@@ -78,8 +78,8 @@ void EwaldHandler::fillFk(KContainer& KList)
7878
else
7979
{
8080
#if OHMMS_DIM == 2
81-
mRealType kgauss = 1.0 / (4 * Sigma * Sigma);
82-
mRealType knorm = 2 * M_PI / Volume;
81+
mRealType kgauss = 1.0 / (4 * Sigma * Sigma);
82+
mRealType knorm = 2 * M_PI / Volume;
8383
for (int ks = 0, ki = 0; ks < Fk_symm.size(); ks++)
8484
{
8585
mRealType t2e = KList.ksq[ki] * kgauss;
@@ -90,8 +90,8 @@ void EwaldHandler::fillFk(KContainer& KList)
9090
}
9191
PreFactors[3] = 0.0;
9292
#elif OHMMS_DIM == 3
93-
mRealType kgauss = 1.0 / (4 * Sigma * Sigma);
94-
mRealType knorm = 4 * M_PI / Volume;
93+
mRealType kgauss = 1.0 / (4 * Sigma * Sigma);
94+
mRealType knorm = 4 * M_PI / Volume;
9595
for (int ks = 0, ki = 0; ks < Fk_symm.size(); ks++)
9696
{
9797
mRealType t2e = KList.ksq[ki] * kgauss;
@@ -100,27 +100,51 @@ void EwaldHandler::fillFk(KContainer& KList)
100100
while (ki < KList.kshell[ks + 1] && ki < Fk.size())
101101
Fk[ki++] = uk;
102102
}
103-
PreFactors[3] = 0.0;
103+
PreFactors[3] = 0.0;
104104
#endif
105105
}
106106
app_log().flush();
107107
}
108108

109-
EwaldHandler::mRealType EwaldHandler::evaluate_slab(mRealType z,
110-
const std::vector<int>& kshell,
111-
const pComplexType* restrict eikr_i,
112-
const pComplexType* restrict eikr_j)
109+
EwaldHandler::mRealType EwaldHandler::evaluate_vlr_k(mRealType k)
113110
{
114-
mRealType zp = z * Sigma;
115-
mRealType vk = -SlabFunc0(z, zp);
116-
//cout << "### SLAB " << z << " " << zp << std::endl;
117-
for (int ks = 0, ki = 0; ks < MaxKshell; ks++)
111+
mRealType uk = 0.0;
112+
if (SuperCellEnum == SUPERCELL_SLAB)
118113
{
119-
mRealType u = 0; //\sum Real (e^ikr_i e^(-ikr_j))
120-
for (; ki < kshell[ks + 1]; ki++, eikr_i++, eikr_j++)
121-
u += ((*eikr_i).real() * (*eikr_j).real() + (*eikr_i).imag() * (*eikr_j).imag());
122-
vk += u * Fk_symm[ks] * SlabFuncK(ks, z, zp);
114+
mRealType knorm = M_PI / Area;
115+
uk = knorm / k; //pi/(A*k)
116+
}
117+
else
118+
{
119+
#if OHMMS_DIM == 2
120+
mRealType kgauss = 1.0 / (4 * Sigma * Sigma);
121+
mRealType knorm = 2 * M_PI / Volume;
122+
mRealType k2 = k * k;
123+
uk = knorm * std::exp(-k2 * kgauss) / k2;
124+
#elif OHMMS_DIM == 3
125+
mRealType kgauss = 1.0 / (4 * Sigma * Sigma);
126+
mRealType knorm = 4 * M_PI / Volume;
127+
mRealType k2 = k * k;
128+
uk = knorm * std::exp(-k2 * kgauss) / k2;
129+
}
130+
#endif
131+
return uk;
132+
}
133+
134+
EwaldHandler::mRealType EwaldHandler::evaluate_slab(mRealType z, const std::vector<int>& kshell,
135+
const pComplexType* restrict eikr_i,
136+
const pComplexType* restrict eikr_j)
137+
{
138+
mRealType zp = z * Sigma;
139+
mRealType vk = -SlabFunc0(z, zp);
140+
//cout << "### SLAB " << z << " " << zp << std::endl;
141+
for (int ks = 0, ki = 0; ks < MaxKshell; ks++)
142+
{
143+
mRealType u = 0; //\sum Real (e^ikr_i e^(-ikr_j))
144+
for (; ki < kshell[ks + 1]; ki++, eikr_i++, eikr_j++)
145+
u += ((*eikr_i).real() * (*eikr_j).real() + (*eikr_i).imag() * (*eikr_j).imag());
146+
vk += u * Fk_symm[ks] * SlabFuncK(ks, z, zp);
147+
}
148+
return vk;
123149
}
124-
return vk;
125-
}
126150
} // namespace qmcplusplus

src/LongRange/EwaldHandler.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// This file is distributed under the University of Illinois/NCSA Open Source License.
33
// See LICENSE file in top directory for details.
44
//
5-
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
5+
// Copyright (c) 2020 QMCPACK developers.
66
//
77
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
88
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
@@ -93,6 +93,8 @@ class EwaldHandler : public LRHandlerBase
9393
*/
9494
inline mRealType srDf(mRealType r, mRealType rinv) { return 0.0; }
9595

96+
inline mRealType evaluate_vlr_k(mRealType k) override;
97+
9698
void fillFk(KContainer& KList);
9799

98100
/** evaluate k-dependent

src/LongRange/EwaldHandler3D.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// This file is distributed under the University of Illinois/NCSA Open Source License.
33
// See LICENSE file in top directory for details.
44
//
5-
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
5+
// Copyright (c) 2020 QMCPACK developers.
66
//
77
// File developed by: Raymond Clay III, j.k.rofling@gmail.com, Lawrence Livermore National Laboratory
88
//
@@ -61,8 +61,8 @@ void EwaldHandler3D::fillFk(KContainer& KList)
6161

6262
Fk_symm.resize(MaxKshell);
6363
kMag.resize(MaxKshell);
64-
mRealType kgauss = 1.0 / (4 * Sigma * Sigma);
65-
mRealType knorm = 4 * M_PI / Volume;
64+
mRealType kgauss = 1.0 / (4 * Sigma * Sigma);
65+
mRealType knorm = 4 * M_PI / Volume;
6666
for (int ks = 0, ki = 0; ks < Fk_symm.size(); ks++)
6767
{
6868
mRealType t2e = KList.ksq[ki] * kgauss;
@@ -78,4 +78,13 @@ void EwaldHandler3D::fillFk(KContainer& KList)
7878
PreFactors[3] = 0.0;
7979
app_log().flush();
8080
}
81+
82+
EwaldHandler3D::mRealType EwaldHandler3D::evaluate_vlr_k(mRealType k)
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+
8190
} // namespace qmcplusplus

src/LongRange/EwaldHandler3D.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// This file is distributed under the University of Illinois/NCSA Open Source License.
33
// See LICENSE file in top directory for details.
44
//
5-
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
5+
// Copyright (c) 2020 QMCPACK developers.
66
//
77
// File developed by: Raymond Clay III, j.k.rofling@gmail.com, Lawrence Livermore National Laboratory
88
//
@@ -75,7 +75,9 @@ class EwaldHandler3D : public LRHandlerBase
7575
return v0;
7676
}
7777

78-
inline mRealType evaluateLR_r0() { return 2.0 * Sigma / std::sqrt(M_PI); }
78+
mRealType evaluate_vlr_k(mRealType k) override;
79+
80+
mRealType evaluateLR_r0() { return 2.0 * Sigma / std::sqrt(M_PI); }
7981

8082
/** evaluate the first derivative of the short range part at r
8183
*

src/LongRange/LRHandlerBase.h

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// This file is distributed under the University of Illinois/NCSA Open Source License.
33
// See LICENSE file in top directory for details.
44
//
5-
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
5+
// Copyright (c) 2020 QMCPACK developers.
66
//
77
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
88
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
@@ -55,6 +55,8 @@ struct LRHandlerBase
5555
///Coefficient for strain fit.
5656
std::vector<mRealType> gstraincoefs;
5757

58+
virtual mRealType evaluate_vlr_k(mRealType k) = 0;
59+
5860

5961
//constructor
6062
explicit LRHandlerBase(mRealType kc) : MaxKshell(0), LR_kc(kc), LR_rc(0), ClassName("LRHandlerBase") {}
@@ -89,6 +91,19 @@ struct LRHandlerBase
8991
return vk;
9092
}
9193

94+
inline mRealType evaluate_w_sk(const std::vector<int>& kshell, const pRealType* restrict sk)
95+
{
96+
mRealType vk = 0.0;
97+
for (int ks = 0, ki = 0; ks < MaxKshell; ks++)
98+
{
99+
mRealType u = 0;
100+
for (; ki < kshell[ks + 1]; ki++)
101+
u += (*sk++);
102+
vk += Fk_symm[ks] * u;
103+
}
104+
return vk;
105+
}
106+
92107
inline mRealType evaluate(const std::vector<int>& kshell,
93108
const pRealType* restrict rk1_r,
94109
const pRealType* restrict rk1_i,
@@ -303,19 +318,20 @@ struct DummyLRHandler : public LRHandlerBase
303318
Fk.resize(KList.kpts_cart.size());
304319
for (ksh = 0, ik = 0; ksh < MaxKshell; ksh++, ik++)
305320
{
306-
mRealType v = norm * myFunc(kk[KList.kshell[ksh]]); //rpa=u0/kk[ik];
321+
mRealType v = norm * myFunc(kk[KList.kshell[ksh]]); //rpa=u0/kk[ik];
307322
Fk_symm[ksh] = v;
308323
for (; ik < KList.kshell[ksh + 1]; ik++)
309324
Fk[ik] = v;
310325
}
311326
}
312327

328+
mRealType evaluate_vlr_k(mRealType k) override { return 0.0; }
313329
mRealType evaluate(mRealType r, mRealType rinv) { return 0.0; }
314330
mRealType evaluateLR(mRealType r) { return 0.0; }
315331
mRealType srDf(mRealType r, mRealType rinv) { return 0.0; }
316332
void Breakup(ParticleSet& ref, mRealType rs_in) {}
317-
void resetTargetParticleSet(ParticleSet& ref) {}
318-
virtual LRHandlerBase* makeClone(ParticleSet& ref){return new DummyLRHandler<Func>(LR_kc);}
333+
void resetTargetParticleSet(ParticleSet& ref) {}
334+
virtual LRHandlerBase* makeClone(ParticleSet& ref) { return new DummyLRHandler<Func>(LR_kc); }
319335
};
320336

321337
} // namespace qmcplusplus

src/LongRange/LRHandlerSRCoulomb.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// This file is distributed under the University of Illinois/NCSA Open Source License.
33
// See LICENSE file in top directory for details.
44
//
5-
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
5+
// Copyright (c) 2020 QMCPACK developers.
66
//
77
// File developed by: Raymond Clay III, j.k.rofling@gmail.com, Lawrence Livermore National Laboratory
88
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
@@ -117,6 +117,8 @@ class LRHandlerSRCoulomb : public LRHandlerBase
117117
return v;
118118
}
119119

120+
inline mRealType evaluate_vlr_k(mRealType k) { return evalYk(k); }
121+
120122
/** evaluate the first derivative of the short range part at r
121123
*
122124
* @param r radius
@@ -282,7 +284,7 @@ class LRHandlerSRCoulomb : public LRHandlerBase
282284
LRBreakup<BreakupBasis> breakuphandler(Basis);
283285
//Find size of basis from cutoffs
284286
mRealType kc = (LR_kc < 0) ? ref.LR_kc : LR_kc;
285-
LR_kc = kc; // set internal kc
287+
LR_kc = kc; // set internal kc
286288
//mRealType kc(ref.LR_kc); //User cutoff parameter...
287289
//kcut is the cutoff for switching to approximate k-point degeneracies for
288290
//better performance in making the breakup. A good bet is 30*K-spacing so that

src/LongRange/LRHandlerTemp.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// This file is distributed under the University of Illinois/NCSA Open Source License.
33
// See LICENSE file in top directory for details.
44
//
5-
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
5+
// Copyright (c) 2020 QMCPACK developers.
66
//
77
// File developed by: Ken Esler, kpesler@gmail.com, University of Illinois at Urbana-Champaign
88
// Bryan Clark, bclark@Princeton.edu, Princeton University
@@ -102,7 +102,8 @@ class LRHandlerTemp : public LRHandlerBase
102102
inline mRealType evaluate(mRealType r, mRealType rinv)
103103
{
104104
mRealType v = 0.0;
105-
if (r>=LR_rc) return v;
105+
if (r >= LR_rc)
106+
return v;
106107
v = myFunc(r, rinv);
107108
for (int n = 0; n < coefs.size(); n++)
108109
v -= coefs[n] * Basis.h(n, r);
@@ -118,21 +119,25 @@ class LRHandlerTemp : public LRHandlerBase
118119
{
119120
APP_ABORT("LRHandlerTemp::srDF not implemented (missing gcoefs)");
120121
mRealType df = 0.0;
121-
if (r>=LR_rc) return df;
122+
if (r >= LR_rc)
123+
return df;
122124
df = myFunc.df(r);
123125
//RealType df = myFunc.df(r, rinv);
124126
for (int n = 0; n < coefs.size(); n++)
125127
df -= gcoefs[n] * Basis.dh_dr(n, r);
126128
return df;
127129
}
128130

131+
inline mRealType evaluate_vlr_k(mRealType k) { return evalFk(k); }
132+
129133

130134
/** evaluate the contribution from the long-range part for for spline
131135
*/
132136
inline mRealType evaluateLR(mRealType r)
133137
{
134138
mRealType v = 0.0;
135-
if (r>=LR_rc) return myFunc(r, 1./r);
139+
if (r >= LR_rc)
140+
return myFunc(r, 1. / r);
136141
for (int n = 0; n < coefs.size(); n++)
137142
v += coefs[n] * Basis.h(n, r);
138143
return v;
@@ -208,7 +213,7 @@ class LRHandlerTemp : public LRHandlerBase
208213
LRBreakup<BreakupBasis> breakuphandler(Basis);
209214
//Find size of basis from cutoffs
210215
mRealType kc = (LR_kc < 0) ? ref.LR_kc : LR_kc;
211-
LR_kc = kc; // set internal kc
216+
LR_kc = kc; // set internal kc
212217
//RealType kc(ref.LR_kc); //User cutoff parameter...
213218
//kcut is the cutoff for switching to approximate k-point degeneracies for
214219
//better performance in making the breakup. A good bet is 30*K-spacing so that

src/LongRange/LRRPABFeeHandlerTemp.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// This file is distributed under the University of Illinois/NCSA Open Source License.
33
// See LICENSE file in top directory for details.
44
//
5-
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
5+
// Copyright (c) 2020 QMCPACK developers.
66
//
77
// File developed by: Miguel Morales, moralessilva2@llnl.gov, Lawrence Livermore National Laboratory
88
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
@@ -155,6 +155,8 @@ struct LRRPABFeeHandlerTemp : public LRHandlerBase
155155
return vk;
156156
}
157157

158+
inline mRealType evaluate_vlr_k(mRealType k) override { return evalFk(k); }
159+
158160
private:
159161
inline mRealType evalFk(mRealType k)
160162
{

0 commit comments

Comments
 (0)