Loading...
Searching...
No Matches
gpr::capi::Potential Class Reference

#include <gpr/capi/gpridge.hpp>

Public Member Functions

 Potential ()=default
 Potential (gpr_potential_t h, adopt_t) noexcept
 Potential (gpr_potential_t h, borrow_t) noexcept
 ~Potential ()
 Potential (const Potential &)=delete
Potential & operator= (const Potential &)=delete
 Potential (Potential &&other) noexcept
Potential & operator= (Potential &&other) noexcept
void reset () noexcept
gpr_potential_t release () noexcept
bool owns () const noexcept
gpr_potential_t handle () const noexcept
 operator bool () const noexcept
void force (long n_atoms, const double *R, const int *atomic_nrs, double *F, double *energy, double *energy_noise_rms=nullptr, const double *box=nullptr) const
void force_with_uncertainty (long n_atoms, const double *R, const int *atomic_nrs, double *F, double *energy, double *energy_noise_rms=nullptr, double *force_noise_rms=nullptr, const double *box=nullptr) const

Static Public Member Functions

static Potential from_force (gpr_force_fn fn, void *user_data=nullptr)
static Potential from_force_with_uncertainty (gpr_force_with_uncertainty_fn fn, void *user_data=nullptr)

Detailed Description

Definition at line 1365 of file gpridge.hpp.

Constructor & Destructor Documentation

◆ Potential() [1/5]

gpr::capi::Potential::Potential ( )
default

◆ Potential() [2/5]

gpr::capi::Potential::Potential ( gpr_potential_t h,
adopt_t  )
inlinenoexcept

Definition at line 1368 of file gpridge.hpp.

1368: handle_(h), owns_(true) { }

◆ Potential() [3/5]

gpr::capi::Potential::Potential ( gpr_potential_t h,
borrow_t  )
inlinenoexcept

Definition at line 1369 of file gpridge.hpp.

1369 : handle_(h), owns_(false)
1370 {
1371 }

◆ ~Potential()

gpr::capi::Potential::~Potential ( )
inline

Definition at line 1372 of file gpridge.hpp.

1373 {
1374 reset();
1375 }
void reset() noexcept
Definition gpridge.hpp:1414

◆ Potential() [4/5]

gpr::capi::Potential::Potential ( const Potential & )
delete

◆ Potential() [5/5]

gpr::capi::Potential::Potential ( Potential && other)
inlinenoexcept

Definition at line 1379 of file gpridge.hpp.

1380 : handle_(other.handle_), owns_(other.owns_)
1381 {
1382 other.handle_ = nullptr;
1383 other.owns_ = false;
1384 }

Member Function Documentation

◆ force()

void gpr::capi::Potential::force ( long n_atoms,
const double * R,
const int * atomic_nrs,
double * F,
double * energy,
double * energy_noise_rms = nullptr,
const double * box = nullptr ) const
inline

Definition at line 1444 of file gpridge.hpp.

1447 {
1448 const double zero_box[9] = {0.0, 0.0, 0.0, 0.0, 0.0,
1449 0.0, 0.0, 0.0, 0.0};
1450 check(gpr_potential_force(handle_, n_atoms, R, atomic_nrs, F, energy,
1451 energy_noise_rms, box ? box : zero_box));
1452 }
int gpr_potential_force(gpr_potential_t pot, long n_atoms, const double *R, const int *atomic_nrs, double *F, double *energy, double *energy_noise_rms, const double *box)
Evaluate energy and forces. energy_noise_rms may be NULL. When non-NULL, it receives the energy-noise...
void check(int status)
Definition gpridge.hpp:323

◆ force_with_uncertainty()

void gpr::capi::Potential::force_with_uncertainty ( long n_atoms,
const double * R,
const int * atomic_nrs,
double * F,
double * energy,
double * energy_noise_rms = nullptr,
double * force_noise_rms = nullptr,
const double * box = nullptr ) const
inline

Definition at line 1454 of file gpridge.hpp.

