Loading...
Searching...
No Matches
eonc::ProcessSearchJob Class Reference

Declaration of the Process Search job. More...

#include <ProcessSearchJob.h>

Inheritance diagram for eonc::ProcessSearchJob:

Public Member Functions

 ProcessSearchJob (std::unique_ptr< Parameters > parameters, Runtime &rt)
 Process Search job Constructor.
 ProcessSearchJob (std::shared_ptr< Potential > potPassed, const Parameters &parameters)
 ~ProcessSearchJob ()=default
 Process Search job De-constructor.
std::vector< std::string > run (void) override
 Kicks off the Process Search.
std::shared_ptr< Matter > runFromMatter (std::shared_ptr< Matter > seed)
 In-process entry: seed reactant Matter, no pos.con.
std::shared_ptr< Matter > getInitial () const
std::shared_ptr< Matter > getSaddle () const
std::shared_ptr< Matter > getMin1 () const
std::shared_ptr< Matter > getMin2 () const
double prefactorForward () const
double prefactorReverse () const
double barrierForward () const
double barrierReverse () const
Public Member Functions inherited from eonc::Job
void adoptRuntime (std::unique_ptr< Runtime > rt)
 Take ownership of a Runtime previously passed as Runtime&.
 Job (std::unique_ptr< Parameters > parameters, Runtime &rt)
 Borrow: caller keeps Runtime alive (CLI stack / Python Session).
 Job (std::unique_ptr< Parameters > parameters, std::unique_ptr< Runtime > rt)
 Own a Runtime (one-shot makeJob / rvalue).
 Job (std::unique_ptr< Parameters > parameters)
 Own a default-constructed Runtime.
 Job (std::shared_ptr< Potential > potPassed, const Parameters &parameters)
virtual ~Job ()=default
JobType getType ()
PotRegistry & pots () noexcept
size_t potRegistryForceCalls () const noexcept
 Force calls charged to pot's registry.
void releasePotential ()
 Drop the Potential so on_destroyed is recorded before Runtime dies.

Private Member Functions

std::shared_ptr< Matter > runPrepared ()
int doProcessSearch (void)
 Runs the correct saddle search; also checks if the run was successful.
void printEndState (int status)
 Logs the run status and makes sure the run was successful.
void saveData (int status)
 Writes the results from the run to file.

Private Attributes

eonc::log::Scoped log
std::vector< std::string > returnFiles
 Container for the results of the run.
std::unique_ptr< SaddleSearchMethod > saddleSearch
 Pulled from parameters.
std::shared_ptr< Matter > initial
 Initial configuration.
std::shared_ptr< Matter > saddle
 Configuration used during the saddle point search.
std::shared_ptr< Matter > displacement
 Configuration used during the saddle point search.
std::shared_ptr< Matter > min1
 First minimum from the saddle.
std::shared_ptr< Matter > min2
 Second minimum from the saddle.
double barriersValues [2] {0.0, 0.0}
double prefactorsValues [2] {0.0, 0.0}
size_t fCallsSaddle {0}
 Force calls to find the saddle.
size_t fCallsMin {0}
 Force calls to minimize.
size_t fCallsPrefactors {0}
 Force calls to find the prefactors.

Additional Inherited Members

Protected Member Functions inherited from eonc::Job
 Job (std::unique_ptr< Parameters > parameters, Runtime &rt, ExclusivePotential)
Protected Attributes inherited from eonc::Job
JobType jtype
Parameters params
std::unique_ptr< Runtime > owned_runtime_
 Non-null when this Job owns the composition root (one-shot makeJob).
Runtime * runtime_
 Always valid: either owned_runtime_.get() or a caller-owned Runtime.
std::unique_ptr< Potential > ownedPot
 Exclusive until a multi-owner job promotes it in the public constructor.
std::shared_ptr< Potential > pot
 Set when one Potential is shared across Matters, images, or a caller.

Detailed Description

Declaration of the Process Search job.

Definition at line 45 of file ProcessSearchJob.h.

Constructor & Destructor Documentation

◆ ProcessSearchJob() [1/2]

