GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
BandLayout.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
#pragma once
6
7
#include <Eigen/Core>
8
9
#include <cstddef>
10
#include <stdexcept>
11
#include <vector>
12
13
namespace
gpr::neb
{
14
16
struct
BandLayout
{
17
std::vector<int>
moving_index
;
18
Eigen::VectorXd
full_template
;
19
20
bool
packed
()
const
{
return
!
moving_index
.empty(); }
21
22
Eigen::VectorXd
pack
(
const
Eigen::VectorXd& full)
const
23
{
24
if
(!
packed
())
return
full;
25
if
(full.size() !=
full_template
.size()) {
26
throw
std::invalid_argument(
27
"GP NEB layout pack expects a full-size coordinate vector"
);
28
}
29
Eigen::VectorXd
out
(3 *
static_cast<
Eigen::Index
>
(
moving_index
.size()));
30
for
(std::size_t k = 0; k <
moving_index
.size(); ++k)
31
out
.segment<3>(3 *
static_cast<
Eigen::Index
>
(k)) =
32
full.segment<3>(3 *
moving_index
[k]);
33
return
out
;
34
}
35
36
Eigen::VectorXd
unpack
(
const
Eigen::VectorXd& moving)
const
37
{
38
if
(!
packed
())
return
moving;
39
return
scatter(moving,
full_template
);
40
}
41
42
Eigen::VectorXd
unpack_gradient
(
const
Eigen::VectorXd& moving)
const
43
{
44
if
(!
packed
())
return
moving;
45
return
scatter(moving, Eigen::VectorXd::Zero(
full_template
.size()));
46
}
47
48
private
:
49
Eigen::VectorXd scatter(
const
Eigen::VectorXd& moving,
50
Eigen::VectorXd full)
const
51
{
52
if
(moving.size() !=
53
3 *
static_cast<
Eigen::Index
>
(
moving_index
.size())) {
54
throw
std::invalid_argument(
55
"GP NEB layout unpack expects moving-atom coordinates only"
);
56
}
57
for
(std::size_t k = 0; k <
moving_index
.size(); ++k)
58
full.segment<3>(3 *
moving_index
[k]) =
59
moving.segment<3>(3 *
static_cast<
Eigen::Index
>
(k));
60
return
full;
61
}
62
};
63
64
}
// namespace gpr::neb
out
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
Definition
eon_relax_engine.h:240
gpr::neb
The nudged elastic band: path, GP-NEB driver, configuration and result, acquisition,...
Definition
ChainRealign.h:29
gpr::neb::BandLayout
Map between caller coordinates and the moving coordinates of a band.
Definition
BandLayout.h:16
gpr::neb::BandLayout::unpack_gradient
Eigen::VectorXd unpack_gradient(const Eigen::VectorXd &moving) const
Definition
BandLayout.h:42
gpr::neb::BandLayout::full_template
Eigen::VectorXd full_template
Definition
BandLayout.h:18
gpr::neb::BandLayout::pack
Eigen::VectorXd pack(const Eigen::VectorXd &full) const
Definition
BandLayout.h:22
gpr::neb::BandLayout::packed
bool packed() const
Definition
BandLayout.h:20
gpr::neb::BandLayout::moving_index
std::vector< int > moving_index
Definition
BandLayout.h:17
gpr::neb::BandLayout::unpack
Eigen::VectorXd unpack(const Eigen::VectorXd &moving) const
Definition
BandLayout.h:36
gpr
neb
BandLayout.h
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf