Loading...
Searching...
No Matches
eon_relax_engine.h File Reference

Tier-2 C ABI: eOn as a dlopen relaxation engine. More...

#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Classes

struct  eon_relax_version_t
struct  eon_relax_band_t
struct  eon_relax_outcome_t
struct  eon_relax_surface_request_t

Macros

#define EON_RELAX_API   __attribute__((visibility("default")))
#define EON_RELAX_ABI_MAJOR   2u
#define EON_RELAX_ABI_MINOR   1u
#define EON_RELAX_VERSION_INIT
#define EON_RELAX_KIND_IS_KNOWN(k)
#define EON_RELAX_IMAGE_NONE   INT64_C(-1)

Typedefs

typedef struct EonRelaxEngine EonRelaxEngine
typedef int(* eon_relax_surface_fn) (void *user, eon_relax_surface_request_t *req)

Enumerations

enum  eon_relax_kind_t { EON_RELAX_KIND_INVALID = 0 , EON_RELAX_KIND_NEB = 1 , EON_RELAX_KIND_SADDLE = 2 }
enum  eon_relax_rc_t {
  EON_RELAX_OK = 0 , EON_RELAX_NULL_ENGINE = -1 , EON_RELAX_NULL_BAND = -2 , EON_RELAX_NULL_SURFACE = -3 ,
  EON_RELAX_NULL_OUTCOME = -4 , EON_RELAX_NULL_POSITIONS = -5 , EON_RELAX_NULL_ATOMIC_NRS = -6 , EON_RELAX_NULL_BOXES = -7 ,
  EON_RELAX_NULL_MODE = -8 , EON_RELAX_BAND_TOO_SHORT = -9 , EON_RELAX_NATOMS = -10 , EON_RELAX_UNKNOWN_KIND = -11 ,
  EON_RELAX_UNKNOWN_STATUS = -12 , EON_RELAX_CAPNP_ROOT = -13 , EON_RELAX_SURFACE_FATAL = -15 , EON_RELAX_SADDLE_NIMAGES = -17 ,
  EON_RELAX_BAND_SIZE = -18 , EON_RELAX_ALLOC = -19 , EON_RELAX_UNAVAILABLE = -21 , EON_RELAX_INVALID_PARAMETER = -22 ,
  EON_RELAX_ABI_MISMATCH = -23
}
enum  eon_relax_neb_status_t {
  EON_RELAX_NEB_GOOD = 0 , EON_RELAX_NEB_INIT = 1 , EON_RELAX_NEB_BAD_MAX_ITERATIONS = 2 , EON_RELAX_NEB_RUNNING = 3 ,
  EON_RELAX_NEB_MAX_UNCERTAINTY = 4
}

Functions

 __attribute__ ((visibility("default"))) int eon_relax_abi_version(void)

Variables

size_t config_len
size_t char * errbuf
size_t char size_t errlen
uint64_t epoch
eon_relax_band_t * band
eon_relax_band_t eon_relax_surface_fn surface
eon_relax_band_t eon_relax_surface_fn void * user
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
int status

Detailed Description

Tier-2 C ABI: eOn as a dlopen relaxation engine.

Reverse of include/eon/potentials/Rgpot/engine_c_abi.h: the host supplies the surface (energy/forces/variance for a band), eOn owns NudgedElasticBand / MinModeSaddleSearch. Configuration is a Cap'n Proto flat-array whose root is RelaxEngineParams in schema/eon_params.capnp (NebParams / SaddleParams arms). NULL config selects Parameters NSDMI defaults and kind=NEB.

Units: positions Angstrom, energy eV, forces eV/Angstrom.

Plugin Matters use the Matter default (PBC on for a non-isolated pot). fill and endpoint dirty write positions with PBC off so the caller frame is kept (a 10 A box must not map x=-0.3 to 9.7).

Layout discipline (dlpack.h is the model):

  • Every wire struct opens with an eon_relax_version_t and a uint64 flags word. The writer stamps the version it was built against; the reader refuses a major it does not know (EON_RELAX_ABI_MISMATCH). Growth is append-only behind the version head, gated on minor.
  • Fixed-width integer types only. Never long in a wire struct.
  • The surface callback takes ONE request struct, so the callback contract can grow without a new function symbol.
  • Return values are three-valued: 0 success (read the outcome), positive recoverable, negative a named fail. SURFACE_FATAL makes the instance unusable. Every other named fail leaves the handle reusable.
  • Closed enums. Unknown kind is EON_RELAX_UNKNOWN_KIND; other unknown enumerants are EON_RELAX_INVALID_PARAMETER. Never a silent fallback.
  • Optional symbols are discovered by dlsym; absence means the operation is unsupported.

