Virtual run; used solely for dynamic dispatch.
29 {
30 std::string posInFilename("pos.con");
31 std::string posOutFilename("min.con");
32
33 if (
params.main_options().checkpoint) {
34 if (std::filesystem::exists("pos_cp.con")) {
35 posInFilename = "pos_cp.con";
36 QUILL_LOG_DEBUG(
log,
"[Minimization] Resuming from checkpoint");
37 } else {
38 QUILL_LOG_DEBUG(
log,
"[Minimization] No checkpoint files found");
39 }
40 }
41
42 std::vector<std::string> returnFiles;
43 returnFiles.push_back(posOutFilename);
44
45 auto pos = std::make_shared<Matter>(
pot,
params);
47 QUILL_LOG_CRITICAL(
log,
"Failed to load {}", posInFilename);
48 throw std::runtime_error("failed to load " + posInFilename);
49 }
50
51 QUILL_LOG_DEBUG(
log,
"\nBeginning minimization of {}", posInFilename);
52
53 bool converged;
54 try {
55 converged =
56 pos->relax(
false,
params.debug_options().write_movies,
57 params.main_options().checkpoint,
"minimization",
"pos");
58 if (converged) {
60 QUILL_LOG_DEBUG(
log,
"Minimization converged within tolerence");
61 } else {
63 QUILL_LOG_DEBUG(
log,
"Minimization did not converge to tolerence!"
64 "Maybe try to increase max_iterations?");
65 }
66 } catch (int e) {
67 if (e == 100) {
69 } else {
70 throw e;
71 }
72 } catch (const std::exception &e) {
73 QUILL_LOG_ERROR(
log,
"Minimization potential failed: {}", e.what());
75 }
76
77 QUILL_LOG_DEBUG(
log,
"Saving result to {}", posOutFilename);
79 QUILL_LOG_ERROR(
log,
"Failed to write {}", posOutFilename);
80 }
82 QUILL_LOG_DEBUG(
log,
"Final Energy: {}", pos->getPotentialEnergy());
83 }
84
85 std::filesystem::path resultsFilename("results.dat");
86 returnFiles.push_back(resultsFilename.string());
87
89 const double energy = hasE ? pos->getPotentialEnergy() : 0.0;
92 this->pot->forceCallCounter.load(), hasE, energy);
93 env.tags.emplace_back("optimizer", std::string(magic_enum::enum_name(
94 params.optimizer_options().method)));
96 env.tags.emplace_back("xtsci_method",
97 params.optimizer_options().xtsci.method);
98 }
101 }
102 env.writeResultsDat(resultsFilename.string());
103
104 return returnFiles;
105}
std::shared_ptr< Potential > pot
constexpr bool io_ok(IoStatus s) noexcept
const std::string & provenance()
Stamp text from the last successful eindir bind. Empty when unused.
static JobResultEnvelope fromMinimization(RunStatus status, PotType pot, std::uint64_t fcalls, bool hasE, double energy)