n2p2 - A neural network potential package
Settings.cpp File Reference
#include "Settings.h"
#include "utility.h"
#include <fstream>
#include <stdexcept>
#include <tuple>
Include dependency graph for Settings.cpp:

Go to the source code of this file.

Functions

map< string, shared_ptr< settings::Key > > const createKnownKeywordsMap ()
 

Function Documentation

◆ createKnownKeywordsMap()

map< string, shared_ptr< settings::Key > > const createKnownKeywordsMap ( )

Definition at line 27 of file Settings.cpp.

28{
29 // Main keyword names and descriptions.
30 map<string, string> m;
31 // Alternative names.
32 map<string, vector<string>> a;
33 // Complete keyword map to return.
34 map<string, shared_ptr<settings::Key>> r;
35
36 // Required for prediction.
37 m["number_of_elements" ] = "";
38 m["elements" ] = "";
39 m["atom_energy" ] = "";
40 m["cutoff_type" ] = "";
41 m["symfunction_short" ] = "";
42 m["scale_symmetry_functions" ] = "";
43 m["scale_min_short" ] = "";
44 m["scale_max_short" ] = "";
45 m["center_symmetry_functions" ] = "";
46 m["scale_symmetry_functions_sigma" ] = "";
47 m["global_hidden_layers_short" ] = "";
48 m["global_hidden_layers_electrostatic" ] = "";
49 m["global_nodes_short" ] = "";
50 m["global_nodes_electrostatic" ] = "";
51 m["global_activation_short" ] = "";
52 m["global_activation_electrostatic" ] = "";
53 m["element_hidden_layers_short" ] = "";
54 m["element_hidden_layers_electrostatic"] = "";
55 m["element_nodes_short" ] = "";
56 m["element_nodes_electrostatic" ] = "";
57 m["element_activation_short" ] = "";
58 m["element_activation_electrostatic" ] = "";
59 m["normalize_nodes" ] = "";
60 m["mean_energy" ] = "";
61 m["conv_length" ] = "";
62 m["conv_energy" ] = "";
63 m["conv_charge" ] = "";
64 m["nnp_type" ] = "";
65 m["fixed_gausswidth" ] = "";
66 m["ewald_truncation_error_method" ] = "";
67 m["ewald_prec" ] = "";
68 m["screen_electrostatics" ] = "";
69 m["four_pi_epsilon" ] = "";
70
71 // Training keywords.
72 m["random_seed" ] = "";
73 m["test_fraction" ] = "";
74 m["epochs" ] = "";
75 m["normalize_data_set" ] = "";
76 m["use_short_forces" ] = "";
77 m["rmse_threshold" ] = "";
78 m["rmse_threshold_energy" ] = "";
79 m["rmse_threshold_force" ] = "";
80 m["rmse_threshold_charge" ] = "";
81 m["rmse_threshold_trials" ] = "";
82 m["rmse_threshold_trials_energy" ] = "";
83 m["rmse_threshold_trials_force" ] = "";
84 m["rmse_threshold_trials_charge" ] = "";
85 m["energy_fraction" ] = "";
86 m["force_fraction" ] = "";
87 m["force_energy_ratio" ] = "";
88 m["charge_fraction" ] = "";
89 m["use_old_weights_short" ] = "";
90 m["use_old_weights_charge" ] = "";
91 m["weights_min" ] = "";
92 m["weights_max" ] = "";
93 m["initial_hardness" ] = "";
94 m["nguyen_widrow_weights_short" ] = "";
95 m["nguyen_widrow_weights_charge" ] = "";
96 m["precondition_weights" ] = "";
97 m["main_error_metric" ] = "";
98 m["write_trainpoints" ] = "";
99 m["write_trainforces" ] = "";
100 m["write_traincharges" ] = "";
101 m["write_weights_epoch" ] = "";
102 m["write_neuronstats" ] = "";
103 m["write_trainlog" ] = "";
104 m["repeated_energy_update" ] = "";
105 m["updater_type" ] = "";
106 m["parallel_mode" ] = "";
107 m["jacobian_mode" ] = "";
108 m["update_strategy" ] = "";
109 m["selection_mode" ] = "";
110 m["selection_mode_energy" ] = "";
111 m["selection_mode_force" ] = "";
112 m["selection_mode_charge" ] = "";
113 m["task_batch_size_energy" ] = "";
114 m["task_batch_size_force" ] = "";
115 m["task_batch_size_charge" ] = "";
116 m["gradient_type" ] = "";
117 m["gradient_eta" ] = "";
118 m["gradient_adam_eta" ] = "";
119 m["gradient_adam_beta1" ] = "";
120 m["gradient_adam_beta2" ] = "";
121 m["gradient_adam_epsilon" ] = "";
122 m["kalman_type" ] = "";
123 m["kalman_epsilon" ] = "";
124 m["kalman_eta" ] = "";
125 m["kalman_etatau" ] = "";
126 m["kalman_etamax" ] = "";
127 m["kalman_q0" ] = "";
128 m["kalman_qtau" ] = "";
129 m["kalman_qmin" ] = "";
130 m["kalman_lambda_short" ] = "";
131 m["kalman_nue_short" ] = "";
132 m["memorize_symfunc_results" ] = "";
133 m["force_weight" ] = "";
134
135 // Alternative keyword names.
136 a["nnp_type" ] = {"nnp_generation", "nnp_type_gen", "nnp_gen"};
137 a["rmse_threshold_energy"] = {"short_energy_error_threshold"};
138 a["rmse_threshold_force" ] = {"short_force_error_threshold"};
139 a["energy_fraction" ] = {"short_energy_fraction"};
140 a["force_fraction" ] = {"short_force_fraction"};
141 a["symfunction_short" ] = {"symfunction"};
142
143 for (auto im : m)
144 {
145 // Check if keyword was already inserted.
146 if (r.find(im.first) != r.end())
147 {
148 throw runtime_error("ERROR: Multiple definition of keyword.\n");
149 }
150 // Insert new shared pointer to a Key object.
151 r[im.first] = make_shared<settings::Key>();
152 // Add main keyword as first entry in alternatives list.
153 r.at(im.first)->addAlternative(im.first);
154 // Add description text.
155 r.at(im.first)->setDescription(im.second);
156 // Check if alternative keywords exist.
157 if (a.find(im.first) != a.end())
158 {
159 // Loop over all alternative keywords.
160 for (auto alt : a.at(im.first))
161 {
162 // Check if alternative keyword is already inserted.
163 if (r.find(alt) != r.end())
164 {
165 throw runtime_error("ERROR: Multiple definition of "
166 "alternative keyword.\n");
167 }
168 // Set map entry, i.e. shared pointer, to Key object.
169 r[alt] = r.at(im.first);
170 // Add alternative keyword to list.
171 r[alt]->addAlternative(alt);
172 }
173 }
174 }
175
176 return r;
177}