Loading...
Searching...
No Matches
RgpotPot Class Referencefinal

Potential backed by rgpot NWChemPot / CPMDPot (in-process dlopen of libnwchemc / libcpmdc). More...

#include <RgpotPot.h>

Inheritance diagram for RgpotPot:

Public Member Functions

 RgpotPot (const Parameters &p)
 ~RgpotPot () override
 RgpotPot (const RgpotPot &)=delete
RgpotPotoperator= (const RgpotPot &)=delete
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
 Whether this potential's force() can be called from multiple threads on the SAME instance.
bool requiresIsolatedMoleculeLayout () const noexcept override
 NWChem molecular SCF does not support PBC; CPMD may be periodic.
const std::string & backend () const noexcept
bool engineAvailable () const
Public Member Functions inherited from eonc::Potential
 Potential (PotType a_ptype)
 Potential (PotType a_ptype, const Parameters &)
 Potential (const Parameters &a_params)
virtual ~Potential ()
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 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.

Private Attributes

std::unique_ptr< RGPotEngineimpl_
std::string backend_

Additional Inherited Members

Public Attributes inherited from eonc::Potential
std::atomic< size_t > forceCallCounter
Protected Attributes inherited from eonc::Potential
PotType ptype

Detailed Description

Potential backed by rgpot NWChemPot / CPMDPot (in-process dlopen of libnwchemc / libcpmdc).

Not potserv RPC. Configure via [RgpotPot] INI; energy eV, forces eV/Angstrom.

Definition at line 25 of file RgpotPot.h.

Constructor & Destructor Documentation

◆ RgpotPot() [1/2]

RgpotPot::RgpotPot ( const Parameters & p)
explicit

Definition at line 13 of file RgpotPot.cpp.

