Loading...
Searching...
No Matches
EffectiveMediumTheory Class Reference

EMT potential. More...

#include <EffectiveMediumTheory.h>

Inheritance diagram for EffectiveMediumTheory:

Public Member Functions

 EffectiveMediumTheory (const eonc::Parameters &p)
 ~EffectiveMediumTheory ()
void cleanMemory ()
void force (long N, const double *R, const int *atomicNrs, double *F, double *U, double *variance, const double *box)
bool isSharedInstanceThreadSafe () const noexcept override
 ASAP Atoms/EMT objects are mutated in force(); do not share one instance.
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 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 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

bool emtRasmussen {false}
long numberOfAtoms {0}
bool periodicity [3] {true, true, true}
Atoms * AtomsObj {nullptr}
EMTDefaultParameterProvider * EMTParameterObj {nullptr}
EMT * EMTObj {nullptr}
SuperCell * SuperCellObj {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

EMT potential.

Inspect the EMT_parms.h to see what the EMT potential is hardcoded to describe.

Definition at line 29 of file EffectiveMediumTheory.h.

Constructor & Destructor Documentation

◆ EffectiveMediumTheory()

EffectiveMediumTheory::EffectiveMediumTheory ( const eonc::Parameters & p)
inline

Definition at line 41 of file EffectiveMediumTheory.h.

42 : eonc::Potential(p), emtRasmussen{p.potential_options().EMTRasmussen} {}
const potential_options_t & potential_options() const

◆ ~EffectiveMediumTheory()

EffectiveMediumTheory::~EffectiveMediumTheory ( )
inline

Definition at line 43 of file EffectiveMediumTheory.h.

Member Function Documentation

◆ cleanMemory()

void EffectiveMediumTheory::cleanMemory ( )

Definition at line 18 of file EffectiveMediumTheory.cpp.

18 {
19 delete EMTObj;
20 EMTObj = nullptr;
21 delete SuperCellObj;
22 SuperCellObj = nullptr;
23 delete AtomsObj;
24 AtomsObj = nullptr;
25 delete EMTParameterObj;
26 EMTParameterObj = nullptr;
27}
EMTDefaultParameterProvider * EMTParameterObj

◆ force()

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

Implements eonc::Potential.

Definition at line 32 of file EffectiveMediumTheory.cpp.

34 {
35 variance = nullptr;
36
37 // Copy positions (Asap may modify them internally)
38 std::vector<double> pos(R, R + 3 * N);
39
40 // Reinitialize if atom count changed
41 if (numberOfAtoms != N) {
42 numberOfAtoms = N;
44
45 Vec tempBasis[3] = {
46 Vec(box[0], box[1], box[2]),
47 Vec(box[3], box[4], box[5]),
48 Vec(box[6], box[7], box[8]),
49 };
50
51 SuperCellObj = new SuperCell(tempBasis, periodicity);
52 AtomsObj = new Atoms(reinterpret_cast<Vec *>(pos.data()), N, SuperCellObj);
53
54 std::vector<int> atomicNrsTemp(atomicNrs, atomicNrs + N);
55 AtomsObj->SetAtomicNumbers(atomicNrsTemp.data());
56
57 if (emtRasmussen) {
58 EMTParameterObj = new EMTRasmussenParameterProvider();
60 } else {
61 EMTObj = new EMT(nullptr);
62 }
63 AtomsObj->SetCalculator(EMTObj);
64 }
65
66 AtomsObj->SetCartesianPositions(reinterpret_cast<Vec *>(pos.data()));
67
68 // Update the box
69 Vec tempBasis[3] = {
70 Vec(box[0], box[1], box[2]),
71 Vec(box[3], box[4], box[5]),
72 Vec(box[6], box[7], box[8]),
73 };
74 AtomsObj->SetUnitCell(tempBasis, true);
75
76 *U = EMTObj->GetPotentialEnergy();
77
78 const Vec *tempF = EMTObj->GetCartesianForces();
79 std::memcpy(F, tempF, N * sizeof(Vec));
80}

◆ isSharedInstanceThreadSafe()

bool EffectiveMediumTheory::isSharedInstanceThreadSafe ( ) const
inlinenodiscardoverridevirtualnoexcept

ASAP Atoms/EMT objects are mutated in force(); do not share one instance.

Reimplemented from eonc::Potential.

Definition at line 51 of file EffectiveMediumTheory.h.

51 {
52 return false;
53 }

Member Data Documentation

◆ AtomsObj

Atoms* EffectiveMediumTheory::AtomsObj {nullptr}
private

Definition at line 35 of file EffectiveMediumTheory.h.

35{nullptr};

◆ EMTObj

EMT* EffectiveMediumTheory::EMTObj {nullptr}
private

Definition at line 37 of file EffectiveMediumTheory.h.

37{nullptr};

◆ EMTParameterObj

EMTDefaultParameterProvider* EffectiveMediumTheory::EMTParameterObj {nullptr}
private

Definition at line 36 of file EffectiveMediumTheory.h.

36{nullptr};

◆ emtRasmussen

bool EffectiveMediumTheory::emtRasmussen {false}
private

Definition at line 32 of file EffectiveMediumTheory.h.

32{false};

◆ numberOfAtoms

long EffectiveMediumTheory::numberOfAtoms {0}
private

Definition at line 33 of file EffectiveMediumTheory.h.

33{0};

◆ periodicity

bool EffectiveMediumTheory::periodicity[3] {true, true, true}
private

Definition at line 34 of file EffectiveMediumTheory.h.

34{true, true, true};

◆ SuperCellObj

SuperCell* EffectiveMediumTheory::SuperCellObj {nullptr}
private

Definition at line 38 of file EffectiveMediumTheory.h.

38{nullptr};

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