Loading...
Searching...
No Matches
ParametersSSOT.cpp
Go to the documentation of this file.
1/*
2** Apply defaults originating from schema/eon_params.capnp (via codegen).
3*/
7
8#include <string>
9#include <unordered_set>
10
11namespace eonc::config {
12namespace {
13
14using GD = eonc::params_ssot::GeneratedDefaults;
15
16// Catalog field index for ssot_has_field (mirrors generated catalog sections).
17const std::unordered_set<std::string> &field_index() {
18 static const std::unordered_set<std::string> idx = {
19#include "eon/generated/ParametersSSOTFieldIndex.inc"
20 };
21 return idx;
22}
23
24JobType job_from_ssot(std::string_view j) {
25 if (j == "process_search")
27 if (j == "minimization")
29 if (j == "saddle_search")
31 if (j == "basin_hopping")
33 if (j == "parallel_replica" || j == "unbiased_parallel_replica")
35 if (j == "nudged_elastic_band")
37 if (j == "dynamics" || j == "molecular_dynamics")
38 return JobType::Dynamics;
39 if (j == "hessian")
40 return JobType::Hessian;
41 if (j == "point")
42 return JobType::Point;
43 if (j == "prefactor")
44 return JobType::Prefactor;
45 if (j == "monte_carlo")
47 if (j == "structure_comparison")
49 if (j == "gp_surrogate")
51 if (j == "safe_hyperdynamics")
53 if (j == "tad")
54 return JobType::TAD;
55 if (j == "replica_exchange")
57 if (j == "finite_difference" || j == "finite_differences")
59 if (j == "global_optimization")
62}
63
64PotType pot_from_ssot(std::string_view pot) {
65 if (pot == "lj")
66 return PotType::LJ;
67 if (pot == "eam_al")
68 return PotType::EAM_AL;
69 if (pot == "emt")
70 return PotType::EMT;
71 if (pot == "lammps")
72 return PotType::LAMMPS;
73 if (pot == "morse_pt")
74 return PotType::MORSE_PT;
75 if (pot == "metatomic")
76 return PotType::METATOMIC;
77 if (pot == "xtb")
78 return PotType::XTB;
79 if (pot == "rgpot")
80 return PotType::RGPOT;
81 if (pot == "ext_pot")
82 return PotType::EXT_POT;
83 return PotType::LJ;
84}
85
86OptType opt_from_ssot(std::string_view m) {
87 if (m == "cg")
88 return OptType::CG;
89 if (m == "lbfgs")
90 return OptType::LBFGS;
91 if (m == "qm" || m == "quickmin")
92 return OptType::QM;
93 if (m == "sd")
94 return OptType::SD;
95 if (m == "fire")
96 return OptType::FIRE;
97 return OptType::CG;
98}
99
100} // namespace
101
103 p.main_options.job = job_from_ssot(GD::MAIN_JOB);
104 p.main_options.randomSeed = GD::MAIN_RANDOM_SEED;
105 p.main_options.temperature = GD::MAIN_TEMPERATURE;
106 p.main_options.quiet = GD::MAIN_QUIET;
107 p.main_options.writeLog = GD::MAIN_WRITE_LOG;
108 p.main_options.checkpoint = GD::MAIN_CHECKPOINT;
109 p.main_options.iniFilename = std::string(GD::MAIN_INI_FILENAME);
110 p.main_options.conFilename = std::string(GD::MAIN_CON_FILENAME);
111 p.main_options.finiteDifference = GD::MAIN_FINITE_DIFFERENCE;
112 p.main_options.maxForceCalls = GD::MAIN_MAX_FORCE_CALLS;
113 p.main_options.removeNetForce = GD::MAIN_REMOVE_NET_FORCE;
114 p.main_options.writeConForces = GD::MAIN_WRITE_CON_FORCES;
115 p.main_options.parallel = GD::MAIN_PARALLEL;
116
117 p.potential_options.potential = pot_from_ssot(GD::POTENTIAL_POTENTIAL);
118 p.potential_options.MPIPollPeriod = GD::POTENTIAL_MPI_POLL_PERIOD;
119 p.potential_options.LAMMPSLogging = GD::POTENTIAL_LAMMPS_LOGGING;
120 p.potential_options.LAMMPSThreads = GD::POTENTIAL_LAMMPS_THREADS;
121 p.potential_options.EMTRasmussen = GD::POTENTIAL_EMT_RASMUSSEN;
122 p.potential_options.LogPotential = GD::POTENTIAL_LOG_POTENTIAL;
123 p.potential_options.extPotPath = std::string(GD::POTENTIAL_EXT_POT_PATH);
125 std::string(GD::POTENTIAL_POTENTIALS_PATH);
126
128 GD::STRUCTURE_COMPARISON_DISTANCE_DIFFERENCE;
130 GD::STRUCTURE_COMPARISON_NEIGHBOR_CUTOFF;
132 GD::STRUCTURE_COMPARISON_CHECK_ROTATION;
134 GD::STRUCTURE_COMPARISON_INDISTINGUISHABLE_ATOMS;
136 GD::STRUCTURE_COMPARISON_ENERGY_DIFFERENCE;
138 GD::STRUCTURE_COMPARISON_REMOVE_TRANSLATION;
139
140 p.process_search_options.minimize_first = GD::PROCESS_SEARCH_MINIMIZE_FIRST;
142 GD::PROCESS_SEARCH_MINIMIZATION_OFFSET;
143
144 p.optimizer_options.method = opt_from_ssot(GD::OPTIMIZER_OPT_METHOD);
146 std::string(GD::OPTIMIZER_CONVERGENCE_METRIC);
147 p.optimizer_options.max_iterations = GD::OPTIMIZER_MAX_ITERATIONS;
148 p.optimizer_options.max_move = GD::OPTIMIZER_MAX_MOVE;
149 p.optimizer_options.converged_force = GD::OPTIMIZER_CONVERGED_FORCE;
150 p.optimizer_options.time_step_input = GD::OPTIMIZER_TIME_STEP;
151 p.optimizer_options.max_time_step_input = GD::OPTIMIZER_MAX_TIME_STEP;
152
153 p.optimizer_options.lbfgs.memory = GD::OPTIMIZER_LBFGS_MEMORY;
155 GD::OPTIMIZER_LBFGS_INVERSE_CURVATURE;
157 GD::OPTIMIZER_LBFGS_MAX_INVERSE_CURVATURE;
158 p.optimizer_options.lbfgs.auto_scale = GD::OPTIMIZER_LBFGS_AUTO_SCALE;
159 p.optimizer_options.lbfgs.angle_reset = GD::OPTIMIZER_LBFGS_ANGLE_RESET;
160 p.optimizer_options.lbfgs.distance_reset = GD::OPTIMIZER_LBFGS_DISTANCE_RESET;
161
162 p.optimizer_options.cg.no_overshooting = GD::OPTIMIZER_CG_NO_OVERSHOOTING;
164 GD::OPTIMIZER_CG_KNOCK_OUT_MAX_MOVE;
165 p.optimizer_options.cg.line_search = GD::OPTIMIZER_CG_LINE_SEARCH;
166 p.optimizer_options.cg.line_converged = GD::OPTIMIZER_CG_LINE_CONVERGED;
168 GD::OPTIMIZER_CG_LINE_SEARCH_MAX_ITER;
170 GD::OPTIMIZER_CG_MAX_ITER_BEFORE_RESET;
171
173 GD::OPTIMIZER_QUICKMIN_STEEPEST_DESCENT;
174 p.optimizer_options.sd.alpha = GD::OPTIMIZER_SD_ALPHA;
175 p.optimizer_options.sd.two_point = GD::OPTIMIZER_SD_TWO_POINT;
176}
177
178bool ssot_has_field(const char *section, const char *key) {
179 if (!section || !key)
180 return false;
181 std::string id = std::string(section) + "." + key;
182 return field_index().count(id) > 0;
183}
184
185} // namespace eonc::config
struct eonc::Parameters::optimizer_options_t optimizer_options
struct eonc::Parameters::structure_comparison_options_t structure_comparison_options
struct eonc::Parameters::potential_options_t potential_options
struct eonc::Parameters::process_search_options_t process_search_options
struct eonc::Parameters::main_options_t main_options
void apply_ssot_defaults(Parameters &p)
Apply SSoT defaults for covered groups (Main, Potential, Optimizer, Structure Comparison,...
bool ssot_has_field(const char *section, const char *key)
Return true if section‍/*key* (snake_case INI name) is declared in the Cap'n Proto L0 catalog for cov...
bool writeConForces
Opt-in "Forces of Component" sections in written .con frames (enables force+energy co-load on restart...
Definition Parameters.h:62
struct eonc::Parameters::optimizer_options_t::quickmin_t quickmin
struct eonc::Parameters::optimizer_options_t::sd_t sd
struct eonc::Parameters::optimizer_options_t::cg_t cg
struct eonc::Parameters::optimizer_options_t::lbfgs_t lbfgs