1460 {
1461 const double zero_box[9] = {0.0, 0.0, 0.0, 0.0, 0.0,
1462 0.0, 0.0, 0.0, 0.0};
1464 handle_, n_atoms, R, atomic_nrs, F, energy, energy_noise_rms,
1465 force_noise_rms, box ? box : zero_box));
1466 }
int gpr_potential_force_with_uncertainty(gpr_potential_t pot, long n_atoms, const double *R, const int *atomic_nrs, double *F, double *energy, double *energy_noise_rms, double *force_noise_rms, const double *box)
Evaluate energy, forces, and both uncertainty channels. energy_noise_rms and force_noise_rms may be N...

◆ from_force()

Potential gpr::capi::Potential::from_force ( gpr_force_fn fn,
void * user_data = nullptr )
inlinestaticnodiscard

Definition at line 1397 of file gpridge.hpp.

1399 {
1400 gpr_potential_t h = gpr_potential_from_force(fn, user_data);
1401 if (!h) throw Error(gpr_last_status(), gpr_last_error_message());
1402 return Potential(h, adopt);
1403 }
int gpr_last_status(void)
Status of the last call on this thread that failed (ABI 1.1), like errno: a constructor that returns ...
const char * gpr_last_error_message(void)
The same string as gpr_last_error (ABI 1.6). Never NULL. Fortran and the other bindings call this nam...
struct gpr_potential_s * gpr_potential_t
Definition gpridge_c.h:391
gpr_potential_t gpr_potential_from_force(gpr_force_fn fn, void *user_data)
Wrap a plain force callback (the gpr_dimer_search signature) as a potential handle (ABI 1....
constexpr adopt_t adopt
Definition gpridge.hpp:37

◆ from_force_with_uncertainty()

Potential gpr::capi::Potential::from_force_with_uncertainty ( gpr_force_with_uncertainty_fn fn,
void * user_data = nullptr )
inlinestaticnodiscard

Definition at line 1405 of file gpridge.hpp.

1407 {
1408 gpr_potential_t h =
1410 if (!h) throw Error(gpr_last_status(), gpr_last_error_message());
1411 return Potential(h, adopt);
1412 }
gpr_potential_t gpr_potential_from_force_with_uncertainty(gpr_force_with_uncertainty_fn fn, void *user_data)
Wrap a C force-with-uncertainty callback as a PotentialWrapper.

◆ handle()

gpr_potential_t gpr::capi::Potential::handle ( ) const
inlinenodiscardnoexcept

Definition at line 1435 of file gpridge.hpp.

1436 {
1437 return handle_;
1438 }

◆ operator bool()

gpr::capi::Potential::operator bool ( ) const
inlineexplicitnodiscardnoexcept

Definition at line 1439 of file gpridge.hpp.

1440 {
1441 return handle_ != nullptr;
1442 }

◆ operator=() [1/2]

Potential & gpr::capi::Potential::operator= ( const Potential & )
delete

◆ operator=() [2/2]

Potential & gpr::capi::Potential::operator= ( Potential && other)
inlinenoexcept

Definition at line 1385 of file gpridge.hpp.

1386 {
1387 if (this != &other) {
1388 reset();
1389 handle_ = other.handle_;
1390 owns_ = other.owns_;
1391 other.handle_ = nullptr;
1392 other.owns_ = false;
1393 }
1394 return *this;
1395 }

◆ owns()

bool gpr::capi::Potential::owns ( ) const
inlinenodiscardnoexcept

Definition at line 1431 of file gpridge.hpp.

1432 {
1433 return owns_;
1434 }

◆ release()

gpr_potential_t gpr::capi::Potential::release ( )
inlinenodiscardnoexcept

Definition at line 1423 of file gpridge.hpp.

1424 {
1425 gpr_potential_t h = handle_;
1426 handle_ = nullptr;
1427 owns_ = false;
1428 return h;
1429 }

◆ reset()

void gpr::capi::Potential::reset ( )
inlinenoexcept

Definition at line 1414 of file gpridge.hpp.

1415 {
1416 if (handle_ && owns_) {
1417 gpr_potential_destroy(handle_);
1418 }
1419 handle_ = nullptr;
1420 owns_ = false;
1421 }
void gpr_potential_destroy(gpr_potential_t pot)
Destroy a potential handle. Destroying NULL or a live handle clears gpr_last_status() and gpr_last_er...

The documentation for this class was generated from the following file: