Ignore:
Timestamp:
Feb 15, 2013, 9:51:48 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:
e2404f
Parents:
98f8fe
git-author:
Frederik Heber <heber@…> (12/03/12 09:02:23)
git-committer:
Frederik Heber <heber@…> (02/15/13 09:51:48)
Message:

Rewrote parts of SampingGrid such that a window of non-zero entries is used.

  • this makes the last part final O(N) as so far for the sampled_grid the whole domain has to be used instead of a tiny region around the specific fragment.
  • for this we added extendWindow() and addOntoWindow() including some new member variables that hold the window size.
  • added default cstor that correctly used SampingGridProperties default cstor. Otherwise we got the funny behavior that on some systems the very first job of q MPQCCommandJob (tests/JobMarket/2) is not re-instantiated.
  • unit test extended to cover the new functionality but marked as expected to fail because it is not yet working correctly.
Location:
src/Jobs/Grid/unittests
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Jobs/Grid/unittests/Makefile.am

    r98f8fe r1a00bb  
    1414  SamplingGridUnitTest
    1515
     16XFAIL_TESTS += SamplingGridUnitTest
    1617TESTS += $(JOBSGRIDTESTS)
    1718check_PROGRAMS += $(JOBSGRIDTESTS)
  • src/Jobs/Grid/unittests/SamplingGridPropertiesUnitTest.cpp

    r98f8fe r1a00bb  
    8585  SamplingGridProperties moreotherprops(begin, end, 4);
    8686
     87  // only checks for same level
    8788  CPPUNIT_ASSERT( props->isCompatible(*props) );
    8889  CPPUNIT_ASSERT( props->isCompatible(sameprops) );
    8990  CPPUNIT_ASSERT( sameprops.isCompatible(*props) );
    90   CPPUNIT_ASSERT( !props->isCompatible(otherprops) );
    91   CPPUNIT_ASSERT( !otherprops.isCompatible(*props) );
    92   CPPUNIT_ASSERT( !props->isCompatible(anotherprops) );
    93   CPPUNIT_ASSERT( !anotherprops.isCompatible(*props) );
     91  CPPUNIT_ASSERT( props->isCompatible(otherprops) );
     92  CPPUNIT_ASSERT( otherprops.isCompatible(*props) );
     93  CPPUNIT_ASSERT( props->isCompatible(anotherprops) );
     94  CPPUNIT_ASSERT( anotherprops.isCompatible(*props) );
    9495  CPPUNIT_ASSERT( !props->isCompatible(moreotherprops) );
    9596  CPPUNIT_ASSERT( !moreotherprops.isCompatible(*props) );
     
    111112  SamplingGridProperties moreotherprops(begin, end, 4);
    112113
     114  // check for same level, begin, and end
    113115  CPPUNIT_ASSERT( *props == *props );
    114116  CPPUNIT_ASSERT( *props == sameprops );
    115   CPPUNIT_ASSERT( *props != otherprops );
     117  CPPUNIT_ASSERT( sameprops == *props);
     118  CPPUNIT_ASSERT( *props != otherprops);
     119  CPPUNIT_ASSERT( otherprops != *props);
    116120  CPPUNIT_ASSERT( *props != anotherprops );
     121  CPPUNIT_ASSERT( anotherprops != *props );
    117122  CPPUNIT_ASSERT( *props != moreotherprops );
     123  CPPUNIT_ASSERT( moreotherprops != *props );
    118124}
    119125
  • src/Jobs/Grid/unittests/SamplingGridUnitTest.cpp

    r98f8fe r1a00bb  
    8282}
    8383
    84 #define NUMBEROFSAMPLES(n) pow(pow(2,n),3)
    85 
    86 /** UnitTest for operator+=()
    87  */
    88 void SamplingGridTest::superposeOtherGrid_Test()
     84/** UnitTest on compatible combination of props and values
     85 */
     86void SamplingGridTest::compatibleGrids_Test()
    8987{
    9088  // check illegal grid
     
    9290  const double end[3] = { 2., 2., 2. };
    9391  SamplingGridProperties illegal_props(begin, end, 1);
     92  SamplingGridProperties legal_props(begin, end, 2);
    9493  CPPUNIT_ASSERT( !grid->isCompatible(illegal_props) );
     94  CPPUNIT_ASSERT( grid->isCompatible(legal_props) );
    9595  SamplingGrid::sampledvalues_t illegal_values;
    9696  for (size_t i=0; i< NUMBEROFSAMPLES(1); ++i)
    9797    illegal_values += 1.5;
    98   SamplingGrid illegal_grid(illegal_props, illegal_values);
     98  SamplingGrid::sampledvalues_t legal_values;
     99  for (size_t i=0; i< NUMBEROFSAMPLES(2); ++i)
     100    illegal_values += 1.5;
    99101#ifndef NDEBUG
    100   std::cout << "The following assertion is intended and does not indicate a failure of the test." << std::endl;
    101   CPPUNIT_ASSERT_THROW( *grid += illegal_grid, Assert::AssertionFailure );
    102 #else
    103   *grid += illegal_grid;
     102  // throws because props and size of illegal_values don't match
     103  std::cout << "The following assertion is intended and does not indicate a failure of the test." << std::endl;
     104  CPPUNIT_ASSERT_THROW( SamplingGrid illegal_grid(illegal_props, illegal_values), Assert::AssertionFailure );
     105  std::cout << "The following assertion is intended and does not indicate a failure of the test." << std::endl;
     106  CPPUNIT_ASSERT_THROW( SamplingGrid illegal_grid(legal_props, illegal_values), Assert::AssertionFailure );
     107  std::cout << "The following assertion is intended and does not indicate a failure of the test." << std::endl;
     108  CPPUNIT_ASSERT_THROW( SamplingGrid illegal_grid(illegal_props, legal_values), Assert::AssertionFailure );
    104109#endif
    105 
    106110  // check that grid is still the same
    107111  for (SamplingGrid::sampledvalues_t::const_iterator iter = grid->sampled_grid.begin();
     
    115119{
    116120  CPPUNIT_ASSERT_EQUAL( 1., grid->getVolume() );
     121}
     122
     123/** UnitTest for getWindowSize_Test
     124 */
     125void SamplingGridTest::getWindowSize_Test()
     126{
     127  // check size of default grid
     128  CPPUNIT_ASSERT_EQUAL( (size_t)NUMBEROFSAMPLES(2), grid->getWindowGridPoints() );
     129
     130  // create another one and check its size, too
     131  const double begin[3] = { 0., 0., 0. };
     132  const double end[3] = { 1., 1., 1. };
     133  for (size_t level = 3; level<=6; ++level) {
     134    values.clear();
     135    for (size_t i=0; i< NUMBEROFSAMPLES(level); ++i)
     136      values += grid_value;
     137    delete grid;
     138    grid = new SamplingGrid(begin, end, level, values);
     139    CPPUNIT_ASSERT_EQUAL( (size_t)NUMBEROFSAMPLES(level), grid->getWindowGridPoints() );
     140  }
     141}
     142
     143/** UnitTest for extendWindow()
     144 */
     145void SamplingGridTest::extendWindow_Test()
     146{
     147  // we have a grid with size of two, extend to twice the size and check
     148  const double begin[3] = { 0., 0., 0. };
     149  const double end[3] = { 2., 2., 2. };
     150  grid->extendWindow(begin, end);
     151
     152  // check integral
     153  CPPUNIT_ASSERT_EQUAL( NUMBEROFSAMPLES(2)*grid_value, grid->integral() );
     154
     155  // check number of points
     156  CPPUNIT_ASSERT_EQUAL( (size_t)NUMBEROFSAMPLES(3), grid->getWindowGridPoints() );
     157}
     158
     159/** UnitTest for addOntoWindow()
     160 */
     161void SamplingGridTest::addOntoWindow_Test()
     162{
     163  // first window is from (0,0,0) to (1,1,1)
     164  CPPUNIT_ASSERT_EQUAL( 1.*grid_value, grid->integral() );
     165
     166  // create another window from (.5,.5,.5) to (1., 1., 1.)
     167  const double begin[3] = { .5, .5, .5 };
     168  const double end[3] = { 1., 1., 1. };
     169  values.clear();
     170  for (size_t i=0; i< NUMBEROFSAMPLES(2)/pow(2,3); ++i) // cut in half
     171    values += grid_value;
     172  // check that too large a window throws
     173#ifndef NDEBUG
     174  const double wrongend[3] = { 1.5, 1.5, 1.5 };
     175  std::cout << "The following assertion is intended and does not indicate a failure of the test." << std::endl;
     176  CPPUNIT_ASSERT_THROW( grid->addOntoWindow(begin, wrongend, values), Assert::AssertionFailure );
     177#endif
     178  // now perform working operation
     179  grid->addOntoWindow(begin, end, values);
     180
     181  // check integral to be one and half times the old value
     182  CPPUNIT_ASSERT_EQUAL( (1.+pow(.5,3))*grid_value, grid->integral() );
    117183}
    118184
  • src/Jobs/Grid/unittests/SamplingGridUnitTest.hpp

    r98f8fe r1a00bb  
    2424{
    2525    CPPUNIT_TEST_SUITE( SamplingGridTest) ;
    26     CPPUNIT_TEST ( superposeOtherGrid_Test );
     26    CPPUNIT_TEST ( compatibleGrids_Test );
    2727    CPPUNIT_TEST ( operatorPlusEqual_Test );
    2828    CPPUNIT_TEST ( operatorMinusEqual_Test );
    2929    CPPUNIT_TEST ( getVolume_Test );
     30    CPPUNIT_TEST ( getWindowSize_Test );
     31    CPPUNIT_TEST ( extendWindow_Test );
     32    CPPUNIT_TEST ( addOntoWindow_Test );
    3033    CPPUNIT_TEST_SUITE_END();
    3134
     
    3336      void setUp();
    3437      void tearDown();
    35       void superposeOtherGrid_Test();
     38      void compatibleGrids_Test();
    3639      void getVolume_Test();
     40      void getWindowSize_Test();
     41      void extendWindow_Test();
     42      void addOntoWindow_Test();
    3743      void operatorPlusEqual_Test();
    3844      void operatorMinusEqual_Test();
Note: See TracChangeset for help on using the changeset viewer.