eonc::ProcessSearchJob::ProcessSearchJob ( std::unique_ptr< Parameters > parameters,
Runtime & rt )
inline

Process Search job Constructor.

Parameters
parametersdefined by the config.init file
rtprocess runtime

Definition at line 52 of file ProcessSearchJob.h.

53 : Job(std::move(parameters), rt), fCallsSaddle{0}, fCallsMin{0},
Job(std::unique_ptr< Parameters > parameters, Runtime &rt, ExclusivePotential)
Definition Job.h:71
size_t fCallsPrefactors
Force calls to find the prefactors.
size_t fCallsMin
Force calls to minimize.
size_t fCallsSaddle
Force calls to find the saddle.

◆ ProcessSearchJob() [2/2]

eonc::ProcessSearchJob::ProcessSearchJob ( std::shared_ptr< Potential > potPassed,
const Parameters & parameters )
inline

Definition at line 55 of file ProcessSearchJob.h.

57 : Job(std::move(potPassed), parameters), fCallsSaddle{0}, fCallsMin{0},

◆ ~ProcessSearchJob()

eonc::ProcessSearchJob::~ProcessSearchJob ( )
default

Process Search job De-constructor.

Member Function Documentation

◆ barrierForward()

double eonc::ProcessSearchJob::barrierForward ( ) const
inline

Definition at line 72 of file ProcessSearchJob.h.

72{ return barriersValues[0]; }

◆ barrierReverse()

double eonc::ProcessSearchJob::barrierReverse ( ) const
inline

Definition at line 73 of file ProcessSearchJob.h.

73{ return barriersValues[1]; }

◆ doProcessSearch()

int eonc::ProcessSearchJob::doProcessSearch ( void )
private

Runs the correct saddle search; also checks if the run was successful.

Definition at line 287 of file ProcessSearchJob.cpp.

