Loading...
Searching...
No Matches
eonc::MetatomicDynPot Class Reference

#include <MetatomicDynPot.h>

Inheritance diagram for eonc::MetatomicDynPot:

Public Member Functions

 MetatomicDynPot (const eonc::Parameters &params)
 Production: process-default MetatomicLoader::instance().
 MetatomicDynPot (const eonc::Parameters &params, IMetatomicLoader &loader)
 Test seam: injected loader, no process-default libmetatomic_pot load.
 ~MetatomicDynPot () override
void force (long nAtoms, const double *positions, const int *atomicNrs, double *forces, double *energy, double *variance, const double *box) override
bool isThreadSafe () const noexcept override
 Whether this potential's force() can be called from multiple threads on the SAME instance.
bool needsPerImageInstance () const noexcept override
 Whether NEB should create separate Potential instances per image for true parallel force evaluation.
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 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

IMetatomicLoader & loader_
EonMtaPot * m_handle {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

Definition at line 18 of file MetatomicDynPot.h.

Constructor & Destructor Documentation

◆ MetatomicDynPot() [1/2]

eonc::MetatomicDynPot::MetatomicDynPot ( const eonc::Parameters & params)
explicit

Production: process-default MetatomicLoader::instance().

Definition at line 40 of file MetatomicDynPot.cpp.

MetatomicDynPot(const eonc::Parameters &params)
Production: process-default MetatomicLoader::instance().
static MetatomicLoader & instance()
Thread-safe singleton accessor (Meyer's pattern). Does not dlopen.

◆ MetatomicDynPot() [2/2]

eonc::MetatomicDynPot::MetatomicDynPot ( const eonc::Parameters & params,
IMetatomicLoader & loader )

Test seam: injected loader, no process-default libmetatomic_pot load.

Definition at line 43 of file MetatomicDynPot.cpp.

45 : eonc::Potential(PotType::METATOMIC),
46 loader_{loader} {
47 loader_.require_loaded();
48 std::array<char, 1024> err{};
49 auto cfg = config_from_params(params);
50 m_handle = loader_.create(&cfg, err.data(), err.size());
51 if (!m_handle) {
52 throw std::runtime_error(std::string("MetatomicDynPot: create failed: ") +
53 err.data());
54 }
55}
IMetatomicLoader & loader_
static EonMtaConfig config_from_params(const Parameters &params)

◆ ~MetatomicDynPot()

eonc::MetatomicDynPot::~MetatomicDynPot ( )
override

Definition at line 57 of file MetatomicDynPot.cpp.

57 {
58 if (m_handle) {
59 loader_.destroy(m_handle);
60 m_handle = nullptr;
61 }
62}

Member Function Documentation

◆ force()

void eonc::MetatomicDynPot::force ( long nAtoms,
const double * positions,
const int * atomicNrs,
double * forces,
double * energy,
double * variance,
const double * box )
overridevirtual

Implements eonc::Potential.

Definition at line 64 of file MetatomicDynPot.cpp.

67 {
68 const int rc = loader_.force(m_handle, nAtoms, positions, atomicNrs, forces,
69 energy, variance, box);
70 if (rc != 0) {
71 throw std::runtime_error("MetatomicDynPot: eon_mta_pot_force failed rc=" +
72 std::to_string(rc));
73 }
74}

◆ isThreadSafe()

bool eonc::MetatomicDynPot::isThreadSafe ( ) const
inlinenodiscardoverridevirtualnoexcept

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.

Reimplemented from eonc::Potential.

Definition at line 30 of file MetatomicDynPot.h.

30{ return false; }

◆ needsPerImageInstance()

bool eonc::MetatomicDynPot::needsPerImageInstance ( ) const
inlinenodiscardoverridevirtualnoexcept

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).

Reimplemented from eonc::Potential.

Definition at line 31 of file MetatomicDynPot.h.

31 {
32 return false;
33 }

Member Data Documentation

◆ loader_

IMetatomicLoader& eonc::MetatomicDynPot::loader_
private

Definition at line 36 of file MetatomicDynPot.h.

◆ m_handle

EonMtaPot* eonc::MetatomicDynPot::m_handle {nullptr}
private

Definition at line 37 of file MetatomicDynPot.h.

37{nullptr};

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