Skip to content

Commit

Permalink
Merge pull request #2329 from camelto2/qmcFScorr
Browse files Browse the repository at this point in the history
adding qmcfinitesize tool
  • Loading branch information
ye-luo authored Mar 30, 2020
2 parents 472cc3d + 2113d4c commit b08b191
Show file tree
Hide file tree
Showing 29 changed files with 10,511 additions and 40 deletions.
1 change: 1 addition & 0 deletions src/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ CheckOptions: [ { key: readability-identifier-naming.NamespaceCase, value: lower
{ key: readability-identifier-naming.VariableCase, value: lower_case },
{ key: readability-identifier-naming.ClassMethodCase, value: camelBack },
{ key: readability-identifier-naming.PrivateMemberPostfix, value: _ }]

1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ else() #{{{
SUBDIRS(OpenMP/tests)
SUBDIRS(Optimize/tests)
SUBDIRS(MinimalContainers/tests)
SUBDIRS(QMCTools/tests)
endif() #}

endif() #}}}
64 changes: 44 additions & 20 deletions src/LongRange/EwaldHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file is distributed under the University of Illinois/NCSA Open Source License.
// See LICENSE file in top directory for details.
//
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
// Copyright (c) 2020 QMCPACK developers.
//
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
Expand Down Expand Up @@ -78,8 +78,8 @@ void EwaldHandler::fillFk(KContainer& KList)
else
{
#if OHMMS_DIM == 2
mRealType kgauss = 1.0 / (4 * Sigma * Sigma);
mRealType knorm = 2 * M_PI / Volume;
mRealType kgauss = 1.0 / (4 * Sigma * Sigma);
mRealType knorm = 2 * M_PI / Volume;
for (int ks = 0, ki = 0; ks < Fk_symm.size(); ks++)
{
mRealType t2e = KList.ksq[ki] * kgauss;
Expand All @@ -90,8 +90,8 @@ void EwaldHandler::fillFk(KContainer& KList)
}
PreFactors[3] = 0.0;
#elif OHMMS_DIM == 3
mRealType kgauss = 1.0 / (4 * Sigma * Sigma);
mRealType knorm = 4 * M_PI / Volume;
mRealType kgauss = 1.0 / (4 * Sigma * Sigma);
mRealType knorm = 4 * M_PI / Volume;
for (int ks = 0, ki = 0; ks < Fk_symm.size(); ks++)
{
mRealType t2e = KList.ksq[ki] * kgauss;
Expand All @@ -100,27 +100,51 @@ void EwaldHandler::fillFk(KContainer& KList)
while (ki < KList.kshell[ks + 1] && ki < Fk.size())
Fk[ki++] = uk;
}
PreFactors[3] = 0.0;
PreFactors[3] = 0.0;
#endif
}
app_log().flush();
}

EwaldHandler::mRealType EwaldHandler::evaluate_slab(mRealType z,
const std::vector<int>& kshell,
const pComplexType* restrict eikr_i,
const pComplexType* restrict eikr_j)
EwaldHandler::mRealType EwaldHandler::evaluate_vlr_k(mRealType k)
{
mRealType zp = z * Sigma;
mRealType vk = -SlabFunc0(z, zp);
//cout << "### SLAB " << z << " " << zp << std::endl;
for (int ks = 0, ki = 0; ks < MaxKshell; ks++)
mRealType uk = 0.0;
if (SuperCellEnum == SUPERCELL_SLAB)
{
mRealType u = 0; //\sum Real (e^ikr_i e^(-ikr_j))
for (; ki < kshell[ks + 1]; ki++, eikr_i++, eikr_j++)
u += ((*eikr_i).real() * (*eikr_j).real() + (*eikr_i).imag() * (*eikr_j).imag());
vk += u * Fk_symm[ks] * SlabFuncK(ks, z, zp);
mRealType knorm = M_PI / Area;
uk = knorm / k; //pi/(A*k)
}
else
{
#if OHMMS_DIM == 2
mRealType kgauss = 1.0 / (4 * Sigma * Sigma);
mRealType knorm = 2 * M_PI / Volume;
mRealType k2 = k * k;
uk = knorm * std::exp(-k2 * kgauss) / k2;
#elif OHMMS_DIM == 3
mRealType kgauss = 1.0 / (4 * Sigma * Sigma);
mRealType knorm = 4 * M_PI / Volume;
mRealType k2 = k * k;
uk = knorm * std::exp(-k2 * kgauss) / k2;
}
#endif
return uk;
}

