Ignore:
Timestamp:
Sep 12, 2016, 11:48:36 PM (8 years ago)
Author:
Frederik Heber <heber@…>
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, SaturateAtoms_findBestMatching, 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:
0983e6
Parents:
450adf
git-author:
Frederik Heber <heber@…> (06/30/14 09:35:42)
git-committer:
Frederik Heber <heber@…> (09/12/16 23:48:36)
Message:

SphericalPointDistribution is now working with bond degree weights.

  • recurseMatching() now works on IndexTupleList_t.
  • also rewrote calculatePairwiseDistances() and calculateErrorOfMatching().
  • L1THRESHOLD in recurseMatching() moved over to class body.
  • increased verbosity level of ...Matching() functions by one, added note on eventually chosen matching and why.
  • we assert that bestL2 is not too large.
  • FIX: calculateErrorOfMatching() did not use absolute value of gap for L1 error.
  • TESTFIX: Using limited accuracy on point coordinates.
  • TESTS: Regresssion test FragmentMolecule-cycles working again.
Location:
src/Fragmentation/Exporters/unittests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp

    r450adf r653cea  
    6868CPPUNIT_TEST_SUITE_REGISTRATION( SphericalPointDistributionTest );
    6969
     70/** due to root-taking in function we only have limited numerical precision,
     71 * basically half of the double range.
     72 */
     73const double CenterAccuracy = sqrt(std::numeric_limits<double>::epsilon()*1e2);
    7074
    7175void SphericalPointDistributionTest::setUp()
     
    638642}
    639643
     644/** UnitTest for matchSphericalPointDistributions() with four points and weights
     645 * not all equal to one.
     646 */
     647void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_multiple()
     648{
     649  SphericalPointDistribution SPD(1.);
     650
     651  // test with four points: one point having weight of two
     652  {
     653    SphericalPointDistribution::WeightedPolygon_t polygon;
     654    polygon += std::make_pair( Vector(1.,0.,0.), 2);
     655    SphericalPointDistribution::Polygon_t newpolygon =
     656        SPD.get<4>();
     657    SphericalPointDistribution::Polygon_t expected;
     658    expected += Vector(-0.5773502691896,-5.551115123126e-17,0.8164965809277);
     659    expected += Vector(-0.5773502691896,-5.551115123126e-17,-0.8164965809277);
     660    SphericalPointDistribution::Polygon_t remaining =
     661        SphericalPointDistribution::matchSphericalPointDistributions(
     662            polygon,
     663            newpolygon);
     664//    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
     665//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     666    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     667  }
     668
     669  // test with five points: one point having weight of two
     670  {
     671    SphericalPointDistribution::WeightedPolygon_t polygon;
     672    polygon += std::make_pair( Vector(1.,0.,0.), 2);
     673    SphericalPointDistribution::Polygon_t newpolygon =
     674        SPD.get<5>();
     675    SphericalPointDistribution::Polygon_t expected;
     676    expected += Vector(-0.7071067811865,0.7071067811865,0);
     677    expected += Vector(-0.3535533905933,-0.3535533905933,0.8660254037844);
     678    expected += Vector(-0.3535533905933,-0.3535533905933,-0.8660254037844);
     679    SphericalPointDistribution::Polygon_t remaining =
     680        SphericalPointDistribution::matchSphericalPointDistributions(
     681            polygon,
     682            newpolygon);
     683//    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
     684//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     685    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     686  }
     687
     688
     689  // test with five points: one point having weight of two, one weight of one
     690  {
     691    SphericalPointDistribution::WeightedPolygon_t polygon;
     692    polygon += std::make_pair( Vector(M_SQRT1_2,M_SQRT1_2,0.), 2);
     693    polygon += std::make_pair( Vector(-1.,0.,0.), 1);
     694    SphericalPointDistribution::Polygon_t newpolygon =
     695        SPD.get<5>();
     696    SphericalPointDistribution::Polygon_t expected;
     697    expected += Vector(0.3535533786708,-0.3535533955317,-0.8660254066357);
     698    expected += Vector(0.3535534025157,-0.3535533856548,0.8660254009332);
     699    SphericalPointDistribution::Polygon_t remaining =
     700        SphericalPointDistribution::matchSphericalPointDistributions(
     701            polygon,
     702            newpolygon);
     703//    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
     704//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     705    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     706  }
     707
     708  // test with six points: two points each having weight of two
     709  {
     710    SphericalPointDistribution::WeightedPolygon_t polygon;
     711    polygon += std::make_pair( Vector(M_SQRT1_2,-M_SQRT1_2,0.), 2);
     712    polygon += std::make_pair( Vector(-M_SQRT1_2,M_SQRT1_2,0.), 2);
     713    SphericalPointDistribution::Polygon_t newpolygon =
     714        SPD.get<6>();
     715    SphericalPointDistribution::Polygon_t expected;
     716    expected += Vector(0.,0.,-1.);
     717    expected += Vector(0.,0.,1.);
     718    SphericalPointDistribution::Polygon_t remaining =
     719        SphericalPointDistribution::matchSphericalPointDistributions(
     720            polygon,
     721            newpolygon);
     722//    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
     723//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     724    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     725  }
     726}
     727
    640728/** UnitTest for matchSphericalPointDistributions() with five points
    641729 */
  • src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.hpp

    r450adf r653cea  
    3131    CPPUNIT_TEST ( matchSphericalPointDistributionsTest_7 );
    3232    CPPUNIT_TEST ( matchSphericalPointDistributionsTest_8 );
     33    CPPUNIT_TEST ( matchSphericalPointDistributionsTest_multiple );
    3334    CPPUNIT_TEST_SUITE_END();
    3435
     
    4546      void matchSphericalPointDistributionsTest_7();
    4647      void matchSphericalPointDistributionsTest_8();
     48      void matchSphericalPointDistributionsTest_multiple();
    4749
    4850private:
Note: See TracChangeset for help on using the changeset viewer.