Changeset 82e5fb
- Timestamp:
- May 25, 2021, 11:04:50 PM (4 years ago)
- Branches:
- Candidate_v1.7.0, stable
- Children:
- 91793c
- Parents:
- 889067e
- git-author:
- Frederik Heber <frederik.heber@…> (05/25/21 21:55:59)
- git-committer:
- Frederik Heber <frederik.heber@…> (05/25/21 23:04:50)
- Files:
-
- 9 edited
-
doc/userguide/userguide.xml (modified) (2 diffs)
-
src/Actions/PotentialAction/FitCompoundPotentialAction.cpp (modified) (1 diff)
-
src/Actions/PotentialAction/FitCompoundPotentialAction.def (modified) (1 diff)
-
src/Actions/PotentialAction/FitPotentialAction.cpp (modified) (1 diff)
-
src/Actions/PotentialAction/FitPotentialAction.def (modified) (1 diff)
-
src/Potentials/PotentialTrainer.cpp (modified) (2 diffs)
-
src/Potentials/PotentialTrainer.hpp (modified) (1 diff)
-
tests/Python/AllActions/options.dat (modified) (1 diff)
-
tests/regression/Potential/FitCompoundPotential/testsuite-potential-fit-compound-potential.at (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
doc/userguide/userguide.xml
r889067e r82e5fb 2430 2430 --set-threshold 1e-3 \ 2431 2431 --training-file test.dat 2432 --error-file error.dat 2432 2433 </programlisting> 2433 2434 <para>Now, all empirical potential functions are summed up into a … … 2437 2438 potential between oxygen and hydrogen and another angular potential 2438 2439 for the angle between hydrogen, oxygen, and hydrogen atom. Then, we would 2439 fit a function consisting of the sum of the two potentials functions in order to approximate the energy of a single 2440 water molecule (actually, it's the sum of three potentials. As mentioned before, a constant potential is always added to compensate non-bonding energies, i.e. not depending on interatomic distances). Here, the threshold criterion takes the place of the 2441 <emphasis role="bold"> take-best-of</emphasis> option. Here, the minimization is reiterated so often on random (but to some extent chosen from a sensible range) starting parameters until the final L2 error is below 1e-3. Also, all data used 2442 for training, i.e. the tuples consisting of the fragments nuclei 2443 coordinates and the associated energy value are written to the file 2444 <filename>test.dat</filename>. This allows for graphical representation or other 2445 way of analysis, e.g. for a Morse potential between oxygen and hydrogen the bonding energy can be plotted as a one-dimensional function and compared to the "point cloud" of sample points from the fragment term of Born-Oppenheimer surface. It is this point cloud, i.e. the training data, that is written to the file 2446 <filename>test.dat</filename>.</para> 2440 fit a function consisting of the sum of the two potentials functions in 2441 order to approximate the energy of a single water molecule (actually, 2442 it's the sum of three potentials. As mentioned before, a constant 2443 potential is always added to compensate non-bonding energies, i.e. not 2444 depending on interatomic distances). Here, the threshold criterion takes 2445 the place of the<emphasis role="bold"> take-best-of</emphasis> option. 2446 Here, the minimization is reiterated so often on random (but to some 2447 extent chosen from a sensible range) starting parameters until the final 2448 L2 error is below 1e-3. Also, all data used for training, i.e. the tuples 2449 consisting of the fragments nuclei coordinates and the associated energy 2450 value are written to the file <filename>test.dat</filename>. This allows 2451 for graphical representation or other way of analysis, e.g. for a Morse 2452 potential between oxygen and hydrogen the bonding energy can be plotted 2453 as a one-dimensional function and compared to the "point cloud" 2454 of sample points from the fragment term of Born-Oppenheimer surface. 2455 It is this point cloud, i.e. the training data, that is written to the file 2456 <filename>test.dat</filename>. Moreover, the error per fragment is written 2457 to the file <filename>error.dat</filename></para> 2447 2458 <para>Note that you can combine the two ways, i.e. start with a 2448 2459 fit-potential call but give an empty potential file. The resulting -
src/Actions/PotentialAction/FitCompoundPotentialAction.cpp
r889067e r82e5fb 104 104 graph, 105 105 params.training_file.get(), 106 params.error_file.get(), 106 107 params.max_iterations.get(), 107 108 params.threshold.get(), -
src/Actions/PotentialAction/FitCompoundPotentialAction.def
r889067e r82e5fb 23 23 // ValueStorage by the token "Z" -> first column: int, Z, "Z" 24 24 // "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value 25 #define paramtypes (boost::filesystem::path)( std::vector<const element *>)(unsigned int)(double)(unsigned int)26 #define paramtokens ("training-file")(" fragment-charges")("take-best-of")("set-threshold")("set-max-iterations")27 #define paramdescriptions ("optional file to write training data to")(" charges specifying the fragment")("take the best among this many approximations")("Require L2 error to be smaller than threshold, overrides number of attempts")("sets the maximum number of iterations spent on the optimization of parameters")28 #define paramdefaults (PARAM_DEFAULT(""))( NOPARAM_DEFAULT)(PARAM_DEFAULT(3))(PARAM_DEFAULT(1.))(PARAM_DEFAULT(100))29 #define paramreferences (training_file)( fragment)(best_of_howmany)(threshold)(max_iterations)25 #define paramtypes (boost::filesystem::path)(boost::filesystem::path)(std::vector<const element *>)(unsigned int)(double)(unsigned int) 26 #define paramtokens ("training-file")("error-file")("fragment-charges")("take-best-of")("set-threshold")("set-max-iterations") 27 #define paramdescriptions ("optional file to write training data to")("optional file to write error data to")("charges specifying the fragment")("take the best among this many approximations")("Require L2 error to be smaller than threshold, overrides number of attempts")("sets the maximum number of iterations spent on the optimization of parameters") 28 #define paramdefaults (PARAM_DEFAULT(""))(PARAM_DEFAULT(""))(NOPARAM_DEFAULT)(PARAM_DEFAULT(3))(PARAM_DEFAULT(1.))(PARAM_DEFAULT(100)) 29 #define paramreferences (training_file)(error_file)(fragment)(best_of_howmany)(threshold)(max_iterations) 30 30 #define paramvalids \ 31 (DummyValidator<boost::filesystem::path>()) \ 31 32 (DummyValidator<boost::filesystem::path>()) \ 32 33 (STLVectorValidator< std::vector<const element *> >(1,99, ElementValidator())) \ -
src/Actions/PotentialAction/FitPotentialAction.cpp
r889067e r82e5fb 141 141 graph, 142 142 params.training_file.get(), 143 params.error_file.get(), 143 144 params.max_iterations.get(), 144 145 params.threshold.get(), -
src/Actions/PotentialAction/FitPotentialAction.def
r889067e r82e5fb 23 23 // ValueStorage by the token "Z" -> first column: int, Z, "Z" 24 24 // "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value 25 #define paramtypes (boost::filesystem::path)( std::string)(std::vector<const element *>)(std::vector<const element *>)(unsigned int)(double)(unsigned int)26 #define paramtokens ("training-file")(" potential-type")("potential-charges")("fragment-charges")("take-best-of")("set-threshold")("set-max-iterations")27 #define paramdescriptions ("optional file to write training data to")(" potential type to fit")("charges specifying the potential")("charges specifying the fragment")("take the best among this many approximations")("Require L2 error to be smaller than threshold, overrides number of attempts")("sets the maximum number of iterations spent on the optimization of parameters")28 #define paramdefaults (PARAM_DEFAULT(""))( NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(PARAM_DEFAULT(3))(PARAM_DEFAULT(1.))(PARAM_DEFAULT(100))29 #define paramreferences (training_file)( potentialtype)(charges)(fragment)(best_of_howmany)(threshold)(max_iterations)25 #define paramtypes (boost::filesystem::path)(boost::filesystem::path)(std::string)(std::vector<const element *>)(std::vector<const element *>)(unsigned int)(double)(unsigned int) 26 #define paramtokens ("training-file")("error-file")("potential-type")("potential-charges")("fragment-charges")("take-best-of")("set-threshold")("set-max-iterations") 27 #define paramdescriptions ("optional file to write training data to")("optional file to write error data to")("potential type to fit")("charges specifying the potential")("charges specifying the fragment")("take the best among this many approximations")("Require L2 error to be smaller than threshold, overrides number of attempts")("sets the maximum number of iterations spent on the optimization of parameters") 28 #define paramdefaults (PARAM_DEFAULT(""))(PARAM_DEFAULT(""))(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(PARAM_DEFAULT(3))(PARAM_DEFAULT(1.))(PARAM_DEFAULT(100)) 29 #define paramreferences (training_file)(error_file)(potentialtype)(charges)(fragment)(best_of_howmany)(threshold)(max_iterations) 30 30 #define paramvalids \ 31 (DummyValidator<boost::filesystem::path>()) \ 31 32 (DummyValidator<boost::filesystem::path>()) \ 32 33 (PotentialTypeValidator()) \ -
src/Potentials/PotentialTrainer.cpp
r889067e r82e5fb 71 71 const HomologyGraph &_graph, 72 72 const boost::filesystem::path &_trainingfile, 73 const boost::filesystem::path &_errorfile, 73 74 const unsigned int _maxiterations, 74 75 const double _threshold, … … 180 181 TrainingData::L2ErrorConfigurationIndexMap_t WorseFragmentMap = 181 182 data.getWorstFragmentMap(model, fragmentrange); 182 LOG(0, "RESULT: WorstFragmentMap " << WorseFragmentMap << "."); 183 183 if (_errorfile.string().empty()) { 184 LOG(0, "RESULT: WorstFragmentMap " << WorseFragmentMap << "."); 185 } else { 186 std::ofstream errorstream(_errorfile.string().c_str()); 187 if (errorstream.good()) { 188 LOG(3, "DEBUG: Writing error data to file " << 189 _errorfile.string() << "."); 190 errorstream << "step\terror" << std::endl; 191 // resort into step as key 192 typedef std::map< size_t, double > step_error_t; 193 step_error_t step_error; 194 for (TrainingData::L2ErrorConfigurationIndexMap_t::const_reverse_iterator iter = WorseFragmentMap.rbegin(); 195 iter != WorseFragmentMap.rend(); ++iter) 196 step_error.insert( std::make_pair(iter->second, iter->first) ); 197 for (step_error_t::const_iterator iter = step_error.begin(); 198 iter != step_error.end(); ++iter) 199 errorstream << iter->first << "\t" << iter->second << std::endl; 200 } 201 errorstream.close(); 202 } 184 203 } 185 204 -
src/Potentials/PotentialTrainer.hpp
r889067e r82e5fb 36 36 const HomologyGraph &_graph, 37 37 const boost::filesystem::path &_trainingfile, 38 const boost::filesystem::path &_errorfile, 38 39 const unsigned int _maxiterations, 39 40 const double _threshold, -
tests/Python/AllActions/options.dat
r889067e r82e5fb 78 78 end_step "1" 79 79 enforce_net_zero_charge "0" 80 error_file "" 80 81 ExcludeHydrogen "1" 81 82 fastparsing "1" -
tests/regression/Potential/FitCompoundPotential/testsuite-potential-fit-compound-potential.at
r889067e r82e5fb 35 35 --parse-potentials ${abs_top_srcdir}/tests/regression/Potential/FitCompoundPotential/pre/water.potentials \ 36 36 --fit-compound-potential \ 37 --error-file error.csv \ 37 38 --fragment-charges 1 8 1 \ 38 39 --take-best-of 3 \ 39 40 --save-potentials water.potentials], 0, [stdout], [ignore]) 41 # check that error file was written 42 AT_CHECK([test -e error.csv], 0, [ignore], [ignore]) 40 43 # check that L_2 error 41 44 AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 0.34) exit 1}'], 0, [ignore], [ignore])
Note:
See TracChangeset
for help on using the changeset viewer.