EwaldHandler::mRealType EwaldHandler::evaluate_slab(mRealType z, const std::vector<int>& kshell,
const pComplexType* restrict eikr_i,
const pComplexType* restrict eikr_j)
{
mRealType zp = z * Sigma;
mRealType vk = -SlabFunc0(z, zp);
//cout << "### SLAB " << z << " " << zp << std::endl;
for (int ks = 0, ki = 0; ks < MaxKshell; ks++)
{
mRealType u = 0; //\sum Real (e^ikr_i e^(-ikr_j))
for (; ki < kshell[ks + 1]; ki++, eikr_i++, eikr_j++)
u += ((*eikr_i).real() * (*eikr_j).real() + (*eikr_i).imag() * (*eikr_j).imag());
vk += u * Fk_symm[ks] * SlabFuncK(ks, z, zp);
}
return vk;
}
return vk;
}
} // namespace qmcplusplus
4 changes: 3 additions & 1 deletion src/LongRange/EwaldHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file is distributed under the University of Illinois/NCSA Open Source License.
// See LICENSE file in top directory for details.
//
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
// Copyright (c) 2020 QMCPACK developers.
//
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
Expand Down Expand Up @@ -93,6 +93,8 @@ class EwaldHandler : public LRHandlerBase
*/
inline mRealType srDf(mRealType r, mRealType rinv) { return 0.0; }

inline mRealType evaluate_vlr_k(mRealType k) override;

void fillFk(KContainer& KList);