Definition in file eon_relax_engine.h.

Macro Definition Documentation

◆ EON_RELAX_ABI_MAJOR

#define EON_RELAX_ABI_MAJOR   2u

Definition at line 70 of file eon_relax_engine.h.

◆ EON_RELAX_ABI_MINOR

#define EON_RELAX_ABI_MINOR   1u

Definition at line 71 of file eon_relax_engine.h.

◆ EON_RELAX_API

#define EON_RELAX_API   __attribute__((visibility("default")))

Definition at line 65 of file eon_relax_engine.h.

◆ EON_RELAX_IMAGE_NONE

#define EON_RELAX_IMAGE_NONE   INT64_C(-1)

Definition at line 129 of file eon_relax_engine.h.

◆ EON_RELAX_KIND_IS_KNOWN

#define EON_RELAX_KIND_IS_KNOWN ( k)
Value:
@ EON_RELAX_KIND_SADDLE
@ EON_RELAX_KIND_NEB

Definition at line 90 of file eon_relax_engine.h.

90#define EON_RELAX_KIND_IS_KNOWN(k) \
91 ((k) == EON_RELAX_KIND_NEB || (k) == EON_RELAX_KIND_SADDLE)

◆ EON_RELAX_VERSION_INIT

#define EON_RELAX_VERSION_INIT
Value:
{ \
}
#define EON_RELAX_ABI_MAJOR
#define EON_RELAX_ABI_MINOR

Definition at line 79 of file eon_relax_engine.h.

79#define EON_RELAX_VERSION_INIT \
80 { \
81 EON_RELAX_ABI_MAJOR, EON_RELAX_ABI_MINOR \
82 }

Typedef Documentation

◆ eon_relax_surface_fn

typedef int(* eon_relax_surface_fn) (void *user, eon_relax_surface_request_t *req)

Return 0 on success, positive recoverable, negative fatal.

Definition at line 199 of file eon_relax_engine.h.

◆ EonRelaxEngine

Definition at line 68 of file eon_relax_engine.h.

Enumeration Type Documentation

◆ eon_relax_kind_t

Enumerator
EON_RELAX_KIND_INVALID 
EON_RELAX_KIND_NEB 
EON_RELAX_KIND_SADDLE 

Definition at line 84 of file eon_relax_engine.h.

◆ eon_relax_neb_status_t

NudgedElasticBand::NEBStatus integers. Written to outcome.status for NEB.

Enumerator
EON_RELAX_NEB_GOOD 
EON_RELAX_NEB_INIT 
EON_RELAX_NEB_BAD_MAX_ITERATIONS 
EON_RELAX_NEB_RUNNING 
EON_RELAX_NEB_MAX_UNCERTAINTY 

Definition at line 121 of file eon_relax_engine.h.

