[Saddle Search] irc_after. runIrc follows the intrinsic reaction coordinate from the converged saddle and relaxes both ends. It writes irc.con, irc.dat, irc_min1.con and irc_min2.con.
251 {
253 const size_t before =
pot->forceCallCounter;
254 IrcPath path;
255 try {
257 } catch (const std::exception &e) {
258 irc.forceCalls =
pot->forceCallCounter - before;
259 QUILL_LOG_ERROR(
log,
"[Saddle Search] IRC failed: {}", e.what());
260 return;
261 }
262 irc.forceCalls =
pot->forceCallCounter - before;
263 irc.branchesAtMinimum =
264 int{path.minus.reachedMinimum} + int{path.plus.reachedMinimum};
265
266
267
268
271 double energy;
272 double maxForce;
273 };
274 std::vector<Point> points;
275 for (size_t i = path.minus.positions.size(); i-- > 0;) {
276 points.push_back({&path.minus.positions[i], path.minus.energies[i],
277 path.minus.maxForces[i]});
278 }
279 const size_t saddleIndex = points.size();
281 const double saddleEnergy =
saddle->getPotentialEnergy();
282 points.push_back({&saddlePos, saddleEnergy,
saddle->maxForce()});
283 for (size_t i = 0; i < path.plus.positions.size(); ++i) {
284 points.push_back({&path.plus.positions[i], path.plus.energies[i],
285 path.plus.maxForces[i]});
286 }
287 std::vector<double> arc(points.size(), 0.0);
288 for (size_t i = 1; i < points.size(); ++i) {
289 arc[i] =
290 arc[i - 1] +
saddle->pbc(*points[i].pos - *points[i - 1].pos).norm();
291 }
293 std::ofstream dat("irc.dat", std::ios::binary);
294 dat << std::format("{:>3s} {:>12s} {:>12s} {:>12s}\n", "img", "rxn_coord",
295 "energy", "max_force");
296 for (size_t i = 0; i < points.size(); ++i) {
297 frame.setPositions(*points[i].pos);
298 eonc::io::ConFrameMetadata meta;
299 meta.
energy = points[i].energy;
301 QUILL_LOG_ERROR(
log,
"Failed to write irc.con");
302 }
303 dat << std::format("{:>3} {:>12.6f} {:>12.6f} {:>12.6f}\n", i,
304 arc[i] - arc[saddleIndex],
305 points[i].energy - saddleEnergy, points[i].maxForce);
306 }
309
310 const size_t minBefore =
pot->forceCallCounter;
311 irc.endsRelaxed =
true;
312 const IrcBranch *branches[2] = {&path.minus, &path.plus};
313 for (int k = 0; k < 2; ++k) {
315 if (!branches[k]->positions.empty()) {
316 end.setPositions(branches[k]->positions.back());
317 }
318 irc.endsRelaxed = end.relax(
true) &&
irc.endsRelaxed;
319 irc.energies[k] = end.getPotentialEnergy();
321 irc.connectsReactant =
irc.connectsReactant ||
reactant.compare(end);
322 const std::string name = std::format("irc_min{}.con", k + 1);
325 QUILL_LOG_ERROR(
log,
"Failed to write {}", name);
326 }
327 }
328 irc.forceCallsMin =
pot->forceCallCounter - minBefore;
330 "[Saddle Search] IRC: {} of 2 branches at a minimum, {} force "
331 "calls, {} more to relax the ends",
332 irc.branchesAtMinimum,
irc.forceCalls,
irc.forceCallsMin);
333}
struct eonc::SaddleSearchJob::IrcSummary irc
IrcPath followIrc(const Matter &saddle, const AtomMatrix &mode, const Parameters ¶ms)
Follows the rgsaddle IRC from a converged saddle along both signs of its lowest mode.