/** evaluate k-dependent
Expand Down
15 changes: 12 additions & 3 deletions src/LongRange/EwaldHandler3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file is distributed under the University of Illinois/NCSA Open Source License.
// See LICENSE file in top directory for details.
//
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
// Copyright (c) 2020 QMCPACK developers.
//
// File developed by: Raymond Clay III, j.k.rofling@gmail.com, Lawrence Livermore National Laboratory
//
Expand Down Expand Up @@ -61,8 +61,8 @@ void EwaldHandler3D::fillFk(KContainer& KList)

Fk_symm.resize(MaxKshell);
kMag.resize(MaxKshell);
mRealType kgauss = 1.0 / (4 * Sigma * Sigma);
mRealType knorm = 4 * M_PI / Volume;
mRealType kgauss = 1.0 / (4 * Sigma * Sigma);
mRealType knorm = 4 * M_PI / Volume;
for (int ks = 0, ki = 0; ks < Fk_symm.size(); ks++)
{
mRealType t2e = KList.ksq[ki] * kgauss;
Expand All @@ -78,4 +78,13 @@ void EwaldHandler3D::fillFk(KContainer& KList)
PreFactors[3] = 0.0;
app_log().flush();
}

EwaldHandler3D::mRealType EwaldHandler3D::evaluate_vlr_k(mRealType k)
{
mRealType kgauss = 1.0 / (4 * Sigma * Sigma);
mRealType knorm = 4 * M_PI / Volume;
mRealType k2 = k * k;
return knorm * std::exp(-k2 * kgauss) / k2;
}

} // namespace qmcplusplus
6 changes: 4 additions & 2 deletions src/LongRange/EwaldHandler3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file is distributed under the University of Illinois/NCSA Open Source License.
// See LICENSE file in top directory for details.
//
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
// Copyright (c) 2020 QMCPACK developers.
//
// File developed by: Raymond Clay III, j.k.rofling@gmail.com, Lawrence Livermore National Laboratory
//
Expand Down Expand Up @@ -75,7 +75,9 @@ class EwaldHandler3D : public LRHandlerBase
return v0;
}

inline mRealType evaluateLR_r0() { return 2.0 * Sigma / std::sqrt(M_PI); }
mRealType evaluate_vlr_k(mRealType k) override;

mRealType evaluateLR_r0() { return 2.0 * Sigma / std::sqrt(M_PI); }

/** evaluate the first derivative of the short range part at r
*
Expand Down
24 changes: 20 additions & 4 deletions src/LongRange/LRHandlerBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file is distributed under the University of Illinois/NCSA Open Source License.
// See LICENSE file in top directory for details.
//
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
// Copyright (c) 2020 QMCPACK developers.
//
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
Expand Down Expand Up @@ -55,6 +55,8 @@ struct LRHandlerBase
///Coefficient for strain fit.
std::vector<mRealType> gstraincoefs;

virtual mRealType evaluate_vlr_k(mRealType k) = 0;


//constructor
explicit LRHandlerBase(mRealType kc) : MaxKshell(0), LR_kc(kc), LR_rc(0), ClassName("LRHandlerBase") {}
Expand Down Expand Up @@ -89,6 +91,19 @@ struct LRHandlerBase
return vk;
}

inline mRealType evaluate_w_sk(const std::vector<int>& kshell, const pRealType* restrict sk)
{
mRealType vk = 0.0;
for (int ks = 0, ki = 0; ks < MaxKshell; ks++)
{
mRealType u = 0;
for (; ki < kshell[ks + 1]; ki++)
u += (*sk++);
vk += Fk_symm[ks] * u;
}
return vk;
}

inline mRealType evaluate(const std::vector<int>& kshell,
const pRealType* restrict rk1_r,
const pRealType* restrict rk1_i,
Expand Down Expand Up @@ -303,19 +318,20 @@ struct DummyLRHandler : public LRHandlerBase
Fk.resize(KList.kpts_cart.size());
for (ksh = 0, ik = 0; ksh < MaxKshell; ksh++, ik++)
{
mRealType v = norm * myFunc(kk[KList.kshell[ksh]]); //rpa=u0/kk[ik];
mRealType v = norm * myFunc(kk[KList.kshell[ksh]]); //rpa=u0/kk[ik];
Fk_symm[ksh] = v;
for (; ik < KList.kshell[ksh + 1]; ik++)
Fk[ik] = v;
}
}

mRealType evaluate_vlr_k(mRealType k) override { return 0.0; }
mRealType evaluate(mRealType r, mRealType rinv) { return 0.0; }
mRealType evaluateLR(mRealType r) { return 0.0; }
mRealType srDf(mRealType r, mRealType rinv) { return 0.0; }
void Breakup(ParticleSet& ref, mRealType rs_in) {}
void resetTargetParticleSet(ParticleSet& ref) {}
virtual LRHandlerBase* makeClone(ParticleSet& ref){return new DummyLRHandler<Func>(LR_kc);}
void resetTargetParticleSet(ParticleSet& ref) {}
virtual LRHandlerBase* makeClone(ParticleSet& ref) { return new DummyLRHandler<Func>(LR_kc); }
};

} // namespace qmcplusplus
Expand Down
6 changes: 4 additions & 2 deletions src/LongRange/LRHandlerSRCoulomb.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file is distributed under the University of Illinois/NCSA Open Source License.
// See LICENSE file in top directory for details.
//
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
// Copyright (c) 2020 QMCPACK developers.
//
// File developed by: Raymond Clay III, j.k.rofling@gmail.com, Lawrence Livermore National Laboratory
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
Expand Down Expand Up @@ -117,6 +117,8 @@ class LRHandlerSRCoulomb : public LRHandlerBase
return v;
}

inline mRealType evaluate_vlr_k(mRealType k) { return evalYk(k); }

/** evaluate the first derivative of the short range part at r
*
* @param r radius
Expand Down Expand Up @@ -282,7 +284,7 @@ class LRHandlerSRCoulomb : public LRHandlerBase
LRBreakup<BreakupBasis> breakuphandler(Basis);
//Find size of basis from cutoffs
mRealType kc = (LR_kc < 0) ? ref.LR_kc : LR_kc;
LR_kc = kc; // set internal kc
LR_kc = kc; // set internal kc
//mRealType kc(ref.LR_kc); //User cutoff parameter...
//kcut is the cutoff for switching to approximate k-point degeneracies for
//better performance in making the breakup. A good bet is 30*K-spacing so that
Expand Down
15 changes: 10 additions & 5 deletions src/LongRange/LRHandlerTemp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file is distributed under the University of Illinois/NCSA Open Source License.
// See LICENSE file in top directory for details.
//
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
// Copyright (c) 2020 QMCPACK developers.
//
// File developed by: Ken Esler, kpesler@gmail.com, University of Illinois at Urbana-Champaign
// Bryan Clark, bclark@Princeton.edu, Princeton University
Expand Down Expand Up @@ -102,7 +102,8 @@ class LRHandlerTemp : public LRHandlerBase
inline mRealType evaluate(mRealType r, mRealType rinv)
{
mRealType v = 0.0;
if (r>=LR_rc) return v;
if (r >= LR_rc)
return v;
v = myFunc(r, rinv);
for (int n = 0; n < coefs.size(); n++)
v -= coefs[n] * Basis.h(n, r);
Expand All @@ -118,21 +119,25 @@ class LRHandlerTemp : public LRHandlerBase
{
APP_ABORT("LRHandlerTemp::srDF not implemented (missing gcoefs)");
mRealType df = 0.0;
if (r>=LR_rc) return df;
if (r >= LR_rc)
return df;
df = myFunc.df(r);
//RealType df = myFunc.df(r, rinv);
for (int n = 0; n < coefs.size(); n++)
df -= gcoefs[n] * Basis.dh_dr(n, r);
return df;
}

inline mRealType evaluate_vlr_k(mRealType k) { return evalFk(k); }


/** evaluate the contribution from the long-range part for for spline
*/
inline mRealType evaluateLR(mRealType r)
{
mRealType v = 0.0;
if (r>=LR_rc) return myFunc(r, 1./r);
if (r >= LR_rc)
return myFunc(r, 1. / r);
for (int n = 0; n < coefs.size(); n++)
v += coefs[n] * Basis.h(n, r);
return v;
Expand Down Expand Up @@ -208,7 +213,7 @@ class LRHandlerTemp : public LRHandlerBase
LRBreakup<BreakupBasis> breakuphandler(Basis);
//Find size of basis from cutoffs
mRealType kc = (LR_kc < 0) ? ref.LR_kc : LR_kc;
LR_kc = kc; // set internal kc
LR_kc = kc; // set internal kc
//RealType kc(ref.LR_kc); //User cutoff parameter...
//kcut is the cutoff for switching to approximate k-point degeneracies for
//better performance in making the breakup. A good bet is 30*K-spacing so that
Expand Down
4 changes: 3 additions & 1 deletion src/LongRange/LRRPABFeeHandlerTemp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file is distributed under the University of Illinois/NCSA Open Source License.
// See LICENSE file in top directory for details.
//
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
// Copyright (c) 2020 QMCPACK developers.
//
// File developed by: Miguel Morales, moralessilva2@llnl.gov, Lawrence Livermore National Laboratory
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
Expand Down Expand Up @@ -155,6 +155,8 @@ struct LRRPABFeeHandlerTemp : public LRHandlerBase
return vk;
}

