.. index:: pair: class; pot::PotentialWrapper .. _doxid-classpot_1_1_potential_wrapper: class pot::PotentialWrapper =========================== .. toctree:: :hidden: struct_pot_PotentialWrapper_RichForceTag.rst struct_pot_PotentialWrapper_dependent_false.rst Overview ~~~~~~~~ Type-erased wrapper around any potential that provides a :ref:`force() ` interface. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class PotentialWrapper { public: // typedefs typedef std::function :ref:`ForceFn`; typedef std::function :target:`ForceWithUncertaintyFn`; typedef std::function :ref:`ForceBatchFn`; typedef std::function :ref:`ForceBatchWithForceNoiseFn`; typedef std::function :ref:`ForceBatchWithUncertaintyFn`; // structs struct :ref:`RichForceTag`; template struct :ref:`dependent_false`; // construction :target:`PotentialWrapper`(:ref:`ForceFn` fn); // methods void :ref:`force`(long N, const double* R, const int* atomicNrs, double* F, double* U, double* energy_noise_rms, const double* box); void :target:`forceWithUncertainty`(long N, const double* R, const int* atomicNrs, double* F, double* U, double* energy_noise_rms, double* force_noise_rms, const double* box); bool :ref:`hasForceBatch`() const; bool :target:`hasForceBatchWithUncertainty`() const; void :target:`setForceBatch`(:ref:`ForceBatchFn` fn); void :target:`setForceBatch`(std::nullptr_t); void :target:`setForceBatch`(:ref:`ForceBatchWithForceNoiseFn` fn); void :target:`setForceBatchWithUncertainty`(:ref:`ForceBatchWithUncertaintyFn` fn); void :ref:`forceBatch`(long N, std::size_t B, const double* R, const int* atomicNrs, double* F, double* U, const double* box); void :ref:`forceBatch`(long N, std::size_t B, const double* R, const int* atomicNrs, double* F, double* U, double* V, const double* box); void :ref:`forceBatchWithUncertainty`(long N, std::size_t B, const double* R, const int* atomicNrs, double* F, double* U, double* energy_noise, double* force_noise, const double* box); static :ref:`PotentialWrapper` :target:`from_force_with_uncertainty`(:ref:`ForceWithUncertaintyFn` fn); static :ref:`PotentialWrapper` :ref:`composeGeometryAndEnergyUncertainty`(:ref:`PotentialWrapper` geometry, :ref:`PotentialWrapper` uncertainty); static :ref:`PotentialWrapper` :ref:`routeEnergyUncertaintyToForceChannel`(:ref:`PotentialWrapper` source); template static :ref:`PotentialWrapper` :ref:`from_rgpot`(RgPot& pot); template static :ref:`PotentialWrapper` :ref:`from_rgpot`(std::shared_ptr pot); static :ref:`PotentialWrapper` :ref:`from_rgpot`(std::shared_ptr pot); }; .. _details-classpot_1_1_potential_wrapper: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Type-erased wrapper around any potential that provides a :ref:`force() ` interface. Accepts a std::function with the legacy EON :ref:`force() ` signature, allowing any potential (EAM, Morse, rgpot, RPC, lambda) to be used without templates. Typedefs -------- .. index:: pair: typedef; ForceFn .. _doxid-classpot_1_1_potential_wrapper_1a98cb2477b0bb60c6c82cff45868e872f: .. ref-code-block:: cpp :class: doxyrest-title-code-block typedef std::function ForceFn The legacy force signature. The slot before the cell is the energy-noise RMS, a standard deviation in eV and not a variance; it is forwarded as the energy_noise_rms of :ref:`ForceWithUncertaintyFn ` and there is no force-noise slot. .. index:: pair: typedef; ForceBatchFn .. _doxid-classpot_1_1_potential_wrapper_1a33703e8c999a0bb2edc5b447fc074449: .. ref-code-block:: cpp :class: doxyrest-title-code-block typedef std::function ForceBatchFn Batched means: B same-composition systems, B \* 3N coordinates and forces, B energies, and one shared box. .. index:: pair: typedef; ForceBatchWithForceNoiseFn .. _doxid-classpot_1_1_potential_wrapper_1a94fc1d7243fa296d8c20105d9364a7de: .. ref-code-block:: cpp :class: doxyrest-title-code-block typedef std::function ForceBatchWithForceNoiseFn A batch with force noise and zero energy noise. .. index:: pair: typedef; ForceBatchWithUncertaintyFn .. _doxid-classpot_1_1_potential_wrapper_1a12426bbd174777ec11740fce59e1aa3a: .. ref-code-block:: cpp :class: doxyrest-title-code-block typedef std::function ForceBatchWithUncertaintyFn Both optional noise arrays use the single-call RMS conventions. Methods ------- .. index:: pair: function; force .. _doxid-classpot_1_1_potential_wrapper_1af75936b314f1c89124ad95f4d27fa455: .. ref-code-block:: cpp :class: doxyrest-title-code-block void force(long N, const double* R, const int* atomicNrs, double* F, double* U, double* energy_noise_rms, const double* box) Invoke the wrapped potential. .. index:: pair: function; hasForceBatch .. _doxid-classpot_1_1_potential_wrapper_1abcbdee4c66fe9161855b98a3298dc2f9: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool hasForceBatch() const True when the wrapped source can evaluate a same-composition batch in one call (rgpot forceBatch surface). .. index:: pair: function; forceBatch .. _doxid-classpot_1_1_potential_wrapper_1a9473bc571fcd80fd11912742f7d29408: .. ref-code-block:: cpp :class: doxyrest-title-code-block void forceBatch(long N, std::size_t B, const double* R, const int* atomicNrs, double* F, double* U, const double* box) Batched means; requires :ref:`hasForceBatch() `. .. index:: pair: function; forceBatch .. _doxid-classpot_1_1_potential_wrapper_1a652bab9e672020a43c19dbf5a1753162: .. ref-code-block:: cpp :class: doxyrest-title-code-block void forceBatch(long N, std::size_t B, const double* R, const int* atomicNrs, double* F, double* U, double* V, const double* box) Batched evaluation with optional force noise. .. index:: pair: function; forceBatchWithUncertainty .. _doxid-classpot_1_1_potential_wrapper_1a0f885e7587213f6f3d333b1b697de992: .. ref-code-block:: cpp :class: doxyrest-title-code-block void forceBatchWithUncertainty(long N, std::size_t B, const double* R, const int* atomicNrs, double* F, double* U, double* energy_noise, double* force_noise, const double* box) Preserve both noise channels, using single calls if the batch surface provides only means. .. index:: pair: function; composeGeometryAndEnergyUncertainty .. _doxid-classpot_1_1_potential_wrapper_1a222f0f0a8956aab231223500529ad6e3: .. ref-code-block:: cpp :class: doxyrest-title-code-block static :ref:`PotentialWrapper` composeGeometryAndEnergyUncertainty(:ref:`PotentialWrapper` geometry, :ref:`PotentialWrapper` uncertainty) Compose geometry output with an independent energy-uncertainty source. Energy, forces, and force noise come from ``geometry``. Energy noise is published from the second potential only after that call returns. The second potential is evaluated only when energy noise is requested; its energy and forces are discarded. .. index:: pair: function; routeEnergyUncertaintyToForceChannel .. _doxid-classpot_1_1_potential_wrapper_1abc7f75b771ad16e55239352e6c92c019: .. ref-code-block:: cpp :class: doxyrest-title-code-block static :ref:`PotentialWrapper` routeEnergyUncertaintyToForceChannel(:ref:`PotentialWrapper` source) Route a legacy scalar uncertainty into the force-noise channel. This adapts sources whose three-value interface reports a force-scale diagnostic through the legacy energy-uncertainty slot. .. index:: pair: function; from_rgpot .. _doxid-classpot_1_1_potential_wrapper_1ac9151000360431c4a3c82ce6bcd45796: .. ref-code-block:: cpp :class: doxyrest-title-code-block template static :ref:`PotentialWrapper` from_rgpot(RgPot& pot) Factory: adapt an rgpot PotentialBase subclass. Bridges rgpot's operator()(AtomMatrix, vector, box) -> (energy, AtomMatrix) to the legacy :ref:`force() ` signature. .. index:: pair: function; from_rgpot .. _doxid-classpot_1_1_potential_wrapper_1ac706f015a559ee08c993ab53bff9a71e: .. ref-code-block:: cpp :class: doxyrest-title-code-block template static :ref:`PotentialWrapper` from_rgpot(std::shared_ptr pot) Factory: adapt and own an rgpot PotentialBase subclass. Use this when the wrapper outlives the local scope that creates the rgpot instance. .. index:: pair: function; from_rgpot .. _doxid-classpot_1_1_potential_wrapper_1a99ca8ac8df9a2b0f803c84c6ae54f449: .. ref-code-block:: cpp :class: doxyrest-title-code-block static :ref:`PotentialWrapper` from_rgpot(std::shared_ptr pot) C++-only helper: wrap a virtual rgpot::PotentialBase. rgpot does not publish nanobind/pybind types, so Python cannot name this overload. C++ callers that already hold a PotentialBase use this (the caller does not need Potential.hpp in the same TU). Python from_rgpot accepts a bound PotentialBase via the nanobind trampoline, or a callable with the same operator() contract.