Loading...
Searching...
No Matches
MinModeSaddleSearch.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 "Eigen.h"
15#include "EigenmodeStrategy.h"
16#include "Matter.h"
17#include "Optimizer.h"
18#include "SaddleSearchMethod.h"
19
20#include <readcon-core.hpp>
21#include <string>
22#include <vector>
23
24namespace eonc {
25
27
28public:
56
58 static constexpr std::string_view statusMessage(int status) {
59 constexpr std::string_view msgs[] = {
60 "Success", // 0
61 "Initialized", // 1
62 "Initial displacement unable to reach convex region", // 2
63 "Barrier too high", // 3
64 "Too many iterations in concave region", // 4
65 "Too many iterations", // 5
66 "Saddle is not connected to initial state", // 6
67 "Prefactors not within window", // 7
68 "Energy barrier not within window", // 8
69 "Minimizations from saddle did not converge", // 9
70 "Hessian calculation failed", // 10
71 "Potential evaluation failed", // 11
72 "Nonnegative initial mode, aborting", // 12
73 "Nonlocal abort", // 13
74 "Negative barrier detected", // 14
75 "No reaction found during MD trajectory", // 15
76 "Converged to stationary point with zero negative modes", // 16
77 "No forward barrier found along minimized band", // 17
78 "Zero mode abort", // 18
79 "Optimizer error", // 19
80 "Dimer lost mode", // 20
81 "Dimer restored best", // 21
82 };
84 return "Climb reached a known saddle";
85 if (status >= 0 &&
86 status < static_cast<int>(sizeof(msgs) / sizeof(msgs[0])))
87 return msgs[status];
88 return "Unknown status";
89 }
90
94 [[nodiscard]] static constexpr int
95 finalizeClimbStatus(int climbStatus, bool objectiveConverged) noexcept {
96 if (climbStatus == STATUS_GOOD && !objectiveConverged) {
98 }
99 return climbStatus;
100 }
101
102 MinModeSaddleSearch(std::shared_ptr<Matter> matterPassed,
103 AtomMatrix modePassed, double reactantEnergyPassed,
104 const Parameters &parametersPassed,
105 std::shared_ptr<Potential> potPassed);
107 // climb ConFrames are move-only; do not copy the search object.
111 MinModeSaddleSearch &operator=(MinModeSaddleSearch &&) noexcept = default;
112 AtomMatrix getEigenvector(); // lowest eigenmode
113 double getEigenvalue(); // estimate for the lowest eigenvalue
114 std::string_view describeStatus(int status) const override {
115 return statusMessage(status);
116 }
117 int getStatus() const override { return status; }
118 int getIterationCount() const override { return iteration; }
119 int getForceCalls() const override { return forcecalls; }
120
121 int run() override;
122 int run(long max_iterations_override);
125 int runRetainFrames(long max_iterations_override = -1);
126
128 int iteration{0};
129 int status{0};
130
131 [[nodiscard]] const std::vector<readcon::ConFrame> &climbFrames() const {
132 return climb_frames_;
133 }
134 void clearClimbFrames() { climb_frames_.clear(); }
135
139 void setKnownSaddles(std::vector<AtomMatrix> positions,
140 std::vector<double> energies);
141 [[nodiscard]] std::vector<readcon::ConFrame> takeClimbFrames() {
142 return std::move(climb_frames_);
143 }
144
145private:
146 std::vector<readcon::ConFrame> climb_frames_;
150 std::shared_ptr<Matter> matter;
151 std::shared_ptr<EigenmodeStrategy>
152 minModeMethod; // shared with the objective func
154 std::vector<AtomMatrix> knownSaddlePositions_;
155 std::vector<double> knownSaddleEnergies_;
156 [[nodiscard]] bool atKnownSaddle() const;
158};
159
160} // namespace eonc
Eigen::Matrix< double, Eigen::Dynamic, 3, eOnStorageOrder > AtomMatrix
Definition Eigen.h:37
The optimizer class is used to serve as an abstract class for all optimizers, as well as to call an o...
MinModeSaddleSearch(std::shared_ptr< Matter > matterPassed, AtomMatrix modePassed, double reactantEnergyPassed, const Parameters &parametersPassed, std::shared_ptr< Potential > potPassed)
static constexpr std::string_view statusMessage(int status)
Human-readable message for a status code.
int runRetainFrames(long max_iterations_override=-1)
Like run(), but also retain climb ConFrames in memory (same stamps as write_movies climb CON).
std::vector< double > knownSaddleEnergies_
MinModeSaddleSearch & operator=(const MinModeSaddleSearch &)=delete
std::vector< readcon::ConFrame > climb_frames_
int getStatus() const override
std::string_view describeStatus(int status) const override
std::vector< readcon::ConFrame > takeClimbFrames()
const std::vector< readcon::ConFrame > & climbFrames() const
MinModeSaddleSearch(const MinModeSaddleSearch &)=delete
std::shared_ptr< Matter > matter
int getIterationCount() const override
static constexpr int finalizeClimbStatus(int climbStatus, bool objectiveConverged) noexcept
Issue #20 policy: never leave climb as STATUS_GOOD when the climb objective is still unconverged (unf...
std::shared_ptr< EigenmodeStrategy > minModeMethod
void setKnownSaddles(std::vector< AtomMatrix > positions, std::vector< double > energies)
Saddles the server already holds for this state (positions, energies).
std::vector< AtomMatrix > knownSaddlePositions_
int getForceCalls() const override
MinModeSaddleSearch(MinModeSaddleSearch &&) noexcept=default
SaddleSearchMethod(std::shared_ptr< Potential > potPassed, const Parameters &paramsPassed)
RAII resource manager for the ARTn C library with global synchronization.
RAII helper for class-scoped logging.
Definition EonLogger.h:238