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:
54
56 static constexpr std::string_view statusMessage(int status) {
57 constexpr std::string_view msgs[] = {
58 "Success", // 0
59 "Initialized", // 1
60 "Initial displacement unable to reach convex region", // 2
61 "Barrier too high", // 3
62 "Too many iterations in concave region", // 4
63 "Too many iterations", // 5
64 "Saddle is not connected to initial state", // 6
65 "Prefactors not within window", // 7
66 "Energy barrier not within window", // 8
67 "Minimizations from saddle did not converge", // 9
68 "Hessian calculation failed", // 10
69 "Potential evaluation failed", // 11
70 "Nonnegative initial mode, aborting", // 12
71 "Nonlocal abort", // 13
72 "Negative barrier detected", // 14
73 "No reaction found during MD trajectory", // 15
74 "Converged to stationary point with zero negative modes", // 16
75 "No forward barrier found along minimized band", // 17
76 "Zero mode abort", // 18
77 "Optimizer error", // 19
78 "Dimer lost mode", // 20
79 "Dimer restored best", // 21
80 };
81 if (status >= 0 &&
82 status < static_cast<int>(sizeof(msgs) / sizeof(msgs[0])))
83 return msgs[status];
84 return "Unknown status";
85 }
86
90 [[nodiscard]] static constexpr int
91 finalizeClimbStatus(int climbStatus, bool objectiveConverged) noexcept {
92 if (climbStatus == STATUS_GOOD && !objectiveConverged) {
94 }
95 return climbStatus;
96 }
97
98 MinModeSaddleSearch(std::shared_ptr<Matter> matterPassed,
99 AtomMatrix modePassed, double reactantEnergyPassed,
100 const Parameters &parametersPassed,
101 std::shared_ptr<Potential> potPassed);
103 // climb ConFrames are move-only; do not copy the search object.
107 MinModeSaddleSearch &operator=(MinModeSaddleSearch &&) noexcept = default;
108 AtomMatrix getEigenvector(); // lowest eigenmode
109 double getEigenvalue(); // estimate for the lowest eigenvalue
110 std::string_view describeStatus(int status) const override {
111 return statusMessage(status);
112 }
113 int getStatus() const override { return status; }
114 int getIterationCount() const override { return iteration; }
115 int getForceCalls() const override { return forcecalls; }
116
117 int run() override;
118 int run(long max_iterations_override);
121 int runRetainFrames(long max_iterations_override = -1);
122
124 int iteration{0};
125 int status{0};
126
127 [[nodiscard]] const std::vector<readcon::ConFrame> &climbFrames() const {
128 return climb_frames_;
129 }
130 void clearClimbFrames() { climb_frames_.clear(); }
131 [[nodiscard]] std::vector<readcon::ConFrame> takeClimbFrames() {
132 return std::move(climb_frames_);
133 }
134
135private:
136 std::vector<readcon::ConFrame> climb_frames_;
140 std::shared_ptr<Matter> matter;
141 std::shared_ptr<EigenmodeStrategy>
142 minModeMethod; // shared with the objective func
145};
146
147} // namespace eonc
148
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...
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).
MinModeSaddleSearch & operator=(const MinModeSaddleSearch &)=delete
std::vector< readcon::ConFrame > climb_frames_
int getStatus() const override
std::string_view describeStatus(int status) const override
MinModeSaddleSearch(std::shared_ptr< Matter > matterPassed, AtomMatrix modePassed, double reactantEnergyPassed, const Parameters &parametersPassed, std::shared_ptr< Potential > potPassed)
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
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:171