Loading...
Searching...
No Matches
NEBOcinebController.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 "Parameters.h"
16#include <string_view>
17
18namespace eonc {
19class NudgedElasticBand; // forward declaration
20}
21
22namespace eonc::neb {
23
28public:
39
40 static Config fromParams(const Parameters &params);
41 explicit OCINEBController(const Config &cfg);
42
43 void initBaseline(double baseline_force);
44
45 bool shouldTrigger(double convForce, bool ci_active, long climbingImage,
46 long numImages, int ciStabilityCounter) const;
47
53
54 MMFResult run(eonc::NudgedElasticBand &neb, double convForce);
55
57 static double forceMeasure(const AtomMatrix &freeForces, std::string_view metric);
58
59 // Help is the walked image's raw force, not band convergenceForce().
60 // After a downhill dimer step maxEnergyImage can hop; the band CI
61 // force is then a neighbor and is the wrong score for restore.
62 // Status -1 left the band tangent. A lower walked force on that
63 // abort is not help; run() keeps the image and applies the linear
64 // penalty. Status -2 is positive curvature.
65 static bool walkHelped(double walkedForce, double convForce, int mmfStatus) {
66 return walkedForce < convForce && mmfStatus != -1 && mmfStatus != -2;
67 }
68
69 // Positive curvature (status -2) is a well, not a saddle. A band
70 // force under tolerance after that walk is not convergence; run()
71 // restores the climbing image first.
72 static bool convergedClimb(double bandForce, double forceTolerance,
73 int mmfStatus) {
74 return bandForce < forceTolerance && mmfStatus != -2;
75 }
76
78 void updateStability(long climbingImage);
79 int stabilityCount() const { return ciStabilityCounter_; }
80 double threshold() const { return current_threshold_; }
81
82private:
84 double current_threshold_{-1.0};
85 double baseline_force_{-1.0};
89
90 // Warm-start: cache converged eigenvector for next dimer call
91 bool has_cached_mode_{false};
93
94 int runDimer(eonc::NudgedElasticBand &neb, double &alignment);
95 void updateThresholdSuccess(double convForce, double newForce);
96 void updateThresholdBackoff(double alignment);
97};
98
99} // namespace eonc::neb
Eigen::Matrix< double, Eigen::Dynamic, 3, eOnStorageOrder > AtomMatrix
Definition Eigen.h:37
static bool walkHelped(double walkedForce, double convForce, int mmfStatus)
bool shouldTrigger(double convForce, bool ci_active, long climbingImage, long numImages, int ciStabilityCounter) const
static Config fromParams(const Parameters &params)
void updateThresholdSuccess(double convForce, double newForce)
void updateStability(long climbingImage)
MMFResult run(eonc::NudgedElasticBand &neb, double convForce)
int runDimer(eonc::NudgedElasticBand &neb, double &alignment)
void initBaseline(double baseline_force)
static double forceMeasure(const AtomMatrix &freeForces, std::string_view metric)
Measure free-atom forces with the band's configured convergence metric.
void updateThresholdBackoff(double alignment)
static bool convergedClimb(double bandForce, double forceTolerance, int mmfStatus)
RAII resource manager for the ARTn C library with global synchronization.