28 std::string reactantFilename(
"pos.con");
29 std::string displacementFilename(
"displacement.con");
30 std::string modeFilename(
"direction.dat");
32 if (
params.main_options.checkpoint) {
33 if (std::filesystem::exists(
"displacement_cp.con") &&
34 std::filesystem::exists(
"mode_cp.dat")) {
35 displacementFilename =
"displacement_cp.con";
36 modeFilename =
"mode_cp.dat";
37 QUILL_LOG_DEBUG(
log,
"Resuming from checkpoint");
39 QUILL_LOG_DEBUG(
log,
"No checkpoint files found");
49 throw std::runtime_error(
"failed to load " + reactantFilename);
52 const bool standaloneARTn =
params.saddle_search_options.method ==
"artn";
54 if (!standaloneARTn &&
params.saddle_search_options.displace_type ==
59 params.saddle_search_options.displace_magnitude)) {
61 displacementFilename, modeFilename);
62 throw std::runtime_error(
"missing displacement.con and direction.dat");
69 const bool canLoadMode =
71 if (canLoadMode && std::filesystem::exists(modeFilename)) {
75 const bool useStandaloneARTn =
params.saddle_search_options.method ==
"artn";
76 const bool useARTnAsMinMode =
77 params.saddle_search_options.method ==
"min_mode" &&
78 params.saddle_search_options.minmode_method ==
"artn";
81 if (useStandaloneARTn || useARTnAsMinMode) {
88 if (useStandaloneARTn) {
89 throw std::runtime_error(
90 "saddle_search.method=artn requires a build with ARTn support");
92 if (useARTnAsMinMode) {
93 throw std::runtime_error(
94 "saddle_search.minmode_method=artn requires a build with ARTn "
113 f1 = this->
pot->forceCallCounter;
120 printf(
"unknown exception: %i\n", e);
125 if (
params.saddle_search_options.method ==
"min_mode" &&
126 params.saddle_search_options.minmode_method ==
129 }
else if (
params.saddle_search_options.method ==
"artn") {
139 std::string resultsFilename(
"results.dat");
142 std::ofstream out(resultsFilename, std::ios::binary);
144 out << std::format(
"{} termination_reason\n", status);
145 out << std::format(
"{} termination_reason_text\n",
147 out <<
"saddle_search job_type\n";
148 out << std::format(
"{} random_seed\n",
params.main_options.randomSeed);
150 "{} potential_type\n",
151 magic_enum::enum_name<PotType>(
params.potential_options.potential));
152 out << std::format(
"{} total_force_calls\n",
153 this->
pot->forceCallCounter.load());
154 out << std::format(
"{} force_calls_saddle\n",
fCallsSaddle);
155 out << std::format(
"{} iterations\n",
saddleSearch->getIterationCount());
157 out << std::format(
"{:f} potential_energy_saddle\n",
158 saddle->getPotentialEnergy());
159 out << std::format(
"{:f} final_eigenvalue\n",
162 out << std::format(
"{:f} potential_energy_reactant\n",
163 initial->getPotentialEnergy());
166 std::string modeFilename(
"mode.dat");
170 std::string saddleFilename(
"saddle.con");
173 QUILL_LOG_ERROR(
log,
"Failed to write {}", saddleFilename);
180 QUILL_LOG_DEBUG(
log,
"[Saddle Search] {}", msg);
182 QUILL_LOG_WARNING(
log,
"[Saddle Search] {}", msg);
Eigen::Matrix< double, Eigen::Dynamic, 3, eOnStorageOrder > AtomMatrix
#define EONC_LOG_CRITICAL(...)
Finds transition states by finding saddle points on the potential energy surface.
std::vector< std::string > run(void)
Kicks off the Saddle Search.
std::shared_ptr< Potential > pot
static const char MINMODE_GPRDIMER[]
@ STATUS_POTENTIAL_FAILED
void saveData(int status)
Writes the results from the run to file.
std::unique_ptr< SaddleSearchMethod > saddleSearch
Initializes a ref SaddleSearchMethod (base class for polymorphism).
std::vector< std::string > returnFiles
Container for the results of the run.
std::shared_ptr< Matter > saddle
Configuration used during the saddle point search.
int fCallsSaddle
Force calls to find the saddle.
std::shared_ptr< Matter > displacement
Configuration used during the saddle point search.
void printEndState(int status)
Logs the run status and makes sure the run was successful.
int doSaddleSearch()
Runs the correct saddle search; also checks if the run was successful.
std::shared_ptr< Matter > initial
Initial configuration.
bool loadOrSynthesizeDisplacement(Matter &target, const Matter &initial, const std::string &displacementPath, const std::string &modePath, double scale)
AtomMatrix loadMode(FILE *modeFile, int nAtoms)
void saveMode(FILE *modeFile, std::shared_ptr< Matter > matter, AtomMatrix mode)
Write a mode; constrained axes are emitted as 0.
constexpr bool io_ok(IoStatus s) noexcept