GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
SexpatCF.inl
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
// Copyright (c) gpridge developers
3
// See LICENSE for details.
4
5
//
6
// SexpatCF.inl
7
// gpr_dimer
8
//
9
// Created by Maxim Masterov on 21/01/2021.
10
//
11
12
#ifndef SexpatCF_inl
13
#define SexpatCF_inl
14
15
#include "
../numerics/PortableMath.h
"
16
17
namespace
gpr
{
18
19
inline
void
SexpatCF::setMagnSigma2
(
double
value)
20
{
21
magnSigma2 = value;
22
}
23
24
inline
void
SexpatCF::setLengthScale
(
double
value)
25
{
26
auto
& lengths =
getLengthScaleRef
();
27
if
(lengths.size() == 0) lengths.resize(1, 1);
28
lengths.setConstant(value);
29
clearDistanceCache
();
30
}
31
32
inline
void
SexpatCF::setFarFieldRadius
(
double
radius)
33
{
34
dist_calculator_.setFarFieldRadius(radius);
35
far_field_radius_ = dist_calculator_.farFieldRadius();
36
}
37
38
inline
void
SexpatCF::setConfInfo
(
const
AtomsConfiguration
& value)
39
{
40
clearGeodesicHeatKernel
();
41
conf_info = value;
42
}
43
44
inline
void
SexpatCF::setParameters
(
const
Eigen::VectorXd& w)
45
{
46
auto
& lengths =
getLengthScaleRef
();
47
magnSigma2 =
numerics::exp
(w(0));
48
for
(Eigen::Index n = 0; n < lengths.size(); ++n)
49
*(lengths.data() + n) =
numerics::exp
(w(n + 1));
50
clearDistanceCache
();
51
}
52
53
inline
double
SexpatCF::getMagnSigma2
()
54
{
55
return
magnSigma2;
56
}
57
58
inline
FieldMatrixd
&
SexpatCF::getLengthScaleRef
()
59
{
60
return
usesManifoldChart
() ? chart_length_scale_ : lengthScale;
61
}
62
63
inline
const
FieldMatrixd
&
SexpatCF::getLengthScaleRef
()
const
64
{
65
return
usesManifoldChart
() ? chart_length_scale_ : lengthScale;
66
}
67
68
inline
void
SexpatCF::clear
()
69
{
70
clearGeodesicHeatKernel
();
71
initialized =
false
;
72
magnSigma2 = 0.;
73
lengthScale.setConstant(0.);
74
chart_length_scale_.setConstant(0.);
75
conf_info.clearDistribution();
76
}
77
78
inline
void
SexpatCF::setPriorParametersGaussian
(
const
PriorBase
& prior)
79
{
80
prior_parameters_gaussian.setParameters(prior);
81
}
82
83
inline
void
SexpatCF::setPriorParametersSqrtt
(
const
PriorBase
& prior)
84
{
85
prior_parameters_sqrtt.setParameters(prior);
86
}
87
88
inline
void
SexpatCF::setPriorParametersLogNormal
(
const
PriorBase
& prior)
89
{
90
prior_parameters_lognormal.setParameters(prior);
91
}
92
93
inline
PriorBase
SexpatCF::getPriorParametersGaussian
()
94
{
95
return
prior_parameters_gaussian;
96
}
97
98
inline
PriorBase
SexpatCF::getPriorParametersSqrtt
()
99
{
100
return
prior_parameters_sqrtt;
101
}
102
103
inline
PriorBase
SexpatCF::getPriorParametersLogNormal
()
104
{
105
return
prior_parameters_lognormal;
106
}
107
108
inline
void
SexpatCF::setUseLogNormalMagnPrior
(
bool
enabled)
noexcept
109
{
110
use_lognormal_magn_prior_ = enabled;
111
}
112
113
inline
bool
SexpatCF::useLogNormalMagnPrior
() const noexcept
114
{
115
return
use_lognormal_magn_prior_;
116
}
117
118
inline
void
SexpatCF::setModelProfile
(
GPModelProfile
profile)
119
{
120
model_profile_ = profile;
121
if
(
usesClassicJointEnergyForcePrior
(profile)) {
122
clearHierarchicalPrior
();
123
clearPcLengthScalePrior
();
124
// Chart and heat components have independent configuration; choosing
125
// a hyperparameter prior preserves the assembled covariance.
126
}
127
}
128
129
inline
void
SexpatCF::setHierarchicalPrior
(
const
Eigen::VectorXd& mu_log,
130
double
s2_log)
131
{
132
hierarchical_mu_log_ = mu_log;
133
hierarchical_s2_log_ = s2_log;
134
hierarchical_s2_log_per_.resize(0);
135
use_hierarchical_prior_ = (mu_log.size() > 0 && s2_log > 0.0);
136
}
137
138
inline
void
SexpatCF::setHierarchicalPrior
(
const
Eigen::VectorXd& mu_log,
139
double
s2_log,
140
const
Eigen::VectorXd& s2_log_per)
141
{
142
setHierarchicalPrior
(mu_log, s2_log);
143
hierarchical_s2_log_per_ =
144
s2_log_per.size() == mu_log.size() ? s2_log_per : Eigen::VectorXd();
145
// A prior with no shared width still applies to the parameters that
146
// carry their own.
147
use_hierarchical_prior_ =
148
mu_log.size() > 0 &&
149
(s2_log > 0.0 || (hierarchical_s2_log_per_.array() > 0.0).any());
150
}
151
152
inline
void
SexpatCF::clearHierarchicalPrior
()
153
{
154
use_hierarchical_prior_ =
false
;
155
hierarchical_mu_log_.resize(0);
156
hierarchical_s2_log_ = 0.0;
157
hierarchical_s2_log_per_.resize(0);
158
hierarchical_anchor_.clear();
159
}
160
161
inline
void
SexpatCF::setPcLengthScalePrior
(
const
Eigen::VectorXd& lambda)
162
{
163
pc_lambda_ = lambda;
164
use_pc_lengthscale_prior_ = (lambda.size() > 0);
165
}
166
167
inline
void
SexpatCF::clearPcLengthScalePrior
()
168
{
169
use_pc_lengthscale_prior_ =
false
;
170
pc_lambda_.resize(0);
171
}
172
173
inline
Eigen::VectorXd
SexpatCF::combineParameters
()
174
{
175
const
auto
& lengths =
getLengthScaleRef
();
176
Eigen::VectorXd res(1 + lengths.size());
177
178
res(0) =
numerics::log
(magnSigma2);
179
180
for
(Eigen::Index n = 0; n < lengths.size(); ++n)
181
res(n + 1) =
numerics::log
(*(lengths.data() + n));
182
183
// NOTE: Only magnSigma2 and lengths are packed, matching MATLAB
184
// gpcf_sexpat_pak. Prior parameters are not part of the optimization
185
// vector.
186
return
res;
187
}
188
189
}
/* namespace gpr */
190
191
#endif
/* SexpatCF_inl */
PortableMath.h
gpr::PriorBase
Class of prior parameters.
Definition
PriorBase.h:23
gpr::SexpatCF::setParameters
void setParameters(const Eigen::VectorXd &w)
Set parameters of this covariance function using the provided vector.
Definition
SexpatCF.inl:44
gpr::SexpatCF::getPriorParametersSqrtt
PriorBase getPriorParametersSqrtt()
Definition
SexpatCF.inl:98
gpr::SexpatCF::setUseLogNormalMagnPrior
void setUseLogNormalMagnPrior(bool enabled) noexcept
Definition
SexpatCF.inl:108
gpr::SexpatCF::setFarFieldRadius
void setFarFieldRadius(double radius)
Definition
SexpatCF.inl:32
gpr::SexpatCF::setPcLengthScalePrior
void setPcLengthScalePrior(const Eigen::VectorXd &lambda)
Definition
SexpatCF.inl:161
gpr::SexpatCF::clearGeodesicHeatKernel
void clearGeodesicHeatKernel() noexcept
Definition
SexpatCF.cpp:723
gpr::SexpatCF::setModelProfile
void setModelProfile(GPModelProfile profile)
Definition
SexpatCF.inl:118
gpr::SexpatCF::setLengthScale
void setLengthScale(double value)
Definition
SexpatCF.inl:24
gpr::SexpatCF::combineParameters
Eigen::VectorXd combineParameters()
Combine parameters of the covariance function into one Eigen vector.
Definition
SexpatCF.inl:173
gpr::SexpatCF::setPriorParametersSqrtt
void setPriorParametersSqrtt(const PriorBase &prior)
Definition
SexpatCF.inl:83
gpr::SexpatCF::getPriorParametersGaussian
PriorBase getPriorParametersGaussian()
Definition
SexpatCF.inl:93
gpr::SexpatCF::usesManifoldChart
bool usesManifoldChart() const noexcept
Definition
SexpatCF.h:616
gpr::SexpatCF::clearHierarchicalPrior
void clearHierarchicalPrior()
Definition
SexpatCF.inl:152
gpr::SexpatCF::getMagnSigma2
double getMagnSigma2()
Definition
SexpatCF.inl:53
gpr::SexpatCF::setHierarchicalPrior
void setHierarchicalPrior(const Eigen::VectorXd &mu_log, double s2_log)
Definition
SexpatCF.inl:129
gpr::SexpatCF::clearPcLengthScalePrior
void clearPcLengthScalePrior()
Definition
SexpatCF.inl:167
gpr::SexpatCF::setMagnSigma2
void setMagnSigma2(double value)
Definition
SexpatCF.inl:19
gpr::SexpatCF::setPriorParametersGaussian
void setPriorParametersGaussian(const PriorBase &prior)
Definition
SexpatCF.inl:78
gpr::SexpatCF::setPriorParametersLogNormal
void setPriorParametersLogNormal(const PriorBase &prior)
Definition
SexpatCF.inl:88
gpr::SexpatCF::clear
void clear()
Definition
SexpatCF.inl:68
gpr::SexpatCF::getPriorParametersLogNormal
PriorBase getPriorParametersLogNormal()
Definition
SexpatCF.inl:103
gpr::SexpatCF::getLengthScaleRef
FieldMatrixd & getLengthScaleRef()
Definition
SexpatCF.inl:58
gpr::SexpatCF::useLogNormalMagnPrior
bool useLogNormalMagnPrior() const noexcept
Definition
SexpatCF.inl:113
gpr::SexpatCF::setConfInfo
void setConfInfo(const AtomsConfiguration &value)
Definition
SexpatCF.inl:38
gpr::SexpatCF::clearDistanceCache
void clearDistanceCache()
Invalidate the distance cache.
Definition
SexpatCF.cpp:2963
gpr::numerics::log
double log(double x) noexcept
Definition
PortableMath.cpp:24
gpr::numerics::exp
double exp(double x) noexcept
Definition
PortableMath.cpp:20
gpr
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition
Macros.h:16
gpr::usesClassicJointEnergyForcePrior
bool usesClassicJointEnergyForcePrior(GPModelProfile profile) noexcept
Definition
Structures.h:206
gpr::GPModelProfile
GPModelProfile
Definition
Structures.h:201
gpr::FieldMatrixd
Eigen::Matrix< double, EigenDynamic, EigenDynamic, FieldMatrixStorage > FieldMatrixd
Definition
Macros.h:25
gpr::AtomsConfiguration
Stores configurations of all atoms in the system.
Definition
Structures.h:832
gpr
covariance_functions
SexpatCF.inl
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf