Loading...
Searching...
No Matches
Potential Class Referenceabstract

#include <Potential.h>

Inheritance diagram for Potential:

Public Member Functions

 Potential (PotType a_ptype)
 Potential (PotType a_ptype, const Parameters &)
 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
std::tuple< double, AtomMatrixget_ef (const AtomMatrix &pos, const VectorXi &atmnrs, const Matrix3d &box)
PotType getType () const
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 bool isThreadSafe () const noexcept
 Whether this potential's force() can be called from multiple threads on the SAME instance.
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 bool supportsBatchEvaluation () const noexcept
 Whether this potential supports batched evaluation of 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)
 Evaluate forces for N systems in a single call.

Public Attributes

std::atomic< size_t > forceCallCounter

Protected Attributes

PotType ptype

Private Attributes

uint64_t m_registry_id
PotRegistry::TimePoint m_created_at

Detailed Description

Definition at line 23 of file Potential.h.

Constructor & Destructor Documentation

◆ Potential() [1/3]

eonc::Potential::Potential ( PotType a_ptype)
inlineexplicit

Definition at line 35 of file Potential.h.

36 : ptype{a_ptype},
38 m_created_at{PotRegistry::Clock::now()},
std::atomic< size_t > forceCallCounter
Definition Potential.h:32
uint64_t m_registry_id
Definition Potential.h:28
PotRegistry::TimePoint m_created_at
Definition Potential.h:29
PotType ptype
Definition Potential.h:25
uint64_t on_created(PotType t) noexcept
static PotRegistry & get() noexcept
Process-lifetime singleton.

◆ Potential() [2/3]

eonc::Potential::Potential ( PotType a_ptype,
const Parameters &  )
inline

Definition at line 42 of file Potential.h.

43 : Potential(a_ptype) {}
Potential(PotType a_ptype)
Definition Potential.h:35

◆ Potential() [3/3]

eonc::Potential::Potential ( const Parameters & a_params)
inline

Definition at line 45 of file Potential.h.

struct eonc::Parameters::potential_options_t potential_options

◆ ~Potential()

virtual eonc::Potential::~Potential ( )
inlinevirtual

Definition at line 48 of file Potential.h.

48 {
51 }
void on_destroyed(uint64_t id, PotType t, size_t force_calls, TimePoint created_at)

Member Function Documentation

◆ force()

virtual void eonc::Potential::force ( long nAtoms,
const double * positions,
const int * atomicNrs,
double * forces,
double * energy,
double * variance,
const double * box )
pure virtual

◆ forceBatch()

virtual void eonc::Potential::forceBatch ( long nSystems,
long nAtoms,
const double *const * positions,
const int *const * atomicNrs,
double *const * forces,
double * energies,
double * variances,
const double *const * boxes )
inlinevirtual

Evaluate forces for N systems in a single call.

Default: loops over force(). Override in potentials that support native batching (e.g. MetatomicPotential uses a single model.forward() for all N systems).

Definition at line 108 of file Potential.h.

112 {
113 for (long i = 0; i < nSystems; i++) {
114 double var = 0;
115 force(nAtoms, positions[i], atomicNrs[i], forces[i], &energies[i], &var,
116 boxes[i]);
117 if (variances)
118 variances[i] = var;
121 }
122 }
void on_force_call(PotType t) noexcept
virtual void force(long nAtoms, const double *positions, const int *atomicNrs, double *forces, double *energy, double *variance, const double *box)=0

◆ get_ef()

std::tuple< double, AtomMatrix > Potential::get_ef ( const AtomMatrix & pos,
const VectorXi & atmnrs,
const Matrix3d & box )

Definition at line 102 of file Potential.cpp.

104 {
105 double energy{std::numeric_limits<double>::infinity()};
106 long nAtoms = static_cast<long>(pos.rows());
107 AtomMatrix forces{MatrixXd::Zero(nAtoms, 3)};
108 double var{0}; // no variance for true potentials
109 this->force(nAtoms, pos.data(), atmnrs.data(), forces.data(), &energy, &var,
110 box.data());
113
114 return std::make_tuple(energy, forces);
115}
Eigen::Matrix< double, Eigen::Dynamic, 3, eOnStorageOrder > AtomMatrix
Definition Eigen.h:37

◆ getType()

PotType eonc::Potential::getType ( ) const
inlinenodiscard

Definition at line 62 of file Potential.h.

62{ return this->ptype; }

◆ isSharedInstanceThreadSafe()

virtual bool eonc::Potential::isSharedInstanceThreadSafe ( ) const
inlinenodiscardvirtualnoexcept

Conservative gate for sharing one Potential instance across threads.

Defaults to isThreadSafe(); backends whose state lives outside the wrapper instance (global/common-block Fortran entry points) override this to false on their own classes.

Definition at line 85 of file Potential.h.

85 {
86 return isThreadSafe();
87 }
virtual bool isThreadSafe() const noexcept
Whether this potential's force() can be called from multiple threads on the SAME instance.
Definition Potential.h:79

◆ isSurrogate()

virtual bool eonc::Potential::isSurrogate ( ) const
inlinenodiscardvirtualnoexcept

Whether this is a surrogate (GP) potential.

Override in SurrogatePotential.

Definition at line 66 of file Potential.h.

66{ return false; }

◆ isThreadSafe()

virtual bool eonc::Potential::isThreadSafe ( ) const
inlinenodiscardvirtualnoexcept

Whether this potential's force() can be called from multiple threads on the SAME instance.

Python-based potentials return false. Potentials with internal mutex (MetatomicPotential) return true but serialize internally – use needsPerImageInstance() to check if separate instances would enable true parallelism.

Definition at line 79 of file Potential.h.

79{ return true; }

◆ needsPerImageInstance()

virtual bool eonc::Potential::needsPerImageInstance ( ) const
inlinenodiscardvirtualnoexcept

Whether NEB should create separate Potential instances per image for true parallel force evaluation.

When true, NEB calls makePotential() once per image instead of sharing one instance. Override in potentials that use internal mutexes (e.g. MetatomicPotential).

Definition at line 94 of file Potential.h.

94 {
95 return false;
96 }

◆ requiresIsolatedMoleculeLayout()

virtual bool eonc::Potential::requiresIsolatedMoleculeLayout ( ) const
inlinenodiscardvirtualnoexcept

True for molecular QM / non-PBC backends (NWChem socket, ASE ORCA/NWChem, …).

Callers must not apply periodic wraps that can tear molecules (#188).

Definition at line 70 of file Potential.h.

70 {
71 return false;
72 }

◆ supportsBatchEvaluation()

virtual bool eonc::Potential::supportsBatchEvaluation ( ) const
inlinenodiscardvirtualnoexcept

Whether this potential supports batched evaluation of N systems in a single call.

When true, callers (NEB, Dimer) should use forceBatch() instead of N individual force() calls for better GPU utilization.

Definition at line 101 of file Potential.h.

101 {
102 return false;
103 }

Member Data Documentation

◆ forceCallCounter

std::atomic<size_t> eonc::Potential::forceCallCounter

Definition at line 32 of file Potential.h.

◆ m_created_at

◆ m_registry_id

Definition at line 28 of file Potential.h.

◆ ptype

Definition at line 25 of file Potential.h.


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