diff --git a/examples/input.nn.recommended b/examples/input.nn.recommended index 17ee56cfd..42b0a770f 100644 --- a/examples/input.nn.recommended +++ b/examples/input.nn.recommended @@ -41,7 +41,8 @@ memorize_symfunc_results # Keep symmetry function results test_fraction 0.1 # Fraction of structures kept for testing. force_weight 10.0 # Weight of force updates relative to energy updates. short_energy_fraction 1.000 # Fraction of energy updates per epoch. -short_force_fraction 0.02315 # Fraction of force updates per epoch. +#short_force_fraction 0.02315 # Fraction of force updates per epoch (not necessary if force_energy_ratio given). +force_energy_ratio 10.0 # Specifies ratio between force and energy updates (ratio = updates_force / updates_energy). short_energy_error_threshold 0.00 # RMSE threshold for energy update candidates. short_force_error_threshold 1.00 # RMSE threshold for force update candidates. rmse_threshold_trials 3 # Maximum number of RMSE threshold trials. diff --git a/src/libnnp/Mode.h b/src/libnnp/Mode.h index dbd9e0865..12298573c 100644 --- a/src/libnnp/Mode.h +++ b/src/libnnp/Mode.h @@ -91,6 +91,8 @@ class Mode }; Mode(); + virtual ~Mode() {}; + /** Write welcome message with version information. */ void initialize(); diff --git a/src/libnnp/Settings.cpp b/src/libnnp/Settings.cpp index 063e6ef2e..76ce23a78 100644 --- a/src/libnnp/Settings.cpp +++ b/src/libnnp/Settings.cpp @@ -68,6 +68,7 @@ map> const createKnownKeywordsMap() m["rmse_threshold_trials_charge" ] = ""; m["energy_fraction" ] = ""; m["force_fraction" ] = ""; + m["force_energy_ratio" ] = ""; m["charge_fraction" ] = ""; m["use_old_weights_short" ] = ""; m["use_old_weights_charge" ] = ""; diff --git a/src/libnnpif/LAMMPS/InterfaceLammps.h b/src/libnnpif/LAMMPS/InterfaceLammps.h index d896cedf0..8c1d21a7e 100644 --- a/src/libnnpif/LAMMPS/InterfaceLammps.h +++ b/src/libnnpif/LAMMPS/InterfaceLammps.h @@ -31,6 +31,7 @@ class InterfaceLammps : public Mode { public: InterfaceLammps(); + virtual ~InterfaceLammps() {}; /** Initialize the LAMMPS interface. * diff --git a/src/libnnptrain/Training.cpp b/src/libnnptrain/Training.cpp index 602454c2b..f7bed9b66 100644 --- a/src/libnnptrain/Training.cpp +++ b/src/libnnptrain/Training.cpp @@ -2874,7 +2874,30 @@ void Training::setupUpdatePlan(string const& property) // Actual property modified here. Property& pa = p[property]; string keyword = property + "_fraction"; - pa.epochFraction = atof(settings[keyword].c_str()); + + // Override force fraction if keyword "energy_force_ratio" is provided. + if (property == "force" && + p.exists("energy") && + settings.keywordExists("force_energy_ratio")) + { + double const ratio = atof(settings["force_energy_ratio"].c_str()); + if (settings.keywordExists(keyword)) + { + log << "WARNING: Given force fraction is ignored because " + "force/energy ratio is provided.\n"; + } + log << strpr("Desired force/energy update ratio : %.6f\n", + ratio); + log << "----------------------------------------------\n"; + pa.epochFraction = (p["energy"].numTrainPatterns * ratio) + / p["force"].numTrainPatterns; + } + // Default action = read "_fraction" keyword. + else + { + pa.epochFraction = atof(settings[keyword].c_str()); + } + keyword = "task_batch_size_" + property; pa.taskBatchSize = (size_t)atoi(settings[keyword].c_str()); if (pa.taskBatchSize == 0) @@ -2933,8 +2956,12 @@ void Training::setupUpdatePlan(string const& property) log << "Update plan for property \"" + property + "\":\n"; log << strpr("- Per-task batch size : %zu\n", pa.taskBatchSize); - log << strpr("- Fraction of patterns used per epoch : %.4f\n", + log << strpr("- Fraction of patterns used per epoch : %.6f\n", pa.epochFraction); + if (pa.numUpdates == 0) + { + log << "WARNING: No updates are planned for this property."; + } log << strpr("- Updates per epoch : %zu\n", pa.numUpdates); log << strpr("- Patterns used per update (rank %3d / global) : "