QMCPACK
CuspCorrectionConstruction.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) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Mark Dewing, mdewing@anl.gov, Argonne National Laboratory
8 // Ye Luo, yeluo@anl.gov, Argonne National Laboratory
9 //
10 // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
11 //////////////////////////////////////////////////////////////////////////////////////
12 
13 
14 #ifndef QMCPLUSPLUS_CUSP_CORRECTION_CONSTRUCTOR_H
15 #define QMCPLUSPLUS_CUSP_CORRECTION_CONSTRUCTOR_H
16 
17 #include "LCAOrbitalSet.h"
19 #include "CuspCorrection.h"
20 
21 class Communicate;
22 namespace qmcplusplus
23 {
24 
25 class ParticleSet;
26 /// Broadcast cusp correction parameters
27 void broadcastCuspInfo(CuspCorrectionParameters& param, Communicate& Comm, int root);
28 
30 {
36  using SPOSetPtr = SPOSet*;
37 
38 public:
40  {
42  dr[0] = r;
43 
45  targetPtcl->makeMove(0, dr);
47 
48  return val1[curOrb];
49  }
50 
51  void phi_vgl(RealType r, RealType& val, GradType& grad, RealType& lap)
52  {
54  dr[0] = r;
55 
57  targetPtcl->makeMove(0, dr);
59 
60  val = val1[curOrb];
61  grad = grad1[curOrb];
62  lap = lap1[curOrb];
63  }
64 
66  : targetPtcl(targetP), sourcePtcl(sourceP), curOrb(0), curCenter(0)
67  {
68  Psi1 = Phi;
69  int norb = Psi1->getOrbitalSetSize();
70  val1.resize(norb);
71  grad1.resize(norb);
72  lap1.resize(norb);
73  }
74 
75  void changeOrbital(int centerIdx, int orbIdx)
76  {
77  curCenter = centerIdx;
78  curOrb = orbIdx;
79  }
80 
81 private:
82  /// Temporary storage for real wavefunction values
86 
87  /// target ParticleSet
89  /// source ParticleSet
91 
92  /// Index of orbital
93  int curOrb;
94 
95  /// Index of atomic center
96  int curCenter;
97 
99 };
100 
101 /// Read cusp correction parameters from XML file
102 bool readCuspInfo(const std::string& cuspInfoFile,
103  const std::string& objectName,
104  int OrbitalSetSize,
106 
107 /// save cusp correction info to a file.
108 void saveCusp(const std::string& filename, const Matrix<CuspCorrectionParameters>& info, const std::string& id);
109 
110 /// Divide molecular orbital into atomic S-orbitals on this center (phi), and everything else (eta).
111 void splitPhiEta(int center, const std::vector<bool>& corrCenter, LCAOrbitalSet& phi, LCAOrbitalSet& eta);
112 
113 /// Remove S atomic orbitals from all molecular orbitals on all centers.
114 void removeSTypeOrbitals(const std::vector<bool>& corrCenter, LCAOrbitalSet& Phi);
115 
116 /// Compute the radial part of the corrected wavefunction
117 void computeRadialPhiBar(ParticleSet* targetP,
118  ParticleSet* sourceP,
119  int curOrb_,
120  int curCenter_,
121  SPOSet* Phi,
124  const CuspCorrectionParameters& data);
125 
130 
131 /** Ideal local energy at one point
132  * @param r input radial distance
133  * @param Z nuclear charge
134  * @param beta0 adjustable parameter to make energy continuous at Rc
135  */
137 
138 /** Ideal local energy at a vector of points
139  * @param pos input vector of radial distances
140  * @param Z nuclear charge
141  * @param Rc cutoff radius where the correction meets the actual orbital
142  * @param ELorigAtRc local energy at Rc. beta0 is adjusted to make energy continuous at Rc
143  * @param ELideal - output the ideal local energy at pos values
144  */
145 void getIdealLocalEnergy(const ValueVector& pos, RealType Z, RealType Rc, RealType ELorigAtRc, ValueVector& ELideal);
146 
147 /** Evaluate various orbital quantities that enter as constraints on the correction
148  * @param valRc orbital value at Rc
149  * @param gradRc orbital gradient at Rc
150  * @param lapRc orbital laplacian at Rc
151  * @param Rc cutoff radius
152  * @param Z nuclear charge
153  * @param C offset to keep correction to a single sign
154  * @param valAtZero orbital value at zero
155  * @param eta0 value of non-corrected pieces of the orbital at zero
156  * @param X output
157  */
158 void evalX(RealType valRc,
159  GradType gradRc,
160  ValueType lapRc,
161  RealType Rc,
162  RealType Z,
163  RealType C,
164  RealType valAtZero,
165  RealType eta0,
167 
168 /** Convert constraints to polynomial parameters
169  * @param X input from evalX
170  * @param Rc cutoff radius
171  * @param alpha output the polynomial parameters for the correction
172  */
174 
175 /** Effective nuclear charge to keep effective local energy finite at zero
176  * @param Z nuclear charge
177  * @param etaAtZero value of non-S orbitals at this center
178  * @param phiBarAtZero value of corrected orbital at zero
179  */
180 RealType getZeff(RealType Z, RealType etaAtZero, RealType phiBarAtZero);
181 
183 
184 /** Compute effective local energy at vector of points
185  * @param pos input vector of radial distances
186  * @param Zeff effective charge from getZeff
187  * @param Rc cutoff radius
188  * @param originalELatRc Local energy at the center from the uncorrected orbital
189  * @param cusp cusp correction parameters
190  * @param phiMO uncorrected orbital (S-orbitals on this center only)
191  * @param ELcurr output local energy at each distance in pos
192  */
193 void getCurrentLocalEnergy(const ValueVector& pos,
194  RealType Zeff,
195  RealType Rc,
196  RealType originalELatRc,
197  CuspCorrection& cusp,
198  OneMolecularOrbital& phiMO,
199  ValueVector& ELcurr);
200 
201 /** Local energy from uncorrected orbital
202  * @param pos input vector of radial distances
203  * @param Zeff nuclear charge
204  * @param Rc cutoff radius
205  * @param phiMO uncorrected orbital (S-orbitals on this center only)
206  * @param ELorig output local energy at each distance in pos
207  *
208  * Return is value of local energy at zero. This is the value needed for subsequent computations.
209  * The routine can be called with an empty vector of positions to get just this value.
210  */
212  RealType Zeff,
213  RealType Rc,
214  OneMolecularOrbital& phiMO,
215  ValueVector& Elorig);
216 
217 /** Sum of squares difference between the current and ideal local energies
218  * This is the objective function to be minimized.
219  * @param Elcurr current local energy
220  * @param Elideal ideal local energy
221  */
222 RealType getELchi2(const ValueVector& ELcurr, const ValueVector& ELideal);
223 
224 
225 /** Minimize chi2 with respect to phi at zero for a fixed Rc
226  * @param cusp correction parameters
227  * @param phiMO uncorrected orbital (S-orbitals on this center only)
228  * @param Z nuclear charge
229  * @param eta0 value at zero for parts of the orbital that don't require correction - the non-S-orbitals on this center and all orbitals on other centers
230  * @param pos vector of radial positions
231  * @param Elcurr storage for current local energy
232  * @param Elideal storage for ideal local energy
233  */
235  OneMolecularOrbital& phiMO,
236  RealType Z,
237  RealType eta0,
238  ValueVector& pos,
239  ValueVector& ELcurr,
240  ValueVector& ELideal,
241  RealType start_phi0);
242 
243 
244 /** Minimize chi2 with respect to Rc and phi at zero.
245  * @param cusp correction parameters
246  * @param phiMO uncorrected orbital (S-orbitals on this center only)
247  * @param Z nuclear charge
248  * @param Rc_init initial value for Rc
249  * @param Rc_max maximum value for Rc
250  * @param eta0 value at zero for parts of the orbital that don't require correction - the non-S-orbitals on this center and all orbitals on other centers
251  * @param pos vector of radial positions
252  * @param Elcurr storage for current local energy
253  * @param Elideal storage for ideal local energy
254  *
255  * Output is parameter values in cusp.cparam
256  */
257 void minimizeForRc(CuspCorrection& cusp,
258  OneMolecularOrbital& phiMO,
259  RealType Z,
260  RealType Rc_init,
261  RealType Rc_max,
262  RealType eta0,
263  ValueVector& pos,
264  ValueVector& ELcurr,
265  ValueVector& ELideal);
266 
267 // Modifies orbital set lcwc
269  ParticleSet& targetPtcl,
270  ParticleSet& sourcePtcl,
271  LCAOrbitalSet& lcao,
272  SoaCuspCorrection& cusp,
273  const std::string& id);
274 
276  const ParticleSet& targetPtcl,
277  const ParticleSet& sourcePtcl,
278  const LCAOrbitalSet& lcao,
279  const std::string& id,
280  Communicate& Comm);
281 
282 } // namespace qmcplusplus
283 
284 #endif
base class for Single-particle orbital sets
Definition: SPOSet.h:46
Fixed-size array.
Definition: OhmmsTinyMeta.h:30
void minimizeForRc(CuspCorrection &cusp, OneMolecularOrbital &phiMO, RealType Z, RealType Rc_init, RealType Rc_max, RealType eta0, ValueVector &pos, ValueVector &ELcurr, ValueVector &ELideal)
Minimize chi2 with respect to Rc and phi at zero.
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
QTBase::GradType GradType
Definition: Configuration.h:62
QTBase::RealType RealType
Definition: Configuration.h:58
RealType phiBar(const CuspCorrection &cusp, RealType r, OneMolecularOrbital &phiMO)
Cusp correction parameters.
OrbitalSetTraits< ValueType >::ValueVector ValueVector
void getCurrentLocalEnergy(const ValueVector &pos, RealType Zeff, RealType Rc, RealType originalELatRc, CuspCorrection &cusp, OneMolecularOrbital &phiMO, ValueVector &ELcurr)
Compute effective local energy at vector of points.
LatticeGaussianProduct::GradType GradType
OneMolecularOrbital(ParticleSet *targetP, ParticleSet *sourceP, SPOSetPtr Phi)
void evalX(RealType valRc, GradType gradRc, ValueType lapRc, RealType Rc, RealType Z, RealType C, RealType valAtZero, RealType eta0, TinyVector< ValueType, 5 > &X)
Evaluate various orbital quantities that enter as constraints on the correction.
void saveCusp(const std::string &filename, const Matrix< CuspCorrectionParameters > &info, const std::string &id)
save cusp correction info to a file.
void broadcastCuspInfo(CuspCorrectionParameters &param, Communicate &Comm, int root)
Broadcast cusp correction parameters.
OrbitalSetTraits< ValueType >::ValueVector ValueVector
void applyCuspCorrection(const Matrix< CuspCorrectionParameters > &info, ParticleSet &targetPtcl, ParticleSet &sourcePtcl, LCAOrbitalSet &lcao, SoaCuspCorrection &cusp, const std::string &id)
bool readCuspInfo(const std::string &cuspInfoFile, const std::string &objectName, int OrbitalSetSize, Matrix< CuspCorrectionParameters > &info)
Read cusp correction parameters from XML file.
void getIdealLocalEnergy(const ValueVector &pos, RealType Z, RealType Rc, RealType ELorigAtRc, ValueVector &ELideal)
Ideal local energy at a vector of points.
Wrapping information on parallelism.
Definition: Communicate.h:68
RealType getOriginalLocalEnergy(const ValueVector &pos, RealType Zeff, RealType Rc, OneMolecularOrbital &phiMO, ValueVector &ELorig)
Local energy from uncorrected orbital.
virtual void evaluateValue(const ParticleSet &P, int iat, ValueVector &psi)=0
evaluate the values of this single-particle orbital set
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
void removeSTypeOrbitals(const std::vector< bool > &corrCenter, LCAOrbitalSet &Phi)
Remove S atomic orbitals from all molecular orbitals on all centers.
QTBase::ValueType ValueType
Definition: Configuration.h:60
void changeOrbital(int centerIdx, int orbIdx)
OrbitalSetTraits< ValueType >::GradVector GradVector
void generateCuspInfo(Matrix< CuspCorrectionParameters > &info, const ParticleSet &targetPtcl, const ParticleSet &sourcePtcl, const LCAOrbitalSet &lcao, const std::string &id, Communicate &Comm)
virtual void evaluateVGL(const ParticleSet &P, int iat, ValueVector &psi, GradVector &dpsi, ValueVector &d2psi)=0
evaluate the values, gradients and laplacians of this single-particle orbital set ...
ValueVector val1
Temporary storage for real wavefunction values.
A localized basis set derived from BasisSetBase<typename COT::ValueType>
Formulas for applying the cusp correction.
int getOrbitalSetSize() const
return the size of the orbitals
Definition: SPOSet.h:88
ParticlePos R
Position.
Definition: ParticleSet.h:79
Corrections to electron-nucleus cusp for all-electron molecular calculations.
RealType getOneIdealLocalEnergy(RealType r, RealType Z, RealType beta0)
Ideal local energy at one point.
ParticleSet * sourcePtcl
source ParticleSet
void computeRadialPhiBar(ParticleSet *targetP, ParticleSet *sourceP, int curOrb_, int curCenter_, SPOSet *Phi, Vector< QMCTraits::RealType > &xgrid, Vector< QMCTraits::RealType > &rad_orb, const CuspCorrectionParameters &data)
Compute the radial part of the corrected wavefunction.
void makeMove(Index_t iat, const SingleParticlePos &displ, bool maybe_accept=true)
move the iat-th particle to active_pos_
void X2alpha(const TinyVector< ValueType, 5 > &X, RealType Rc, TinyVector< ValueType, 5 > &alpha)
Convert constraints to polynomial parameters.
LatticeGaussianProduct::ValueType ValueType
RealType minimizeForPhiAtZero(CuspCorrection &cusp, OneMolecularOrbital &phiMO, RealType Z, RealType eta0, ValueVector &pos, ValueVector &ELcurr, ValueVector &ELideal, RealType start_phi0)
Minimize chi2 with respect to phi at zero for a fixed Rc.
class to handle linear combinations of basis orbitals used to evaluate the Dirac determinants.
Definition: LCAOrbitalSet.h:30
ParticleSet * targetPtcl
target ParticleSet
trait class to handel a set of Orbitals
void phi_vgl(RealType r, RealType &val, GradType &grad, RealType &lap)
RealType getZeff(RealType Z, RealType etaAtZero, RealType phiBarAtZero)
Effective nuclear charge to keep effective local energy finite at zero.
RealType getELchi2(const ValueVector &ELcurr, const ValueVector &ELideal)
Sum of squares difference between the current and ideal local energies This is the objective function...
void splitPhiEta(int center, const std::vector< bool > &corrCenter, LCAOrbitalSet &Phi, LCAOrbitalSet &Eta)
Divide molecular orbital into atomic S-orbitals on this center (phi), and everything else (eta)...