diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ecbbcbd22..e3b9f394d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -169,7 +169,6 @@ ENDIF() Particle/ParticleSet.BC.cpp Particle/DistanceTableAA.cpp Particle/DistanceTableAB.cpp - Particle/DistanceTable.cpp ) ADD_LIBRARY(qmcbase ${PARTICLE} ${PARTICLEIO}) diff --git a/src/Drivers/CMakeLists.txt b/src/Drivers/CMakeLists.txt index b67d0c779..5a223795e 100644 --- a/src/Drivers/CMakeLists.txt +++ b/src/Drivers/CMakeLists.txt @@ -8,7 +8,7 @@ FOREACH(p ${ESTEST}) TARGET_LINK_LIBRARIES(${p} qmcbase qmcutil ${QMC_UTIL_LIBS} ${MPI_LIBRARY}) ENDFOREACH(p ${ESTEST}) -ADD_LIBRARY(miniwfs ../QMCWaveFunctions/WaveFunctionRef.cpp ../QMCWaveFunctions/WaveFunction.cpp) +ADD_LIBRARY(miniwfs ../QMCWaveFunctions/WaveFunction.cpp) ADD_EXECUTABLE(miniqmc miniqmc.cpp) TARGET_LINK_LIBRARIES(miniqmc miniwfs qmcbase qmcutil ${QMC_UTIL_LIBS} ${MPI_LIBRARY}) diff --git a/src/Drivers/check_wfc.cpp b/src/Drivers/check_wfc.cpp index fd50af273..ccb635253 100644 --- a/src/Drivers/check_wfc.cpp +++ b/src/Drivers/check_wfc.cpp @@ -186,10 +186,10 @@ int main(int argc, char **argv) els_ref.RSoA = els_ref.R; // create tables - DistanceTable::add(els, DT_SOA); - DistanceTable::add(els_ref, DT_SOA); - DistanceTableData *d_ie = DistanceTable::add(ions, els_ref, DT_SOA); - d_ie->setRmax(Rmax); + els.addTable(els, DT_SOA); + els_ref.addTable(els_ref, DT_SOA); + const int ei_TableID = els_ref.addTable(ions, DT_SOA); + els_ref.DistTables[ei_TableID]->setRmax(Rmax); ParticlePos_t delta(nels); @@ -381,12 +381,12 @@ int main(int argc, char **argv) int nsphere = 0; for (int iat = 0; iat < nions; ++iat) { - for (int nj = 0, jmax = d_ie->nadj(iat); nj < jmax; ++nj) + for (int nj = 0, jmax = els_ref.DistTables[ei_TableID]->nadj(iat); nj < jmax; ++nj) { - const RealType r = d_ie->distance(iat, nj); + const RealType r = els_ref.DistTables[ei_TableID]->distance(iat, nj); if (r < Rmax) { - const int iel = d_ie->iadj(iat, nj); + const int iel = els_ref.DistTables[ei_TableID]->iadj(iat, nj); nsphere++; random_th.generate_uniform(&delta[0][0], nknots * 3); for (int k = 0; k < nknots; ++k) diff --git a/src/Drivers/miniqmc.cpp b/src/Drivers/miniqmc.cpp index 1a30f3ef7..00ee014a0 100644 --- a/src/Drivers/miniqmc.cpp +++ b/src/Drivers/miniqmc.cpp @@ -155,6 +155,7 @@ void print_help() app_summary() << " miniqmc [-hjvV] [-g \"n0 n1 n2\"] [-m meshfactor]" << '\n'; app_summary() << " [-n steps] [-N substeps] [-r rmax] [-s seed]" << '\n'; app_summary() << "options:" << '\n'; + app_summary() << " -b use reference implementations default: off" << '\n'; app_summary() << " -g set the 3D tiling. default: 1 1 1" << '\n'; app_summary() << " -h print help and exit" << '\n'; app_summary() << " -j enable three body Jastrow default: off" << '\n'; @@ -210,11 +211,14 @@ int main(int argc, char **argv) int opt; while(optind < argc) { - if ((opt = getopt(argc, argv, "hjvVa:c:g:m:n:N:r:s:")) != -1) + if ((opt = getopt(argc, argv, "bhjvVa:c:g:m:n:N:r:s:")) != -1) { switch (opt) { case 'a': tileSize = atoi(optarg); break; + case 'b': + useRef = true; + break; case 'c': // number of members per team team_size = atoi(optarg); break; @@ -370,20 +374,15 @@ int main(int argc, char **argv) els.RSoA = els.R; } - WaveFunctionBase *wavefunction; + WaveFunction *wavefunction = new WaveFunction(); if (useRef) - { - wavefunction = - new miniqmcreference::WaveFunctionRef(ions, els, random_th, enableJ3); - } + build_WaveFunction(true, *wavefunction, ions, els, random_th, enableJ3); else - { - wavefunction = new WaveFunction(ions, els, random_th, enableJ3); - } + build_WaveFunction(false, *wavefunction, ions, els, random_th, enableJ3); // set Rmax for ion-el distance table for PP - wavefunction->setRmax(Rmax); + els.DistTables[wavefunction->get_ei_TableID()]->setRmax(Rmax); // create pseudopp NonLocalPP ecp(random_th); @@ -484,7 +483,7 @@ int main(int argc, char **argv) // Compute NLPP energy using integral over spherical points ecp.randomize(rOnSphere); // pick random sphere - const DistanceTableData *d_ie = wavefunction->d_ie; + const DistanceTableData *d_ie = els.DistTables[wavefunction->get_ei_TableID()]; Timers[Timer_ECP]->start(); for (int iat = 0; iat < nions; ++iat) diff --git a/src/Particle/DistanceTable.cpp b/src/Particle/DistanceTable.cpp deleted file mode 100644 index b8fa0a316..000000000 --- a/src/Particle/DistanceTable.cpp +++ /dev/null @@ -1,52 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// 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. -// -// File developed by: -// Ken Esler, kpesler@gmail.com, -// University of Illinois at Urbana-Champaign -// Jeremy McMinnis, jmcminis@gmail.com, -// University of Illinois at Urbana-Champaign -// Jeongnim Kim, jeongnim.kim@gmail.com, -// University of Illinois at Urbana-Champaign -// Jaron T. Krogel, krogeljt@ornl.gov, -// Oak Ridge National Laboratory -// Mark A. Berrill, berrillma@ornl.gov, -// Oak Ridge National Laboratory -// -// File created by: -// Jeongnim Kim, jeongnim.kim@gmail.com, -// University of Illinois at Urbana-Champaign -//////////////////////////////////////////////////////////////////////////////// - -#include "Particle/DistanceTable.h" -#include "Particle/DistanceTableData.h" -#include "Particle/Lattice/ParticleBConds.h" -namespace qmcplusplus -{ - -/** Adding SymmetricDTD to the list, e.g., el-el distance table - *\param s source/target particle set - *\return DistanceTableData* - */ -DistanceTableData *DistanceTable::add(ParticleSet &s, int dt_type) -{ - int tid = s.addTable(s, dt_type); - return s.DistTables[tid]; -} - -/** Adding AsymmetricDTD to the list, e.g., el-nuclei distance table - *\param s source particle set - *\param t target particle set - *\return DistanceTableData* - */ -DistanceTableData *DistanceTable::add(const ParticleSet &s, ParticleSet &t, - int dt_type) -{ - int tid = t.addTable(s, dt_type); - return t.DistTables[tid]; -} - -} // namespace qmcplusplus diff --git a/src/Particle/DistanceTable.h b/src/Particle/DistanceTable.h index 91e8a9044..93f8055d7 100644 --- a/src/Particle/DistanceTable.h +++ b/src/Particle/DistanceTable.h @@ -39,17 +39,6 @@ namespace qmcplusplus *DistanceTable * to generically control the crystalline structure. */ -// struct DistanceTable -namespace DistanceTable -{ -/// add a named DistanceTableData_t of Symmectric type -DistanceTableData *add(ParticleSet &s, - int dt_type); //, const char* aname = NULL); - -/// add a named DistanceTableData_t of Asymmectric type -DistanceTableData *add(const ParticleSet &s, ParticleSet &t, - int dt_type); //, const char* aname = NULL); -} /// free function to create a distable table of s-s DistanceTableData *createDistanceTable(ParticleSet &s, int dt_type); diff --git a/src/QMCWaveFunctions/Determinant.h b/src/QMCWaveFunctions/Determinant.h index c9d830ccf..28f691a97 100644 --- a/src/QMCWaveFunctions/Determinant.h +++ b/src/QMCWaveFunctions/Determinant.h @@ -179,7 +179,7 @@ void checkDiff(const MT1 &a, const MT2 &b, const std::string &tag) struct DiracDeterminant : public WaveFunctionComponentBase { - DiracDeterminant(int nels, RandomGenerator &RNG, int First=0) + DiracDeterminant(int nels, const RandomGenerator &RNG, int First=0) : FirstIndex(First), myRandom(RNG) { psiMinv.resize(nels, nels); diff --git a/src/QMCWaveFunctions/DeterminantRef.h b/src/QMCWaveFunctions/DeterminantRef.h index 5dc5bc955..d7259802b 100644 --- a/src/QMCWaveFunctions/DeterminantRef.h +++ b/src/QMCWaveFunctions/DeterminantRef.h @@ -184,7 +184,7 @@ struct DiracDeterminantRef : public qmcplusplus::WaveFunctionComponentBase { using ParticleSet = qmcplusplus::ParticleSet; - DiracDeterminantRef(int nels, qmcplusplus::RandomGenerator &RNG, int First=0) + DiracDeterminantRef(int nels, const qmcplusplus::RandomGenerator &RNG, int First=0) : FirstIndex(First), myRandom(RNG) { psiMinv.resize(nels, nels); diff --git a/src/QMCWaveFunctions/WaveFunction.cpp b/src/QMCWaveFunctions/WaveFunction.cpp index 4413814ff..8e463765b 100644 --- a/src/QMCWaveFunctions/WaveFunction.cpp +++ b/src/QMCWaveFunctions/WaveFunction.cpp @@ -19,48 +19,107 @@ namespace qmcplusplus { -WaveFunction::WaveFunction(ParticleSet &ions, ParticleSet &els, - RandomGenerator &RNG, bool enableJ3) -{ - FirstTime = true; - - ions.RSoA = ions.R; - els.RSoA = els.R; - // distance tables - d_ee = DistanceTable::add(els, DT_SOA); - d_ie = DistanceTable::add(ions, els, DT_SOA); - - // determinant component - nelup = els.getTotalNum()/2; - Det_up = new DetType(nelup, RNG, 0); - Det_dn = new DetType(els.getTotalNum()-nelup, RNG, nelup); +void build_WaveFunction(bool useRef, WaveFunction &WF, ParticleSet &ions, ParticleSet &els, const RandomGenerator &RNG, bool enableJ3) +{ + using valT = WaveFunction::valT; + using posT = WaveFunction::posT; - // J1 component - J1 = new J1OrbType(ions, els); - buildJ1(*J1, els.Lattice.WignerSeitzRadius); + if(WF.Is_built) + { + app_log() << "The wavefunction was built before!" << std::endl; + return; + } - // J2 component - J2 = new J2OrbType(els); - buildJ2(*J2, els.Lattice.WignerSeitzRadius); + const int nelup = els.getTotalNum()/2; - // J3 component - if(enableJ3) + if(useRef) { - J3 = new J3OrbType(ions, els); - buildJeeI(*J3, els.Lattice.WignerSeitzRadius); + using J1OrbType = miniqmcreference::OneBodyJastrowRef>; + using J2OrbType = miniqmcreference::TwoBodyJastrowRef>; + using J3OrbType = miniqmcreference::ThreeBodyJastrowRef; + using DetType = miniqmcreference::DiracDeterminantRef; + + ions.RSoA = ions.R; + els.RSoA = els.R; + + // distance tables + els.addTable(els, DT_SOA); + WF.ei_TableID = els.addTable(ions, DT_SOA); + + // determinant component + WF.nelup = nelup; + WF.Det_up = new DetType(nelup, RNG, 0); + WF.Det_dn = new DetType(els.getTotalNum()-nelup, RNG, nelup); + + // J1 component + J1OrbType *J1 = new J1OrbType(ions, els); + buildJ1(*J1, els.Lattice.WignerSeitzRadius); + WF.Jastrows.push_back(J1); + + // J2 component + J2OrbType *J2 = new J2OrbType(els); + buildJ2(*J2, els.Lattice.WignerSeitzRadius); + WF.Jastrows.push_back(J2); + + // J3 component + if(enableJ3) + { + J3OrbType *J3 = new J3OrbType(ions, els); + buildJeeI(*J3, els.Lattice.WignerSeitzRadius); + WF.Jastrows.push_back(J3); + } } else - J3 = nullptr; + { + using J1OrbType = OneBodyJastrow>; + using J2OrbType = TwoBodyJastrow>; + using J3OrbType = ThreeBodyJastrow; + using DetType = DiracDeterminant; + + ions.RSoA = ions.R; + els.RSoA = els.R; + + // distance tables + els.addTable(els, DT_SOA); + WF.ei_TableID = els.addTable(ions, DT_SOA); + + // determinant component + WF.nelup = nelup; + WF.Det_up = new DetType(nelup, RNG, 0); + WF.Det_dn = new DetType(els.getTotalNum()-nelup, RNG, nelup); + + // J1 component + J1OrbType *J1 = new J1OrbType(ions, els); + buildJ1(*J1, els.Lattice.WignerSeitzRadius); + WF.Jastrows.push_back(J1); + + // J2 component + J2OrbType *J2 = new J2OrbType(els); + buildJ2(*J2, els.Lattice.WignerSeitzRadius); + WF.Jastrows.push_back(J2); + + // J3 component + if(enableJ3) + { + J3OrbType *J3 = new J3OrbType(ions, els); + buildJeeI(*J3, els.Lattice.WignerSeitzRadius); + WF.Jastrows.push_back(J3); + } + } + + WF.Is_built = true; } WaveFunction::~WaveFunction() { - delete Det_up; - delete Det_dn; - delete J1; - delete J2; - if(J3) delete J3; + if (Is_built) + { + delete Det_up; + delete Det_dn; + for(size_t i=0; ievaluateLog(P, P.G, P.L); - LogValue += Det_dn->evaluateLog(P, P.G, P.L); - LogValue += J1->evaluateLog(P, P.G, P.L); - LogValue += J2->evaluateLog(P, P.G, P.L); - if(J3) LogValue += J3->evaluateLog(P, P.G, P.L); + LogValue = Det_up -> evaluateLog(P, P.G, P.L); + LogValue += Det_dn -> evaluateLog(P, P.G, P.L); + for(size_t i=0; ievaluateLog(P, P.G, P.L); FirstTime = false; } } -WaveFunctionBase::posT WaveFunction::evalGrad(ParticleSet &P, int iat) +WaveFunction::posT WaveFunction::evalGrad(ParticleSet &P, int iat) { - return ( iatevalGrad(P, iat) : Det_dn->evalGrad(P, iat) ) - + J1->evalGrad(P, iat) - + J2->evalGrad(P, iat) - + (J3?J3->evalGrad(P, iat):posT(0)); + posT grad_iat = ( iatevalGrad(P, iat) : Det_dn->evalGrad(P, iat) ); + for(size_t i=0; ievalGrad(P, iat); + return grad_iat; } -WaveFunctionBase::valT WaveFunction::ratioGrad(ParticleSet &P, int iat, +WaveFunction::valT WaveFunction::ratioGrad(ParticleSet &P, int iat, posT &grad) { - return ( iatratioGrad(P, iat, grad) : Det_dn->ratioGrad(P, iat, grad) ) - * J1->ratioGrad(P, iat, grad) - * J2->ratioGrad(P, iat, grad) - * (J3?J3->ratioGrad(P, iat, grad):1.0); + valT ratio = ( iatratioGrad(P, iat, grad) : Det_dn->ratioGrad(P, iat, grad) ); + for(size_t i=0; iratioGrad(P, iat, grad); + return ratio; } -WaveFunctionBase::valT WaveFunction::ratio(ParticleSet &P, int iat) +WaveFunction::valT WaveFunction::ratio(ParticleSet &P, int iat) { - return ( iatratio(P, iat) : Det_dn->ratio(P, iat) ) - * J1->ratio(P, iat) - * J2->ratio(P, iat) - * (J3?J3->ratio(P, iat):1.0); + valT ratio = ( iatratio(P, iat) : Det_dn->ratio(P, iat) ); + for(size_t i=0; iratio(P, iat); + return ratio; } void WaveFunction::acceptMove(ParticleSet &P, int iat) @@ -110,9 +168,8 @@ void WaveFunction::acceptMove(ParticleSet &P, int iat) Det_up->acceptMove(P, iat); else Det_dn->acceptMove(P, iat); - J1->acceptMove(P, iat); - J2->acceptMove(P, iat); - if(J3) J3->acceptMove(P, iat); + for(size_t i=0; iacceptMove(P, iat); } void WaveFunction::restore(int iat) {} @@ -124,8 +181,11 @@ void WaveFunction::evaluateGL(ParticleSet &P) P.L = czero; Det_up->evaluateGL(P, P.G, P.L); Det_dn->evaluateGL(P, P.G, P.L); - J1->evaluateGL(P, P.G, P.L); - J2->evaluateGL(P, P.G, P.L); - if(J3) J3->evaluateGL(P, P.G, P.L); + LogValue = Det_up->LogValue + Det_dn->LogValue; + for(size_t i=0; ievaluateGL(P, P.G, P.L); + LogValue += Jastrows[i]->LogValue; + } } } // qmcplusplus diff --git a/src/QMCWaveFunctions/WaveFunction.h b/src/QMCWaveFunctions/WaveFunction.h index ca84d815b..8cb13942b 100644 --- a/src/QMCWaveFunctions/WaveFunction.h +++ b/src/QMCWaveFunctions/WaveFunction.h @@ -40,45 +40,26 @@ namespace qmcplusplus { /** A minimal TrialWavefunction */ -struct WaveFunctionBase + +struct WaveFunction { + friend void build_WaveFunction(bool useRef, WaveFunction &WF, ParticleSet &ions, ParticleSet &els, const RandomGenerator &RNG, bool enableJ3); + + using RealType = OHMMS_PRECISION; using valT = OHMMS_PRECISION; - using posT = TinyVector; - typedef OHMMS_PRECISION RealType; + using posT = TinyVector; + private: + std::vector Jastrows; + WaveFunctionComponentBase *Det_up; + WaveFunctionComponentBase *Det_dn; valT LogValue; - DistanceTableData *d_ee; - DistanceTableData *d_ie; - - inline void setRmax(valT x) { d_ie->setRmax(x); } - - virtual ~WaveFunctionBase() {} - virtual void evaluateLog(ParticleSet &P) = 0; - virtual posT evalGrad(ParticleSet &P, int iat) = 0; - virtual valT ratioGrad(ParticleSet &P, int iat, posT &grad) = 0; - virtual valT ratio(ParticleSet &P, int iat) = 0; - virtual void acceptMove(ParticleSet &P, int iat) = 0; - virtual void restore(int iat) = 0; - virtual void evaluateGL(ParticleSet &P) = 0; -}; - -struct WaveFunction : public WaveFunctionBase -{ - using J1OrbType = OneBodyJastrow>; - using J2OrbType = TwoBodyJastrow>; - using J3OrbType = ThreeBodyJastrow; - using DetType = DiracDeterminant; - bool FirstTime; - J1OrbType *J1; - J2OrbType *J2; - J3OrbType *J3; - int nelup; - DetType *Det_up; - DetType *Det_dn; + bool FirstTime, Is_built; + int nelup, ei_TableID; - WaveFunction(ParticleSet &ions, ParticleSet &els, - RandomGenerator &RNG, bool enableJ3); + public: + WaveFunction(): FirstTime(true), Is_built(false), nelup(0), ei_TableID(1), Det_up(nullptr), Det_dn(nullptr), LogValue(0.0) { } ~WaveFunction(); void evaluateLog(ParticleSet &P); posT evalGrad(ParticleSet &P, int iat); @@ -87,43 +68,12 @@ struct WaveFunction : public WaveFunctionBase void acceptMove(ParticleSet &P, int iat); void restore(int iat); void evaluateGL(ParticleSet &P); + int get_ei_TableID() const {return ei_TableID;} + valT getLogValue() const {return LogValue;} }; -} // qmcplusplus - -namespace miniqmcreference -{ -/** A minimial TrialWaveFunction - the reference version. - */ -using namespace qmcplusplus; -struct WaveFunctionRef : public qmcplusplus::WaveFunctionBase -{ +void build_WaveFunction(bool useRef, WaveFunction &WF, ParticleSet &ions, ParticleSet &els, const RandomGenerator &RNG, bool enableJ3); - using J1OrbType = OneBodyJastrow>; - using J2OrbType = TwoBodyJastrow>; - using J3OrbType = ThreeBodyJastrow; - using DetType = DiracDeterminantRef; - - bool FirstTime; - J1OrbType *J1; - J2OrbType *J2; - J3OrbType *J3; - int nelup; - DetType *Det_up; - DetType *Det_dn; - PooledData Buffer; - - WaveFunctionRef(ParticleSet &ions, ParticleSet &els, - RandomGenerator &RNG, bool enableJ3); - ~WaveFunctionRef(); - void evaluateLog(ParticleSet &P); - posT evalGrad(ParticleSet &P, int iat); - valT ratioGrad(ParticleSet &P, int iat, posT &grad); - valT ratio(ParticleSet &P, int iat); - void acceptMove(ParticleSet &P, int iat); - void restore(int iat); - void evaluateGL(ParticleSet &P); -}; -} // miniqmcreference +} // qmcplusplus #endif diff --git a/src/QMCWaveFunctions/WaveFunctionComponentBase.h b/src/QMCWaveFunctions/WaveFunctionComponentBase.h index fc5c1fde2..dff92ffa8 100644 --- a/src/QMCWaveFunctions/WaveFunctionComponentBase.h +++ b/src/QMCWaveFunctions/WaveFunctionComponentBase.h @@ -107,7 +107,7 @@ struct WaveFunctionComponentBase : public QMCTraits /// default constructor WaveFunctionComponentBase() : IsOptimizing(false), Optimizable(true), UpdateMode(ORB_WALKER), - LogValue(1.0), PhaseValue(0.0), WaveFunctionComponentName("WaveFunctionComponentBase") + LogValue(0.0), PhaseValue(0.0), WaveFunctionComponentName("WaveFunctionComponentBase") { } /// default destructor diff --git a/src/QMCWaveFunctions/WaveFunctionRef.cpp b/src/QMCWaveFunctions/WaveFunctionRef.cpp deleted file mode 100644 index d4033b820..000000000 --- a/src/QMCWaveFunctions/WaveFunctionRef.cpp +++ /dev/null @@ -1,137 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// 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. -// -// File developed by: -// -// File created by: Jeongnim Kim, jeongnim.kim@intel.com, Intel Corp. -//////////////////////////////////////////////////////////////////////////////// -// -*- C++ -*- -#include -#include - -/*! - * @file WaveFunctionRef.cpp - * @brief Wavefunction based on reference implemenation - */ - -/*! - * Namespace containing reference implementation. - */ - -namespace miniqmcreference -{ -using namespace qmcplusplus; - -WaveFunctionRef::WaveFunctionRef(ParticleSet &ions, ParticleSet &els, - RandomGenerator &RNG, bool enableJ3) -{ - FirstTime = true; - - ions.RSoA = ions.R; - els.RSoA = els.R; - - // distance tables - d_ee = DistanceTable::add(els, DT_SOA); - d_ie = DistanceTable::add(ions, els, DT_SOA); - - // determinant component - nelup = els.getTotalNum()/2; - Det_up = new DetType(nelup, RNG, 0); - Det_dn = new DetType(els.getTotalNum()-nelup, RNG, nelup); - - // J1 component - J1 = new J1OrbType(ions, els); - buildJ1(*J1, els.Lattice.WignerSeitzRadius); - - // J2 component - J2 = new J2OrbType(els); - buildJ2(*J2, els.Lattice.WignerSeitzRadius); - - // J3 component - if(enableJ3) - { - J3 = new J3OrbType(ions, els); - buildJeeI(*J3, els.Lattice.WignerSeitzRadius); - } - else - J3 = nullptr; -} - -WaveFunctionRef::~WaveFunctionRef() -{ - delete Det_up; - delete Det_dn; - delete J1; - delete J2; - if(J3) delete J3; -} - -void WaveFunctionRef::evaluateLog(ParticleSet &P) -{ - constexpr valT czero(0); - if (FirstTime) - { - P.G = czero; - P.L = czero; - LogValue = Det_up->evaluateLog(P, P.G, P.L); - LogValue += Det_dn->evaluateLog(P, P.G, P.L); - LogValue += J1->evaluateLog(P, P.G, P.L); - LogValue += J2->evaluateLog(P, P.G, P.L); - if(J3) LogValue += J3->evaluateLog(P, P.G, P.L); - FirstTime = false; - } -} - -WaveFunctionBase::posT WaveFunctionRef::evalGrad(ParticleSet &P, int iat) -{ - return ( iatevalGrad(P, iat) : Det_dn->evalGrad(P, iat) ) - + J1->evalGrad(P, iat) - + J2->evalGrad(P, iat) - + (J3?J3->evalGrad(P, iat):posT()); -} - -WaveFunctionBase::valT WaveFunctionRef::ratioGrad(ParticleSet &P, int iat, - posT &grad) -{ - return ( iatratioGrad(P, iat, grad) : Det_dn->ratioGrad(P, iat, grad) ) - * J1->ratioGrad(P, iat, grad) - * J2->ratioGrad(P, iat, grad) - * (J3?J3->ratioGrad(P, iat, grad):1.0); -} - -WaveFunctionBase::valT WaveFunctionRef::ratio(ParticleSet &P, int iat) -{ - return ( iatratio(P, iat) : Det_dn->ratio(P, iat) ) - * J1->ratio(P, iat) - * J2->ratio(P, iat) - * (J3?J3->ratio(P, iat):1.0); -} - -void WaveFunctionRef::acceptMove(ParticleSet &P, int iat) -{ - if(iatacceptMove(P, iat); - else - Det_dn->acceptMove(P, iat); - J1->acceptMove(P, iat); - J2->acceptMove(P, iat); - if(J3) J3->acceptMove(P, iat); -} - -void WaveFunctionRef::restore(int iat) {} - -void WaveFunctionRef::evaluateGL(ParticleSet &P) -{ - constexpr valT czero(0); - P.G = czero; - P.L = czero; - Det_up->evaluateGL(P, P.G, P.L); - Det_dn->evaluateGL(P, P.G, P.L); - J1->evaluateGL(P, P.G, P.L); - J2->evaluateGL(P, P.G, P.L); - if(J3) J3->evaluateGL(P, P.G, P.L); -} -} // miniqmcreferencce