Changeset e1fe7e for src/Potentials/Specifics/PairPotential_Harmonic.cpp
- Timestamp:
- Jun 27, 2014, 9:32:55 PM (11 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:
- 550f2a
- Parents:
- 16227a
- git-author:
- Frederik Heber <heber@…> (02/27/14 20:15:41)
- git-committer:
- Frederik Heber <heber@…> (06/27/14 21:32:55)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Potentials/Specifics/PairPotential_Harmonic.cpp
r16227a re1fe7e 117 117 PairPotential_Harmonic::results_t 118 118 PairPotential_Harmonic::operator()( 119 const arguments_t &arguments119 const list_of_arguments_t &listarguments 120 120 ) const 121 121 { 122 ASSERT( arguments.size() == 1, 123 "PairPotential_Harmonic::operator() - requires exactly one argument."); 124 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 125 arguments, getParticleTypes()), 126 "PairPotential_Harmonic::operator() - types don't match with ones in arguments."); 127 const argument_t &r_ij = arguments[0]; 128 const result_t result = 129 params[spring_constant] 130 * Helpers::pow( r_ij.distance - params[equilibrium_distance], 2 ); 131 return std::vector<result_t>(1, result); 122 result_t result = 0.; 123 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 124 iter != listarguments.end(); ++iter) { 125 const arguments_t &arguments = *iter; 126 ASSERT( arguments.size() == 1, 127 "PairPotential_Harmonic::operator() - requires exactly one argument."); 128 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 129 arguments, getParticleTypes()), 130 "PairPotential_Harmonic::operator() - types don't match with ones in arguments."); 131 const argument_t &r_ij = arguments[0]; 132 result += 133 params[spring_constant] 134 * Helpers::pow( r_ij.distance - params[equilibrium_distance], 2 ); 135 } 136 return results_t(1, result); 132 137 } 133 138 134 139 PairPotential_Harmonic::derivative_components_t 135 140 PairPotential_Harmonic::derivative( 136 const arguments_t &arguments141 const list_of_arguments_t &listarguments 137 142 ) const 138 143 { 139 ASSERT( arguments.size() == 1, 140 "PairPotential_Harmonic::operator() - requires exactly one argument."); 141 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 142 arguments, getParticleTypes()), 143 "PairPotential_Harmonic::operator() - types don't match with ones in arguments."); 144 derivative_components_t result; 145 const argument_t &r_ij = arguments[0]; 146 result.push_back( 2. * params[spring_constant] * ( r_ij.distance - params[equilibrium_distance]) ); 147 ASSERT( result.size() == 1, 148 "PairPotential_Harmonic::operator() - we did not create exactly one component."); 149 return result; 144 result_t result = 0.; 145 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 146 iter != listarguments.end(); ++iter) { 147 const arguments_t &arguments = *iter; 148 ASSERT( arguments.size() == 1, 149 "PairPotential_Harmonic::operator() - requires exactly one argument."); 150 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 151 arguments, getParticleTypes()), 152 "PairPotential_Harmonic::operator() - types don't match with ones in arguments."); 153 const argument_t &r_ij = arguments[0]; 154 result += 155 2. * params[spring_constant] * 156 ( r_ij.distance - params[equilibrium_distance]); 157 } 158 return derivative_components_t(1, result); 150 159 } 151 160 152 161 PairPotential_Harmonic::results_t 153 162 PairPotential_Harmonic::parameter_derivative( 154 const arguments_t &arguments,163 const list_of_arguments_t &listarguments, 155 164 const size_t index 156 165 ) const 157 166 { 158 ASSERT( arguments.size() == 1, 159 "PairPotential_Harmonic::parameter_derivative() - requires exactly one argument."); 160 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 161 arguments, getParticleTypes()), 162 "PairPotential_Harmonic::operator() - types don't match with ones in arguments."); 163 const argument_t &r_ij = arguments[0]; 164 switch (index) { 165 case spring_constant: 166 { 167 const result_t result = 168 Helpers::pow( r_ij.distance - params[equilibrium_distance], 2 ); 169 return std::vector<result_t>(1, result); 170 break; 167 result_t result = 0.; 168 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 169 iter != listarguments.end(); ++iter) { 170 const arguments_t &arguments = *iter; 171 ASSERT( arguments.size() == 1, 172 "PairPotential_Harmonic::parameter_derivative() - requires exactly one argument."); 173 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 174 arguments, getParticleTypes()), 175 "PairPotential_Harmonic::operator() - types don't match with ones in arguments."); 176 const argument_t &r_ij = arguments[0]; 177 switch (index) { 178 case spring_constant: 179 { 180 result += 181 Helpers::pow( r_ij.distance - params[equilibrium_distance], 2 ); 182 break; 183 } 184 case equilibrium_distance: 185 { 186 result += 187 -2. * params[spring_constant] 188 * ( r_ij.distance - params[equilibrium_distance]); 189 break; 190 } 191 default: 192 ASSERT(0, "PairPotential_Harmonic::parameter_derivative() - derivative to unknown parameter desired."); 193 break; 171 194 } 172 case equilibrium_distance:173 {174 const result_t result =175 -2. * params[spring_constant]176 * ( r_ij.distance - params[equilibrium_distance]);177 return std::vector<result_t>(1, result);178 break;179 }180 default:181 ASSERT(0, "PairPotential_Harmonic::parameter_derivative() - derivative to unknown parameter desired.");182 break;183 195 } 184 185 return PairPotential_Harmonic::results_t(1, 0.); 196 return results_t(1, result); 186 197 } 187 198
Note:
See TracChangeset
for help on using the changeset viewer.