121 {
eon_relax_neb_status_t
@ EON_RELAX_NEB_GOOD
@ EON_RELAX_NEB_MAX_UNCERTAINTY
@ EON_RELAX_NEB_BAD_MAX_ITERATIONS
@ EON_RELAX_NEB_RUNNING
@ EON_RELAX_NEB_INIT

◆ eon_relax_rc_t

Call rc: 0 success (read outcome), positive recoverable, negative a named fail. SURFACE_FATAL makes the instance unusable. Every other named fail leaves the handle reusable.

Enumerator
EON_RELAX_OK 
EON_RELAX_NULL_ENGINE 
EON_RELAX_NULL_BAND 
EON_RELAX_NULL_SURFACE 
EON_RELAX_NULL_OUTCOME 
EON_RELAX_NULL_POSITIONS 
EON_RELAX_NULL_ATOMIC_NRS 
EON_RELAX_NULL_BOXES 
EON_RELAX_NULL_MODE 
EON_RELAX_BAND_TOO_SHORT 
EON_RELAX_NATOMS 
EON_RELAX_UNKNOWN_KIND 
EON_RELAX_UNKNOWN_STATUS 
EON_RELAX_CAPNP_ROOT 
EON_RELAX_SURFACE_FATAL 
EON_RELAX_SADDLE_NIMAGES 
EON_RELAX_BAND_SIZE 
EON_RELAX_ALLOC 
EON_RELAX_UNAVAILABLE 
EON_RELAX_INVALID_PARAMETER 
EON_RELAX_ABI_MISMATCH 

Definition at line 96 of file eon_relax_engine.h.

96 {
97 EON_RELAX_OK = 0,
107 EON_RELAX_NATOMS = -10,
114 EON_RELAX_ALLOC = -19,
eon_relax_rc_t
@ EON_RELAX_NULL_BAND
@ EON_RELAX_ALLOC
@ EON_RELAX_OK
@ EON_RELAX_SURFACE_FATAL
@ EON_RELAX_NULL_ENGINE
@ EON_RELAX_BAND_SIZE
@ EON_RELAX_NULL_ATOMIC_NRS
@ EON_RELAX_NULL_POSITIONS
@ EON_RELAX_NULL_BOXES
@ EON_RELAX_NULL_SURFACE
@ EON_RELAX_UNKNOWN_STATUS
@ EON_RELAX_CAPNP_ROOT
@ EON_RELAX_ABI_MISMATCH
@ EON_RELAX_UNKNOWN_KIND
@ EON_RELAX_SADDLE_NIMAGES
@ EON_RELAX_BAND_TOO_SHORT
@ EON_RELAX_NULL_OUTCOME
@ EON_RELAX_INVALID_PARAMETER
@ EON_RELAX_NATOMS
@ EON_RELAX_UNAVAILABLE
@ EON_RELAX_NULL_MODE

Function Documentation

◆ __attribute__()

__attribute__ ( (visibility("default")) )

(major << 16) | minor.

Immortal dest identity string. Never NULL.

FNV-1a 64-bit hash of eon_relax_version_hash_str(). Copied to outcome.version_hash.

Create. NULL config && config_len==0 selects Parameters NSDMI defaults and kind=NEB. A non-empty buffer is a Cap'n Proto flat-array whose root is RelaxEngineParams. kind tokens are "neb" and "saddle"; any other token fails closed (EON_RELAX_UNKNOWN_KIND). An unparseable buffer is EON_RELAX_CAPNP_ROOT. config!=NULL && config_len==0 is refused.

Last named create/run/step/reset/set_epoch rc on this handle. 0 if none.

Run the bound engine to completion. Writes updated interior coordinates into band->positions (caller-owned); endpoints stay in the caller frame. Endpoint minimization stays with the host (NudgedElasticBand::compute does not minimize endpoints). surface may not be NULL. Kind is bound at create (NULL config => NEB). Returns eon_relax_rc_t; on 0, out->status is the eOn NEB or saddle table.

One band optimizer step (kind=NEB only). The first call on a fresh or reset engine initializes the band state from the caller's positions and captures the baseline force; every call syncs band->positions in (the host may have moved images between steps), assembles NEB forces on the host surface, takes ONE optimizer step, and writes the stepped INTERIOR positions back (endpoints are the caller's and are never rewritten, so the caller's frame survives eOn's own cell wrapping). Climbing-image activation follows the engine's own trigger rule; saddle POLICY (MMF bursts, resampling, acquisition) stays with the host. outcome.status is RUNNING until convergenceForce() reaches the configured tolerance (GOOD), host variance exceeds the GP-surrogate threshold (MAX_UNCERTAINTY), or neb.max_iterations is hit (BAD_MAX_ITERATIONS). surface and user must not change across steps without an eon_relax_reset.

Drop the stepper's band state and optimizer history; the next eon_relax_step reinitializes from the caller's band. This is the host's model-update hook: quasi-Newton memory taken on one surface epoch must not survive onto the next.

NULL if kind or status is unknown.

Variable Documentation

◆ band

Definition at line 238 of file eon_relax_engine.h.

◆ config_len

size_t config_len

Definition at line 221 of file eon_relax_engine.h.

◆ epoch

uint64_t epoch

Definition at line 225 of file eon_relax_engine.h.

◆ errbuf

size_t char* errbuf

Definition at line 221 of file eon_relax_engine.h.

◆ errlen

size_t char size_t errlen

Definition at line 222 of file eon_relax_engine.h.

◆ out

◆ status

int status

Definition at line 275 of file eon_relax_engine.h.

◆ surface

Definition at line 239 of file eon_relax_engine.h.

◆ user

Definition at line 239 of file eon_relax_engine.h.