inline mRealType evaluate_vlr_k(mRealType k) override { return evalFk(k); }

private:
inline mRealType evalFk(mRealType k)
{
Expand Down
5 changes: 4 additions & 1 deletion src/LongRange/LRRPAHandlerTemp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file is distributed under the University of Illinois/NCSA Open Source License.
// See LICENSE file in top directory for details.
//
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
// Copyright (c) 2020 QMCPACK developers.
//
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
Expand Down Expand Up @@ -156,6 +156,9 @@ struct LRRPAHandlerTemp : public LRHandlerBase
return vk;
}

// use what is put in fillFk. Multiplies evalFk by -1
inline mRealType evaluate_vlr_k(mRealType k) override { return -1.0 * evalFk(k); }

private:
inline mRealType evalFk(mRealType k)
{
Expand Down
18 changes: 17 additions & 1 deletion src/QMCTools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ PROJECT(qmctools)

SET(MOSRCS
../Particle/InitMolecularSystem.cpp
../Particle/ParticleSetPool.cpp
QMCGaussianParserBase.cpp
GaussianFCHKParser.cpp
GamesXmlParser.cpp
Expand Down Expand Up @@ -69,6 +68,23 @@ TARGET_LINK_LIBRARIES(convertpw4qmc PRIVATE qmcutil Math::FFTW3)
INSTALL(TARGETS convertpw4qmc
RUNTIME DESTINATION bin)

SET(FSSRCS
QMCFiniteSize/QMCFiniteSize.cpp
QMCFiniteSize/SkParserBase.cpp
QMCFiniteSize/SkParserASCII.cpp
QMCFiniteSize/SkParserScalarDat.cpp
QMCFiniteSize/FSUtilities.cpp
)

ADD_LIBRARY(fstool ${FSSRCS})
TARGET_LINK_LIBRARIES(fstool PUBLIC qmc qmcbase qmcwfs)

ADD_EXECUTABLE(qmcfinitesize qmcfinitesize.cpp)
TARGET_LINK_LIBRARIES(qmcfinitesize PRIVATE fstool)

INSTALL(TARGETS qmcfinitesize
RUNTIME DESTINATION bin)

#ppconvert
if( BUILD_PPCONVERT )
SUBDIRS(ppconvert)
Expand Down
Loading

0 comments on commit b08b191

Please sign in to comment.