Ignore:
Timestamp:
Feb 15, 2013, 9:51:49 AM (12 years ago)
Author:
Frederik Heber <heber@…>
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:
c6355f
Parents:
e2404f
git-author:
Frederik Heber <heber@…> (02/11/13 09:24:45)
git-committer:
Frederik Heber <heber@…> (02/15/13 09:51:49)
Message:

Extending AddOntoWindow() by prefactor, can deal with differently sized windows.

  • also extended unit tests to check on working asymmetry.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Jobs/Grid/unittests/SamplingGridUnitTest.cpp

    re2404f rde6dfb  
    149149  // we have a grid with size of two, extend to twice the size and check
    150150  const double begin[3] = { 0., 0., 0. };
     151  const double size = 2.;
     152  const double end[3] = { size, size, size };
     153  grid->extendWindow(begin, end);
     154
     155  // check integral
     156  CPPUNIT_ASSERT_EQUAL( grid_value/(NUMBEROFSAMPLES(grid->level)/NUMBEROFSAMPLES(grid->level)), grid->integral() );
     157
     158  // check number of points
     159  CPPUNIT_ASSERT_EQUAL( (size_t)NUMBEROFSAMPLES(grid->level), grid->getWindowGridPoints() );
     160}
     161
     162/** UnitTest for extendWindow() with asymmetric values
     163 */
     164void SamplingGridTest::extendWindow_asymmetric_Test()
     165{
     166  const double begin[3] = { 0., 0., 0. };
    151167  const double end[3] = { 2., 2., 2. };
     168  grid->sampled_grid.clear();
     169  SamplingGrid::sampledvalues_t::iterator griditer = grid->sampled_grid.begin();
     170  for (size_t i=0; i< NUMBEROFSAMPLES(grid->level); ++i)
     171     *griditer++ += grid_value*i;
    152172  grid->extendWindow(begin, end);
    153173
    154   // check integral
    155   CPPUNIT_ASSERT_EQUAL( NUMBEROFSAMPLES(2)*grid_value, grid->integral() );
    156 
    157   // check number of points
    158   CPPUNIT_ASSERT_EQUAL( (size_t)NUMBEROFSAMPLES(3), grid->getWindowGridPoints() );
     174  CPPUNIT_ASSERT_EQUAL( grid_value, grid->integral() );
    159175}
    160176
     
    176192  const double wrongend[3] = { 1.5, 1.5, 1.5 };
    177193  std::cout << "The following assertion is intended and does not indicate a failure of the test." << std::endl;
    178   CPPUNIT_ASSERT_THROW( grid->addOntoWindow(begin, wrongend, values), Assert::AssertionFailure );
     194  CPPUNIT_ASSERT_THROW( grid->addOntoWindow(begin, wrongend, values, +1.), Assert::AssertionFailure );
    179195#endif
    180196  // now perform working operation
    181   grid->addOntoWindow(begin, end, values);
     197  grid->addOntoWindow(begin, end, values, +1.);
    182198
    183199  // check integral to be one and half times the old value
    184200  CPPUNIT_ASSERT_EQUAL( (1.+pow(.5,3))*grid_value, grid->integral() );
     201}
     202
     203/** UnitTest for addOntoWindow() with asymmetric values
     204 */
     205void SamplingGridTest::addOntoWindow_asymmetric_Test()
     206{
     207  // check with asymmetric values
     208  grid->sampled_grid.clear();
     209  grid->sampled_grid.resize(NUMBEROFSAMPLES(2), 0.);
     210
     211  for (size_t i=0;i<grid->level*(grid->end[0]-grid->begin[0]);++i)
     212    grid->sampled_grid[(i*2+0)*2+0] += .5*grid_value;
     213  for (size_t i=0;i<grid->level*(grid->end[1]-grid->begin[1]);++i)
     214    grid->sampled_grid[(0*2+i)*2+0] += 1.*grid_value;
     215  for (size_t i=0;i<grid->level*(grid->end[2]-grid->begin[2]);++i)
     216    grid->sampled_grid[(0*2+0)*2+i] += 1.5*grid_value;
     217
     218  const double integral = grid->integral();
     219  const double begin[3] = { 0., 0., 0. };
     220  for(double size=2.; size<=5.; size += 1.) {
     221    const double newend[3] = {size, size, size};
     222    grid->extendWindow(begin, newend);
     223    CPPUNIT_ASSERT_EQUAL( pow(size,3)*integral, grid->integral() );
     224  }
    185225}
    186226
Note: See TracChangeset for help on using the changeset viewer.