287 {
288 Matter matterTemp(pot, params);
289 long status;
290 size_t fctmp{0};
291
292 fctmp = potRegistryForceCalls();
293 status = saddleSearch->run();
294 if (params.saddle_search_options().method == "min_mode" &&
295 params.saddle_search_options().minmode_method ==
297 fCallsSaddle += saddleSearch->getForceCalls();
298 } else if (params.saddle_search_options().method == "artn") {
299 fCallsSaddle += saddleSearch->getForceCalls();
300 } else {
302 }
303 EONC_LOG_DEBUG("Got {} calls in the saddle search, with previous {}",
304 fCallsSaddle, fctmp);
305
306 if (status != MinModeSaddleSearch::STATUS_GOOD) {
307 return status;
308 }
309
310 AtomMatrix posSaddle = saddle->getPositions();
311 AtomMatrix displacedPos;
312
313 // Matter's copy assignment copies the potential; keep each endpoint's
314 // own instance so the two minimizations can run at the same time.
315 const auto min1Pot = min1->getPotential();
316 const auto min2Pot = min2->getPotential();
317 *min1 = *saddle;
318 min1->setPotential(min1Pot);
319
320 displacedPos =
321 posSaddle - saddleSearch->getEigenvector() *
322 params.process_search_options().minimization_offset;
323 min1->setPositions(displacedPos);
324
325 *min2 = *saddle;
326 min2->setPotential(min2Pot);
327 displacedPos =
328 posSaddle + saddleSearch->getEigenvector() *
329 params.process_search_options().minimization_offset;
330 min2->setPositions(displacedPos);
331
332 // Minimize both endpoints concurrently when the shared potential instance is
333 // safe to call from multiple threads, or when each endpoint owns a separate
334 // potential instance.
335 QUILL_LOG_DEBUG(log, "Starting Minimization 1 & 2");
336 bool converged1{false}, converged2{false};
337 long fc1_before = min1->getPotentialCalls();
338 long fc2_before = min2->getPotentialCalls();
339
340 // Two threads may share an instance only when it is thread safe; a
341 // per-image potential needs the endpoints to hold distinct instances.
342 bool canParallel = eonc::potAllowsSharedInstance(*pot) ||
343 (pot->needsPerImageInstance() &&
344 min1->getPotential().get() != min2->getPotential().get());
345 if (params.main_options().parallel && canParallel) {
346 // An exception may not leave a thread function (std::terminate), and a
347 // joinable std::thread may not be destroyed: t1 hands its error back and
348 // the caller joins before rethrowing either side's.
349 std::exception_ptr t1Error;
350 std::thread t1([&] {
351 try {
352 converged1 = min1->relax(false, params.debug_options().write_movies,
353 false, "min1");
354 } catch (...) {
355 t1Error = std::current_exception();
356 }
357 });
358 try {
359 converged2 = min2->relax(false, params.debug_options().write_movies,
360 false, "min2");
361 } catch (...) {
362 t1.join();
363 throw;
364 }
365 t1.join();
366 if (t1Error)
367 std::rethrow_exception(t1Error);
368 } else {
369 converged1 =
370 min1->relax(false, params.debug_options().write_movies, false, "min1");
371 converged2 =
372 min2->relax(false, params.debug_options().write_movies, false, "min2");
373 }
374
375 if (min1->getPotential().get() == min2->getPotential().get()) {
376 fCallsMin += min1->getPotentialCalls() - fc1_before;
377 } else {
378 fCallsMin += (min1->getPotentialCalls() - fc1_before) +
379 (min2->getPotentialCalls() - fc2_before);
380 }
381 QUILL_LOG_DEBUG(log, "Min1: {} fcalls, Min2: {} fcalls",
382 min1->getPotentialCalls() - fc1_before,
383 min2->getPotentialCalls() - fc2_before);
384
385 if (!converged1 || !converged2) {
387 }
388
389 auto sameAs = [](const Matter &a, const Matter &b) {
390 Matter probe(a);
391 return probe.compare(b);
392 };
393
394 if (!sameAs(*initial, *min1) && sameAs(*initial, *min2)) {
395 matterTemp = *min1;
396 *min1 = *min2;
397 *min2 = matterTemp;
398 }
399
400 if (!sameAs(*initial, *min1)) {
401 // Report how far off the endpoint landed. Whether the minimisation
402 // stopped just outside the state-identity tolerance or relaxed into a
403 // different state entirely calls for opposite fixes, and the status
404 // alone does not distinguish them.
405 const double tol =
406 params.structure_comparison_options().distance_difference;
407 auto countMoved = [&](const Matter &m) {
408 long moved = 0;
409 for (long i = 0; i < initial->numberOfAtoms(); ++i) {
410 if (initial
411 ->pbc(initial->getPositions().row(i) - m.getPositions().row(i))
412 .norm() > tol) {
413 ++moved;
414 }
415 }
416 return moved;
417 };
418 QUILL_LOG_INFO(log,
419 "initial != min1: {} of {} atoms past the {} A tolerance "
420 "for min1 ({} for min2); largest separation {} A",
421 countMoved(*min1), initial->numberOfAtoms(), tol,
422 countMoved(*min2), initial->perAtomNorm(*min1));
424 }
425
426 if (sameAs(*initial, *min2)) {
427 QUILL_LOG_DEBUG(log, "both minima are the initial state");
429 }
430
431 if (!params.process_search_options().minimize_first) {
432 min1 = initial;
433 }
434
435 barriersValues[0] = saddle->getPotentialEnergy() - min1->getPotentialEnergy();
436 barriersValues[1] = saddle->getPotentialEnergy() - min2->getPotentialEnergy();
437
438 if ((params.saddle_search_options().max_energy < barriersValues[0]) ||
439 (params.saddle_search_options().max_energy < barriersValues[1])) {
441 }
442
443 if (barriersValues[0] < 0.0 || barriersValues[1] < 0.0) {
445 }
446
447 if (!params.prefactor_options().default_value) {
448 // With [Main] parallel the min2 Hessian runs on min2's own instance,
449 // so only the registry sees every prefactor call.
450 fctmp = potRegistryForceCalls();
451 int prefStatus;
452 double pref1, pref2;
454 params, min1.get(), saddle.get(), min2.get(), pref1, pref2);
456 if (prefStatus == -1) {
457 EONC_LOG_ERROR("Prefactor: bad calculation");
459 }
460
461 if ((pref1 > params.prefactor_options().max_value) ||
462 (pref1 < params.prefactor_options().min_value)) {
463 EONC_LOG_ERROR("Bad reactant-to-saddle prefactor: {}", pref1);
465 }
466 if ((pref2 > params.prefactor_options().max_value) ||
467 (pref2 < params.prefactor_options().min_value)) {
468 EONC_LOG_ERROR("Bad product-to-saddle prefactor: {}", pref2);
470 }
471 prefactorsValues[0] = pref1;
472 prefactorsValues[1] = pref2;
473
474 } else {
475 prefactorsValues[0] = params.prefactor_options().default_value;
476 prefactorsValues[1] = params.prefactor_options().default_value;
477 }
479}
Eigen::Matrix< double, Eigen::Dynamic, 3, eOnStorageOrder > AtomMatrix
Definition Eigen.h:37
#define EONC_LOG_DEBUG(...)
Definition EonLogger.h:310
#define EONC_LOG_ERROR(...)
Definition EonLogger.h:328
size_t potRegistryForceCalls() const noexcept
Force calls charged to pot's registry.
Definition Job.cpp:44
std::shared_ptr< Potential > pot
Set when one Potential is shared across Matters, images, or a caller.
Definition Job.h:66
Parameters params
Definition Job.h:58
static const char MINMODE_GPRDIMER[]
eonc::log::Scoped log
std::shared_ptr< Matter > min1
First minimum from the saddle.
std::shared_ptr< Matter > min2
Second minimum from the saddle.
std::shared_ptr< Matter > saddle
Configuration used during the saddle point search.
std::shared_ptr< Matter > initial
Initial configuration.
std::unique_ptr< SaddleSearchMethod > saddleSearch
Pulled from parameters.
int getPrefactors(const Parameters &parameters, Matter *min1, Matter *saddle, Matter *min2, double &pref1, double &pref2)
Definition Prefactor.cpp:24
bool potAllowsSharedInstance(const P &p) noexcept

