Loading...
Searching...
No Matches
engine_c_abi.h
Go to the documentation of this file.
1
41#pragma once
42
43#include <stddef.h>
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49#ifdef _WIN32
50#ifdef RGPOT_ENGINE_BUILD
51#define RGPOT_ENGINE_API __declspec(dllexport)
52#else
53#define RGPOT_ENGINE_API __declspec(dllimport)
54#endif
55#else
56#define RGPOT_ENGINE_API __attribute__((visibility("default")))
57#endif
58
60
67typedef int (*rgpot_engine_coord_transform)(void *user, long nAtoms,
68 double *positions, double *box);
69
70#define RGPOT_ENGINE_ABI_VERSION 1
71
73
75
84 size_t config_len,
85 char *errbuf,
86 size_t errlen);
87
101#define RGPOT_ENGINE_GPR_GATE_MAGIC 0x47505247u /* "GRPG" */
102#define RGPOT_ENGINE_GPR_GATE_VERSION 1u
103
104typedef struct {
105 unsigned magic;
106 unsigned version;
117 unsigned long long refitTrainingRevisions;
119
121
127 const double *positions,
128 const int *atomicNrs, double *forces,
129 double *energy, double *variance,
130 const double *box,
132 void *transform_user);
133
134/* ------------------------------------------------------------------ */
135/* Optional symbols: probe with dlsym; absence means unsupported. */
136/* ------------------------------------------------------------------ */
137
149 RgpotEnginePot *pot, long nSystems, long nAtoms, const double *positions,
150 const int *atomicNrs, double *forces, double *energies, double *variances,
151 const double *boxes, rgpot_engine_coord_transform transform,
152 void *transform_user);
153
161RGPOT_ENGINE_API unsigned long long
163
172
183typedef struct {
184 void *ctx;
185 int (*oracle)(void *ctx, long nAtoms, const double *positions,
186 const int *atomicNrs, double *forces, double *energy,
187 const double *box);
189 void (*on_model_update)(void *ctx, unsigned long long model_state);
191
200 const RgpotEngineCallbacks *callbacks);
201
211 size_t msg_len, char *errbuf,
212 size_t errlen);
213
220typedef struct {
221 double cutoff;
223 int strict;
225
233 RgpotEngineNeighborOptions *opts, long capacity);
234
235#ifdef __cplusplus
236}
237#endif
RGPOT_ENGINE_API void rgpot_engine_destroy(RgpotEnginePot *pot)
rgpot_engine_acquire_reason
Why a learning engine delegated a point to the oracle.
@ RGPOT_ACQUIRE_REJECT
geometry above sigma_hi, evaluated but not incorporated
@ RGPOT_ACQUIRE_BATCH
batched acquisition sweep
@ RGPOT_ACQUIRE_CERTIFY
verifying a surrogate convergence claim
@ RGPOT_ACQUIRE_VARIANCE
predictive variance above sigma_lo
RGPOT_ENGINE_API int rgpot_engine_force_batch(RgpotEnginePot *pot, long nSystems, long nAtoms, const double *positions, const int *atomicNrs, double *forces, double *energies, double *variances, const double *boxes, rgpot_engine_coord_transform transform, void *transform_user)
Strided-uniform batched evaluation: nSystems systems sharing one composition (atomicNrs,...
RGPOT_ENGINE_API int rgpot_engine_force(RgpotEnginePot *pot, long nAtoms, const double *positions, const int *atomicNrs, double *forces, double *energy, double *variance, const double *box, rgpot_engine_coord_transform transform, void *transform_user)
Energy + forces.
RGPOT_ENGINE_API long rgpot_engine_neighbor_options(const RgpotEnginePot *pot, RgpotEngineNeighborOptions *opts, long capacity)
Writes up to capacity declarations into opts and returns the total count (call with capacity 0 to siz...
RGPOT_ENGINE_API RgpotEnginePot * rgpot_engine_create(const void *config, size_t config_len, char *errbuf, size_t errlen)
Create a potential from a Cap'n Proto flat-array message whose root struct is the engine's params arm...
#define RGPOT_ENGINE_API
RGPOT_ENGINE_API int rgpot_engine_available(void)
struct RgpotEnginePot RgpotEnginePot
RGPOT_ENGINE_API int rgpot_engine_set_callbacks(RgpotEnginePot *pot, const RgpotEngineCallbacks *callbacks)
Register host callbacks.
int(* rgpot_engine_coord_transform)(void *user, long nAtoms, double *positions, double *box)
Optional host-side transform applied by the engine to its scratch copy of (positions,...
RGPOT_ENGINE_API int rgpot_engine_hint(RgpotEnginePot *pot, const void *msg, size_t msg_len, char *errbuf, size_t errlen)
Runtime hint/tunable message: a Cap'n Proto flat-array whose root is the engine's hint arm on the sha...
RGPOT_ENGINE_API int rgpot_engine_abi_version(void)
RGPOT_ENGINE_API unsigned long long rgpot_engine_model_state(const RgpotEnginePot *pot)
Monotone model-state counter for engines with internal mutable state.
Host callbacks for learning engines.
void(* on_model_update)(void *ctx, unsigned long long model_state)
void(* on_acquire)(void *ctx, rgpot_engine_acquire_reason reason)
int(* oracle)(void *ctx, long nAtoms, const double *positions, const int *atomicNrs, double *forces, double *energy, const double *box)
unsigned magic
RGPOT_ENGINE_GPR_GATE_MAGIC.
unsigned long long refitTrainingRevisions
Refit cadence in training-set appends; zero refits at every incorporation boundary.
double sigmaLoFactor
Answer from the model below this multiple of its likelihood noise.
unsigned version
RGPOT_ENGINE_GPR_GATE_VERSION.
double sigmaHiFactor
Above this multiple the geometry is not learned from.
double certifyBelowForce
Predicted force magnitude under this (eV/Angstrom) forces a ground-truth call, so a driver's converge...
Neighbor-list declaration.
int full_list
1 full, 0 half
int strict
0: over-inclusion tolerated