QMCPACK
HamiltonianRef.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) 2021 QMCPACK developers.
6 //
7 // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
8 //
9 // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "HamiltonianRef.h"
14 #include "CPU/math.hpp"
15 
16 namespace qmcplusplus
17 {
19 
21 
23  const opt_variables_type& optvars,
24  Vector<ValueType>& dlogpsi,
25  Vector<ValueType>& dhpsioverpsi)
26 {
27  FullPrecRealType LocalEnergy(0);
28  for (OperatorBase& Href : Hrefs_)
29  LocalEnergy += Href.evaluateValueAndDerivatives(P, optvars, dlogpsi, dhpsioverpsi);
30  return LocalEnergy;
31 }
32 
33 /// the same evaluate as QMCHamiltonian
35 {
36  FullPrecRealType LocalEnergy = 0.0;
37  for (int i = 0; i < Hrefs_.size(); ++i)
38  {
39  const auto LocalEnergyComponent = Hrefs_[i].get().evaluate(P);
40  if (qmcplusplus::isnan(LocalEnergyComponent))
41  APP_ABORT("HamiltonianRef::evaluate component " + Hrefs_[i].get().getName() + " returns NaN\n");
42  LocalEnergy += LocalEnergyComponent;
43  }
44  return LocalEnergy;
45 }
46 
47 } // namespace qmcplusplus
FullPrecRealType evaluate(ParticleSet &P)
the same evaluate as QMCHamiltonian
HamiltonianRef::FullPrecRealType FullPrecRealType
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
QMCTraits::FullPrecRealType FullPrecRealType
class to handle a set of variables that can be modified during optimizations
Definition: VariableSet.h:49
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
An abstract class for Local Energy operators.
Definition: OperatorBase.h:59
std::vector< std::reference_wrapper< T > > RefVector
FullPrecRealType evaluateValueAndDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)
the same evaluateValueAndDerivatives as QMCHamiltonian
HamiltonianRef(const RefVector< OperatorBase >)
const RefVector< OperatorBase > Hrefs_
collected references
bool isnan(float a)
return true if the value is NaN.
Definition: math.cpp:18