◆ getInitial()

std::shared_ptr< Matter > eonc::ProcessSearchJob::getInitial ( ) const
inline

Definition at line 66 of file ProcessSearchJob.h.

66{ return initial; }

◆ getMin1()

std::shared_ptr< Matter > eonc::ProcessSearchJob::getMin1 ( ) const
inline

Definition at line 68 of file ProcessSearchJob.h.

68{ return min1; }

◆ getMin2()

std::shared_ptr< Matter > eonc::ProcessSearchJob::getMin2 ( ) const
inline

Definition at line 69 of file ProcessSearchJob.h.

69{ return min2; }

◆ getSaddle()

std::shared_ptr< Matter > eonc::ProcessSearchJob::getSaddle ( ) const
inline

Definition at line 67 of file ProcessSearchJob.h.

67{ return saddle; }

◆ prefactorForward()

double eonc::ProcessSearchJob::prefactorForward ( ) const
inline

Definition at line 70 of file ProcessSearchJob.h.

70{ return prefactorsValues[0]; }

◆ prefactorReverse()

double eonc::ProcessSearchJob::prefactorReverse ( ) const
inline

Definition at line 71 of file ProcessSearchJob.h.

71{ return prefactorsValues[1]; }

◆ printEndState()

void eonc::ProcessSearchJob::printEndState ( int status)
private

Logs the run status and makes sure the run was successful.

Definition at line 532 of file ProcessSearchJob.cpp.

532 {
533 auto msg = saddleSearch->describeStatus(status);
534 if (status == MinModeSaddleSearch::STATUS_GOOD) {
535 QUILL_LOG_DEBUG(log, "[Saddle Search] {}", msg);
536 } else {
537 QUILL_LOG_ERROR(log, "[Saddle Search] {}", msg);
538 }
539}

◆ run()

std::vector< std::string > eonc::ProcessSearchJob::run ( void )
overridevirtual

