.. index:: pair: class; pot::EnginePotential .. _doxid-classpot_1_1_engine_potential: class pot::EnginePotential ========================== .. toctree:: :hidden: Overview ~~~~~~~~ One instance owns one engine handle. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class EnginePotential { public: // construction :target:`EnginePotential`(const EnginePotential&); :target:`~EnginePotential`(); // methods static std::unique_ptr<:ref:`EnginePotential`> :ref:`open`(const std::string& library, const std::vector& config, std::string& err, bool torch_cuda = false, int oracle_threads = 1); static :ref:`PotentialWrapper` :ref:`wrap`(std::shared_ptr<:ref:`EnginePotential`> engine); :ref:`EnginePotential`& :target:`operator=`(const :ref:`EnginePotential`&); int :ref:`force`(long n_atoms, const double* positions, const int* atomic_nrs, const double* box, double* forces, double* energy, double* variance); bool :ref:`hasBatch`() const; int :ref:`forceBatch`(long n_systems, long n_atoms, const double* positions, const int* atomic_nrs, const double* boxes, double* forces, double* energies, double* variances); bool :ref:`hasCallbacks`() const; int :ref:`setCallbacks`(const RgpotEngineCallbacks& callbacks); bool :ref:`hasHessianChecked`() const; int :ref:`hessianChecked`(long n_atoms, const double* positions, std::size_t positions_len, const int* atomic_nrs, double* hessian_out, std::size_t hessian_len, const double* box); bool :ref:`hasHessianActionChecked`() const; int :ref:`hessianActionChecked`(long n_atoms, const double* positions, std::size_t positions_len, const int* atomic_nrs, const double* direction, std::size_t direction_len, double* hv_out, std::size_t hv_len, const double* box, unsigned long long* ops_out, double* scale_out); bool :ref:`hasPredictionSupportedChecked`() const; int :ref:`predictionSupportedChecked`(long n_atoms, const double* positions, std::size_t positions_len, const int* atomic_nrs, const double* box, int* supported_out); bool :ref:`hasGprStats`() const; int :ref:`gprStats`(:ref:`RgpotEngineGprStats`& stats_out) const; unsigned long long :ref:`modelState`() const; int :ref:`hint`(const std::vector& message, std::string& err); :ref:`EngineAbiStamp` :ref:`abiStamp`() const; int :ref:`caps`(:ref:`EngineCaps`& out, std::string& err); int :ref:`hvp`(long n_atoms, const double* positions, const int* atomic_nrs, const double* direction, double* hv_out, const double* box, std::string& err); int :ref:`taylorJet`(long n_systems, long n_atoms, const double* positions, const int* atomic_nrs, const double* directions, long order, double* jet_out, :ref:`EngineDerivativeReport`* report, const double* boxes, std::string& err); int :ref:`setCache`(const char* path, std::string& err); int :ref:`cacheCounts`(std::uint64_t& computed, std::uint64_t& served, std::string& err); std::string :ref:`lastError`() const; bool :ref:`unloadSafe`() const; int :target:`abiVersion`() const; int :ref:`threadCount`() const; void :target:`setThreadCount`(int threads); const std::string& :target:`library`() const; const std::string& :ref:`resolvedPath`() const; bool :ref:`dead`() const; }; .. _details-classpot_1_1_engine_potential: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ One instance owns one engine handle. ``:ref:`caps() `.reentrancy`` says whether the plugin allows concurrent calls on that handle. This host still uses one handle from one thread; a caller that evaluates from several threads opens one instance per thread. Methods ------- .. index:: pair: function; open .. _doxid-classpot_1_1_engine_potential_1a5f5e20cecd3684093470469570b32823: .. ref-code-block:: cpp :class: doxyrest-title-code-block static std::unique_ptr<:ref:`EnginePotential`> open(const std::string& library, const std::vector& config, std::string& err, bool torch_cuda = false, int oracle_threads = 1) .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - library - path or soname handed to dlopen (RTLD_LOCAL). * - config - capnp flat-array message for the engine's params arm. * - err - failure detail when construction returns nullptr. * - torch_cuda - the engine evaluates on a CUDA device: load the libtorch_cuda runtime next to the libtorch_cpu the engine brought in before the engine is created. A torch engine links libtorch_cpu only, and the CUDA hooks register when libtorch_cuda is loaded. * - oracle_threads - Evaluation thread count; at least one. .. index:: pair: function; wrap .. _doxid-classpot_1_1_engine_potential_1a48dd3298bf9d133e67eeb4fe63018ad6: .. ref-code-block:: cpp :class: doxyrest-title-code-block static :ref:`PotentialWrapper` wrap(std::shared_ptr<:ref:`EnginePotential`> engine) Adapt a shared engine handle to the host's potential interface. Positive statuses throw :ref:`EngineError `; negative statuses mark the handle dead and throw as well. .. index:: pair: function; force .. _doxid-classpot_1_1_engine_potential_1a424ca7af54d6b87b557ae4673c6ec5f6: .. ref-code-block:: cpp :class: doxyrest-title-code-block int force(long n_atoms, const double* positions, const int* atomic_nrs, const double* box, double* forces, double* energy, double* variance) Energy and forces for one system. Returns the engine status; zero is success. ``variance`` may be null. .. index:: pair: function; hasBatch .. _doxid-classpot_1_1_engine_potential_1a3f3fd93729ad02833b9a6780657ed77a: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool hasBatch() const True when the engine exports ``:ref:`rgpot_engine_force_batch ```. .. index:: pair: function; forceBatch .. _doxid-classpot_1_1_engine_potential_1ae8af0a0d1ebc09bdf0b32b3204049d3f: .. ref-code-block:: cpp :class: doxyrest-title-code-block int forceBatch(long n_systems, long n_atoms, const double* positions, const int* atomic_nrs, const double* boxes, double* forces, double* energies, double* variances) Strided-uniform batch: ``n_systems`` systems of one composition. ``boxes`` holds 9 doubles per system. .. index:: pair: function; hasCallbacks .. _doxid-classpot_1_1_engine_potential_1a9b4177cb4eec537bef116e61985003c1: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool hasCallbacks() const True when the engine exports ``:ref:`rgpot_engine_set_callbacks ```. .. index:: pair: function; setCallbacks .. _doxid-classpot_1_1_engine_potential_1a8ef54b2b361ca6cb7b7701f6fa72a8e6: .. ref-code-block:: cpp :class: doxyrest-title-code-block int setCallbacks(const RgpotEngineCallbacks& callbacks) Register host callbacks for a learning engine. .. index:: pair: function; hasHessianChecked .. _doxid-classpot_1_1_engine_potential_1afc8ed7beb82ec64f045c4a7b141c77ba: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool hasHessianChecked() const True when the engine exports ``:ref:`rgpot_engine_hessian_checked ```. .. index:: pair: function; hessianChecked .. _doxid-classpot_1_1_engine_potential_1a0656317e7b9a019f0f68c8c8032b8b40: .. ref-code-block:: cpp :class: doxyrest-title-code-block int hessianChecked(long n_atoms, const double* positions, std::size_t positions_len, const int* atomic_nrs, double* hessian_out, std::size_t hessian_len, const double* box) Extent-checked dense Hessian at one geometry. .. index:: pair: function; hasHessianActionChecked .. _doxid-classpot_1_1_engine_potential_1a75a9bfbf97a4c4e108ba7a5752e33649: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool hasHessianActionChecked() const True when the engine exports ``:ref:`rgpot_engine_hessian_action_checked ```. .. index:: pair: function; hessianActionChecked .. _doxid-classpot_1_1_engine_potential_1a9d3dd6292da77e68ddf2ef3342b5a838: .. ref-code-block:: cpp :class: doxyrest-title-code-block int hessianActionChecked(long n_atoms, const double* positions, std::size_t positions_len, const int* atomic_nrs, const double* direction, std::size_t direction_len, double* hv_out, std::size_t hv_len, const double* box, unsigned long long* ops_out, double* scale_out) Extent-checked Hessian-vector product with optional operation accounting. .. index:: pair: function; hasPredictionSupportedChecked .. _doxid-classpot_1_1_engine_potential_1af3bd9458623ae2a01c3fd38d0b527aeb: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool hasPredictionSupportedChecked() const True when the engine exports ``:ref:`rgpot_engine_prediction_supported_checked ```. .. index:: pair: function; predictionSupportedChecked .. _doxid-classpot_1_1_engine_potential_1ab87ebc7e57c6928cc7776e5945c453c9: .. ref-code-block:: cpp :class: doxyrest-title-code-block int predictionSupportedChecked(long n_atoms, const double* positions, std::size_t positions_len, const int* atomic_nrs, const double* box, int* supported_out) Extent-checked prediction-support query. .. index:: pair: function; hasGprStats .. _doxid-classpot_1_1_engine_potential_1a7f3923db228d47372690437f6b599e2a: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool hasGprStats() const True when the engine exports ``:ref:`rgpot_engine_gpr_stats ```. .. index:: pair: function; gprStats .. _doxid-classpot_1_1_engine_potential_1a20137b7630197e8e4ac40cf452b4d507: .. ref-code-block:: cpp :class: doxyrest-title-code-block int gprStats(:ref:`RgpotEngineGprStats`& stats_out) const Read learning-engine operation counters. .. index:: pair: function; modelState .. _doxid-classpot_1_1_engine_potential_1ae0b50de6537158b86e475bce6568cb8c: .. ref-code-block:: cpp :class: doxyrest-title-code-block unsigned long long modelState() const Monotone model-state counter; zero for an engine without one. .. index:: pair: function; hint .. _doxid-classpot_1_1_engine_potential_1acb57b682ea0187de27ad3fe4561f5eca: .. ref-code-block:: cpp :class: doxyrest-title-code-block int hint(const std::vector& message, std::string& err) Send a runtime hint message; returns the engine status, or -1 when the engine exports no hint entry point. .. index:: pair: function; abiStamp .. _doxid-classpot_1_1_engine_potential_1aa2b658e9f4d548060642a1fb2d6c235b: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`EngineAbiStamp` abiStamp() const The stamp the plugin reported, or {1, 0, 1} when it exports none. .. index:: pair: function; caps .. _doxid-classpot_1_1_engine_potential_1a6d91d780f4f2a3df90994bcf3963680e: .. ref-code-block:: cpp :class: doxyrest-title-code-block int caps(:ref:`EngineCaps`& out, std::string& err) ``:ref:`rgpot_engine_caps ```. Returns 3 when the plugin exports no caps symbol. ``jet_order`` is zero when the written size ends before that field. .. index:: pair: function; hvp .. _doxid-classpot_1_1_engine_potential_1aa22bba748251c60f55386ad6ce4e37e6: .. ref-code-block:: cpp :class: doxyrest-title-code-block int hvp(long n_atoms, const double* positions, const int* atomic_nrs, const double* direction, double* hv_out, const double* box, std::string& err) Analytic Hessian-vector product. Returns 3 when the plugin does not export ``:ref:`rgpot_engine_hvp ``` or ``:ref:`rgpot_engine_caps ```, or when ``analytic_hvp`` is clear. A negative status marks the handle dead. .. index:: pair: function; taylorJet .. _doxid-classpot_1_1_engine_potential_1aa32fe9a30b8f962632a8511b99a93ef5: .. ref-code-block:: cpp :class: doxyrest-title-code-block int taylorJet(long n_systems, long n_atoms, const double* positions, const int* atomic_nrs, const double* directions, long order, double* jet_out, :ref:`EngineDerivativeReport`* report, const double* boxes, std::string& err) Directional derivatives of the gradient up to ``order``, one uniform batch. Returns 3 when the plugin exports no jet or caps symbol, or when ``order`` exceeds ``jet_order``. A non-finite position, direction or cell, an order below 1, and a negative or non-finite report scale are status 1 and do not replace ``report``. Inputs and output must not overlap. .. index:: pair: function; setCache .. _doxid-classpot_1_1_engine_potential_1a270e59f3858e4b219cceed304fc4d8c6: .. ref-code-block:: cpp :class: doxyrest-title-code-block int setCache(const char* path, std::string& err) Attach a persistent result cache, or detach it when ``path`` is null. Returns 3 when the plugin exports no ``rgpot_engine_set_cache``. .. index:: pair: function; cacheCounts .. _doxid-classpot_1_1_engine_potential_1a87407f817379baf4d4769a4b295b53fc: .. ref-code-block:: cpp :class: doxyrest-title-code-block int cacheCounts(std::uint64_t& computed, std::uint64_t& served, std::string& err) Kernel-computed and cache-served counts since the cache was attached. Returns 3 when the plugin exports no query, or when none is attached. .. index:: pair: function; lastError .. _doxid-classpot_1_1_engine_potential_1a0083f2b02c613b0e05be371ccec090df: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::string lastError() const Text of ``:ref:`rgpot_engine_last_error ```, or empty when the plugin exports none or there is no message. .. index:: pair: function; unloadSafe .. _doxid-classpot_1_1_engine_potential_1a0aa711bab817a9c21d5d28f45d357dbd: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool unloadSafe() const True only when the stamp minor is at least 7 and ``rgpot_engine_unload_policy`` returns ``RGPOT_ENGINE_UNLOAD_SAFE``. .. index:: pair: function; threadCount .. _doxid-classpot_1_1_engine_potential_1ace8e0db9598c792f0dae35e54bf45313: .. ref-code-block:: cpp :class: doxyrest-title-code-block int threadCount() const OpenMP team requested explicitly by the host for every engine call. .. index:: pair: function; resolvedPath .. _doxid-classpot_1_1_engine_potential_1a14da9432108af62f1208ed54514593d4: .. ref-code-block:: cpp :class: doxyrest-title-code-block const std::string& resolvedPath() const Absolute path of the loaded object, from the dynamic loader. .. index:: pair: function; dead .. _doxid-classpot_1_1_engine_potential_1ad5df511e6b3729b2fd69490c55c56e3a: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool dead() const True once a negative status was returned: the handle is unusable.