QMCPACK
NaNguard Class Reference
+ Collaboration diagram for NaNguard:

Static Public Member Functions

static void checkOneParticleRatio (const PsiValue &ratio, const std::string_view info)
 check if ratio is NaN and throw an error if yes. More...
 
static void checkOneParticleGradients (const GradType &grads, const std::string_view info)
 check if any gradient component (x,y,z) is NaN and throw an error if yes. More...
 

Private Types

using PsiValue = QMCTraits::QTFull::ValueType
 
using GradType = QMCTraits::GradType
 

Detailed Description

Definition at line 21 of file NaNguard.h.

Member Typedef Documentation

◆ GradType

using GradType = QMCTraits::GradType
private

Definition at line 24 of file NaNguard.h.

◆ PsiValue

Definition at line 23 of file NaNguard.h.

Member Function Documentation

◆ checkOneParticleGradients()

void checkOneParticleGradients ( const GradType grads,
const std::string_view  info 
)
static

check if any gradient component (x,y,z) is NaN and throw an error if yes.

Parameters
gradsgradients to be checked
messageprintout to indicate what the issue is.

Definition at line 29 of file NaNguard.cpp.

References qmcplusplus::dot(), qmcplusplus::isnan(), norm(), and TinyVector< T, D >::size().

Referenced by TrialWaveFunction::calcRatioGrad(), TrialWaveFunction::calcRatioGradWithSpin(), TrialWaveFunction::evalGrad(), TrialWaveFunction::evalGradWithSpin(), TrialWaveFunction::mw_calcRatioGrad(), TrialWaveFunction::mw_evalGrad(), and qmcplusplus::TEST_CASE().

30 {
31  if (qmcplusplus::isnan(std::norm(dot(grads, grads))))
32  {
33  std::ostringstream error_message;
34  error_message << "NaNguard::checkOneParticleGradients error message: " << info << std::endl;
35  for (int i = 0; i < grads.size(); ++i)
36  if (qmcplusplus::isnan(std::norm(grads[i])))
37  error_message << " grads[" << i << "] = " << grads[i] << std::endl;
38  throw std::runtime_error(error_message.str());
39  }
40 }
double norm(const zVec &c)
Definition: VectorOps.h:118
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
bool isnan(float a)
return true if the value is NaN.
Definition: math.cpp:18

◆ checkOneParticleRatio()

void checkOneParticleRatio ( const PsiValue ratio,
const std::string_view  info 
)
static

check if ratio is NaN and throw an error if yes.

Parameters
ratiopsi ratio to be checked
messageprintout to indicate what the issue is.

Definition at line 18 of file NaNguard.cpp.

References qmcplusplus::isnan(), and norm().

Referenced by TrialWaveFunction::calcRatio(), TrialWaveFunction::calcRatioGrad(), TrialWaveFunction::calcRatioGradWithSpin(), TrialWaveFunction::mw_calcRatio(), TrialWaveFunction::mw_calcRatioGrad(), and qmcplusplus::TEST_CASE().

19 {
20  if (qmcplusplus::isnan(std::norm(ratio)))
21  {
22  std::ostringstream error_message;
23  error_message << "NaNguard::checkOneParticleRatio error message: " << info << std::endl
24  << " ratio = " << ratio << std::endl;
25  throw std::runtime_error(error_message.str());
26  }
27 }
double norm(const zVec &c)
Definition: VectorOps.h:118
bool isnan(float a)
return true if the value is NaN.
Definition: math.cpp:18

The documentation for this class was generated from the following files: