31 std::string displacementFilename(
"displacement.con");
32 std::string modeFilename(
"direction.dat");
34 if (
params.main_options().checkpoint) {
35 if (std::filesystem::exists(
"displacement_cp.con") &&
36 std::filesystem::exists(
"mode_cp.dat")) {
37 displacementFilename =
"displacement_cp.con";
38 modeFilename =
"mode_cp.dat";
39 QUILL_LOG_DEBUG(
log,
"Resuming from checkpoint");
41 QUILL_LOG_DEBUG(
log,
"No checkpoint files found");
51 throw std::runtime_error(
"failed to load " + reactantFilename);
54 const bool standaloneARTn =
params.saddle_search_options().method ==
"artn";
57 if (!standaloneARTn &&
params.saddle_search_options().displace_type ==
62 params.saddle_search_options().displace_magnitude)) {
64 displacementFilename, modeFilename);
65 throw std::runtime_error(
"missing displacement.con and direction.dat");
67 if (std::filesystem::exists(modeFilename)) {
77 if (standaloneARTn && std::filesystem::exists(modeFilename)) {
85std::shared_ptr<Matter>
88 throw std::runtime_error(
"SaddleSearchJob::runFromMatter: null Matter");
104 const bool useStandaloneARTn =
105 params.saddle_search_options().method ==
"artn";
106 const bool useARTnAsMinMode =
107 params.saddle_search_options().method ==
"min_mode" &&
108 params.saddle_search_options().minmode_method ==
"artn";
111 if (useStandaloneARTn || useARTnAsMinMode) {
118 if (useStandaloneARTn) {
119 throw std::runtime_error(
120 "saddle_search.method=artn requires a build with ARTn support");
122 if (useARTnAsMinMode) {
123 throw std::runtime_error(
124 "saddle_search.minmode_method=artn requires a build with ARTn "
142 f1 = this->
pot->forceCallCounter;
149 QUILL_LOG_ERROR(
log,
"unknown exception: {}", e);
152 }
catch (
const std::exception &e) {
153 QUILL_LOG_ERROR(
log,
"Saddle search potential failed: {}", e.what());
157 if (
params.saddle_search_options().method ==
"min_mode" &&
158 params.saddle_search_options().minmode_method ==
161 }
else if (
params.saddle_search_options().method ==
"artn") {
171 std::string resultsFilename(
"results.dat");
174 std::ofstream out(resultsFilename, std::ios::binary);
176 out << std::format(
"{} termination_reason\n", status);
177 out << std::format(
"{} termination_reason_text\n",
179 out <<
"saddle_search job_type\n";
180 out << std::format(
"{} random_seed\n",
params.main_options().randomSeed);
182 "{} potential_type\n",
183 magic_enum::enum_name<PotType>(
params.potential_options().potential));
184 out << std::format(
"{} total_force_calls\n",
185 this->
pot->forceCallCounter.load());
186 out << std::format(
"{} force_calls_saddle\n",
fCallsSaddle);
187 out << std::format(
"{} iterations\n",
saddleSearch->getIterationCount());
189 out << std::format(
"{:f} potential_energy_saddle\n",
190 saddle->getPotentialEnergy());
191 out << std::format(
"{:f} final_eigenvalue\n",
194 out << std::format(
"{:f} potential_energy_reactant\n",
195 initial->getPotentialEnergy());
198 std::string modeFilename(
"mode.dat");
202 std::string saddleFilename(
"saddle.con");
205 QUILL_LOG_ERROR(
log,
"Failed to write {}", saddleFilename);
212 QUILL_LOG_DEBUG(
log,
"[Saddle Search] {}", msg);
214 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::shared_ptr< Potential > pot
static const char MINMODE_GPRDIMER[]
@ STATUS_POTENTIAL_FAILED
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 > runFromMatter(std::shared_ptr< Matter > seed)
In-process entry: seed reactant Matter, no pos.con.
std::shared_ptr< Matter > saddle
Configuration used during the saddle point search.
std::vector< std::string > run(void) override
Kicks off the Saddle Search.
int doSaddleSearch()
Runs the correct saddle search; also checks if the run was successful.
int fCallsSaddle
Force calls to find the saddle.
std::shared_ptr< Matter > displacement
Configuration used during the saddle point search.
void saveData(int status)
Writes the results from the run to file.
void printEndState(int status)
Logs the run status and makes sure the run was successful.
std::shared_ptr< Matter > initial
Initial configuration.
std::shared_ptr< Matter > runPrepared(const AtomMatrix &mode)
bool applyClientDisplacement(Matter &target, const Matter &initial, const Parameters ¶ms, AtomMatrix *modeOut)
std::string getRelevantFile(std::string filename)
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
RAII resource manager for the ARTn C library with global synchronization.