Virtual run; used solely for dynamic dispatch.
23 {
24 std::string posInFilename("pos.con");
25 std::string posOutFilename("out.con");
26
27 if (
params.main_options.checkpoint) {
28 if (std::filesystem::exists("pos_cp.con")) {
29 posInFilename = "pos_cp.con";
30 QUILL_LOG_DEBUG(
log,
"Resuming from checkpoint\n");
31 } else {
32 QUILL_LOG_DEBUG(
log,
"No checkpoint files found\n");
33 }
34 }
35
36 std::vector<std::string> returnFiles;
37
38 auto matter = std::make_shared<Matter>(
pot,
params);
40 QUILL_LOG_CRITICAL(
log,
"Failed to load {}", posInFilename);
41 throw std::runtime_error("failed to load " + posInFilename);
42 }
43
44 MonteCarlo mc = MonteCarlo(matter,
params);
45 mc.
run(
params.monte_carlo_options.steps,
params.main_options.temperature,
46 params.monte_carlo_options.step_size);
47
48 QUILL_LOG_DEBUG(
log,
"Saving result to {}", posOutFilename);
50 returnFiles.push_back(posOutFilename);
51 } else {
52 QUILL_LOG_ERROR(
log,
"Failed to write {}", posOutFilename);
53 }
54
55 std::string resultsFilename("results.dat");
56
57 std::ofstream out(resultsFilename, std::ios::binary);
58 if (!out) {
59 QUILL_LOG_CRITICAL(
log,
"Failed to open {}", resultsFilename);
60 throw std::runtime_error("failed to open " + resultsFilename);
61 }
62 out << std::format(
63 "{} potential_type\n",
64 magic_enum::enum_name<PotType>(
params.potential_options.potential));
65 out << std::format("{} total_force_calls\n",
67 out << std::format("{:f} potential_energy\n", matter->getPotentialEnergy());
68 out.close();
69 if (!out) {
70 QUILL_LOG_CRITICAL(
log,
"Failed to write {}", resultsFilename);
71 throw std::runtime_error("failed to write " + resultsFilename);
72 }
73 returnFiles.push_back(resultsFilename);
74
75 return returnFiles;
76}
std::shared_ptr< Potential > pot
void run(int numSteps, double temperature, double stepSize)
static PotRegistry & get() noexcept
Process-lifetime singleton.
constexpr bool io_ok(IoStatus s) noexcept