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")
61 if (j == "instanton")
62 return JobType::Instanton;
64}
65
66PotType pot_from_ssot(std::string_view pot) {
67 if (pot == "lj")
68 return PotType::LJ;
69 if (pot == "eam_al")
70 return PotType::EAM_AL;
71 if (pot == "emt")
72 return PotType::EMT;
73 if (pot == "lammps")
74 return PotType::LAMMPS;
75 if (pot == "morse_pt")
76 return PotType::MORSE_PT;
77 if (pot == "metatomic")
78 return PotType::METATOMIC;
79 if (pot == "xtb")
80 return PotType::XTB;
81 if (pot == "rgpot")
82 return PotType::RGPOT;
83 if (pot == "ext_pot")
84 return PotType::EXT_POT;
85 return PotType::LJ;
86}
87
88OptType opt_from_ssot(std::string_view m) {
89 if (m == "cg")
90 return OptType::CG;
91 if (m == "lbfgs")
92 return OptType::LBFGS;
93 if (m == "qm" || m == "quickmin")
94 return OptType::QM;
95 if (m == "sd")
96 return OptType::SD;
97 if (m == "fire")
98 return OptType::FIRE;
99 if (m == "xtsci")
100 return OptType::XTSCI;
101 return OptType::CG;
102}
103
104} // namespace
105
107 ParametersLoadAccess::main_options(p).job = job_from_ssot(GD::MAIN_JOB);
108 ParametersLoadAccess::main_options(p).randomSeed = GD::MAIN_RANDOM_SEED;
109 ParametersLoadAccess::main_options(p).temperature = GD::MAIN_TEMPERATURE;
110 ParametersLoadAccess::main_options(p).quiet = GD::MAIN_QUIET;
111 ParametersLoadAccess::main_options(p).writeLog = GD::MAIN_WRITE_LOG;
112 ParametersLoadAccess::main_options(p).checkpoint = GD::MAIN_CHECKPOINT;
114 std::string(GD::MAIN_INI_FILENAME);
116 std::string(GD::MAIN_CON_FILENAME);
118 GD::MAIN_FINITE_DIFFERENCE;
120 GD::MAIN_MAX_FORCE_CALLS;
122 GD::MAIN_REMOVE_NET_FORCE;
124 GD::MAIN_WRITE_CON_FORCES;
125 ParametersLoadAccess::main_options(p).parallel = GD::MAIN_PARALLEL;
126
128 pot_from_ssot(GD::POTENTIAL_POTENTIAL);
130 GD::POTENTIAL_MPI_POLL_PERIOD;
132 GD::POTENTIAL_LAMMPS_LOGGING;
134 GD::POTENTIAL_LAMMPS_THREADS;
136 GD::POTENTIAL_EMT_RASMUSSEN;
138 GD::POTENTIAL_LOG_POTENTIAL;
140 std::string(GD::POTENTIAL_EXT_POT_PATH);
142 std::string(GD::POTENTIAL_POTENTIALS_PATH);
143
145 GD::STRUCTURE_COMPARISON_DISTANCE_DIFFERENCE;
147 GD::STRUCTURE_COMPARISON_NEIGHBOR_CUTOFF;
149 GD::STRUCTURE_COMPARISON_CHECK_ROTATION;
152 GD::STRUCTURE_COMPARISON_INDISTINGUISHABLE_ATOMS;
154 GD::STRUCTURE_COMPARISON_ENERGY_DIFFERENCE;
156 GD::STRUCTURE_COMPARISON_REMOVE_TRANSLATION;
157
159 GD::PROCESS_SEARCH_MINIMIZE_FIRST;
161 GD::PROCESS_SEARCH_MINIMIZATION_OFFSET;
162
164 opt_from_ssot(GD::OPTIMIZER_OPT_METHOD);
166 std::string(GD::OPTIMIZER_CONVERGENCE_METRIC);
168 GD::OPTIMIZER_MAX_ITERATIONS;
169 ParametersLoadAccess::optimizer_options(p).max_move = GD::OPTIMIZER_MAX_MOVE;
171 GD::OPTIMIZER_CONVERGED_FORCE;
173 GD::OPTIMIZER_TIME_STEP;
175 GD::OPTIMIZER_MAX_TIME_STEP;
176
178 GD::OPTIMIZER_LBFGS_MEMORY;
180 GD::OPTIMIZER_LBFGS_INVERSE_CURVATURE;
182 GD::OPTIMIZER_LBFGS_MAX_INVERSE_CURVATURE;
184 GD::OPTIMIZER_LBFGS_AUTO_SCALE;
186 GD::OPTIMIZER_LBFGS_ANGLE_RESET;
188 GD::OPTIMIZER_LBFGS_DISTANCE_RESET;
190 std::string(GD::OPTIMIZER_LBFGS_CURVATURE);
192 GD::OPTIMIZER_LBFGS_PROJECT_RIGID;
194 std::string(GD::OPTIMIZER_LBFGS_SECANT);
196 std::string(GD::OPTIMIZER_LBFGS_PRECON);
198 std::string(GD::OPTIMIZER_LBFGS_STEP);
200 std::string(GD::OPTIMIZER_LBFGS_H0);
202 std::string(GD::OPTIMIZER_LBFGS_ACCEPT);
204 GD::OPTIMIZER_LBFGS_EXTRA_UPDATES;
206 GD::OPTIMIZER_LBFGS_CAUTIOUS_EPS;
208 GD::OPTIMIZER_LBFGS_CAUTIOUS_ALPHA;
210 GD::OPTIMIZER_LBFGS_PRECON_A;
212 GD::OPTIMIZER_LBFGS_PRECON_MU;
214 GD::OPTIMIZER_LBFGS_PRECON_RCUT;
216 std::string(GD::OPTIMIZER_XTSCI_METHOD);
218 std::string(GD::OPTIMIZER_XTSCI_QN_STEP);
220 std::string(GD::OPTIMIZER_XTSCI_PRECON);
222 std::string(GD::OPTIMIZER_XTSCI_ACCEPT);
224 GD::OPTIMIZER_XTSCI_HIGHS;
226 std::string(GD::OPTIMIZER_XTSCI_MANIFOLD);
228 std::string(GD::OPTIMIZER_XTSCI_METHOD);
229
231 GD::OPTIMIZER_CG_NO_OVERSHOOTING;
233 GD::OPTIMIZER_CG_KNOCK_OUT_MAX_MOVE;
235 GD::OPTIMIZER_CG_LINE_SEARCH;
237 GD::OPTIMIZER_CG_LINE_CONVERGED;
239 GD::OPTIMIZER_CG_LINE_SEARCH_MAX_ITER;
241 GD::OPTIMIZER_CG_MAX_ITER_BEFORE_RESET;
242
244 GD::OPTIMIZER_QUICKMIN_STEEPEST_DESCENT;
245 ParametersLoadAccess::optimizer_options(p).sd.alpha = GD::OPTIMIZER_SD_ALPHA;
247 GD::OPTIMIZER_SD_TWO_POINT;
248}
249
250bool ssot_has_field(const char *section, const char *key) {
251 if (!section || !key)
252 return false;
253 std::string id = std::string(section) + "." + key;
254 return field_index().count(id) > 0;
255}
256
257} // namespace eonc::config
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...
static structure_comparison_options_t & structure_comparison_options(Parameters &p)
static main_options_t & main_options(Parameters &p)
static process_search_options_t & process_search_options(Parameters &p)
static optimizer_options_t & optimizer_options(Parameters &p)
static potential_options_t & potential_options(Parameters &p)
bool writeConForces
Opt-in "Forces of Component" sections in written .con frames (enables force+energy co-load on restart...
struct eonc::optimizer_options_t::sd_t sd
struct eonc::optimizer_options_t::quickmin_t quickmin
struct eonc::optimizer_options_t::xtsci_t xtsci
struct eonc::optimizer_options_t::cg_t cg
struct eonc::optimizer_options_t::lbfgs_t lbfgs