Changeset 1dca9a
- Timestamp:
- Dec 19, 2012, 3:25:31 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:
- 5b5724
- Parents:
- 3ccea3
- git-author:
- Frederik Heber <heber@…> (10/03/12 19:58:07)
- git-committer:
- Frederik Heber <heber@…> (12/19/12 15:25:31)
- Location:
- src/Potentials/Specifics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Potentials/Specifics/PairPotential_Harmonic.cpp
r3ccea3 r1dca9a 43 43 #include "Potentials/helpers.hpp" 44 44 45 PairPotential_Harmonic::PairPotential_Harmonic() : 46 params(parameters_t(MAXPARAMS, 0.)) 47 {} 48 49 PairPotential_Harmonic::PairPotential_Harmonic( 50 const double _spring_constant, 51 const double _equilibrium_distance, 52 const double _energy_offset) : 53 params(parameters_t(MAXPARAMS, 0.)) 54 { 55 params[spring_constant] = _spring_constant; 56 params[equilibrium_distance] = _equilibrium_distance; 57 params[energy_offset] = _energy_offset; 58 } 59 45 60 PairPotential_Harmonic::results_t 46 61 PairPotential_Harmonic::operator()( … … 51 66 "PairPotential_Harmonic::operator() - requires exactly one argument."); 52 67 const argument_t &r_ij = arguments[0]; 53 const result_t result = spring_constant * Helpers::pow( r_ij.distance - equilibrium_distance, 2 ) - energy_offset; 68 const result_t result = 69 params[spring_constant] 70 * Helpers::pow( r_ij.distance - params[equilibrium_distance], 2 ) 71 + params[energy_offset]; 54 72 return std::vector<result_t>(1, result); 55 73 } … … 64 82 derivative_components_t result; 65 83 const argument_t &r_ij = arguments[0]; 66 result.push_back( 2. * spring_constant * ( r_ij.distance - equilibrium_distance) );84 result.push_back( 2. * params[spring_constant] * ( r_ij.distance - params[equilibrium_distance]) ); 67 85 ASSERT( result.size() == 1, 68 86 "PairPotential_Harmonic::operator() - we did not create exactly one component."); … … 70 88 } 71 89 72 void PairPotential_Harmonic::setParameters(const parameters_t &_params)73 {74 ASSERT( _params.size() == 3,75 "PairPotential_Harmonic::setParameters() - we need exactly two parameters.");76 spring_constant = _params[0];77 equilibrium_distance = _params[1];78 energy_offset = _params[2];79 }80 81 PairPotential_Harmonic::parameters_t PairPotential_Harmonic::getParameters() const82 {83 parameters_t params(3, 0.);84 params[0] = spring_constant;85 params[1] = equilibrium_distance;86 params[2] = energy_offset;87 return params;88 } -
src/Potentials/Specifics/PairPotential_Harmonic.hpp
r3ccea3 r1dca9a 15 15 #endif 16 16 17 #include "CodePatterns/Assert.hpp" 17 18 18 19 #include "Potentials/EmpiricalPotential.hpp" … … 31 32 typedef FunctionModel::results_t results_t; 32 33 typedef EmpiricalPotential::derivative_components_t derivative_components_t; 34 typedef FunctionModel::parameters_t parameters_t; 33 35 public: 34 36 PairPotential_Harmonic(); … … 36 38 const double _spring_constant, 37 39 const double _equilibrium_distance, 38 const double _energy_offset) : 39 spring_constant(_spring_constant), 40 equilibrium_distance(_equilibrium_distance), 41 energy_offset(_energy_offset) 42 {} 40 const double _energy_offset); 43 41 virtual ~PairPotential_Harmonic() {} 44 42 … … 47 45 * \param _params given set of parameters 48 46 */ 49 void setParameters(const parameters_t &_params); 47 void setParameters(const parameters_t &_params) 48 { 49 ASSERT( _params.size() <= getParameterDimension(), 50 "PairPotential_Harmonic::setParameters() - we need not more than " 51 +toString(getParameterDimension())+" parameters."); 52 for(size_t i=0;i<_params.size();++i) 53 params[i] = _params[i]; 54 } 50 55 51 56 /** Getter for parameters as required by FunctionModel interface. … … 53 58 * \return set of parameters 54 59 */ 55 parameters_t getParameters() const; 60 parameters_t getParameters() const 61 { 62 return params; 63 } 56 64 57 65 /** Getter for the number of parameters of this model function. … … 89 97 90 98 private: 91 //!> the spring constant for the harmonic potential 92 double spring_constant; 93 //!> the equilibrium distance indicating the potential minimum 94 double equilibrium_distance; 95 //!> energy offset 96 double energy_offset; 99 enum parameter_enum_t { 100 spring_constant=0, 101 equilibrium_distance=1, 102 energy_offset=2, 103 MAXPARAMS 104 }; 105 //!> parameter vector with parameters as in enum parameter_enum_t 106 parameters_t params; 97 107 }; 98 108
Note:
See TracChangeset
for help on using the changeset viewer.