Changeset b3c052 for src/Fragmentation/Exporters/unittests
- Timestamp:
- Sep 12, 2016, 2:03:15 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, 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:
- 158ecb
- Parents:
- 8e4471
- git-author:
- Frederik Heber <heber@…> (06/05/14 17:42:39)
- git-committer:
- Frederik Heber <heber@…> (09/12/16 14:03:15)
- Location:
- src/Fragmentation/Exporters/unittests
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Exporters/unittests/Makefile.am
r8e4471 rb3c052 21 21 22 22 TESTS += $(FRAGMENTATIONEXPORTERSTESTS) 23 XFAIL_TESTS += SphericalPointDistributionUnitTest24 23 check_PROGRAMS += $(FRAGMENTATIONEXPORTERSTESTS) 25 24 noinst_PROGRAMS += $(FRAGMENTATIONEXPORTERSTESTS) -
src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp
r8e4471 rb3c052 82 82 } 83 83 84 void SphericalPointDistributionTest::QuaternionTest()85 {86 Vector oldCenter(0.,1.,0.);87 Vector newCenter(1.,0.,0.);88 89 {90 // setup quaternion91 Vector RotationAxis = newCenter;92 RotationAxis.VectorProduct(oldCenter);93 RotationAxis.Normalize();94 const double RotationAngle = oldCenter.Angle(newCenter)/(M_PI/2.);95 // RotationAxis.Angle(oldCenter) - RotationAxis.Angle(newCenter);96 boost::math::quaternion<double> q97 (RotationAngle, RotationAxis[0], RotationAxis[1], RotationAxis[2]);98 LOG(5, "DEBUG: RotationAxis is " << RotationAxis99 << ", RotationAngle is " << RotationAngle);100 LOG(5, "DEBUG: Quaternion describing rotation is " << q);101 boost::math::quaternion<double> q_inverse =102 boost::math::conj(q)/(boost::math::norm(q));103 LOG(5, "DEBUG: Quaternion inverse is " << q_inverse);104 boost::math::quaternion<double> identity(1,0,0,0);105 const boost::math::quaternion<double> unity = q*q_inverse;106 LOG(5, "DEBUG: q * q^-1 is " << unity);107 CPPUNIT_ASSERT( boost::math::norm(unity - identity) < std::numeric_limits<double>::epsilon()*1e4);108 109 // check that rotation works110 boost::math::quaternion<double> p(0., newCenter[0], newCenter[1], newCenter[2]);111 LOG(5, "DEBUG: Original newCenter is " << p);112 p = p * q_inverse;113 p = q * p;114 LOG(5, "DEBUG: Rotated newCenter is " << p);115 boost::math::quaternion<double> comparison(0., -oldCenter[0], oldCenter[1], oldCenter[2]);116 LOG(5, "DEBUG: Difference norm is " << boost::math::norm(p - comparison));117 CPPUNIT_ASSERT( boost::math::norm(p - comparison) < std::numeric_limits<double>::epsilon()*1e4);118 }119 120 // rotating with angle = 0 flips the vector unwantedly121 {122 // setup quaternion123 Vector RotationAxis = newCenter;124 RotationAxis.VectorProduct(oldCenter);125 RotationAxis.Normalize();126 const double RotationAngle = 0.;127 // RotationAxis.Angle(oldCenter) - RotationAxis.Angle(newCenter);128 boost::math::quaternion<double> q129 (RotationAngle, RotationAxis[0], RotationAxis[1], RotationAxis[2]);130 LOG(5, "DEBUG: RotationAxis is " << RotationAxis131 << ", RotationAngle is " << RotationAngle);132 LOG(5, "DEBUG: Quaternion describing rotation is " << q);133 boost::math::quaternion<double> q_inverse =134 boost::math::conj(q)/(boost::math::norm(q));135 LOG(5, "DEBUG: Quaternion inverse is " << q_inverse);136 boost::math::quaternion<double> identity(1,0,0,0);137 const boost::math::quaternion<double> unity = q*q_inverse;138 LOG(5, "DEBUG: q * q^-1 is " << unity);139 CPPUNIT_ASSERT( boost::math::norm(unity - identity) < std::numeric_limits<double>::epsilon()*1e4);140 141 // check that rotation works142 boost::math::quaternion<double> p(0., newCenter[0], newCenter[1], newCenter[2]);143 boost::math::quaternion<double> comparison(0., -newCenter[0], newCenter[1], newCenter[2]);144 LOG(5, "DEBUG: Original newCenter is " << p);145 p = p * q_inverse;146 p = q * p;147 LOG(5, "DEBUG: Rotated newCenter is " << p);148 LOG(5, "DEBUG: Difference norm is " << boost::math::norm(p - comparison));149 CPPUNIT_ASSERT( boost::math::norm(p - comparison) < std::numeric_limits<double>::epsilon()*1e4);150 }151 }152 84 153 85 /** UnitTest for matchSphericalPointDistributions() with two points -
src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.hpp
r8e4471 rb3c052 22 22 { 23 23 CPPUNIT_TEST_SUITE( SphericalPointDistributionTest) ; 24 CPPUNIT_TEST ( QuaternionTest );25 24 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_2 ); 26 25 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_3 ); … … 35 34 void setUp(); 36 35 void tearDown(); 37 void QuaternionTest();38 36 void matchSphericalPointDistributionsTest_2(); 39 37 void matchSphericalPointDistributionsTest_3();
Note:
See TracChangeset
for help on using the changeset viewer.