Changeset bbc338 for src


Ignore:
Timestamp:
Oct 14, 2009, 11:18:14 AM (15 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:
db6bf74
Parents:
6cd79d
Message:

Unit tests AnalysisCorrelation is done.

  • four carbon atoms were added around the hydrogen tetraeder to test CorrelationToSurface.
  • everything seems to work fine, three bugs were found (see previous commits).

Signed-off-by: Frederik Heber <heber@…>

Location:
src/unittests
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/AnalysisCorrelationToPointUnitTest.cpp

    r6cd79d rbbc338  
    4444  hydrogen->Z = 1;
    4545  strcpy(hydrogen->name, "hydrogen");
    46   hydrogen->symbol[0] = 'H';
     46  strcpy(hydrogen->symbol, "H");
     47
    4748
    4849  // construct periodentafel
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    r6cd79d rbbc338  
    4646  hydrogen->Z = 1;
    4747  strcpy(hydrogen->name, "hydrogen");
    48   hydrogen->symbol[0] = 'H';
     48  strcpy(hydrogen->symbol, "H");
     49  carbon = new element;
     50  carbon->Z = 6;
     51  strcpy(carbon->name, "carbon");
     52  strcpy(carbon->symbol, "C");
    4953
    5054  // construct periodentafel
    5155  tafel = new periodentafel;
    5256  tafel->AddElement(hydrogen);
    53 
    54   // construct molecule (tetraeder of hydrogens)
     57  tafel->AddElement(carbon);
     58
     59  // construct molecule (tetraeder of hydrogens) base
    5560  TestMolecule = new molecule(tafel);
    5661  Walker = new atom();
     
    7782  Surface = new Tesselation;
    7883  TestMolecule->TesselStruct = Surface;
    79   FindNonConvexBorder((ofstream *)&cout, TestMolecule, LC, 2.5, NULL);
     84  FindNonConvexBorder((ofstream *)&cerr, TestMolecule, LC, 2.5, NULL);
    8085  LC = new LinkedCell(TestMolecule, 5.);
    8186  CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );
     
    8388  CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->TrianglesOnBoundary.size() );
    8489
     90  // add outer atoms
     91  Walker = new atom();
     92  Walker->type = carbon;
     93  Walker->node->Init(4., 0., 4. );
     94  TestMolecule->AddAtom(Walker);
     95  Walker = new atom();
     96  Walker->type = carbon;
     97  Walker->node->Init(0., 4., 4. );
     98  TestMolecule->AddAtom(Walker);
     99  Walker = new atom();
     100  Walker->type = carbon;
     101  Walker->node->Init(4., 4., 0. );
     102  TestMolecule->AddAtom(Walker);
     103  // add inner atoms
     104  Walker = new atom();
     105  Walker->type = carbon;
     106  Walker->node->Init(0.5, 0.5, 0.5 );
     107  TestMolecule->AddAtom(Walker);
     108
    85109  // init maps
    86   surfacemap = CorrelationToSurface( (ofstream *)&cout, TestMolecule, hydrogen, Surface, LC );
     110  surfacemap = NULL;
    87111  binmap = NULL;
    88112
     
    109133{
    110134  // do the pair correlation
     135  surfacemap = CorrelationToSurface( (ofstream *)&cout, TestMolecule, hydrogen, Surface, LC );
    111136  CPPUNIT_ASSERT( surfacemap != NULL );
    112137  CPPUNIT_ASSERT_EQUAL( (size_t)4, surfacemap->size() );
    113138};
    114139
    115 void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceBinNoRangeTest()
    116 {
    117   BinPairMap::iterator tester;
     140void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceHydrogenBinNoRangeTest()
     141{
     142  BinPairMap::iterator tester;
     143  surfacemap = CorrelationToSurface( (ofstream *)&cout, TestMolecule, hydrogen, Surface, LC );
    118144  // put pair correlation into bins and check with no range
    119145  binmap = BinData( (ofstream *)&cout, surfacemap, 0.5, 0., 0. );
     
    126152};
    127153
    128 void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceBinRangeTest()
    129 {
    130   BinPairMap::iterator tester;
     154void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceHydrogenBinRangeTest()
     155{
     156  BinPairMap::iterator tester;
     157  surfacemap = CorrelationToSurface( (ofstream *)&cout, TestMolecule, hydrogen, Surface, LC );
    131158  // ... and check with [0., 2.] range
    132159  binmap = BinData( (ofstream *)&cout, surfacemap, 0.5, 0., 2. );
     
    142169};
    143170
     171void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceCarbonBinNoRangeTest()
     172{
     173  BinPairMap::iterator tester;
     174  surfacemap = CorrelationToSurface( (ofstream *)&cout, TestMolecule, carbon, Surface, LC );
     175  // put pair correlation into bins and check with no range
     176  binmap = BinData( (ofstream *)&cout, surfacemap, 0.5, 0., 0. );
     177  CPPUNIT_ASSERT_EQUAL( (size_t)2, binmap->size() );
     178  OutputCorrelation ( (ofstream *)&cout, binmap );
     179  // inside point is first and must have negative value
     180  tester = binmap->lower_bound(2.95); // start depends on the min value and
     181  CPPUNIT_ASSERT( tester != binmap->end() );
     182  CPPUNIT_ASSERT_EQUAL( 3, tester->second );
     183  // inner point
     184  tester = binmap->lower_bound(0.);
     185  CPPUNIT_ASSERT( tester != binmap->end() );
     186  CPPUNIT_ASSERT_EQUAL( 1, tester->second );
     187};
     188
     189void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceCarbonBinRangeTest()
     190{
     191  BinPairMap::iterator tester;
     192  surfacemap = CorrelationToSurface( (ofstream *)&cout, TestMolecule, carbon, Surface, LC );
     193  // ... and check with [0., 2.] range
     194  binmap = BinData( (ofstream *)&cout, surfacemap, 0.5, -2., 4. );
     195  CPPUNIT_ASSERT_EQUAL( (size_t)13, binmap->size() );
     196  OutputCorrelation ( (ofstream *)&cout, binmap );
     197  // three outside points
     198  tester = binmap->find(3.);
     199  CPPUNIT_ASSERT( tester != binmap->end() );
     200  CPPUNIT_ASSERT_EQUAL( 3, tester->second );
     201  // inner point
     202  tester = binmap->find(0.);
     203  CPPUNIT_ASSERT( tester != binmap->end() );
     204  CPPUNIT_ASSERT_EQUAL( 1, tester->second );
     205
     206};
     207
    144208/********************************************** Main routine **************************************/
    145209
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp

    r6cd79d rbbc338  
    2323    CPPUNIT_TEST_SUITE( AnalysisCorrelationToSurfaceUnitTest ) ;
    2424    CPPUNIT_TEST ( CorrelationToSurfaceTest );
    25     CPPUNIT_TEST ( CorrelationToSurfaceBinNoRangeTest );
    26     CPPUNIT_TEST ( CorrelationToSurfaceBinRangeTest );
     25    CPPUNIT_TEST ( CorrelationToSurfaceHydrogenBinNoRangeTest );
     26    CPPUNIT_TEST ( CorrelationToSurfaceHydrogenBinRangeTest );
     27    CPPUNIT_TEST ( CorrelationToSurfaceCarbonBinNoRangeTest );
     28    CPPUNIT_TEST ( CorrelationToSurfaceCarbonBinRangeTest );
    2729    CPPUNIT_TEST_SUITE_END();
    2830
     
    3133      void tearDown();
    3234      void CorrelationToSurfaceTest();
    33       void CorrelationToSurfaceBinNoRangeTest();
    34       void CorrelationToSurfaceBinRangeTest();
     35      void CorrelationToSurfaceHydrogenBinNoRangeTest();
     36      void CorrelationToSurfaceHydrogenBinRangeTest();
     37      void CorrelationToSurfaceCarbonBinNoRangeTest();
     38      void CorrelationToSurfaceCarbonBinRangeTest();
    3539
    3640private:
     
    3842      molecule *TestMolecule;
    3943      element *hydrogen;
     44      element *carbon;
    4045      periodentafel *tafel;
    4146
  • src/unittests/AnalysisPairCorrelationUnitTest.cpp

    r6cd79d rbbc338  
    4444  hydrogen->Z = 1;
    4545  strcpy(hydrogen->name, "hydrogen");
    46   hydrogen->symbol[0] = 'H';
     46  strcpy(hydrogen->symbol, "H");
    4747
    4848  // construct periodentafel
Note: See TracChangeset for help on using the changeset viewer.