eOn 3.2.0
Long-timescale dynamics: aKMC, NEB, parallel replica
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
GPRPotential.cpp
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
*/
12
13
#include "
eon/potentials/GPRPotential/GPRPotential.h
"
14
#include "subprojects/gprdimer/gpr/auxiliary/AdditionalFunctionality.h"
15
#include "subprojects/gprdimer/structures/Structures.h"
16
17
#include <stdexcept>
18
19
GPRPotential::GPRPotential
(
const
eonc::Parameters
&p)
20
:
eonc
::
Potential
(
eonc
::PotType::GPR, p) {}
21
22
void
GPRPotential::registerGPRObject
(
23
gpr::GaussianProcessRegression *_gpr_model) {
24
gpr_model
= _gpr_model;
25
}
26
27
void
GPRPotential::initialize
() {}
28
29
void
GPRPotential::cleanMemory
() {}
30
31
// pointer to number of atoms, pointer to array of positions
32
// pointer to array of forces, pointer to internal energy
33
// adress to supercell size
34
void
GPRPotential::force
(
long
N,
const
double
*R,
const
int
*atomicNrs,
35
double
*F,
double
*U,
double
*variance,
36
const
double
*box) {
37
(void)atomicNrs;
38
(void)box;
39
if
(variance !=
nullptr
) {
40
*variance = 0.0;
41
}
42
if
(
gpr_model
==
nullptr
) {
43
throw
std::runtime_error(
"GPRPotential: no GPR model registered"
);
44
}
45
gpr::Observation observation;
46
47
// Copy R points. Note, R should correspond to the moving atoms only.
48
observation.R.resize(1, N * 3);
49
for
(
int
i = 0; i < N; i++) {
50
observation.R.set(i, {R[3 * i], R[3 * i + 1], R[3 * i + 2]});
51
}
52
53
// Note, the following functions should be called before calling for
54
// gpr_model->calculatePotential() gpr_model->decomposeCovarianceMatrix(R,
55
// ind) - takes covariance matrix and vector of repetitive indices
56
// gpr_model->calculateMeanPrediction() - takes a vector of combined energy
57
// and force gpr_model->calculatePosteriorMeanPrediction() - no arguments
58
gpr_model
->calculatePotential(observation);
59
60
for
(
int
i = 0; i < N; i++) {
61
F[3 * i] = observation.G[3 * i];
62
F[3 * i + 1] = observation.G[3 * i + 1];
63
F[3 * i + 2] = observation.G[3 * i + 2];
64
}
65
66
if
(observation.E.size() < 1) {
67
throw
std::runtime_error(
"GPRPotential: empty energy from GPR model"
);
68
}
69
*U = observation.E[0];
70
}
GPRPotential.h
GPRPotential::GPRPotential
GPRPotential(const eonc::Parameters &p)
Definition
GPRPotential.cpp:19
GPRPotential::initialize
void initialize()
Definition
GPRPotential.cpp:27
GPRPotential::registerGPRObject
void registerGPRObject(gpr::GaussianProcessRegression *_gpr_model)
Definition
GPRPotential.cpp:22
GPRPotential::cleanMemory
void cleanMemory()
Definition
GPRPotential.cpp:29
GPRPotential::force
void force(long N, const double *R, const int *atomicNrs, double *F, double *U, double *variance, const double *box) override
Definition
GPRPotential.cpp:34
GPRPotential::gpr_model
gpr::GaussianProcessRegression * gpr_model
Definition
GPRPotential.h:21
eonc::Parameters
Definition
Parameters.h:35
eonc::Potential::Potential
Potential(PotType a_ptype)
Production default: construction-scope registry, else PotRegistry::get().
Definition
PotentialParams.cpp:29
eonc
RAII resource manager for the ARTn C library with global synchronization.
Definition
ARTnSaddleSearch.cpp:23
client
potentials
GPRPotential
GPRPotential.cpp
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf