Loading...
Searching...
No Matches
GprMeanPotential.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3// See LICENSE for details.
4
5#ifndef GPR_POTENTIALS_GPRMEANPOTENTIAL_H_
6#define GPR_POTENTIALS_GPRMEANPOTENTIAL_H_
7
8#include <cstdint>
9#include <memory>
10#include <vector>
11
12#include "PotentialWrapper.h"
14#include "rgpot/Potential.hpp"
15
16namespace gpr {
17namespace neb {
19}
20} // namespace gpr
21
22namespace pot {
23
31class GprMeanPotential : public rgpot::Potential<GprMeanPotential> {
32public:
33 using rgpot::Potential<GprMeanPotential>::forceBatch;
34
36 explicit GprMeanPotential(
37 std::shared_ptr<gpr::GaussianProcessRegression> model);
39 void resetModel(std::shared_ptr<gpr::GaussianProcessRegression> model);
40
41 [[nodiscard]] std::uint64_t surfaceEpoch() const noexcept;
42 [[nodiscard]] std::uint64_t paramsKey() const noexcept override;
43 [[nodiscard]] rgpot::PotCaps caps() const noexcept override;
44 void forceImpl(const rgpot::ForceInput& in,
45 rgpot::ForceOut* out) const override;
46 void hessianVectorImpl(const rgpot::ForceInput& in, const double* direction,
47 double* action) const;
48
49 void force(long N, const double* R, const int* atomicNrs, double* F,
50 double* U, double* variance, const double* box);
51
52 void forceBatch(long N, std::size_t B, const double* R,
53 const int* atomicNrs, double* F, double* U,
54 const double* box);
55
56 [[nodiscard]] PotentialWrapper asWrapper();
57
58private:
59 std::shared_ptr<gpr::GaussianProcessRegression> owned_model_;
60 std::uint64_t epoch_base_ = 0;
61 std::uint64_t base_factor_epoch_ = 0;
62 gpr::GaussianProcessRegression* model_ = nullptr;
63 gpr::neb::ActiveLearningSession* session_ = nullptr;
64
65 [[nodiscard]] gpr::GaussianProcessRegression& model();
66 [[nodiscard]] const gpr::GaussianProcessRegression& model() const;
67 void validateSystem(long N, const int* atomicNrs, const double* box,
68 const char* caller) const;
69};
70
71} // namespace pot
72
73#endif
std::uint64_t paramsKey() const noexcept override
void hessianVectorImpl(const rgpot::ForceInput &in, const double *direction, double *action) const
rgpot::PotCaps caps() const noexcept override
PotentialWrapper asWrapper()
void force(long N, const double *R, const int *atomicNrs, double *F, double *U, double *variance, const double *box)
void resetModel(std::shared_ptr< gpr::GaussianProcessRegression > model)
void forceImpl(const rgpot::ForceInput &in, rgpot::ForceOut *out) const override
std::uint64_t surfaceEpoch() const noexcept
void forceBatch(long N, std::size_t B, const double *R, const int *atomicNrs, double *F, double *U, const double *box)
GprMeanPotential(gpr::GaussianProcessRegression &model)
Type-erased wrapper around any potential that provides a force() interface.
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
The nudged elastic band: path, GP-NEB driver, configuration and result, acquisition,...
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition Macros.h:16
Potential wrappers and the batched oracle interface.