- Timestamp:
- Aug 9, 2013, 2:20:35 PM (12 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 51e0e3
- Parents:
- f0025d
- git-author:
- Frederik Heber <heber@…> (06/25/13 10:54:50)
- git-committer:
- Frederik Heber <heber@…> (08/09/13 14:20:35)
- Location:
- src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
src/FunctionApproximation/FunctionModel.hpp
rf0025d r0f5d38 29 29 * as possible. 30 30 * 31 * We always work in distances, i.e. pairs of atoms and the distance in between. 32 * As fragments do not contain these distances directly but the atomic positions 33 * (and charges) instead, we need to extract these from the fragment. For this 34 * purpose we need a bound function, termed an 'Extractor'. However, this is only 35 * required when one wants to use a FunctionModel directly on a given fragment. 36 * In FunctionApproximation we instead have TrainingData generate automatically 37 * a list of all pair-wise distances. The FunctionModel's Extractor may however 38 * create a more specific (and tighter) list of arguments, which however can 39 * then only be used with this specific FunctionModel. 40 * 41 * Furthermore, the underlying function to fit may require these distances, or 42 * arguments (termed so if paired with charges and atomic indices), to be in a 43 * certain order or does need only a subset. For this purpose we need another 44 * bound function, called a 'Filter'. 45 * 46 * As a fragment may contain multiple sets of arguments or distances that serve 47 * as valid function arguments, we need to split these sets up, such that they 48 * can be served one by one to the function. For this purpose we need a function 49 * that gives the number of arguments per set. (note that the Filter is supposed 50 * to place related arguments consecutively. 51 * 31 52 */ 32 53 class FunctionModel … … 45 66 //!> typedef for a function containing how to extract required information from a Fragment. 46 67 typedef boost::function< arguments_t (const Fragment &, const size_t)> extractor_t; 68 //!> typedef for a function containing how to filter required distances from a full argument list. 69 typedef boost::function< arguments_t (const arguments_t &)> filter_t; 47 70 //!> typedef for the magic triple function that gets the other two distances for a given argument 48 71 typedef boost::function< std::vector<arguments_t>(const argument_t &, const double)> triplefunction_t; … … 130 153 */ 131 154 virtual extractor_t getSpecificExtractor() const=0; 155 156 /** Returns a bound function to be used with TrainingData, extracting distances 157 * from a Fragment. 158 * 159 * \return bound function extracting distances from a fragment 160 */ 161 virtual filter_t getSpecificFilter() const=0; 162 163 /** Returns the number of arguments the underlying function requires. 164 * 165 * \return number of arguments of the function 166 */ 167 virtual size_t getSpecificArgumentCount() const=0; 132 168 }; 133 169 -
src/Potentials/CompoundPotential.cpp
rf0025d r0f5d38 53 53 #include "FunctionApproximation/Extractors.hpp" 54 54 #include "Potentials/EmpiricalPotential.hpp" 55 #include "Potentials/helpers.hpp" 55 56 #include "Potentials/PotentialRegistry.hpp" 56 57 … … 433 434 { 434 435 // create initial returnfunction 435 particletypes_per_model_t::const_iterator typesiter = particletypes_per_model.begin();436 Fragment::charges_t charges;437 {438 charges.resize((*typesiter).size());439 std::transform((*typesiter).begin(), (*typesiter).end(),440 charges.begin(), boost::lambda::_1);441 }442 436 FunctionModel::extractor_t returnfunction = 443 boost::bind(&Extractors::gatherAllDistancesFromFragment, 444 boost::bind(&Fragment::getPositions, _1), 445 boost::bind(&Fragment::getCharges, _1), 446 charges, // no crefs here as are temporaries! 447 _2); 437 boost::bind(&Helpers::returnEmptyArguments); 448 438 449 439 // every following fragments combines its arguments with the initial function 450 for (; typesiter != particletypes_per_model.end(); ++typesiter) { 440 for (particletypes_per_model_t::const_iterator typesiter = particletypes_per_model.begin(); 441 typesiter != particletypes_per_model.end(); ++typesiter) { 451 442 Fragment::charges_t charges; 452 443 { … … 468 459 return returnfunction; 469 460 } 461 462 FunctionModel::filter_t CompoundPotential::getSpecificFilter() const 463 { 464 // we must concatenate all filtered arguments here 465 // create initial returnfunction 466 FunctionModel::filter_t returnfunction = 467 boost::bind(&Helpers::returnEmptyArguments); 468 469 // every following fragments combines its arguments with the initial function 470 for (models_t::const_iterator modeliter = models.begin(); 471 modeliter != models.end(); ++modeliter) { 472 returnfunction = 473 boost::bind(&Extractors::concatenateArguments, 474 boost::bind(returnfunction, _1), 475 boost::bind((*modeliter)->getSpecificFilter(), _1) 476 ); 477 } 478 return returnfunction; 479 } 480 481 size_t CompoundPotential::getSpecificArgumentCount() const 482 { 483 std::vector<size_t> argument_counts(models.size(), 0); 484 std::transform(models.begin(), models.end(), argument_counts.begin(), 485 boost::bind(&FunctionModel::getSpecificArgumentCount, _1)); 486 return std::accumulate(argument_counts.begin(), argument_counts.end(), 0, 487 std::plus<size_t>()); 488 } 489 -
src/Potentials/CompoundPotential.hpp
rf0025d r0f5d38 127 127 * from a Fragment. 128 128 * 129 * Here, we simply concatenate the arguments delivered by the extractors of each model. 130 * 129 131 * \return bound function extracting distances from a fragment 130 132 */ 131 133 FunctionModel::extractor_t getSpecificExtractor() const; 134 135 /** Returns a bound function to be used with TrainingData, extracting distances 136 * from a Fragment. 137 * 138 * \note CompoundPotential has only default filter, as filter needs to be 139 * model-specific. 140 * 141 * \return bound function extracting distances from a fragment 142 */ 143 FunctionModel::filter_t getSpecificFilter() const; 144 145 /** Returns the number of arguments the underlying function requires. 146 * 147 * We give the total sum over the argument counts of all models. 148 * 149 * \return number of arguments of the function 150 */ 151 size_t getSpecificArgumentCount() const; 132 152 133 153 private: -
src/Potentials/Specifics/ConstantPotential.cpp
rf0025d r0f5d38 177 177 } 178 178 179 FunctionModel::filter_t ConstantPotential::getSpecificFilter() const 180 { 181 FunctionModel::filter_t returnfunction = 182 boost::bind(&Helpers::NoOp_Filterfunction, 183 _1); 184 return returnfunction; 185 } 186 179 187 void 180 188 ConstantPotential::setParametersToRandomInitialValues( -
src/Potentials/Specifics/ConstantPotential.hpp
rf0025d r0f5d38 163 163 FunctionModel::extractor_t getSpecificExtractor() const; 164 164 165 /** Returns a bound function to be used with TrainingData, extracting distances 166 * from a Fragment. 167 * 168 * \return bound function extracting distances from a fragment 169 */ 170 FunctionModel::filter_t getSpecificFilter() const; 171 172 /** Returns the number of arguments the underlying function requires. 173 * 174 * \return number of arguments of the function 175 */ 176 size_t getSpecificArgumentCount() const 177 { return 0; } 178 165 179 enum parameter_enum_t { 166 180 energy_offset=0, -
src/Potentials/Specifics/ManyBodyPotential_Tersoff.cpp
rf0025d r0f5d38 698 698 } 699 699 700 FunctionModel::filter_t ManyBodyPotential_Tersoff::getSpecificFilter() const 701 { 702 FunctionModel::filter_t returnfunction = 703 boost::bind(&Helpers::NoOp_Filterfunction, 704 _1); 705 return returnfunction; 706 } 707 700 708 void 701 709 ManyBodyPotential_Tersoff::setParametersToRandomInitialValues( -
src/Potentials/Specifics/ManyBodyPotential_Tersoff.hpp
rf0025d r0f5d38 188 188 FunctionModel::extractor_t getSpecificExtractor() const; 189 189 190 /** Returns a bound function to be used with TrainingData, extracting distances 191 * from a Fragment. 192 * 193 * \return bound function extracting distances from a fragment 194 */ 195 FunctionModel::filter_t getSpecificFilter() const; 196 197 /** Returns the number of arguments the underlying function requires. 198 * 199 * \return number of arguments of the function 200 */ 201 size_t getSpecificArgumentCount() const 202 { return 1; } 203 190 204 /** Sets the magic triple function that we use for getting angle distances. 191 205 * -
src/Potentials/Specifics/PairPotential_Angle.cpp
rf0025d r0f5d38 221 221 } 222 222 223 FunctionModel::filter_t PairPotential_Angle::getSpecificFilter() const 224 { 225 FunctionModel::filter_t returnfunction = 226 boost::bind(&Extractors::reorderArgumentsByParticleTypes, 227 _1, 228 getParticleTypes() 229 ); 230 return returnfunction; 231 } 232 223 233 void 224 234 PairPotential_Angle::setParametersToRandomInitialValues( -
src/Potentials/Specifics/PairPotential_Angle.hpp
rf0025d r0f5d38 166 166 FunctionModel::extractor_t getSpecificExtractor() const; 167 167 168 /** Returns a bound function to be used with TrainingData, extracting distances 169 * from a Fragment. 170 * 171 * \return bound function extracting distances from a fragment 172 */ 173 FunctionModel::filter_t getSpecificFilter() const; 174 175 /** Returns the number of arguments the underlying function requires. 176 * 177 * \return number of arguments of the function 178 */ 179 size_t getSpecificArgumentCount() const 180 { return 3; } 181 168 182 enum parameter_enum_t { 169 183 spring_constant=0, -
src/Potentials/Specifics/PairPotential_Harmonic.cpp
rf0025d r0f5d38 198 198 } 199 199 200 FunctionModel::filter_t PairPotential_Harmonic::getSpecificFilter() const 201 { 202 FunctionModel::filter_t returnfunction = 203 boost::bind(&Helpers::NoOp_Filterfunction, 204 _1); 205 return returnfunction; 206 } 207 200 208 void 201 209 PairPotential_Harmonic::setParametersToRandomInitialValues( -
src/Potentials/Specifics/PairPotential_Harmonic.hpp
rf0025d r0f5d38 148 148 FunctionModel::extractor_t getSpecificExtractor() const; 149 149 150 /** Returns a bound function to be used with TrainingData, extracting distances 151 * from a Fragment. 152 * 153 * \return bound function extracting distances from a fragment 154 */ 155 FunctionModel::filter_t getSpecificFilter() const; 156 157 /** Returns the number of arguments the underlying function requires. 158 * 159 * \return number of arguments of the function 160 */ 161 size_t getSpecificArgumentCount() const 162 { return 1; } 163 150 164 /** Return the token name of this specific potential. 151 165 * -
src/Potentials/Specifics/PairPotential_Morse.cpp
rf0025d r0f5d38 227 227 } 228 228 229 FunctionModel::filter_t PairPotential_Morse::getSpecificFilter() const 230 { 231 FunctionModel::filter_t returnfunction = 232 boost::bind(&Helpers::NoOp_Filterfunction, 233 _1); 234 return returnfunction; 235 } 236 229 237 void 230 238 PairPotential_Morse::setParametersToRandomInitialValues( -
src/Potentials/Specifics/PairPotential_Morse.hpp
rf0025d r0f5d38 165 165 FunctionModel::extractor_t getSpecificExtractor() const; 166 166 167 /** Returns a bound function to be used with TrainingData, extracting distances 168 * from a Fragment. 169 * 170 * \return bound function extracting distances from a fragment 171 */ 172 FunctionModel::filter_t getSpecificFilter() const; 173 174 /** Returns the number of arguments the underlying function requires. 175 * 176 * \return number of arguments of the function 177 */ 178 size_t getSpecificArgumentCount() const 179 { return 1; } 180 167 181 enum parameter_enum_t { 168 182 spring_constant=0, -
src/Potentials/helpers.hpp
rf0025d r0f5d38 94 94 } 95 95 96 inline FunctionModel::arguments_t 97 NoOp_Filterfunction( 98 const FunctionModel::arguments_t &args 99 ) 100 { 101 return args; 102 } 103 104 inline FunctionModel::arguments_t 105 returnEmptyArguments() 106 { 107 return FunctionModel::arguments_t(); 108 } 109 96 110 }; /* namespace Helpers */ 97 111
Note:
See TracChangeset
for help on using the changeset viewer.