Ignore:
Timestamp:
Feb 15, 2013, 5:09:57 PM (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:
fb3485
Parents:
56b04c
git-author:
Frederik Heber <heber@…> (01/31/13 12:09:56)
git-committer:
Frederik Heber <heber@…> (02/15/13 17:09:57)
Message:

Added SamplingGrid::isCongruent().

  • also added unit test function.
Location:
src/Jobs/Grid/unittests
Files:
2 edited

Legend:

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

    r56b04c rc0e8fb  
    116116}
    117117
     118/** UnitTest for isCongruent()
     119 */
     120void SamplingGridTest::isCongruent_Test()
     121{
     122  const double begin[3] = { 0., 0., 0. };
     123  const double end[3] = { 2., 2., 2. };
     124  const double otherbegin[3] = { 0.1, 0.1, 0.1 };
     125  const double otherend[3] = { 1., 1., 1. };
     126  SamplingGridProperties illegal_begin_props(otherbegin, end, 5);
     127  SamplingGridProperties illegal_end_props(begin, otherend, 5);
     128  SamplingGridProperties illegal_level_props(begin, end, 5);
     129  SamplingGridProperties legal_props(begin, end, 2);
     130
     131  // differing windows
     132  const double begin_window[3] = { 0.5, 0.5, 0.5 };
     133  const double end_window[3] = { 1., 1., 1. };
     134  const double otherbegin_window[3] = { 0.45, 0.45, 0.45 };
     135  const double otherend_window[3] = { 1.05, 1.05, 1.05 };
     136
     137  // check that incompatible grid are also incongruent
     138  SamplingGrid default_grid(legal_props);
     139  // note that we always construct a temporary SamplingGrid from given props
     140  CPPUNIT_ASSERT( default_grid.isCompatible(illegal_begin_props) == default_grid.isCongruent(illegal_begin_props));
     141  CPPUNIT_ASSERT( default_grid.isCompatible(illegal_end_props) == default_grid.isCongruent(illegal_end_props));
     142  CPPUNIT_ASSERT( default_grid.isCompatible(illegal_level_props) == default_grid.isCongruent(illegal_level_props));
     143  CPPUNIT_ASSERT( default_grid.isCompatible(legal_props) == default_grid.isCongruent(legal_props) );
     144
     145  default_grid.setWindowSize(begin, end);
     146  // same window
     147  {
     148    SamplingGrid illegal_begin_grid(illegal_begin_props);
     149    SamplingGrid illegal_end_grid(illegal_end_props);
     150    SamplingGrid illegal_level_grid(illegal_level_props);
     151    SamplingGrid legal_grid(legal_props);
     152    illegal_begin_grid.setWindowSize(begin, end);
     153    illegal_end_grid.setWindowSize(begin, end);
     154    illegal_level_grid.setWindowSize(begin, end);
     155    legal_grid.setWindowSize(begin, end);
     156    CPPUNIT_ASSERT( !illegal_begin_grid.isCongruent(default_grid) );
     157    CPPUNIT_ASSERT( !illegal_end_grid.isCongruent(default_grid) );
     158    CPPUNIT_ASSERT( !illegal_level_grid.isCongruent(default_grid) );
     159    CPPUNIT_ASSERT( legal_grid.isCongruent(default_grid) );
     160  }
     161
     162  // different begin
     163  {
     164    SamplingGrid illegal_begin_grid(illegal_begin_props);
     165    SamplingGrid illegal_end_grid(illegal_end_props);
     166    SamplingGrid illegal_level_grid(illegal_level_props);
     167    SamplingGrid legal_grid(legal_props);
     168    illegal_begin_grid.setWindowSize(otherbegin_window, end);
     169    illegal_end_grid.setWindowSize(otherbegin_window, end);
     170    illegal_level_grid.setWindowSize(otherbegin_window, end);
     171    legal_grid.setWindowSize(begin, end);
     172    CPPUNIT_ASSERT( !illegal_begin_grid.isCongruent(legal_grid) );
     173    CPPUNIT_ASSERT( !illegal_end_grid.isCongruent(legal_grid) );
     174    CPPUNIT_ASSERT( !illegal_level_grid.isCongruent(legal_grid) );
     175    CPPUNIT_ASSERT( legal_grid.isCongruent(default_grid) );
     176  }
     177
     178  // different end
     179  {
     180    SamplingGrid illegal_begin_grid(illegal_begin_props);
     181    SamplingGrid illegal_end_grid(illegal_end_props);
     182    SamplingGrid illegal_level_grid(illegal_level_props);
     183    SamplingGrid legal_grid(legal_props);
     184    illegal_begin_grid.setWindowSize(begin, otherend_window);
     185    illegal_end_grid.setWindowSize(begin, otherend_window);
     186    illegal_level_grid.setWindowSize(begin, otherend_window);
     187    legal_grid.setWindowSize(begin, end);
     188    CPPUNIT_ASSERT( !illegal_begin_grid.isCongruent(legal_grid) );
     189    CPPUNIT_ASSERT( !illegal_end_grid.isCongruent(legal_grid) );
     190    CPPUNIT_ASSERT( !illegal_level_grid.isCongruent(legal_grid) );
     191    CPPUNIT_ASSERT( legal_grid.isCongruent(default_grid) );
     192  }
     193
     194  // different begin and end
     195  {
     196    SamplingGrid illegal_begin_grid(illegal_begin_props);
     197    SamplingGrid illegal_end_grid(illegal_end_props);
     198    SamplingGrid illegal_level_grid(illegal_level_props);
     199    SamplingGrid legal_grid(legal_props);
     200    illegal_begin_grid.setWindowSize(otherbegin_window, otherend_window);
     201    illegal_end_grid.setWindowSize(otherbegin_window, otherend_window);
     202    illegal_level_grid.setWindowSize(otherbegin_window, otherend_window);
     203    legal_grid.setWindowSize(begin, end);
     204    CPPUNIT_ASSERT( !illegal_begin_grid.isCongruent(legal_grid) );
     205    CPPUNIT_ASSERT( !illegal_end_grid.isCongruent(legal_grid) );
     206    CPPUNIT_ASSERT( !illegal_level_grid.isCongruent(legal_grid) );
     207    CPPUNIT_ASSERT( legal_grid.isCongruent(default_grid) );
     208  }
     209}
     210
    118211/** UnitTest for integral()
    119212 */
  • src/Jobs/Grid/unittests/SamplingGridUnitTest.hpp

    r56b04c rc0e8fb  
    2727    CPPUNIT_TEST ( operatorPlusEqual_Test );
    2828    CPPUNIT_TEST ( operatorMinusEqual_Test );
     29    CPPUNIT_TEST ( isCongruent_Test );
    2930    CPPUNIT_TEST ( integral_Test );
    3031    CPPUNIT_TEST ( getVolume_Test );
     
    4041      void tearDown();
    4142      void compatibleGrids_Test();
     43      void isCongruent_Test();
    4244      void integral_Test();
    4345      void getVolume_Test();
Note: See TracChangeset for help on using the changeset viewer.