Virtual run; used solely for dynamic dispatch.
31 {
33 size_t f1;
35
38
39
40
41 bool tsInterpolate = false;
42 std::shared_ptr<Matter> transitionState = nullptr;
44 std::filesystem::exists("ts.con")) {
45 std::string transitionStateFilename =
47 transitionState = std::make_shared<Matter>(
pot,
params);
48 tsInterpolate = true;
50 transitionState->con2matter(transitionStateFilename))) {
52 throw std::runtime_error("failed to load " + transitionStateFilename);
53 }
54 }
55
56 auto initial = std::make_shared<Matter>(
pot,
params);
57 auto final_state = std::make_shared<Matter>(
pot,
params);
58
59
60
61
62 const bool usePathEndpoints =
64 !
params.neb_options().initialization.input_path.empty();
65
66 if (usePathEndpoints) {
68 params.neb_options().initialization.input_path);
69 if (file_paths.size() < 2) {
70 throw std::runtime_error(
71 "NEB initial_path_in must list at least two frames "
72 "(reactant and product endpoints)");
73 }
74 if (!
eonc::io::io_ok(initial->con2matter(file_paths.front().string()))) {
76 file_paths.front().string());
77 throw std::runtime_error("failed to load NEB path reactant frame");
78 }
79 if (!
eonc::io::io_ok(final_state->con2matter(file_paths.back().string()))) {
81 file_paths.back().string());
82 throw std::runtime_error("failed to load NEB path product frame");
83 }
85 "NEB endpoints from initial path list (skipped {} / {})",
86 reactantFilename, productFilename);
87 } else {
90 throw std::runtime_error("failed to load reactant.con");
91 }
94 throw std::runtime_error("failed to load product.con");
95 }
96 }
97
99 "reactant and product");
100 if (tsInterpolate) {
102 "reactant and ts.con");
103 }
104
105
106
107
108
109
110
111
112
113
114 bool shouldMinimizeEndpoints = false;
115 if (!
params.neb_options().endpoints.minimize) {
116 QUILL_LOG_DEBUG(
m_log,
117 "minimize_endpoints == false: not minimizing endpoints.");
118 shouldMinimizeEndpoints = false;
119 } else {
120 if (
params.neb_options().initialization.input_path.empty()) {
121 QUILL_LOG_DEBUG(
m_log,
"minimize_endpoints == true and nebIpath "
122 "empty: minimizing endpoints.");
123 shouldMinimizeEndpoints = true;
124 } else {
125
126
127 if (
params.neb_options().endpoints.use_path_file) {
128 QUILL_LOG_DEBUG(
130 "minimize_endpoints == true and nebIpath provided, but "
131 "minimize_endpoints_for_ipath == true: minimizing endpoints.");
132 shouldMinimizeEndpoints = true;
133 } else {
134 QUILL_LOG_DEBUG(
136 "minimize_endpoints == true but nebIpath provided and "
137 "minimize_endpoints_for_ipath == false: not minimizing endpoints.");
138 shouldMinimizeEndpoints = false;
139 }
140 }
141 }
142
143 if (shouldMinimizeEndpoints) {
144 QUILL_LOG_DEBUG(
m_log,
"Minimizing reactant");
145 initial->relax(
false,
params.debug_options().write_movies,
146 params.main_options().checkpoint,
"react_neb",
"react_neb");
147 QUILL_LOG_DEBUG(
m_log,
"Minimized reactant");
148 QUILL_LOG_DEBUG(
m_log,
"Minimizing product");
149 final_state->relax(
false,
params.debug_options().write_movies,
150 params.main_options().checkpoint,
"prod_neb",
151 "prod_neb");
152 }
153
154 auto neb =
155 std::make_unique<NudgedElasticBand>(initial, final_state,
params,
pot);
156
157 if (tsInterpolate) {
158 AtomMatrix reactantToTS = transitionState->pbc(
159 transitionState->getPositions() - initial->getPositions());
160 AtomMatrix TSToProduct = transitionState->pbc(
161 final_state->getPositions() - transitionState->getPositions());
162 for (int image = 1; image <= neb->numImages; image++) {
163 int mid = neb->numImages / 2 + 1;
164 if (image < mid) {
165 double frac = static_cast<double>(image) / static_cast<double>(mid);
166 neb->path[image]->setPositions(initial->getPositions() +
167 frac * reactantToTS);
168 } else if (image > mid) {
169 double frac = static_cast<double>(image - mid) /
170 static_cast<double>(neb->numImages - mid + 1);
171 neb->path[image]->setPositions(transitionState->getPositions() +
172 frac * TSToProduct);
173 } else if (image == mid) {
174 neb->path[image]->setPositions(transitionState->getPositions());
175 }
176 }
177 }
178
180 status = neb->compute();
182
184 neb->printImageData();
185 neb->findExtrema();
186 if (
params.saddle_search_options().prfo_refine.enabled) {
188 }
189 }
190
193
195}
#define EONC_LOG_CRITICAL(...)
std::shared_ptr< Potential > pot
Set when one Potential is shared across Matters, images, or a caller.
void printEndState(NudgedElasticBand::NEBStatus status)
void saveData(NudgedElasticBand::NEBStatus status, NudgedElasticBand *neb)
void refineClimbingImage(NudgedElasticBand &neb)
void requireSameAtomCount(const Matter &a, const Matter &b, std::string_view what)
Abort before Eigen subtracts two position matrices of different size.
std::vector< fs::path > readFilePaths(const std::string &listFilePath)
Reads a file where each line contains a path to another file.
std::string getRelevantFile(std::string filename)
void requirePrfoRefine(const Parameters ¶ms)
Does nothing unless [Saddle Search] prfo_refine is on.