QMCPACK
BareKineticEnergy.cpp
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: Ken Esler, kpesler@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
9 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
10 // Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory
11 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
12 //
13 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
14 //////////////////////////////////////////////////////////////////////////////////////
15 
16 
17 #include "BareKineticEnergy.h"
18 #include "Particle/ParticleSet.h"
20 #include "BareKineticHelper.h"
25 
26 namespace qmcplusplus
27 {
30 
32 {
33  MultiWalkerResource() : Resource("BareKineticEnergy") {}
34 
35  std::unique_ptr<Resource> makeClone() const override { return std::make_unique<MultiWalkerResource>(*this); }
36 
39 };
40 
41 /** constructor with particleset
42  * @param target particleset
43  *
44  * Store mass per species and use SameMass to choose the methods.
45  * if SameMass, probably faster and easy to vectorize but no impact on the performance.
46  */
48 {
51  update_mode_.set(OPTIMIZABLE, 1);
52  SpeciesSet& tspecies(p.getSpeciesSet());
53  minus_over_2m_.resize(tspecies.size());
54  int massind = tspecies.addAttribute("mass");
55  same_mass_ = true;
56  particle_mass_ = tspecies(massind, 0);
58  for (int i = 0; i < tspecies.size(); ++i)
59  {
60  same_mass_ &= (std::abs(tspecies(massind, i) - particle_mass_) < 1e-6);
61  minus_over_2m_[i] = -1.0 / (2.0 * tspecies(massind, i));
62  }
63 }
64 
65 ///destructor
67 
68 bool BareKineticEnergy::dependsOnWaveFunction() const { return true; }
69 
70 std::string BareKineticEnergy::getClassName() const { return "BareKineticEnergy"; }
71 
73 
74 #if !defined(REMOVE_TRACEMANAGER)
76 {
78  request_.contribute_array(name_ + "_complex");
79  request_.contribute_array("momentum");
80 }
81 
83 {
85  request_.streaming_array("momentum");
87  {
88  t_sample_ = tm.checkout_real<1>(name_, ps_);
89  t_sample_comp_ = tm.checkout_complex<1>(name_ + "_complex", ps_);
90  p_sample_ = tm.checkout_complex<2>("momentum", ps_, DIM);
91  }
92 }
93 
95 {
97  {
98  delete t_sample_;
99  delete t_sample_comp_;
100  delete p_sample_;
101  }
102 }
103 #endif
104 
105 
107 {
108 #if !defined(REMOVE_TRACEMANAGER)
110  {
111  value_ = evaluate_sp(P);
112  }
113  else
114 #endif
115  if (same_mass_)
116  {
117 #ifdef QMC_COMPLEX
118  value_ = std::real(CplxDot(P.G, P.G) + CplxSum(P.L));
119  value_ *= -one_over_2m_;
120 #else
121  value_ = Dot(P.G, P.G) + Sum(P.L);
122  value_ *= -one_over_2m_;
123 #endif
124  }
125  else
126  {
127  value_ = 0.0;
128  for (int i = 0; i < minus_over_2m_.size(); ++i)
129  {
130  Return_t x = 0.0;
131  for (int j = P.first(i); j < P.last(i); ++j)
132  x += laplacian(P.G[j], P.L[j]);
133  value_ += x * minus_over_2m_[i];
134  }
135  }
136  return value_;
137 }
138 
140  const opt_variables_type& optvars,
141  const Vector<ValueType>& dlogpsi,
142  Vector<ValueType>& dhpsioverpsi)
143 {
144  // const_cast is needed because TWF::evaluateDerivatives calculates dlogpsi.
145  // KineticEnergy must be the first element in the hamiltonian array.
146  psi_.evaluateDerivatives(P, optvars, const_cast<Vector<ValueType>&>(dlogpsi), dhpsioverpsi);
147  return evaluate(P);
148 }
149 
151  const RefVectorWithLeader<ParticleSet>& p_list,
152  const opt_variables_type& optvars,
153  const RecordArray<ValueType>& dlogpsi,
154  RecordArray<ValueType>& dhpsioverpsi) const
155 {
157  for (int i = 0; i < o_list.size(); i++)
158  wf_list.push_back(o_list.getCastedElement<BareKineticEnergy>(i).psi_);
159  mw_evaluate(o_list, wf_list, p_list);
160  // const_cast is needed because TWF::evaluateDerivatives calculates dlogpsi.
161  // KineticEnergy must be the first element in the hamiltonian array.
163  const_cast<RecordArray<ValueType>&>(dlogpsi), dhpsioverpsi);
164 }
165 
166 /**@brief Function to compute the value, direct ionic gradient terms, and pulay terms for the local kinetic energy.
167  *
168  * This general function represents the OperatorBase interface for computing. For an operator \hat{O}, this
169  * function will return \frac{\hat{O}\Psi_T}{\Psi_T}, \frac{\partial(\hat{O})\Psi_T}{\Psi_T}, and
170  * \frac{\hat{O}\partial\Psi_T}{\Psi_T} - \frac{\hat{O}\Psi_T}{\Psi_T}\frac{\partial \Psi_T}{\Psi_T}. These are
171  * referred to as Value, HF term, and pulay term respectively.
172  *
173  * @param P electron particle set.
174  * @param ions ion particle set
175  * @param psi Trial wave function object.
176  * @param hf_terms 3Nion dimensional object. All direct force terms, or ionic gradient of operator itself.
177  * Contribution of this operator is ADDED onto hf_terms.
178  * @param pulay_terms The terms coming from ionic gradients of trial wavefunction. Contribution of this operator is
179  * ADDED onto pulay_terms.
180  * @return Value of kinetic energy operator at electron/ion positions given by P and ions. The force contributions from
181  * this operator are added into hf_terms and pulay_terms.
182  */
184  ParticleSet& ions,
185  TrialWaveFunction& psi,
186  ParticleSet::ParticlePos& hf_terms,
187  ParticleSet::ParticlePos& pulay_terms)
188 {
189  using ParticlePos = ParticleSet::ParticlePos;
190  using ParticleGradient = ParticleSet::ParticleGradient;
191  using ParticleLaplacian = ParticleSet::ParticleLaplacian;
192 
193  int Nions = ions.getTotalNum();
194  int Nelec = P.getTotalNum();
195 
196  //These are intermediate arrays for potentially complex math.
197  ParticleLaplacian term2_(Nelec);
198  ParticleGradient term4_(Nelec);
199 
200  //Potentially complex temporary array for \partial \psi/\psi and \nabla^2 \partial \psi / \psi
201  ParticleGradient iongradpsi_(Nions), pulaytmp_(Nions);
202  //temporary arrays that will be explicitly real.
203  ParticlePos pulaytmpreal_(Nions), iongradpsireal_(Nions);
204 
205 
208 
209  for (int iondim = 0; iondim < OHMMS_DIM; iondim++)
210  {
211  iongrad_grad_[iondim].resize(Nelec);
212  iongrad_lapl_[iondim].resize(Nelec);
213  }
214 
215  iongradpsi_ = 0;
216  iongradpsireal_ = 0;
217  pulaytmpreal_ = 0;
218  pulaytmp_ = 0;
219 
220  RealType logpsi_ = psi.evaluateLog(P);
221  for (int iat = 0; iat < Nions; iat++)
222  {
223  //reset the iongrad_X containers.
224  for (int iondim = 0; iondim < OHMMS_DIM; iondim++)
225  {
226  iongrad_grad_[iondim] = 0;
227  iongrad_lapl_[iondim] = 0;
228  }
229  iongradpsi_[iat] = psi.evalGradSource(P, ions, iat, iongrad_grad_, iongrad_lapl_);
230  //conversion from potentially complex to definitely real.
231  convertToReal(iongradpsi_[iat], iongradpsireal_[iat]);
232  if (same_mass_)
233  {
234  for (int iondim = 0; iondim < OHMMS_DIM; iondim++)
235  {
236  //These term[24]_ variables exist because I want to do complex math first, and then take the real part at the
237  //end. Sum() and Dot() perform the needed functions and spit out the real part at the end.
238  term2_ = P.L * iongradpsi_[iat][iondim];
239  term4_ = P.G * iongradpsi_[iat][iondim];
240  pulaytmp_[iat][iondim] = -one_over_2m_ *
241  (Sum(iongrad_lapl_[iondim]) + Sum(term2_) + 2.0 * Dot(iongrad_grad_[iondim], P.G) + Dot(P.G, term4_));
242  }
243  }
244  else
245  {
246  for (int iondim = 0; iondim < OHMMS_DIM; iondim++)
247  {
248  for (int g = 0; g < minus_over_2m_.size(); g++)
249  {
250  for (int iel = P.first(g); iel < P.last(g); iel++)
251  {
252  pulaytmp_[iat][iondim] += minus_over_2m_[g] *
253  (dlaplacian(P.G[iel], P.L[iel], iongrad_grad_[iondim][iel], iongrad_lapl_[iondim][iel],
254  iongradpsi_[iat][iondim]));
255  }
256  }
257  }
258  }
259  convertToReal(pulaytmp_[iat], pulaytmpreal_[iat]);
260  }
261 
262  if (same_mass_)
263  {
264  value_ = Dot(P.G, P.G) + Sum(P.L);
265  value_ *= -one_over_2m_;
266  }
267  else
268  {
269  value_ = 0.0;
270  for (int i = 0; i < minus_over_2m_.size(); ++i)
271  {
272  Return_t x = 0.0;
273  for (int j = P.first(i); j < P.last(i); ++j)
274  x += laplacian(P.G[j], P.L[j]);
275  value_ += x * minus_over_2m_[i];
276  }
277  }
278  pulaytmpreal_ -= value_ * iongradpsireal_;
279 
280 
281  pulay_terms += pulaytmpreal_;
282  return value_;
283 }
284 
286  const TWFFastDerivWrapper& psi,
287  std::vector<ValueMatrix>& B)
288 {
291 
292  const IndexType nelec = P.getTotalNum();
293  G.resize(nelec);
294  L.resize(nelec);
295 
296  const IndexType ngroups = P.groups();
297  assert(B.size() == ngroups);
298  std::vector<ValueMatrix> M;
299  std::vector<GradMatrix> grad_M;
300  std::vector<ValueMatrix> lapl_M;
301  std::vector<ValueMatrix> gradJdotgradPhi;
302  for (int ig = 0; ig < ngroups; ig++)
303  {
304  const IndexType sid = psi.getTWFGroupIndex(ig);
305  const IndexType norbs = psi.numOrbitals(sid);
306  const IndexType first = P.first(ig);
307  const IndexType last = P.last(ig);
308  const IndexType nptcls = last - first;
309  ValueMatrix zeromat;
310  GradMatrix zerogradmat;
311 
312  zeromat.resize(nptcls, norbs);
313  zerogradmat.resize(nptcls, norbs);
314 
315  M.push_back(zeromat);
316  grad_M.push_back(zerogradmat);
317  lapl_M.push_back(zeromat);
318  gradJdotgradPhi.push_back(zeromat);
319  }
320 
321  psi.getEGradELaplM(P, M, grad_M, lapl_M);
322  psi.evaluateJastrowVGL(P, G, L);
323 
324  for (int ig = 0; ig < ngroups; ig++)
325  {
326  const IndexType sid = psi.getTWFGroupIndex(ig);
327  const IndexType norbs = psi.numOrbitals(sid);
328  const IndexType first = P.first(ig);
329  const IndexType last = P.last(ig);
330  const IndexType nptcls = last - first;
331  for (int iel = first; iel < last; iel++)
332  {
333  for (int iorb = 0; iorb < norbs; iorb++)
334  {
335  gradJdotgradPhi[sid][iel - first][iorb] = RealType(2.0) * dot(GradType(G[iel]), grad_M[sid][iel - first][iorb]);
336  B[sid][iel - first][iorb] += RealType(minus_over_2m_[ig]) *
337  (lapl_M[sid][iel - first][iorb] + gradJdotgradPhi[sid][iel - first][iorb] +
338  ValueType(L[iel] + dot(G[iel], G[iel])) * M[sid][iel - first][iorb]);
339  }
340  }
341  }
342 }
343 
345  ParticleSet& source,
346  const TWFFastDerivWrapper& psi,
347  const int iat,
348  std::vector<std::vector<ValueMatrix>>& Bforce)
349 {
350  const IndexType ngroups = P.groups();
351  const IndexType nelec = P.getTotalNum();
352 
355  Gtmp.resize(nelec);
356  G.resize(nelec);
357  Ltmp.resize(nelec);
358  L.resize(nelec);
359 
360  std::vector<ValueMatrix> M;
361  std::vector<GradMatrix> grad_M;
362  std::vector<ValueMatrix> lapl_M;
363 
366 
367  for (int dim = 0; dim < OHMMS_DIM; dim++)
368  {
369  dG[dim] = Gtmp;
370  dL[dim] = Ltmp;
371  }
372 
373  assert(Bforce.size() == OHMMS_DIM);
374  assert(Bforce[0].size() == ngroups);
375  std::vector<ValueMatrix> mtmp;
376  for (int ig = 0; ig < ngroups; ig++)
377  {
378  const IndexType sid = psi.getTWFGroupIndex(ig);
379  const IndexType norbs = psi.numOrbitals(sid);
380  const IndexType first = P.first(ig);
381  const IndexType last = P.last(ig);
382  const IndexType nptcls = last - first;
383 
384  ValueMatrix zeromat;
385  GradMatrix zerogradmat;
386 
387  zeromat.resize(nptcls, norbs);
388  zerogradmat.resize(nptcls, norbs);
389 
390  mtmp.push_back(zeromat);
391  M.push_back(zeromat);
392  grad_M.push_back(zerogradmat);
393  lapl_M.push_back(zeromat);
394  }
395 
396 
397  std::vector<std::vector<ValueMatrix>> dm, dlapl;
398  std::vector<std::vector<GradMatrix>> dgmat;
399  dm.push_back(mtmp);
400  dm.push_back(mtmp);
401  dm.push_back(mtmp);
402 
403  dlapl.push_back(mtmp);
404  dlapl.push_back(mtmp);
405  dlapl.push_back(mtmp);
406 
407  dgmat.push_back(grad_M);
408  dgmat.push_back(grad_M);
409  dgmat.push_back(grad_M);
410 
411  psi.getEGradELaplM(P, M, grad_M, lapl_M);
412  psi.getIonGradIonGradELaplM(P, source, iat, dm, dgmat, dlapl);
413  psi.evaluateJastrowVGL(P, G, L);
414  psi.evaluateJastrowGradSource(P, source, iat, dG, dL);
415  for (int idim = 0; idim < OHMMS_DIM; idim++)
416  for (int ig = 0; ig < ngroups; ig++)
417  {
418  const IndexType sid = psi.getTWFGroupIndex(ig);
419  const IndexType norbs = psi.numOrbitals(sid);
420  const IndexType first = P.first(ig);
421  const IndexType last = P.last(ig);
422  const IndexType nptcls = last - first;
423 
424  for (int iel = first; iel < last; iel++)
425  {
426  for (int iorb = 0; iorb < norbs; iorb++)
427  {
428  Bforce[idim][sid][iel - first][iorb] = RealType(minus_over_2m_[ig]) *
429  (dlapl[idim][sid][iel - first][iorb] +
430  RealType(2.0) *
431  (dot(GradType(G[iel]), dgmat[idim][sid][iel - first][iorb]) +
432  dot(GradType(dG[idim][iel]), grad_M[sid][iel - first][iorb])) +
433  M[sid][iel - first][iorb] * ValueType(dL[idim][iel] + 2.0 * dot(dG[idim][iel], G[iel])) +
434  ValueType(L[iel] + dot(G[iel], G[iel])) * dm[idim][sid][iel - first][iorb]);
435  }
436  }
437  }
438 }
439 
441 {
442  auto new_res = std::make_unique<MultiWalkerResource>();
443  auto resource_index = collection.addResource(std::move(new_res));
444 }
445 
447  const RefVectorWithLeader<OperatorBase>& o_list) const
448 {
449  auto& O_leader = o_list.getCastedLeader<BareKineticEnergy>();
450  O_leader.mw_res_ = collection.lendResource<MultiWalkerResource>();
451 }
452 
454  const RefVectorWithLeader<OperatorBase>& o_list) const
455 {
456  auto& O_leader = o_list.getCastedLeader<BareKineticEnergy>();
457  collection.takebackResource(O_leader.mw_res_);
458 }
459 
462  const RefVectorWithLeader<ParticleSet>& p_list,
463  const std::vector<ListenerVector<RealType>>& listeners,
464  const std::vector<ListenerVector<RealType>>& ion_listeners) const
465 {
466  auto& o_leader = o_list.getCastedLeader<BareKineticEnergy>();
467  auto& p_leader = p_list.getLeader();
468  assert(this == &o_list.getLeader());
469 
470  auto num_particles = p_leader.getTotalNum();
471  auto& name = o_leader.name_;
472  Vector<RealType>& t_samp = o_leader.mw_res_.getResource().t_samples;
473  Vector<std::complex<RealType>>& tcmp_samp = o_leader.mw_res_.getResource().tcmp_samples;
474 
475  auto num_species = p_leader.getSpeciesSet().getTotalNum();
476  t_samp.resize(num_particles);
477  tcmp_samp.resize(num_particles);
478  const RealType clambda(-one_over_2m_);
479  auto evaluate_walker_per_particle = [num_particles, name, &t_samp, &tcmp_samp,
480  clambda](const int walker_index, const BareKineticEnergy& bke,
481  const ParticleSet& pset,
482  const std::vector<ListenerVector<RealType>>& listeners) {
483  RealType value = 0;
484  std::fill(t_samp.begin(), t_samp.end(), 0.0);
485  std::fill(tcmp_samp.begin(), tcmp_samp.end(), 0.0);
486 
487  std::complex<RealType> t1 = 0.0;
488  if (bke.same_mass_)
489  for (int i = 0; i < num_particles; i++)
490  {
491  t1 = pset.L[i] + dot(pset.G[i], pset.G[i]);
492  t1 = clambda * t1;
493  t_samp[i] = real(t1);
494  tcmp_samp[i] = t1;
495  value += real(t1);
496  }
497  else
498  {
499  for (int s = 0; s < bke.minus_over_2m_.size(); ++s)
500  {
501  FullPrecRealType mlambda = bke.minus_over_2m_[s];
502  for (int i = pset.first(s); i < pset.last(s); ++i)
503  {
504  t1 = pset.L[i] + dot(pset.G[i], pset.G[i]);
505  t1 *= mlambda;
506  t_samp[i] = real(t1);
507  tcmp_samp[i] = t1;
508  value += real(t1);
509  }
510  }
511  }
512  for (auto& listener : listeners)
513  {
514  listener.report(walker_index, name, t_samp);
515  }
516  return value;
517  };
518 
519  for (int iw = 0; iw < o_list.size(); iw++)
520  {
521  auto& bare_kinetic_energy = o_list.getCastedElement<BareKineticEnergy>(iw);
522  bare_kinetic_energy.value_ = evaluate_walker_per_particle(iw, bare_kinetic_energy, p_list[iw], listeners);
523  }
524 }
525 
527  const RefVectorWithLeader<OperatorBase>& o_list,
529  const RefVectorWithLeader<ParticleSet>& p_list,
530  const std::vector<ListenerVector<RealType>>& listeners,
531  const std::vector<ListenerVector<RealType>>& ion_listeners) const
532 {
533  mw_evaluatePerParticle(o_list, wf_list, p_list, listeners, ion_listeners);
534 }
535 
536 #if !defined(REMOVE_TRACEMANAGER)
538 {
539  Array<RealType, 1>& T_samp = *t_sample_;
540  Array<std::complex<RealType>, 1>& T_samp_comp = *t_sample_comp_;
542  std::complex<RealType> t1 = 0.0;
543  const RealType clambda(-one_over_2m_);
544  value_ = 0.0;
545  if (same_mass_)
546  {
547  for (int i = 0; i < P.getTotalNum(); i++)
548  {
549  t1 = P.L[i] + dot(P.G[i], P.G[i]);
550  t1 = clambda * t1;
551  T_samp(i) = real(t1);
552  T_samp_comp(i) = t1;
553  for (int d = 0; d < DIM; ++d)
554  p_samp(i, d) = P.G[i][d];
555  value_ += real(t1);
556  }
557  }
558  else
559  {
560  for (int s = 0; s < minus_over_2m_.size(); ++s)
561  {
562  FullPrecRealType mlambda = minus_over_2m_[s];
563  for (int i = P.first(s); i < P.last(s); ++i)
564  {
565  t1 = P.L[i] + dot(P.G[i], P.G[i]);
566  t1 *= mlambda;
567  T_samp(i) = real(t1);
568  T_samp_comp(i) = t1;
569  for (int d = 0; d < DIM; ++d)
570  p_samp(i, d) = P.G[i][d];
571  value_ += real(t1);
572  }
573  }
574  }
575 #if defined(TRACE_CHECK)
576  RealType Vnow = value_;
577  RealType Vsum = T_samp.sum();
578  RealType Vold = evaluate_orig(P);
579  if (std::abs(Vsum - Vnow) > TraceManager::trace_tol)
580  {
581  app_log() << "accumtest: BareKineticEnergy::evaluate()" << std::endl;
582  app_log() << "accumtest: tot:" << Vnow << std::endl;
583  app_log() << "accumtest: sum:" << Vsum << std::endl;
584  APP_ABORT("Trace check failed");
585  }
586  if (std::abs(Vold - Vnow) > TraceManager::trace_tol)
587  {
588  app_log() << "versiontest: BareKineticEnergy::evaluate()" << std::endl;
589  app_log() << "versiontest: orig:" << Vold << std::endl;
590  app_log() << "versiontest: mod:" << Vnow << std::endl;
591  APP_ABORT("Trace check failed");
592  }
593 #endif
594  return value_;
595 }
596 
597 #endif
598 
600 {
601  if (same_mass_)
602  {
603  value_ = Dot(P.G, P.G) + Sum(P.L);
604  value_ *= -one_over_2m_;
605  }
606  else
607  {
608  value_ = 0.0;
609  for (int i = 0; i < minus_over_2m_.size(); ++i)
610  {
611  Return_t x = 0.0;
612  for (int j = P.first(i); j < P.last(i); ++j)
613  x += laplacian(P.G[j], P.L[j]);
614  value_ += x * minus_over_2m_[i];
615  }
616  }
617  return value_;
618 }
619 
620 /** implements the virtual function.
621  *
622  * Nothing is done but should check the mass
623  */
624 bool BareKineticEnergy::put(xmlNodePtr) { return true; }
625 
626 bool BareKineticEnergy::get(std::ostream& os) const
627 {
628  os << "Kinetic energy";
629  return true;
630 }
631 
632 std::unique_ptr<OperatorBase> BareKineticEnergy::makeClone(ParticleSet& qp, TrialWaveFunction& psi)
633 {
634  return std::make_unique<BareKineticEnergy>(qp, psi);
635 }
636 
637 } // namespace qmcplusplus
~BareKineticEnergy() override
destructor
virtual void mw_evaluate(const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list) const
Evaluate the contribution of this component of multiple walkers.
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
HamiltonianRef::FullPrecRealType FullPrecRealType
T Sum(const ParticleAttrib< T > &pa)
Fixed-size array.
Definition: OhmmsTinyMeta.h:30
size_t addResource(std::unique_ptr< Resource > &&res, bool noprint=false)
Array< TraceComp, D > * checkout_complex(const std::string &name, int n1=1, int n2=0, int n3=0, int n4=0)
void takebackResource(ResourceHandle< RS > &res_handle)
std::complex< T > CplxDot(const ParticleAttrib< TinyVector< std::complex< T >, D >> &pa, const ParticleAttrib< TinyVector< std::complex< T >, D >> &pb)
QMCTraits::RealType real
std::unique_ptr< Resource > makeClone() const override
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
QTBase::GradType GradType
Definition: Configuration.h:62
bool dependsOnWaveFunction() const override
return true if this operator depends on a wavefunction
bool streaming_array(const std::string &name)
Definition: TraceManager.h:249
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)
evaluate derivatives of KE wrt optimizable varibles
QTBase::RealType RealType
Definition: Configuration.h:58
T dlaplacian(const TinyVector< T, D > &g, const T l, const TinyVector< T, D > &gg, const T gl, const T ideriv)
Convenience function to compute .
void resetTargetParticleSet(ParticleSet &p) override
Reset the data with the target ParticleSet.
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
Return_t evaluate_orig(ParticleSet &P)
FullPrecRealType particle_mass_
mass of the particle
size_t getTotalNum() const
Definition: ParticleSet.h:493
std::ostream & app_log()
Definition: OutputManager.h:65
std::unique_ptr< OperatorBase > makeClone(ParticleSet &qp, TrialWaveFunction &psi) final
void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const override
acquire a shared resource from a collection
void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const override
return a shared resource to a collection
std::complex< T > CplxSum(const ParticleAttrib< std::complex< T >> &pa)
void convertToReal(const T1 &in, T2 &out)
generic conversion from type T1 to type T2 using implicit conversion
Definition: ConvertToReal.h:32
Declaration of OperatorBase.
std::string getClassName() const override
return class name
GradType evaluateJastrowGradSource(ParticleSet &P, ParticleSet &source, const int iat) const
Return ionic gradient of J(r).
An object of this type is a listener expecting a callback to the report function with a vector of val...
Definition: Listener.hpp:38
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
SPOSet::GradMatrix GradMatrix
Definition: OperatorBase.h:69
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
void evaluateOneBodyOpMatrixForceDeriv(ParticleSet &P, ParticleSet &source, const TWFFastDerivWrapper &psi, const int iat, std::vector< std::vector< ValueMatrix >> &Bforce) override
Evaluate "dB/dR" matrices for observable.
Return_t evaluateWithIonDerivs(ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_terms, ParticleSet::ParticlePos &pulay_terms) override
Function to compute the value, direct ionic gradient terms, and pulay terms for the local kinetic ene...
int first(int igroup) const
return the first index of a group i
Definition: ParticleSet.h:514
void getEGradELaplM(const ParticleSet &P, std::vector< ValueMatrix > &mvec, std::vector< GradMatrix > &gmat, std::vector< ValueMatrix > &lmat) const
Returns value, gradient, and laplacian matrices for all orbitals and all particles, species by species.
IndexType numOrbitals(const IndexType sid) const
Attaches a unit to a Vector for IO.
ParticleLaplacian L
laplacians of the particles
Definition: ParticleSet.h:85
TWFFastDerivWrapper is a wrapper class for TrialWavefunction that provides separate and low level acc...
#define OHMMS_DIM
Definition: config.h:64
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
TraceRequest request_
whether traces are being collected
Definition: OperatorBase.h:531
int groups() const
return the number of groups
Definition: ParticleSet.h:511
std::string name_
name of this object
Definition: OperatorBase.h:527
bool same_mass_
true, if all the species have the same mass
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
void evaluateOneBodyOpMatrix(ParticleSet &P, const TWFFastDerivWrapper &psi, std::vector< ValueMatrix > &B) override
Evaluate "B" matrix for observable.
WalkerProperties::Indexes WP
Definition: ParticleSet.cpp:34
void createResource(ResourceCollection &collection) const override
initialize a shared resource and hand it to a collection
QTBase::ValueType ValueType
Definition: Configuration.h:60
static void mw_evaluateParameterDerivatives(const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, const opt_variables_type &optvars, RecordArray< ValueType > &dlogpsi, RecordArray< ValueType > &dhpsioverpsi)
ParticleGradient G
gradients of the particles
Definition: ParticleSet.h:83
void oneBodyQuantumDomain(const ParticleSet &P)
set quantum domain for one-body operator
CASTTYPE & getCastedElement(size_t i) const
SPOSet::ValueMatrix ValueMatrix
For fast derivative evaluation.
Definition: OperatorBase.h:68
Array< TraceComp, 1 > * t_sample_comp_
class to handle a set of variables that can be modified during optimizations
Definition: VariableSet.h:49
GradType evalGradSource(ParticleSet &P, ParticleSet &source, int iat)
Returns the logarithmic gradient of the trial wave function with respect to the iat^th atom of the so...
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
void checkoutParticleQuantities(TraceManager &tm) override
int last(int igroup) const
return the last index of a group i
Definition: ParticleSet.h:517
void setEnergyDomain(EnergyDomains edomain)
Set the Energy Domain.
T laplacian(const TinyVector< T, D > &g, T l)
compute real(laplacian)
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65
bool get(std::ostream &os) const override
write about the class
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
Definition: ParticleSet.h:231
Array< TraceReal, D > * checkout_real(const std::string &name, int n1=1, int n2=0, int n3=0, int n4=0)
Declaration of a TrialWaveFunction.
Return_t evaluateValueAndDerivatives(ParticleSet &P, const opt_variables_type &optvars, const Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
FullPrecRealType Return_t
type of return value of evaluate
Definition: OperatorBase.h:64
Type_t sum() const
Definition: OhmmsArray.h:214
Array< TraceComp, 2 > * p_sample_
void mw_evaluatePerParticleWithToperator(const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< ListenerVector< RealType >> &listeners, const std::vector< ListenerVector< RealType >> &ion_listeners) const override
For BareKineticEnergy since it does override any Toperator evals this needs to decay to mw_evaluatePe...
BareKineticEnergy(ParticleSet &p, TrialWaveFunction &psi)
constructor with particleset
ResourceHandle< MultiWalkerResource > mw_res_
Class to represent a many-body trial wave function.
Return_t evaluate(ParticleSet &P) override
Evaluate the local energy contribution of this component.
Return_t value_
current value
Definition: OperatorBase.h:524
Indexes
an enum denoting index of physical properties
ParticleAttrib< SingleParticlePos > ParticlePos
Definition: Configuration.h:92
void contribute_array(const std::string &name, bool default_quantity=false)
Definition: TraceManager.h:198
void getIonGradIonGradELaplM(const ParticleSet &P, const ParticleSet &source, int iat, std::vector< std::vector< ValueMatrix >> &dmvec, std::vector< std::vector< GradMatrix >> &dgmat, std::vector< std::vector< ValueMatrix >> &dlmat) const
Returns x,y,z components of ion gradient of slater matrices and their laplacians. ...
std::vector< FullPrecRealType > minus_over_2m_
minus_over_2m_[i] = for the ith species
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
bool put(xmlNodePtr) override
implements the virtual function.
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95
ResourceHandle< RS > lendResource()
IndexType getTWFGroupIndex(const IndexType gid) const
Takes particle set groupID and returns the TWF internal index for it.
Custom container for set of attributes for a set of species.
Definition: SpeciesSet.h:33
void mw_evaluatePerParticle(const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< ListenerVector< RealType >> &listeners, const std::vector< ListenerVector< RealType >> &ion_listeners) const override
Evaluate the contribution of this component for multiple walkers reporting to registered listeners fr...
void contributeParticleQuantities() override
double B(double x, int k, int i, const std::vector< double > &t)
RealType evaluateJastrowVGL(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
Evaluates value, gradient, and laplacian of the total jastrow.
void mw_evaluateWithParameterDerivatives(const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< ParticleSet > &p_list, const opt_variables_type &optvars, const RecordArray< ValueType > &dlogpsi, RecordArray< ValueType > &dhpsioverpsi) const override
std::bitset< 8 > update_mode_
set the current update mode
Definition: OperatorBase.h:521
BareKineticEnergy::Return_t Return_t
Return_t evaluate_sp(ParticleSet &P)
Evaluate the kinetic energy with a single mass.
Array< TraceReal, 1 > * t_sample_