eOn client
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
namespace
{
18
19
const
char
*elementArray[] = {
20
"Unknown"
,
"H"
,
"He"
,
"Li"
,
"Be"
,
"B"
,
"C"
,
"N"
,
"O"
,
"F"
,
"Ne"
,
"Na"
,
21
"Mg"
,
"Al"
,
"Si"
,
"P"
,
"S"
,
"Cl"
,
"Ar"
,
"K"
,
"Ca"
,
"Sc"
,
"Ti"
,
"V"
,
22
"Cr"
,
"Mn"
,
"Fe"
,
"Co"
,
"Ni"
,
"Cu"
,
"Zn"
,
"Ga"
,
"Ge"
,
"As"
,
"Se"
,
"Br"
,
23
"Kr"
,
"Rb"
,
"Sr"
,
"Y"
,
"Zr"
,
"Nb"
,
"Mo"
,
"Tc"
,
"Ru"
,
"Rh"
,
"Pd"
,
"Ag"
,
24
"Cd"
,
"In"
,
"Sn"
,
"Sb"
,
"Te"
,
"I"
,
"Xe"
,
"Cs"
,
"Ba"
,
"La"
,
"Ce"
,
"Pr"
,
25
"Nd"
,
"Pm"
,
"Sm"
,
"Eu"
,
"Gd"
,
"Tb"
,
"Dy"
,
"Ho"
,
"Er"
,
"Tm"
,
"Yb"
,
"Lu"
,
26
"Hf"
,
"Ta"
,
"W"
,
"Re"
,
"Os"
,
"Ir"
,
"Pt"
,
"Au"
,
"Hg"
,
"Tl"
,
"Pb"
,
"Bi"
,
27
"Po"
,
"At"
,
"Rn"
,
"Fr"
,
"Ra"
,
"Ac"
,
"Th"
,
"Pa"
,
"U"
, NULL};
28
29
// guess the atom type from the atomic mass,
30
std::string mass2atom(
double
atomicmass) {
31
return
elementArray[int(atomicmass + .5)];
32
}
33
34
int
symbol2atomicNumber(
char
const
*symbol) {
35
int
i = 0;
36
37
while
(elementArray[i] != NULL) {
38
if
(strcmp(symbol, elementArray[i]) == 0) {
39
return
i;
40
}
41
i++;
42
}
43
// invalid symbol
44
return
-1;
45
}
46
47
char
const
*atomicNumber2symbol(
int
n) {
return
elementArray[n]; }
48
}
// namespace
49
50
GPRPotential::GPRPotential
(
const
Parameters
&p)
51
:
Potential
(
PotType
::GPR, p) {
52
gpr_model
=
nullptr
;
53
}
54
55
void
GPRPotential::registerGPRObject
(
56
gpr::GaussianProcessRegression *_gpr_model) {
57
gpr_model
= _gpr_model;
58
}
59
60
void
GPRPotential::initialize
(
void
) {}
61
62
void
GPRPotential::cleanMemory
(
void
) {}
63
64
// pointer to number of atoms, pointer to array of positions
65
// pointer to array of forces, pointer to internal energy
66
// adress to supercell size
67
void
GPRPotential::force
(
long
N,
const
double
*R,
const
int
*atomicNrs,
68
double
*F,
double
*U,
double
*variance,
69
const
double
*box) {
70
variance =
nullptr
;
71
gpr::Observation observation;
72
73
// Copy R points. Note, R should correspond to the moving atoms only.
74
observation.R.resize(1, N * 3);
75
for
(
int
i = 0; i < N; i++) {
76
observation.R.set(i, {R[3 * i], R[3 * i + 1], R[3 * i + 2]});
77
}
78
79
// Note, the following functions should be called before calling for
80
// gpr_model->calculatePotential() gpr_model->decomposeCovarianceMatrix(R,
81
// ind) - takes covariance matrix and vector of repetitive indices
82
// gpr_model->calculateMeanPrediction() - takes a vector of combined energy
83
// and force gpr_model->calculatePosteriorMeanPrediction() - no arguments
84
gpr_model
->calculatePotential(observation);
85
86
for
(
int
i = 0; i < N; i++) {
87
F[3 * i] = observation.G[3 * i];
88
F[3 * i + 1] = observation.G[3 * i + 1];
89
F[3 * i + 2] = observation.G[3 * i + 2];
90
}
91
92
// FIXME: Test conversion, E should only have one element here
93
*U = observation.E[0];
94
}
GPRPotential.h
GPRPotential::force
void force(long N, const double *R, const int *atomicNrs, double *F, double *U, double *variance, const double *box)
Definition
GPRPotential.cpp:67
GPRPotential::registerGPRObject
void registerGPRObject(gpr::GaussianProcessRegression *_gpr_model)
Definition
GPRPotential.cpp:55
GPRPotential::GPRPotential
GPRPotential(const Parameters &p)
Definition
GPRPotential.cpp:50
GPRPotential::cleanMemory
void cleanMemory(void)
Definition
GPRPotential.cpp:62
GPRPotential::gpr_model
gpr::GaussianProcessRegression * gpr_model
Definition
GPRPotential.h:21
GPRPotential::initialize
void initialize(void)
Definition
GPRPotential.cpp:60
eonc::Parameters
Definition
Parameters.h:28
eonc::Potential::Potential
Potential(PotType a_ptype)
Definition
Potential.h:35
eonc::PotType
PotType
Definition
BaseStructures.h:36
client
potentials
GPRPotential
GPRPotential.cpp
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf