Changeset 7e5b94 for src/Potentials/unittests
- Timestamp:
- Jul 8, 2013, 2:22:02 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:
- 1e565c
- Parents:
- cf4905
- git-author:
- Frederik Heber <heber@…> (05/09/13 13:21:58)
- git-committer:
- Frederik Heber <heber@…> (07/08/13 14:22:02)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Potentials/unittests/CompoundPotentialUnitTest.cpp
rcf4905 r7e5b94 50 50 #include "Potentials/PotentialFactory.hpp" 51 51 #include "Potentials/PotentialRegistry.hpp" 52 #include "Potentials/Specifics/ConstantPotential.hpp" 52 53 #include "Potentials/Specifics/PairPotential_Morse.hpp" 53 54 … … 80 81 PotentialRegistry::getInstance().registerInstance(morse); 81 82 morse = NULL; 83 } 84 // register ConstantPotential with registry 85 { 86 ConstantPotential::ParticleTypes_t types; 87 EmpiricalPotential *constant = 88 PotentialFactory::getInstance().createInstance( 89 std::string("constant"), types); 90 PotentialRegistry::getInstance().registerInstance(constant); 91 constant = NULL; 82 92 } 83 93 … … 144 154 CompoundPotential compound(*graph); 145 155 CompoundPotential::parameters_t params; 146 params += a,c,D,d;156 params += d,a,c,D; 147 157 compound.setParameters(params); 148 158 for (size_t index = 0; index < input.size(); ++index) { 149 159 argument_t arg(argument_t::indices_t(0,1), argument_t::types_t(0,1), input[index]); 160 const double result = compound( FunctionModel::arguments_t(1,arg) )[0]; 150 161 CPPUNIT_ASSERT( 151 162 Helpers::isEqual( 152 163 output[index], 153 compound( FunctionModel::arguments_t(1,arg) )[0],164 result, 154 165 1.e-4/std::numeric_limits<double>::epsilon() // only compare four digits 155 166 ) … … 164 175 // CompoundPotential compound(*graph); 165 176 // CompoundPotential::parameters_t params; 166 // params += a,c,D,d;177 // params += d,a,c,D; 167 178 // compound.setParameters(params); 168 179 // argument_t arg(argument_t::indices_t(0,1), argument_t::types_t(0,1), c); 180 // const double result = compound.derivative(FunctionModel::arguments_t(1,arg))[0] 169 181 // CPPUNIT_ASSERT( 170 182 // Helpers::isEqual( 171 183 // 0., 172 // compound.derivative( 173 // FunctionModel::arguments_t(1,arg) 174 // )[0], 184 // result, 175 185 // 1.e+6 176 186 // ) … … 185 195 CompoundPotential compound(*graph); 186 196 CompoundPotential::parameters_t params; 187 params += a,c,D,d;197 params += d,a,c,D; 188 198 compound.setParameters(params); 189 199 argument_t arg(argument_t::indices_t(0,1), argument_t::types_t(0,1), c); 190 CPPUNIT_ASSERT( 191 Helpers::isEqual( 192 0., 193 compound.parameter_derivative( 194 FunctionModel::arguments_t(1,arg), 195 0 196 )[0], 197 1.e+6 198 ) 199 ); 200 CPPUNIT_ASSERT( 201 Helpers::isEqual( 202 0., 203 compound.parameter_derivative( 204 FunctionModel::arguments_t(1,arg), 205 1 206 )[0], 207 1.e+6 208 ) 209 ); 210 CPPUNIT_ASSERT( 211 Helpers::isEqual( 212 0., 213 compound.parameter_derivative( 214 FunctionModel::arguments_t(1,arg), 215 2 216 )[0], 217 1.e+6 218 ) 219 ); 220 CPPUNIT_ASSERT( 221 Helpers::isEqual( 222 1., 223 compound.parameter_derivative( 224 FunctionModel::arguments_t(1,arg), 225 3 226 )[0], 227 1.e+6 228 ) 229 ); 230 } 200 { 201 const double result = 202 compound.parameter_derivative( 203 FunctionModel::arguments_t(1,arg), 204 0)[0]; 205 CPPUNIT_ASSERT( 206 Helpers::isEqual( 207 1., 208 result, 209 1.e+6 210 ) 211 ); 212 } 213 { 214 const double result = 215 compound.parameter_derivative( 216 FunctionModel::arguments_t(1,arg), 217 1)[0]; 218 CPPUNIT_ASSERT( 219 Helpers::isEqual( 220 0., 221 result, 222 1.e+6 223 ) 224 ); 225 } 226 { 227 const double result = 228 compound.parameter_derivative( 229 FunctionModel::arguments_t(1,arg), 230 2)[0]; 231 CPPUNIT_ASSERT( 232 Helpers::isEqual( 233 0., 234 result, 235 1.e+6 236 ) 237 ); 238 } 239 { 240 const double result = 241 compound.parameter_derivative( 242 FunctionModel::arguments_t(1,arg), 243 3)[0]; 244 CPPUNIT_ASSERT( 245 Helpers::isEqual( 246 0., 247 result, 248 1.e+6 249 ) 250 ); 251 } 252 }
Note:
See TracChangeset
for help on using the changeset viewer.