Loading...
Searching...
No Matches
eonc::SurrogatePotential Class Referenceabstract

#include <SurrogatePotential.h>

Inheritance diagram for eonc::SurrogatePotential:

Public Member Functions

 SurrogatePotential (PotType a_ptype, const Parameters &a_params)
virtual ~SurrogatePotential ()=default
bool isSurrogate () const noexcept override
 Whether this is a surrogate (GP) potential.
std::tuple< double, AtomMatrix, double > get_ef_var (const AtomMatrix pos, const VectorXi atmnrs, const Matrix3d box)
virtual void train_optimize (const MatrixXd &a_features, const MatrixXd &a_targets)=0
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 ()
virtual void force (long nAtoms, const double *positions, const int *atomicNrs, double *forces, double *energy, double *variance, const double *box)=0
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 requiresIsolatedMoleculeLayout () const noexcept
 True for molecular QM / non-PBC backends (NWChem socket, ASE ORCA/NWChem, …).
virtual bool isThreadSafe () const noexcept
 Whether this potential's force() can be called from multiple threads on the SAME instance.
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)

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

Definition at line 18 of file SurrogatePotential.h.

Constructor & Destructor Documentation

◆ SurrogatePotential()

eonc::SurrogatePotential::SurrogatePotential ( PotType a_ptype,
const Parameters & a_params )
inline

Definition at line 21 of file SurrogatePotential.h.

22 : Potential(a_ptype, a_params) {}
Potential(PotType a_ptype)
Production default: construction-scope registry, else PotRegistry::get().

◆ ~SurrogatePotential()

virtual eonc::SurrogatePotential::~SurrogatePotential ( )
virtualdefault

Member Function Documentation

◆ get_ef_var()

std::tuple< double, AtomMatrix, double > eonc::SurrogatePotential::get_ef_var ( const AtomMatrix pos,
const VectorXi atmnrs,
const Matrix3d box )

Definition at line 19 of file SurrogatePotential.cpp.

20 {
21 double energy{std::numeric_limits<double>::infinity()};
22 long nAtoms = static_cast<long>(pos.rows());
23 AtomMatrix forces{MatrixXd::Zero(nAtoms, 3)};
24 double var{0};
25 const auto n = static_cast<size_t>(nAtoms);
26 this->force(std::span<const double>(pos.data(), n * 3),
27 std::span<const int>(atmnrs.data(), n),
28 std::span<double>(forces.data(), n * 3), &energy, &var,
29 std::span<const double>(box.data(), 9));
30 return std::make_tuple(energy, forces, var);
31}
Eigen::Matrix< double, Eigen::Dynamic, 3, eOnStorageOrder > AtomMatrix
Definition Eigen.h:37
virtual void force(long nAtoms, const double *positions, const int *atomicNrs, double *forces, double *energy, double *variance, const double *box)=0

◆ isSurrogate()

bool eonc::SurrogatePotential::isSurrogate ( ) const
inlinenodiscardoverridevirtualnoexcept

Whether this is a surrogate (GP) potential.

Override in SurrogatePotential.

Reimplemented from eonc::Potential.

Definition at line 24 of file SurrogatePotential.h.

24{ return true; }

◆ train_optimize()

virtual void eonc::SurrogatePotential::train_optimize ( const MatrixXd & a_features,
const MatrixXd & a_targets )
pure virtual

Implemented in CatLearnPot.


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