Loading...
Searching...
No Matches
eon_relax_engine.h
Go to the documentation of this file.
1/*
2** This file is part of eOn.
3**
4** SPDX-License-Identifier: BSD-3-Clause
5**
6** Copyright (c) 2010--present, eOn Development Team
7** All rights reserved.
8**
9** Repo:
10** https://github.com/TheochemUI/eOn
11*/
49#pragma once
50
51#include <stddef.h>
52#include <stdint.h>
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58#ifdef _WIN32
59#if defined(EON_RELAX_STATIC)
60#define EON_RELAX_API
61#elif defined(EON_RELAX_ENGINE_BUILD)
62#define EON_RELAX_API __declspec(dllexport)
63#else
64#define EON_RELAX_API __declspec(dllimport)
65#endif
66#else
67#define EON_RELAX_API __attribute__((visibility("default")))
68#endif
69
71
72#define EON_RELAX_ABI_MAJOR 2u
73#define EON_RELAX_ABI_MINOR 1u
74
76typedef struct {
77 uint32_t major;
78 uint32_t minor;
80
81#define EON_RELAX_VERSION_INIT {EON_RELAX_ABI_MAJOR, EON_RELAX_ABI_MINOR}
82
88
89#define EON_RELAX_KIND_IS_KNOWN(k) \
90 ((k) == EON_RELAX_KIND_NEB || (k) == EON_RELAX_KIND_SADDLE)
91
118
127
128#define EON_RELAX_IMAGE_NONE INT64_C(-1)
129
146typedef struct {
148 uint64_t flags;
149 int64_t n_images;
150 int64_t n_atoms;
151 double *positions;
152 const int32_t *atomic_nrs;
153 const double *boxes;
154 const int32_t *is_fixed;
155 const double *mode;
156 const int64_t *image_ids;
157 const double *masses;
159
161typedef struct {
163 uint64_t flags;
164 int32_t kind;
165 int32_t status;
166 int64_t iterations;
168 double max_force;
169 uint64_t version_hash;
172
182typedef struct {
184 uint64_t flags;
185 int64_t n_images;
186 int64_t n_atoms;
187 const double *positions;
188 const int32_t *atomic_nrs;
189 const double *boxes;
190 const int64_t *image_ids;
191 double *energies;
192 double *forces;
193 double *variances;
194 uint64_t *epoch_out;
196
198typedef int (*eon_relax_surface_fn)(void *user,
200
210
220 size_t config_len, char *errbuf,
221 size_t errlen);
222
224 uint64_t epoch);
227
238 eon_relax_surface_fn surface, void *user,
240
259 eon_relax_surface_fn surface, void *user,
261
269
271
274 int status);
275
276#ifdef __cplusplus
277}
278#endif
#define EON_RELAX_API
EON_RELAX_API uint64_t eon_relax_version_hash(void)
64-bit FNV-1a hash of eon_relax_version_hash_str().
EON_RELAX_API int eon_relax_set_surface_epoch(EonRelaxEngine *eng, uint64_t epoch)
EON_RELAX_API int eon_relax_available(void)
EON_RELAX_API int eon_relax_run(EonRelaxEngine *eng, eon_relax_band_t *band, eon_relax_surface_fn surface, void *user, eon_relax_outcome_t *out)
Run the bound engine to completion.
EON_RELAX_API int eon_relax_step(EonRelaxEngine *eng, eon_relax_band_t *band, eon_relax_surface_fn surface, void *user, eon_relax_outcome_t *out)
One band optimizer step (kind=NEB only).
eon_relax_neb_status_t
NudgedElasticBand::NEBStatus integers.
@ 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_API int eon_relax_abi_stamp(eon_relax_version_t *out)
EON_RELAX_API EonRelaxEngine * eon_relax_create(const void *config, size_t config_len, char *errbuf, size_t errlen)
Create.
eon_relax_rc_t
Call rc: 0 success (read outcome), positive recoverable, negative a named fail.
@ 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
EON_RELAX_API int eon_relax_abi_version(void)
(major << 16) | minor.
EON_RELAX_API const char * eon_relax_status_name(eon_relax_kind_t kind, int status)
NULL if kind or status is unknown.
EON_RELAX_API void eon_relax_destroy(EonRelaxEngine *eng)
int(* eon_relax_surface_fn)(void *user, eon_relax_surface_request_t *req)
Return 0 on success, positive recoverable, negative fatal.
EON_RELAX_API int eon_relax_last_error(const EonRelaxEngine *eng)
Last named create/run/step/reset/set_epoch rc on this handle.
eon_relax_kind_t
@ EON_RELAX_KIND_INVALID
@ EON_RELAX_KIND_SADDLE
@ EON_RELAX_KIND_NEB
EON_RELAX_API int eon_relax_reset(EonRelaxEngine *eng)
Drop the stepper's band state and optimizer history; the next eon_relax_step reinitializes from the c...
EON_RELAX_API const char * eon_relax_version_hash_str(void)
Immortal dest identity string.
Caller-owned band.
eon_relax_version_t version
const int32_t * atomic_nrs
const double * boxes
const double * masses
const int32_t * is_fixed
const double * mode
const int64_t * image_ids
Engine-written result.
eon_relax_version_t version
Host-surface request: one struct, engine-stamped version, so the callback contract grows behind the v...
Version head carried by every wire struct (dlpack DLPackVersion).