15 RGPotEngineOptions opt;
16 const auto &o = p.rgpot_options;
17 opt.backend = o.backend;
18 opt.basis = o.basis;
19 opt.theory = o.theory;
20 opt.scf_type = o.scf_type;
21 opt.functional = o.functional;
22 opt.cutoff_ry = o.cutoff_ry;
23 opt.charge = o.charge;
24 opt.multiplicity = o.multiplicity;
25 opt.engine_path = o.engine_path;
26 opt.engine_library = o.engine_library;
27 opt.engine_root = o.engine_root;
28 opt.title = o.title;
29 opt.memory_mb = o.memory_mb;
30 opt.scratch_dir = o.scratch_dir;
31 opt.input_block = o.input_block;
32 opt.model_path = o.model_path;
33 opt.device = o.device;
34 opt.length_unit = o.length_unit;
35 opt.extensions_directory = o.extensions_directory;
36 opt.check_consistency = o.check_consistency;
37 opt.uncertainty_threshold = o.uncertainty_threshold;
38 opt.torch_determinism_strict = o.torch_determinism_strict;
39 opt.xtb_paramset = o.xtb_paramset;
40 opt.xtb_accuracy = o.xtb_accuracy;
41 opt.xtb_electronic_temperature = o.xtb_electronic_temperature;
42 opt.xtb_max_iterations = o.xtb_max_iterations;
43 opt.xtb_charge = o.xtb_charge;
44 opt.xtb_uhf = o.xtb_uhf;
45
46 // Env overrides (CI / benchmarks)
47 if (const char *e = std::getenv("RGPOT_BACKEND"))
48 opt.backend = e;
49 if (const char *e = std::getenv("RGPOT_NWCHEM_BASIS"))
50 opt.basis = e;
51 if (const char *e = std::getenv("RGPOT_NWCHEM_THEORY"))
52 opt.theory = e;
53 if (const char *e = std::getenv("RGPOT_NWCHEM_SCF_TYPE"))
54 opt.scf_type = e;
55 // Engine-path env overrides are backend-scoped: NWCHEMC_LIBRARY must not
56 // leak into a cpmdc configure (CPMDPot resolves CPMDC_LIBRARY itself).
57 std::string backend_lc = opt.backend;
58 std::transform(backend_lc.begin(), backend_lc.end(), backend_lc.begin(),
59 [](unsigned char c) { return std::tolower(c); });
60 if (backend_lc.rfind("nwchem", 0) == 0) {
61 if (const char *e = std::getenv("NWCHEMC_LIBRARY"))
62 opt.engine_path = e;
63 else if (const char *e = std::getenv("RGPOT_NWCHEMC_ENGINE"))
64 opt.engine_path = e;
65 } else if (backend_lc.rfind("cpmd", 0) == 0) {
66 if (const char *e = std::getenv("CPMDC_LIBRARY"))
67 opt.engine_path = e;
68 else if (const char *e = std::getenv("RGPOT_CPMDC_ENGINE"))
69 opt.engine_path = e;
70 } else if (backend_lc.rfind("meta", 0) == 0 || backend_lc == "mta") {
71 if (const char *e = std::getenv("RGPOT_METATOMIC_ENGINE"))
72 opt.engine_path = e;
73 else if (const char *e = std::getenv("METATOMIC_ENGINE"))
74 opt.engine_path = e;
75 if (const char *e = std::getenv("RGPOT_METATOMIC_MODEL"))
76 opt.model_path = e;
77 } else if (backend_lc == "xtb" || backend_lc == "xtbpot" ||
78 backend_lc == "gfn" || backend_lc == "gfnxtb") {
79 if (const char *e = std::getenv("RGPOT_XTB_ENGINE"))
80 opt.engine_path = e;
81 else if (const char *e = std::getenv("XTB_ENGINE"))
82 opt.engine_path = e;
83 if (opt.xtb_paramset.empty() || opt.xtb_paramset == "GFN2xTB") {
84 if (!p.xtb_options.paramset.empty())
86 }
87 }
88
89 // Dual-read [Metatomic] when RGPOT backend is metatomic
90 if ((backend_lc.rfind("meta", 0) == 0 || backend_lc == "mta") &&
91 opt.model_path.empty())
93 if ((backend_lc.rfind("meta", 0) == 0 || backend_lc == "mta") &&
94 opt.device == "cpu" && !p.metatomic_options.device.empty())
96
97 impl_ = std::make_unique<RGPotEngine>(opt);
98 backend_ = impl_->backend();
99 std::cout
100 << "RgpotPot: in-process rgpot backend=" << backend_
101 << " (dlopen: libnwchemc/libcpmdc/libmetatomic_engine/libxtb_engine)"
102 << std::endl;
103}
std::string backend_
Definition RgpotPot.h:46
std::unique_ptr< RGPotEngine > impl_
Definition RgpotPot.h:45
struct eonc::Parameters::xtb_options_t xtb_options
struct eonc::Parameters::rgpot_options_t rgpot_options
struct eonc::Parameters::metatomic_options_t metatomic_options
Potential(PotType a_ptype)
Definition Potential.h:35
std::string scf_type
Definition RGPotEngine.h:10
std::string title
Definition RGPotEngine.h:18
std::string xtb_paramset
Definition RGPotEngine.h:31
std::string basis
Definition RGPotEngine.h:8
std::string scratch_dir
Definition RGPotEngine.h:20
std::string engine_path
Definition RGPotEngine.h:15
std::string backend
Definition RGPotEngine.h:7
std::string extensions_directory
Definition RGPotEngine.h:26
std::string engine_library
Definition RGPotEngine.h:16
double xtb_electronic_temperature
Definition RGPotEngine.h:33
std::string functional
Definition RGPotEngine.h:11
std::string length_unit
Definition RGPotEngine.h:25
bool torch_determinism_strict
Definition RGPotEngine.h:29
std::string device
Definition RGPotEngine.h:24
std::string model_path
Definition RGPotEngine.h:23
std::string engine_root
Definition RGPotEngine.h:17
double uncertainty_threshold
Definition RGPotEngine.h:28
std::string theory
Definition RGPotEngine.h:9
std::string input_block
Definition RGPotEngine.h:21

◆ ~RgpotPot()

RgpotPot::~RgpotPot ( )
overridedefault

◆ RgpotPot() [2/2]

RgpotPot::RgpotPot ( const RgpotPot & )
delete

Member Function Documentation

◆ backend()

const std::string & RgpotPot::backend ( ) const
inlinenodiscardnoexcept

Definition at line 41 of file RgpotPot.h.

41{ return backend_; }

◆ engineAvailable()

bool RgpotPot::engineAvailable ( ) const
nodiscard

Definition at line 107 of file RgpotPot.cpp.

107{ return impl_ && impl_->available(); }

◆ force()

void RgpotPot::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 109 of file RgpotPot.cpp.

110 {
111 (void)variance;
112 impl_->force(N, R, atomicNrs, F, U, box);
113}

◆ isThreadSafe()

bool RgpotPot::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 36 of file RgpotPot.h.

36{ return false; }

◆ operator=()

RgpotPot & RgpotPot::operator= ( const RgpotPot & )
delete

◆ requiresIsolatedMoleculeLayout()

bool RgpotPot::requiresIsolatedMoleculeLayout ( ) const
inlinenodiscardoverridevirtualnoexcept

NWChem molecular SCF does not support PBC; CPMD may be periodic.

Reimplemented from eonc::Potential.

Definition at line 38 of file RgpotPot.h.

38 {
39 return backend_ == "nwchemc";
40 }

Member Data Documentation

◆ backend_

std::string RgpotPot::backend_
private

Definition at line 46 of file RgpotPot.h.

◆ impl_

std::unique_ptr<RGPotEngine> RgpotPot::impl_
private

Definition at line 45 of file RgpotPot.h.


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