Loading...
Searching...
No Matches
GPRPotential Class Reference

Template to use if user want to provide potential. More...

#include <GPRPotential.h>

Inheritance diagram for GPRPotential:

Public Member Functions

 GPRPotential (const eonc::Parameters &p)
void registerGPRObject (gpr::GaussianProcessRegression *_gpr_model)
void initialize ()
void cleanMemory ()
void force (long N, const double *R, const int *atomicNrs, double *F, double *U, double *variance, const double *box) override
bool isThreadSafe () const noexcept override
 The registered model is shared mutable state.
Public Member Functions inherited from eonc::Potential
 Potential (PotType a_ptype)
 Production default: construction-scope registry, else PotRegistry::get().
 Potential (PotType a_ptype, IPotRegistry &registry)
 Test seam: injected registry, no process-default get() counters.
 Potential (PotType a_ptype, const Parameters &p)
 Potential (const Parameters &a_params)
virtual ~Potential ()
void force (std::span< const double > positions, std::span< const int > atomicNrs, std::span< double > forces, double *energy, double *variance, std::span< const double > box)
 C++ call site: size-checked view over the raw FFI force().
virtual void setFixedMask (long nAtoms, const double *isFixed)
 Optional frozen-atom mask (nAtoms*3, 1.0 = fixed).
std::tuple< double, AtomMatrix > get_ef (const AtomMatrix &pos, const VectorXi &atmnrs, const Matrix3d &box)
PotType getType () const
virtual double finiteCutoff () const noexcept
 Finite interaction range in position length units.
virtual bool isSurrogate () const noexcept
 Whether this is a surrogate (GP) potential.
virtual bool requiresIsolatedMoleculeLayout () const noexcept
 True for molecular QM / non-PBC backends (NWChem socket, ASE ORCA/NWChem, …).
virtual unsigned layoutFlags () const noexcept
virtual bool isSharedInstanceThreadSafe () const noexcept
 Conservative gate for sharing one Potential instance across threads.
virtual bool needsPerImageInstance () const noexcept
 Whether NEB should create separate Potential instances per image for true parallel force evaluation.
virtual std::shared_ptr< Potential > clonePotential () const
 Independent instance that does not reload from disk.
virtual bool supportsBatchEvaluation () const noexcept
 Whether this potential supports batched evaluation of N systems in a single call.
virtual bool computesStress () const noexcept
 True when force() leaves a Cauchy stress that cauchyStress() can read until the next force() on this instance.
virtual Matrix3d cauchyStress () const
 Cauchy stress in eV/Angstrom^3.
virtual void forceBatchOwned (long nSystems, long nAtoms, const double *const *positions, const int *const *atomicNrs, double *const *forces, double *energies, double *variances, const double *const *boxes, const long *owners)
 Evaluate forces for N systems in a single call.
virtual void forceBatch (long nSystems, long nAtoms, const double *const *positions, const int *const *atomicNrs, double *const *forces, double *energies, double *variances, const double *const *boxes)

Private Attributes

gpr::GaussianProcessRegression * gpr_model {nullptr}

Additional Inherited Members

Public Types inherited from eonc::Potential
enum class  PotLayout : unsigned { InProcess = 1u << 0 , NeedsWorkingDirectory = 1u << 1 , Subprocess = 1u << 2 }
 How the pot is executed. Combine with bitwise or. More...
Public Attributes inherited from eonc::Potential
std::atomic< size_t > forceCallCounter
Protected Attributes inherited from eonc::Potential
PotType ptype

Detailed Description

Template to use if user want to provide potential.

Definition at line 18 of file GPRPotential.h.

Constructor & Destructor Documentation

◆ GPRPotential()

GPRPotential::GPRPotential ( const eonc::Parameters & p)

Definition at line 19 of file GPRPotential.cpp.

20 : eonc::Potential(eonc::PotType::GPR, p) {}

Member Function Documentation

◆ cleanMemory()

void GPRPotential::cleanMemory ( )

Definition at line 29 of file GPRPotential.cpp.

29{}

◆ force()

void GPRPotential::force ( long N,
const double * R,
const int * atomicNrs,
double * F,
double * U,
double * variance,
const double * box )
overridevirtual

Implements eonc::Potential.

Definition at line 34 of file GPRPotential.cpp.

36 {
37 (void)atomicNrs;
38 (void)box;
39 if (variance != nullptr) {
40 *variance = 0.0;
41 }
42 if (gpr_model == nullptr) {
43 throw std::runtime_error("GPRPotential: no GPR model registered");
44 }
45 gpr::Observation observation;
46
47 // Copy R points. Note, R should correspond to the moving atoms only.
48 observation.R.resize(1, N * 3);
49 for (int i = 0; i < N; i++) {
50 observation.R.set(i, {R[3 * i], R[3 * i + 1], R[3 * i + 2]});
51 }
52
53 // Note, the following functions should be called before calling for
54 // gpr_model->calculatePotential() gpr_model->decomposeCovarianceMatrix(R,
55 // ind) - takes covariance matrix and vector of repetitive indices
56 // gpr_model->calculateMeanPrediction() - takes a vector of combined energy
57 // and force gpr_model->calculatePosteriorMeanPrediction() - no arguments
58 gpr_model->calculatePotential(observation);
59
60 for (int i = 0; i < N; i++) {
61 F[3 * i] = observation.G[3 * i];
62 F[3 * i + 1] = observation.G[3 * i + 1];
63 F[3 * i + 2] = observation.G[3 * i + 2];
64 }
65
66 if (observation.E.size() < 1) {
67 throw std::runtime_error("GPRPotential: empty energy from GPR model");
68 }
69 *U = observation.E[0];
70}
gpr::GaussianProcessRegression * gpr_model

◆ initialize()

void GPRPotential::initialize ( )

Definition at line 27 of file GPRPotential.cpp.

27{}

◆ isThreadSafe()

bool GPRPotential::isThreadSafe ( ) const
inlinenodiscardoverridevirtualnoexcept

The registered model is shared mutable state.

Reimplemented from eonc::Potential.

Definition at line 37 of file GPRPotential.h.

37{ return false; }

◆ registerGPRObject()

void GPRPotential::registerGPRObject ( gpr::GaussianProcessRegression * _gpr_model)

Definition at line 22 of file GPRPotential.cpp.

23 {
24 gpr_model = _gpr_model;
25}

Member Data Documentation

◆ gpr_model

gpr::GaussianProcessRegression* GPRPotential::gpr_model {nullptr}
private

Definition at line 21 of file GPRPotential.h.

21{nullptr};

The documentation for this class was generated from the following files:
  • /home/runner/work/eOn/eOn/include/eon/potentials/GPRPotential/GPRPotential.h
  • /home/runner/work/eOn/eOn/client/potentials/GPRPotential/GPRPotential.cpp