Kicks off the Process Search.

Implements eonc::Job.

Definition at line 85 of file ProcessSearchJob.cpp.

85 {
86 if (params.saddle_search_options().method == "min_mode") {
88 }
89 std::string reactantFilename = eonc::helpers::getRelevantFile("pos.con");
90 std::string displacementFilename("displacement.con");
91 std::string modeFilename("direction.dat");
92 size_t fctmp{0};
93 initial = std::make_shared<Matter>(pot, params);
94 if (params.saddle_search_options().method == "min_mode" ||
95 params.saddle_search_options().method == "basin_hopping" ||
96 params.saddle_search_options().method == "bgsd") {
97 displacement = std::make_shared<Matter>(pot, params);
98 } else if (params.saddle_search_options().method == "dynamics") {
99 displacement = nullptr;
100 }
101 saddle = std::make_shared<Matter>(pot, params);
102 // Give min2 its own potential for parallel endpoint minimization.
103 std::shared_ptr<Potential> min2Pot = pot;
104 if (pot->needsPerImageInstance() && params.main_options().parallel) {
106 }
107 min1 = std::make_shared<Matter>(pot, params);
108 min2 = std::make_shared<Matter>(min2Pot, params);
109
110 if (!eonc::io::io_ok(initial->con2matter(reactantFilename))) {
111 EONC_LOG_CRITICAL("Failed to load {}", reactantFilename);
112 throw std::runtime_error("failed to load " + reactantFilename);
113 }
114
115 if (params.process_search_options().minimize_first) {
116 QUILL_LOG_DEBUG(log, "Minimizing initial structure\n");
117 fctmp = initial->getPotentialCalls();
118 initial->relax();
119 fCallsMin += initial->getPotentialCalls() - fctmp;
120 QUILL_LOG_DEBUG(log, "Initial minimization took {} fcalls",
121 initial->getPotentialCalls() - fctmp);
122 }
123
124 barriersValues[0] = barriersValues[1] = 0;
126
127 AtomMatrix mode = AtomMatrix::Zero(initial->numberOfAtoms(), 3);
128 if (params.saddle_search_options().method == "min_mode" ||
129 params.saddle_search_options().method == "basin_hopping" ||
130 params.saddle_search_options().method == "bgsd") {
131 if (params.saddle_search_options().displace_type ==
133 // Load displacement.con, or synthesize from pos.con + direction.dat
134 // (#79).
136 *saddle, *initial, displacementFilename, modeFilename,
137 params.saddle_search_options().displace_magnitude)) {
138 EONC_LOG_CRITICAL("Failed to load {} (and no usable {})",
139 displacementFilename, modeFilename);
140 throw std::runtime_error("failed to load " + displacementFilename);
141 }
142 *min1 = *min2 = *initial;
144 &mode)) {
145 *min1 = *min2 = *initial;
146 } else {
147 *saddle = *min1 = *min2 = *initial;
148 }
149 if (displacement) {
151 }
152 } else {
153 // ARTn and dynamics start from the initial minimum
154 *saddle = *min1 = *min2 = *initial;
155 }
156 min2->setPotential(min2Pot);
157
158 const bool useARTnAsMinMode =
159 params.saddle_search_options().method == "min_mode" &&
160 params.saddle_search_options().minmode_method == "artn";
161
162 if (params.saddle_search_options().method == "min_mode") {
163 if (params.saddle_search_options().displace_type ==
165 std::filesystem::exists(modeFilename)) {
166 mode = eonc::helpers::loadMode(modeFilename, initial->numberOfAtoms());
167 }
168#ifdef WITH_ARTN
169 // ARTn as a min-mode drop-in: eOn displaces, seeds the mode, ARTn
170 // takes over from the displaced structure.
171 if (useARTnAsMinMode) {
173 std::make_unique<ARTnSaddleSearch>(saddle, pot, mode, params);
174 } else
175#endif
176 {
177 auto minMode = std::make_unique<MinModeSaddleSearch>(
178 saddle, mode, initial->getPotentialEnergy(), params, pot);
179 if (params.process_search_options().known_saddles) {
180 loadKnownSaddles("known_saddles.dat", *initial, *minMode);
181 }
182 saddleSearch = std::move(minMode);
183 }
184#ifdef WITH_ARTN
185 } else if (params.saddle_search_options().method == "artn") {
186 // ARTn handles its own push from the minimum, eigenmode estimation,
187 // and perpendicular relaxation internally.
188 AtomMatrix artnMode = AtomMatrix::Zero(initial->numberOfAtoms(), 3);
189 if (params.saddle_search_options().displace_type ==
191 std::filesystem::exists(modeFilename)) {
192 artnMode =
193 eonc::helpers::loadMode(modeFilename, initial->numberOfAtoms());
194 }
196 std::make_unique<ARTnSaddleSearch>(saddle, pot, artnMode, params);
197#endif
198 } else if (params.saddle_search_options().method == "basin_hopping") {
200 std::make_unique<BasinHoppingSaddleSearch>(min1, saddle, pot, params);
201 } else if (params.saddle_search_options().method == "dynamics") {
202 saddleSearch = std::make_unique<DynamicsSaddleSearch>(saddle, params);
203 } else if (params.saddle_search_options().method == "bgsd") {
204 saddleSearch = std::make_unique<BiasedGradientSquaredDescent>(
205 saddle, initial->getPotentialEnergy(), params);
206 }
207
208#ifndef WITH_ARTN
209 // Post-dispatch guard for both ARTn entry points so users without a
210 // WITH_ARTN build get a clean per-case error instead of a silent
211 // fall-through. Two distinct messages so downstream tooling and the
212 // integration tests can match on the specific entry point.
213 if (params.saddle_search_options().method == "artn") {
214 throw std::runtime_error(
215 "saddle_search.method=artn requires a build with ARTn support "
216 "(reconfigure with -Dwith_artn=true)");
217 }
218 if (useARTnAsMinMode) {
219 throw std::runtime_error(
220 "saddle_search.minmode_method=artn requires a build with ARTn "
221 "support (reconfigure with -Dwith_artn=true)");
222 }
223#endif
224
225 if (!saddleSearch) {
226 throw std::runtime_error("unknown saddle_search.method");
227 }
228
229 static_cast<void>(runPrepared());
230 return returnFiles;
231}
#define EONC_LOG_CRITICAL(...)
Definition EonLogger.h:334
std::shared_ptr< Matter > displacement
Configuration used during the saddle point search.
std::vector< std::string > returnFiles
Container for the results of the run.
std::shared_ptr< Matter > runPrepared()
const char DISP_LOAD[]
Definition EpiCenters.h:20
bool applyClientDisplacement(Matter &target, const Matter &initial, const Parameters &params, AtomMatrix *modeOut)
std::string getRelevantFile(std::string filename)
std::shared_ptr< Potential > makeImagePotential(const Potential &pot, const Parameters &params)
A separate instance of pot for one image of a band, dimer or pair of minimizations: a clone when the ...
bool loadOrSynthesizeDisplacement(Matter &target, const Matter &initial, const std::string &displacementPath, const std::string &modePath, double scale)
AtomMatrix loadMode(FILE *modeFile, int nAtoms)
constexpr bool io_ok(IoStatus s) noexcept
Definition ConFileIO.h:38
void requirePrfoRefine(const Parameters &params)
Does nothing unless [Saddle Search] prfo_refine is on.

