Loading...
Searching...
No Matches
NEBInitialPaths.hpp
Go to the documentation of this file.
1#pragma once
2#include "Matter.h"
3#include <filesystem>
4#include <format>
5#include <memory>
6#include <span>
7#include <stdexcept>
8#include <string_view>
9
10namespace eonc {
11
12namespace helpers::neb_paths {
13namespace fs = std::filesystem;
14
16inline void requireSameAtomCount(const Matter &a, const Matter &b,
17 std::string_view what) {
18 if (a.numberOfAtoms() == b.numberOfAtoms()) {
19 return;
20 }
21 throw std::invalid_argument(std::format(
22 "NEB: {} do not have the same number of atoms ({} vs {})", what,
24}
25
26std::vector<Matter> linearPath(const Matter &initImg, const Matter &finalImg,
27 const size_t nimgs);
28
29std::vector<Matter> filePathInit(const std::vector<fs::path> &fsrcs,
30 const Matter &refImg, const size_t nimgs);
31
41 const AtomMatrix &P1, const AtomMatrix &T1,
42 double f);
43
44std::vector<Matter> resamplePath(const std::vector<Matter> &densePath,
45 size_t targetCount);
46
56void resamplePathInPlace(std::span<std::shared_ptr<Matter>> path);
57
65std::vector<std::filesystem::path>
66readFilePaths(const std::string &listFilePath);
67
69
70std::vector<Matter> idppPath(const Matter &initImg, const Matter &finalImg,
71 size_t nimgs, const Parameters &params,
72 bool use_zbl = false);
73
74std::vector<Matter> idppCollectivePath(const Matter &initImg,
75 const Matter &finalImg, size_t nimgs,
76 const Parameters &params,
77 bool use_zbl = false);
78
79std::vector<Matter> sidppPath(const Matter &initImg, const Matter &finalImg,
80 size_t target_nimgs, const Parameters &params,
81 bool use_zbl = false);
82
86void ensureDistinctAdjacentImages(const std::vector<Matter> &path,
87 double min_sep);
88
89// Helper to insert an image linearly between two others
90Matter interpolateImage(const Matter &A, const Matter &B, double fraction);
91// Helper to construct ZBL potentials
92std::shared_ptr<Potential> createZBLPotential();
93
94} // namespace helpers::neb_paths
95
96} // namespace eonc
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, eOnStorageOrder > MatrixXd
Definition Eigen.h:33
Eigen::Matrix< double, Eigen::Dynamic, 3, eOnStorageOrder > AtomMatrix
Definition Eigen.h:37
long int numberOfAtoms() const
Definition Matter.cpp:273
AtomMatrix cubicInterpolate(const AtomMatrix &P0, const AtomMatrix &T0, const AtomMatrix &P1, const AtomMatrix &T1, double f)
Interpolates positions using a cubic Hermite spline.
std::vector< Matter > resamplePath(const std::vector< Matter > &densePath, size_t targetCount)
std::vector< Matter > sidppPath(const Matter &initImg, const Matter &finalImg, size_t target_nimgs, const Parameters &params, bool use_zbl)
void resamplePathInPlace(std::span< std::shared_ptr< Matter > > path)
In-place path reparameterization for NEB shared_ptr paths.
Matter interpolateImage(const Matter &A, const Matter &B, double fraction)
std::shared_ptr< Potential > createZBLPotential()
std::vector< Matter > linearPath(const Matter &initImg, const Matter &finalImg, const size_t nimgs)
MatrixXd getDistanceMatrix(const Matter &m)
void ensureDistinctAdjacentImages(const std::vector< Matter > &path, double min_sep)
Adjacent images closer than min_sep (RMSD, PBC) are a collapsed path.
void requireSameAtomCount(const Matter &a, const Matter &b, std::string_view what)
Abort before Eigen subtracts two position matrices of different size.
std::vector< Matter > filePathInit(const std::vector< fs::path > &fsrcs, const Matter &refImg, const size_t nimgs)
std::vector< Matter > idppPath(const Matter &initImg, const Matter &finalImg, const size_t nimgs, const Parameters &params, bool use_zbl)
std::vector< Matter > idppCollectivePath(const Matter &initImg, const Matter &finalImg, size_t nimgs, const Parameters &params, bool use_zbl)
std::vector< fs::path > readFilePaths(const std::string &listFilePath)
Reads a file where each line contains a path to another file.
RAII resource manager for the ARTn C library with global synchronization.