Changeset fe8253 for src/LinkedCell/unittests
- Timestamp:
- Jan 2, 2012, 1:00:05 PM (13 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:
- 2614e2a
- Parents:
- 9a5649
- git-author:
- Frederik Heber <heber@…> (11/30/11 10:26:35)
- git-committer:
- Frederik Heber <heber@…> (01/02/12 13:00:05)
- Location:
- src/LinkedCell/unittests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/LinkedCell/unittests/LinkedCell_ControllerUnitTest.cpp
r9a5649 rfe8253 28 28 #include "LinearAlgebra/RealSpaceMatrix.hpp" 29 29 #include "LinkedCell/LinkedCell_Controller.hpp" 30 #include "LinkedCell/LinkedCell_View.hpp" 30 31 #include "LinkedCell/unittests/defs.hpp" 31 32 … … 65 66 } 66 67 67 68 /** UnitTest for LinkedCell_Controller::getViewTest(). 69 */ 70 void LinkedCell_ControllerTest::getViewTest() 71 { 72 CPPUNIT_ASSERT_EQUAL(true, true); 73 74 } 68 /** UnitTest for LinkedCell_Controller's lower and upper thresholds. 69 */ 70 void LinkedCell_ControllerTest::thresholdTest() 71 { 72 /// re-create instances 73 delete controller; 74 delete domain; 75 76 /// create diag(..) matrix beyond upper_threshold 77 const double old_threshold = controller->upper_threshold; 78 controller->lower_threshold = old_threshold*0.9; 79 RealSpaceMatrix BoxM; 80 BoxM.setIdentity(); 81 BoxM *= controller->upper_threshold*.5; 82 83 /// create Box with this matrix 84 domain = new Box(BoxM); 85 86 controller = new LinkedCell::LinkedCell_Controller(*domain); 87 88 /// check that thresholds have been adapted 89 CPPUNIT_ASSERT( controller->upper_threshold != old_threshold ); 90 CPPUNIT_ASSERT( controller->lower_threshold != old_threshold*0.9 ); 91 } 92 93 /** UnitTest for LinkedCell_Controller::getHeuristicRange(). 94 */ 95 void LinkedCell_ControllerTest::getHeuristicRangeTest() 96 { 97 /// re-implementing function to check is nonsense here, instead try some 98 /// hard-coded, working values; 99 controller->lower_threshold = 1.; 100 controller->upper_threshold = 20.; 101 const double inbetween = 9.5; // half and twice is definitely within both thresholds. 102 103 /// check distance in between 104 range<double> interval = controller->getHeuristicRange(inbetween); 105 CPPUNIT_ASSERT ( interval.first != controller->lower_threshold ); 106 CPPUNIT_ASSERT ( interval.last != controller->upper_threshold ); 107 } 108 109 /** UnitTest for LinkedCell_Controller::getViewTest() for getting twice the same view. 110 */ 111 void LinkedCell_ControllerTest::getView_SameViewTest() 112 { 113 /// obtain a view 114 CPPUNIT_ASSERT_EQUAL( (size_t)0, controller->ModelsMap.size() ); 115 LinkedCell::LinkedCell_View view = controller->getView(2.); 116 CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() ); 117 118 { 119 /// get same view again and check that now new instance appears 120 LinkedCell::LinkedCell_View view_again = controller->getView(2.); 121 CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() ); 122 } 123 } 124 125 /** UnitTest for LinkedCell_Controller::getViewTest() for picking two different views. 126 */ 127 void LinkedCell_ControllerTest::getView_DifferentViewTest() 128 { 129 /// obtain a view 130 CPPUNIT_ASSERT_EQUAL( (size_t)0, controller->ModelsMap.size() ); 131 LinkedCell::LinkedCell_View view = controller->getView(2.); 132 CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() ); 133 134 { 135 /// pick another view that is not close enough 136 LinkedCell::LinkedCell_View view_other = controller->getView(5.); 137 CPPUNIT_ASSERT_EQUAL( (size_t)2, controller->ModelsMap.size() ); 138 } 139 } 140 141 /** UnitTest for LinkedCell_Controller::getViewTest() for picking further views in range of present one. 142 */ 143 void LinkedCell_ControllerTest::getView_InRangeViewTest() 144 { 145 /// obtain a view 146 const double edgelength = 2.; 147 CPPUNIT_ASSERT_EQUAL( (size_t)0, controller->ModelsMap.size() ); 148 LinkedCell::LinkedCell_View view = controller->getView(edgelength); 149 CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() ); 150 151 /// pick views that are close enough 152 range<double> interval = controller->getHeuristicRange(edgelength); 153 { 154 /// ... at half lower interval half 155 LinkedCell::LinkedCell_View view_lowerhalf = controller->getView((edgelength + interval.first)/2.); 156 CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() ); 157 } 158 { 159 /// ... at half upper interval half 160 LinkedCell::LinkedCell_View view_upperhalf = controller->getView((interval.last + edgelength)/2.); 161 CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() ); 162 } 163 { 164 /// ... close to lower boundary 165 LinkedCell::LinkedCell_View view_closelower = controller->getView(interval.first + std::numeric_limits<double>::round_error()); 166 CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() ); 167 } 168 { 169 /// ... close to upper boundary 170 LinkedCell::LinkedCell_View view_closerupper = controller->getView(interval.last - std::numeric_limits<double>::round_error()); 171 CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() ); 172 } 173 { 174 /// on lower boundary 175 LinkedCell::LinkedCell_View view_onlower = controller->getView(interval.first); 176 CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() ); 177 } 178 } 179 180 /** UnitTest for LinkedCell_Controller::getViewTest() for picking further views outside range. 181 */ 182 void LinkedCell_ControllerTest::getView_OutOfRangeViewTest() 183 { 184 /// Here we need half of the edge length to be greater than lower_threshold 185 const double edgelength = 2.5; 186 CPPUNIT_ASSERT( (edgelength/2.) > controller->lower_threshold ); 187 /// obtain a view 188 CPPUNIT_ASSERT_EQUAL( (size_t)0, controller->ModelsMap.size() ); 189 LinkedCell::LinkedCell_View view = controller->getView(edgelength); 190 CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() ); 191 192 /// pick views that are not close enough and check for new instance 193 range<double> interval = controller->getHeuristicRange(edgelength); 194 { 195 /// ... outside lower boundary 196 LinkedCell::LinkedCell_View view_outsidelower = controller->getView(interval.first - std::numeric_limits<double>::round_error()); 197 CPPUNIT_ASSERT_EQUAL( (size_t)2, controller->ModelsMap.size() ); 198 } 199 { 200 /// ... on upper boundary 201 LinkedCell::LinkedCell_View view_onupper = controller->getView(interval.last); 202 CPPUNIT_ASSERT_EQUAL( (size_t)3, controller->ModelsMap.size() ); 203 } 204 } 205 206 /** UnitTest for LinkedCell_Controller::getViewTest() for picking views beneath lower threshold. 207 */ 208 void LinkedCell_ControllerTest::getView_LowerThresholdViewTest() 209 { 210 /// obtain a view 211 const double edgelength = 1.9*controller->lower_threshold; 212 CPPUNIT_ASSERT_EQUAL( (size_t)0, controller->ModelsMap.size() ); 213 LinkedCell::LinkedCell_View view = controller->getView(edgelength); 214 CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() ); 215 216 { 217 /// get a view at threshold and check that no new instance has been created 218 LinkedCell::LinkedCell_View view_onlower = controller->getView(controller->lower_threshold); 219 CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() ); 220 } 221 { 222 /// pick a view below 1. 223 LinkedCell::LinkedCell_View view_beneathlower = controller->getView(0.1*controller->lower_threshold); 224 CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() ); 225 } 226 } 227 228 /** UnitTest for LinkedCell_Controller::getViewTest() for picking views above upper threshold. 229 */ 230 void LinkedCell_ControllerTest::getView_UpperThresholdViewTest() 231 { 232 /// obtain a view 233 const double edgelength = controller->upper_threshold; 234 CPPUNIT_ASSERT_EQUAL( (size_t)0, controller->ModelsMap.size() ); 235 LinkedCell::LinkedCell_View view = controller->getView(edgelength); 236 CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() ); 237 238 { 239 /// get a view beyond threshold and check that no new instance has been created 240 LinkedCell::LinkedCell_View view_beyondupper = controller->getView(1.1*controller->upper_threshold); 241 CPPUNIT_ASSERT_EQUAL( (size_t)1, controller->ModelsMap.size() ); 242 } 243 244 { 245 /// pick a view below threshold and check for new instance (if we make it outside acceptable range) 246 range<double> interval = controller->getHeuristicRange(edgelength); 247 if ( !interval.isInRange(0.1*controller->upper_threshold) ) { 248 LinkedCell::LinkedCell_View view_beneathupper = controller->getView(0.1*controller->upper_threshold); 249 CPPUNIT_ASSERT_EQUAL( (size_t)2, controller->ModelsMap.size() ); 250 } 251 } 252 } -
src/LinkedCell/unittests/LinkedCell_ControllerUnitTest.hpp
r9a5649 rfe8253 28 28 { 29 29 CPPUNIT_TEST_SUITE( LinkedCell_ControllerTest) ; 30 CPPUNIT_TEST ( getViewTest ); 30 CPPUNIT_TEST ( thresholdTest ); 31 CPPUNIT_TEST ( getHeuristicRangeTest ); 32 CPPUNIT_TEST ( getView_SameViewTest ); 33 CPPUNIT_TEST ( getView_DifferentViewTest ); 34 CPPUNIT_TEST ( getView_InRangeViewTest ); 35 CPPUNIT_TEST ( getView_OutOfRangeViewTest ); 36 CPPUNIT_TEST ( getView_LowerThresholdViewTest ); 37 CPPUNIT_TEST ( getView_UpperThresholdViewTest ); 31 38 CPPUNIT_TEST_SUITE_END(); 32 39 … … 35 42 void tearDown(); 36 43 37 void getViewTest(); 44 void thresholdTest(); 45 void getHeuristicRangeTest(); 46 void getView_SameViewTest(); 47 void getView_DifferentViewTest(); 48 void getView_InRangeViewTest(); 49 void getView_OutOfRangeViewTest(); 50 void getView_LowerThresholdViewTest(); 51 void getView_UpperThresholdViewTest(); 38 52 39 53 private:
Note:
See TracChangeset
for help on using the changeset viewer.