◆ runFromMatter()

std::shared_ptr< Matter > eonc::ProcessSearchJob::runFromMatter ( std::shared_ptr< Matter > seed)

In-process entry: seed reactant Matter, no pos.con.

Definition at line 234 of file ProcessSearchJob.cpp.

234 {
235 if (!seed) {
236 throw std::runtime_error("ProcessSearchJob::runFromMatter: null Matter");
237 }
238 initial = seed;
239 initial->setPotential(pot);
240 std::shared_ptr<Potential> min2Pot = pot;
241 if (pot->needsPerImageInstance() && params.main_options().parallel) {
243 }
244 displacement = std::make_shared<Matter>(pot, params);
245 saddle = std::make_shared<Matter>(pot, params);
246 min1 = std::make_shared<Matter>(pot, params);
247 min2 = std::make_shared<Matter>(min2Pot, params);
248 AtomMatrix mode = AtomMatrix::Zero(initial->numberOfAtoms(), 3);
250 &mode)) {
251 *saddle = *initial;
252 }
254 *min1 = *min2 = *initial;
255 min2->setPotential(min2Pot);
256 if (params.saddle_search_options().method == "min_mode") {
257 saddleSearch = std::make_unique<MinModeSaddleSearch>(
258 saddle, mode, initial->getPotentialEnergy(), params, pot);
259 } else if (params.saddle_search_options().method == "basin_hopping") {
261 std::make_unique<BasinHoppingSaddleSearch>(min1, saddle, pot, params);
262 } else if (params.saddle_search_options().method == "dynamics") {
263 saddleSearch = std::make_unique<DynamicsSaddleSearch>(saddle, params);
264 } else if (params.saddle_search_options().method == "bgsd") {
265 saddleSearch = std::make_unique<BiasedGradientSquaredDescent>(
266 saddle, initial->getPotentialEnergy(), params);
267 } else {
268 throw std::runtime_error(
269 "ProcessSearchJob::runFromMatter: unsupported saddle_search.method");
270 }
271 return runPrepared();
272}

