Loading...
Searching...
No Matches
NudgedElasticBand.h
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#pragma once
13
14#include <filesystem>
15
16#include "Eigen.h"
17#include "EonLogger.h"
18
19#include "EigenmodeStrategy.h"
20#include "HelperFunctions.h"
21#include "Matter.h"
22#include "NEBProjection.h"
23#include "NEBTangent.h"
24#include "ObjectiveFunction.h"
25#include "Parameters.h"
26
27#include <optional>
28#include <readcon-core.hpp>
29#include <vector>
30
31namespace eonc::neb {
33}
34
35namespace eonc {
36
37// NEB method for determining a minimum energy path between two matter objects
40
41public:
49 NudgedElasticBand(std::shared_ptr<Matter> initialPassed,
50 std::shared_ptr<Matter> finalPassed,
51 const Parameters &parametersPassed,
52 std::shared_ptr<Potential> potPassed);
53 NudgedElasticBand(std::vector<Matter> initPath,
54 const Parameters &parametersPassed,
55 std::shared_ptr<Potential> potPassed);
56 ~NudgedElasticBand() = default;
57
60 void updateForces(bool ci_active);
62 void setCIEnabled(bool enabled) { ci_enabled_ = enabled; }
63 double convergenceForce(void);
64 void findExtrema(void);
65 void printImageData(bool writeToFile = false, size_t idx = 0);
66
69 [[nodiscard]] std::vector<readcon::ConFrame>
70 pathFrames(std::optional<size_t> bandIndex = std::nullopt);
71
72 std::vector<std::shared_ptr<EigenmodeStrategy>> eigenmode_solvers;
73
74 int atoms{0};
76 std::vector<std::shared_ptr<Matter>> path; // NEB images
77 std::vector<std::shared_ptr<AtomMatrix>> tangent;
78 std::vector<std::shared_ptr<AtomMatrix>> projectedForce;
79 std::vector<double> extremumEnergy;
80 std::vector<double> extremumPosition;
81 std::vector<double> extremumCurvature;
82
83 std::size_t maxEnergyImage{0};
86 false};
87 double ksp{0.0};
88 double k_u{0.0}; // Upper-bound value for the spring constant
89 double k_l{0.0}; // Lower-bound value for the spring constant
90 double E_ref; // Reference energy chosen to be equal to the max energy of the
91 // reactant or product energy minimum
92
93private:
94 bool ci_enabled_{false}; // runtime CI state, set by compute()
95 double baseline_force{-1.0};
97 std::shared_ptr<Potential> pot;
100
101 // Cached strategies (constant across iterations)
104};
105
107public:
109 const Parameters &parametersPassed)
110 : ObjectiveFunction(parametersPassed),
111 neb{nebPassed} {}
112 // This is the odd one out, doesn't take a Matter so we null it
113
115
116 VectorXd getGradient(bool fdstep = false);
117 double getEnergy();
118 void setPositions(const VectorXd &x);
119 VectorXd getPositions();
120 int degreesOfFreedom();
121 bool isConverged();
122 bool isUncertain();
123 double getConvergence();
124 VectorXd difference(const VectorXd &a, const VectorXd &b);
126
127private:
129};
130
131} // namespace eonc
132
VectorXd getGradient(bool fdstep=false)
NudgedElasticBand::NEBStatus status
VectorXd difference(const VectorXd &a, const VectorXd &b)
NEBObjectiveFunction(NudgedElasticBand *nebPassed, const Parameters &parametersPassed)
void setPositions(const VectorXd &x)
std::vector< double > extremumEnergy
void printImageData(bool writeToFile=false, size_t idx=0)
std::vector< std::shared_ptr< AtomMatrix > > tangent
std::vector< readcon::ConFrame > pathFrames(std::optional< size_t > bandIndex=std::nullopt)
In-memory ConFrames with the same NEB stamps as writePathCon / neb.con.
std::vector< std::shared_ptr< Matter > > path
bool perImagePotentials_
Whether per-image potential instances exist.
std::vector< double > extremumPosition
std::vector< std::shared_ptr< EigenmodeStrategy > > eigenmode_solvers
NudgedElasticBand::NEBStatus compute(void)
NudgedElasticBand(std::shared_ptr< Matter > initialPassed, std::shared_ptr< Matter > finalPassed, const Parameters &parametersPassed, std::shared_ptr< Potential > potPassed)
neb::TangentStrategy tangentStrat_
std::vector< std::shared_ptr< AtomMatrix > > projectedForce
void setCIEnabled(bool enabled)
std::shared_ptr< Potential > pot
NudgedElasticBand::NEBStatus getStatus()
neb::ProjectionStrategy projectionStrat_
std::vector< double > extremumCurvature
ObjectiveFunction(const Parameters &paramsPassed)
std::variant< PlainEB, NEB_Projection, DNEB_Projection > ProjectionStrategy
std::variant< SimpleTangent, ImprovedTangent > TangentStrategy
Definition NEBTangent.h:38
RAII resource manager for the ARTn C library with global synchronization.
RAII helper for class-scoped logging.
Definition EonLogger.h:171