Changeset 5b1e5e for src/Fragmentation/Summation/SetValues/unittests
- Timestamp:
- Sep 14, 2016, 6:42:52 PM (9 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, 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_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, GeometryObjects, Gui_displays_atomic_force_velocity, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, RotateToPrincipalAxisSystem_UndoRedo, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, Ubuntu_1604_changes, stable
- Children:
- e51f2c
- Parents:
- 028790
- git-author:
- Frederik Heber <heber@…> (05/26/16 09:51:07)
- git-committer:
- Frederik Heber <heber@…> (09/14/16 18:42:52)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Summation/SetValues/unittests/SamplingGridUnitTest.cpp
r028790 r5b1e5e 62 62 const double grid_value=1.; 63 63 64 #define NUMBEROFSAMPLES(n) (size_t)(pow(pow(2,n), 3))65 #define DOMAINVOLUME(l) (size_t)pow(l, 3)64 #define NUMBEROFSAMPLES(n) (size_t)(pow(pow(2,n),(int)NDIM)) 65 #define DOMAINVOLUME(l) (size_t)pow(l,(int)NDIM) 66 66 67 67 // Registers the fixture into the 'registry' … … 75 75 76 76 // create the grid 77 const double begin[ 3] = { 0., 0., 0. };78 const double end[ 3] = { 1., 1., 1. };77 const double begin[NDIM] = { 0., 0., 0. }; 78 const double end[NDIM] = { 1., 1., 1. }; 79 79 for (size_t i=0; i< DOMAINVOLUME(1)*NUMBEROFSAMPLES(2); ++i) 80 80 values += grid_value; … … 94 94 { 95 95 // check illegal grid 96 const double begin[ 3] = { 0., 0., 0. };97 const double end[ 3] = { 2., 2., 2. };96 const double begin[NDIM] = { 0., 0., 0. }; 97 const double end[NDIM] = { 2., 2., 2. }; 98 98 SamplingGridProperties illegal_props(begin, end, 5); 99 99 SamplingGridProperties legal_props(begin, end, 2); … … 125 125 void SamplingGridTest::isCongruent_Test() 126 126 { 127 const double begin[ 3] = { 0., 0., 0. };128 const double end[ 3] = { 2., 2., 2. };129 const double otherbegin[ 3] = { 0.1, 0.1, 0.1 };130 const double otherend[ 3] = { 1., 1., 1. };127 const double begin[NDIM] = { 0., 0., 0. }; 128 const double end[NDIM] = { 2., 2., 2. }; 129 const double otherbegin[NDIM] = { 0.1, 0.1, 0.1 }; 130 const double otherend[NDIM] = { 1., 1., 1. }; 131 131 SamplingGridProperties illegal_begin_props(otherbegin, end, 5); 132 132 SamplingGridProperties illegal_end_props(begin, otherend, 5); … … 135 135 136 136 // differing windows 137 // const double begin_window[ 3] = { 0.5, 0.5, 0.5 };138 // const double end_window[ 3] = { 1., 1., 1. };139 const double otherbegin_window[ 3] = { 0.45, 0.45, 0.45 };140 const double otherend_window[ 3] = { 1.05, 1.05, 1.05 };137 // const double begin_window[NDIM] = { 0.5, 0.5, 0.5 }; 138 // const double end_window[NDIM] = { 1., 1., 1. }; 139 const double otherbegin_window[NDIM] = { 0.45, 0.45, 0.45 }; 140 const double otherend_window[NDIM] = { 1.05, 1.05, 1.05 }; 141 141 142 142 // check that incompatible grid are also incongruent … … 238 238 239 239 // create another one and check its size, too 240 const double begin[ 3] = { 0., 0., 0. };241 const double end[ 3] = { 1., 1., 1. };240 const double begin[NDIM] = { 0., 0., 0. }; 241 const double end[NDIM] = { 1., 1., 1. }; 242 242 for (size_t level = 3; level<=6; ++level) { 243 243 values.clear(); … … 257 257 { 258 258 // we have a grid with size of one, extend to twice the size and check 259 const double begin[ 3] = { 0., 0., 0. };259 const double begin[NDIM] = { 0., 0., 0. }; 260 260 const double size = 2.; 261 const double end[ 3] = { size, size, size };262 double offset[ 3];261 const double end[NDIM] = { size, size, size }; 262 double offset[NDIM]; 263 263 for (offset[0] = 0.; offset[0] <= 1.; offset[0] += .5) 264 264 for (offset[1] = 0.; offset[1] <= 1.; offset[1] += .5) 265 265 for (offset[2] = 0.; offset[2] <= 1.; offset[2] += .5) { 266 const double window_begin[ 3] = { 0.+offset[0], 0.+offset[1], 0.+offset[2]};267 const double window_end[ 3] = { 1.+offset[0], 1.+offset[1], 1.+offset[2]};266 const double window_begin[NDIM] = { 0.+offset[0], 0.+offset[1], 0.+offset[2]}; 267 const double window_end[NDIM] = { 1.+offset[0], 1.+offset[1], 1.+offset[2]}; 268 268 SamplingGrid newgrid(begin, end, 2); 269 269 newgrid.setWindowSize(window_begin, window_end); … … 292 292 { 293 293 std::cout << "SamplingGridTest::extendWindow_asymmetric_Test()" << std::endl; 294 const double begin[ 3] = { 0., 0., 0. };295 const double end[ 3] = { 2., 2., 2. };296 double offset[ 3];294 const double begin[NDIM] = { 0., 0., 0. }; 295 const double end[NDIM] = { 2., 2., 2. }; 296 double offset[NDIM]; 297 297 for (offset[0] = 0.; offset[0] <= 1.; offset[0] += .5) 298 298 for (offset[1] = 0.; offset[1] <= 1.; offset[1] += .5) 299 299 for (offset[2] = 0.; offset[2] <= 1.; offset[2] += .5) { 300 const double window_begin[ 3] = { 0.+offset[0], 0.+offset[1], 0.+offset[2]};301 const double window_end[ 3] = { 1.+offset[0], 1.+offset[1], 1.+offset[2]};300 const double window_begin[NDIM] = { 0.+offset[0], 0.+offset[1], 0.+offset[2]}; 301 const double window_end[NDIM] = { 1.+offset[0], 1.+offset[1], 1.+offset[2]}; 302 302 SamplingGrid newgrid(begin, end, 2); 303 303 CPPUNIT_ASSERT_EQUAL( (size_t)0, newgrid.getWindowGridPoints() ); 304 304 newgrid.setWindowSize(window_begin, window_end); 305 305 // window size is only half of domain size 306 const size_t max_samples = NUMBEROFSAMPLES(newgrid.level)*pow(0.5, 3);306 const size_t max_samples = NUMBEROFSAMPLES(newgrid.level)*pow(0.5,(int)NDIM); 307 307 for (size_t i=0; i< max_samples; ++i) 308 308 newgrid.sampled_grid += grid_value*i; … … 326 326 // create values for half-sized window 327 327 values.clear(); 328 for (size_t i=0; i< (size_t)pow(.5*pow(2,2), 3); ++i)328 for (size_t i=0; i< (size_t)pow(.5*pow(2,2),(int)NDIM); ++i) 329 329 values += grid_value; 330 330 331 331 // check that too large a window throws 332 332 #ifndef NDEBUG 333 const double begin[ 3] = { .5, .5, .5 };334 const double wrongend[ 3] = { 1.5, 1.5, 1.5 };333 const double begin[NDIM] = { .5, .5, .5 }; 334 const double wrongend[NDIM] = { 1.5, 1.5, 1.5 }; 335 335 std::cout << "The following assertion is intended and does not indicate a failure of the test." << std::endl; 336 336 CPPUNIT_ASSERT_THROW( grid->addOntoWindow(begin, wrongend, values, +1.), Assert::AssertionFailure ); … … 338 338 339 339 // create another window from (.5,.5,.5) to (1., 1., 1.) 340 double offset[ 3];340 double offset[NDIM]; 341 341 for (offset[0] = 0.; offset[0] <= .5; offset[0] += .5) 342 342 for (offset[1] = 0.; offset[1] <= .5; offset[1] += .5) 343 343 for (offset[2] = 0.; offset[2] <= .5; offset[2] += .5) { 344 const double window_begin[ 3] = { 0.+offset[0], 0.+offset[1], 0.+offset[2]};345 const double window_end[ 3] = { .5+offset[0], .5+offset[1], .5+offset[2]};344 const double window_begin[NDIM] = { 0.+offset[0], 0.+offset[1], 0.+offset[2]}; 345 const double window_end[NDIM] = { .5+offset[0], .5+offset[1], .5+offset[2]}; 346 346 347 347 SamplingGrid newgrid(*grid); … … 350 350 351 351 // check integral to be one and one eighth times the old value 352 CPPUNIT_ASSERT_EQUAL( (1.+pow(.5, 3))*grid_value, newgrid.integral() );352 CPPUNIT_ASSERT_EQUAL( (1.+pow(.5,(int)NDIM))*grid_value, newgrid.integral() ); 353 353 } 354 354 } … … 383 383 { 384 384 // create other grid 385 const double begin[ 3] = { 0., 0., 0. };386 const double end[ 3] = { 1., 1., 1. };385 const double begin[NDIM] = { 0., 0., 0. }; 386 const double end[NDIM] = { 1., 1., 1. }; 387 387 SamplingGrid::sampledvalues_t othervalues; 388 388 const double othergrid_value = 1.5; … … 407 407 { 408 408 // create other grid 409 const double begin[ 3] = { 0., 0., 0. };410 const double end[ 3] = { 1., 1., 1. };409 const double begin[NDIM] = { 0., 0., 0. }; 410 const double end[NDIM] = { 1., 1., 1. }; 411 411 SamplingGrid::sampledvalues_t othervalues; 412 412 const double othergrid_value = 1.5; … … 431 431 void SamplingGridTest::equality_Test() 432 432 { 433 const double begin[ 3] = { 0., 0., 0. };434 const double otherbegin[ 3] = { .5, 0.1, -0.5 };435 const double end[ 3] = { 1., 1., 1. };436 const double otherend[ 3] = { 2., 2., 2. };437 const double begin_window[ 3] = { 0., 0., 0. };438 const double otherbegin_window[ 3] = { .75, 0.1, 0. };439 const double end_window[ 3] = { 1., 1., 1. };440 const double otherend_window[ 3] = { .9, .9, .9 };433 const double begin[NDIM] = { 0., 0., 0. }; 434 const double otherbegin[NDIM] = { .5, 0.1, -0.5 }; 435 const double end[NDIM] = { 1., 1., 1. }; 436 const double otherend[NDIM] = { 2., 2., 2. }; 437 const double begin_window[NDIM] = { 0., 0., 0. }; 438 const double otherbegin_window[NDIM] = { .75, 0.1, 0. }; 439 const double end_window[NDIM] = { 1., 1., 1. }; 440 const double otherend_window[NDIM] = { .9, .9, .9 }; 441 441 442 442 // create other grid … … 515 515 delete samegrid; 516 516 } 517
Note:
See TracChangeset
for help on using the changeset viewer.