◆ runPrepared()

std::shared_ptr< Matter > eonc::ProcessSearchJob::runPrepared ( )
private

Definition at line 274 of file ProcessSearchJob.cpp.

274 {
275 if (!saddleSearch) {
276 throw std::runtime_error("unknown saddle_search.method");
277 }
278
279 int status = doProcessSearch();
280
281 printEndState(status);
282 saveData(status);
283
284 return min2 ? min2 : saddle;
285}
void printEndState(int status)
Logs the run status and makes sure the run was successful.
void saveData(int status)
Writes the results from the run to file.
int doProcessSearch(void)
Runs the correct saddle search; also checks if the run was successful.

◆ saveData()

void eonc::ProcessSearchJob::saveData ( int status)
private

Writes the results from the run to file.

Definition at line 481 of file ProcessSearchJob.cpp.

481 {
482 std::string resultsFilename("results.dat");
483 returnFiles.push_back(resultsFilename);
484
485 const bool dynamics = params.saddle_search_options().method == "dynamics";
486 double simTime = 0.0;
487 double mdTemp = 0.0;
488 if (dynamics) {
489 auto ds = dynamic_cast<DynamicsSaddleSearch &>(*saddleSearch);
490 simTime = ds.time * params.constants().timeUnit;
491 mdTemp = params.saddle_search_options().dynamics.temperature;
492 }
493 const double disp = params.saddle_search_options().method == "min_mode"
494 ? displacement->perAtomNorm(*saddle)
495 : 0.0;
497 status, std::string(saddleSearch->describeStatus(status)),
498 params.potential_options().potential, params.main_options().randomSeed,
499 fCallsMin, fCallsSaddle, fCallsPrefactors, saddle->getPotentialEnergy(),
500 min1->getPotentialEnergy(), min2->getPotentialEnergy(), barriersValues[0],
502 dynamics, simTime, mdTemp);
503 env.provenance = provenanceForJob(params);
504 env.reactant_frame = eonc::io::matterToConFrame(*min1);
505 env.saddle_frame = eonc::io::matterToConFrame(*saddle);
506 env.product_frame = eonc::io::matterToConFrame(*min2);
507 env.writeResultsDat(resultsFilename);
508
509 std::string reactantFilename("reactant.con");
510 returnFiles.push_back(reactantFilename);
511 if (!eonc::io::io_ok(min1->matter2con(reactantFilename))) {
512 QUILL_LOG_ERROR(log, "Failed to write {}", reactantFilename);
513 }
514
515 std::string modeFilename("mode.dat");
516 returnFiles.push_back(modeFilename);
517 eonc::helpers::saveMode(modeFilename, saddle, saddleSearch->getEigenvector());
518
519 std::string saddleFilename("saddle.con");
520 returnFiles.push_back(saddleFilename);
521 if (!eonc::io::io_ok(saddle->matter2con(saddleFilename))) {
522 QUILL_LOG_ERROR(log, "Failed to write {}", saddleFilename);
523 }
524
525 std::string productFilename("product.con");
526 returnFiles.push_back(productFilename);
527 if (!eonc::io::io_ok(min2->matter2con(productFilename))) {
528 QUILL_LOG_ERROR(log, "Failed to write {}", productFilename);
529 }
530}
void saveMode(FILE *modeFile, std::shared_ptr< Matter > matter, AtomMatrix mode)
Write a mode; constrained axes are emitted as 0.
readcon::ConFrame matterToConFrame(Matter &m, const ConFrameMetadata *metadata)
Build a single stamped ConFrame from Matter (same builder as matter2con).
JobResultProvenance provenanceForJob(const Parameters &params)
Optimizer backend, engine identity, rgpot pin, and xts ABI from a job.
static JobResultEnvelope fromProcessSearch(int status, std::string statusText, PotType pot, std::int64_t seed, std::uint64_t fMin, std::uint64_t fSaddle, std::uint64_t fPref, double eSaddle, double eReactant, double eProduct, double barrierFwd, double barrierRev, double displacement, double prefFwd, double prefRev, bool dynamics, double simTime, double mdTemp)
Definition JobResult.h:265

Member Data Documentation

◆ barriersValues

double eonc::ProcessSearchJob::barriersValues[2] {0.0, 0.0}
private

Array containg the value of the potential barriers from reactant to product and vice versa

Definition at line 107 of file ProcessSearchJob.h.

107{0.0, 0.0};

◆ displacement

std::shared_ptr<Matter> eonc::ProcessSearchJob::displacement
private

Configuration used during the saddle point search.

Definition at line 99 of file ProcessSearchJob.h.

◆ fCallsMin

size_t eonc::ProcessSearchJob::fCallsMin {0}
private

Force calls to minimize.

Definition at line 115 of file ProcessSearchJob.h.

115{0};

◆ fCallsPrefactors

size_t eonc::ProcessSearchJob::fCallsPrefactors {0}
private

Force calls to find the prefactors.

Definition at line 117 of file ProcessSearchJob.h.

117{0};

◆ fCallsSaddle

size_t eonc::ProcessSearchJob::fCallsSaddle {0}
private

Force calls to find the saddle.

Definition at line 113 of file ProcessSearchJob.h.

113{0};

◆ initial

std::shared_ptr<Matter> eonc::ProcessSearchJob::initial
private

Initial configuration.

Definition at line 95 of file ProcessSearchJob.h.

◆ log

eonc::log::Scoped eonc::ProcessSearchJob::log
private

Definition at line 76 of file ProcessSearchJob.h.

◆ min1

std::shared_ptr<Matter> eonc::ProcessSearchJob::min1
private

First minimum from the saddle.

Definition at line 101 of file ProcessSearchJob.h.

◆ min2

std::shared_ptr<Matter> eonc::ProcessSearchJob::min2
private

Second minimum from the saddle.

Definition at line 103 of file ProcessSearchJob.h.

◆ prefactorsValues

double eonc::ProcessSearchJob::prefactorsValues[2] {0.0, 0.0}
private

Array containg the value of the prefactors of the matter from reactant to product and vice versa

Definition at line 110 of file ProcessSearchJob.h.

110{0.0, 0.0};

◆ returnFiles

std::vector<std::string> eonc::ProcessSearchJob::returnFiles
private

Container for the results of the run.

Definition at line 86 of file ProcessSearchJob.h.

◆ saddle

std::shared_ptr<Matter> eonc::ProcessSearchJob::saddle
private

Configuration used during the saddle point search.

Definition at line 97 of file ProcessSearchJob.h.

◆ saddleSearch

std::unique_ptr<SaddleSearchMethod> eonc::ProcessSearchJob::saddleSearch
private

The documentation for this class was generated from the following files: