Changeset 826e8c for src/Analysis
- Timestamp:
- Feb 22, 2012, 11:29:04 AM (13 years ago)
- 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:
- 153985
- Parents:
- cbcda6
- git-author:
- Frederik Heber <heber@…> (02/06/12 17:46:56)
- git-committer:
- Frederik Heber <heber@…> (02/22/12 11:29:04)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Analysis/unittests/CountBondsUnitTest.cpp
rcbcda6 r826e8c 33 33 #include "Atom/atom.hpp" 34 34 #include "Bond/bond.hpp" 35 #include "CodePatterns/Log.hpp" 35 36 #include "Element/element.hpp" 36 37 #include "Element/periodentafel.hpp" … … 62 63 CPPUNIT_ASSERT(oxygen != NULL && "could not find element oxygen"); 63 64 65 //setVerbosity(3); 66 64 67 // construct molecule (water molecule) 65 68 TestMolecule1 = World::getInstance().createMolecule(); 66 CPPUNIT_ASSERT(TestMolecule1 != NULL && "could not create firstmolecule");69 CPPUNIT_ASSERT(TestMolecule1 != NULL && "could not create second molecule"); 67 70 Walker = World::getInstance().createAtom(); 68 71 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); … … 81 84 TestMolecule1->AddAtom(Walker); 82 85 83 TestMolecule2 = World::getInstance().createMolecule();84 CPPUNIT_ASSERT(TestMolecule2 != NULL && "could not create second molecule");85 Walker = World::getInstance().createAtom();86 CPPUNIT_ASSERT(Walker != NULL && "could not create atom");87 Walker->setType(hydrogen);88 Walker->setPosition(Vector(-0.2418, 0.9350, 0. ));89 TestMolecule2->AddAtom(Walker);90 Walker = World::getInstance().createAtom();91 CPPUNIT_ASSERT(Walker != NULL && "could not create atom");92 Walker->setType(hydrogen);93 Walker->setPosition(Vector(0.9658, 0., 0. ));94 TestMolecule2->AddAtom(Walker);95 Walker = World::getInstance().createAtom();96 CPPUNIT_ASSERT(Walker != NULL && "could not create atom");97 Walker->setType(oxygen);98 Walker->setPosition(Vector(0., 0., 0. ));99 TestMolecule2->AddAtom(Walker);100 101 86 molecules = World::getInstance().getMolecules(); 102 87 CPPUNIT_ASSERT(molecules != NULL && "could not obtain list of molecules"); 103 88 molecules->insert(TestMolecule1); 104 molecules->insert(TestMolecule2); 105 106 // check that TestMolecule was correctly constructed 89 90 // check that TestMolecule1 was correctly constructed 107 91 CPPUNIT_ASSERT_EQUAL( TestMolecule1->getAtomCount(), 3 ); 108 CPPUNIT_ASSERT_EQUAL( TestMolecule2->getAtomCount(), 3 );109 92 110 93 // create a small file with table … … 116 99 BG->CreateAdjacency(Set1); 117 100 CPPUNIT_ASSERT( TestMolecule1->getBondCount() != 0); 118 World::AtomComposite Set2 = TestMolecule2->getAtomSet();119 BG->CreateAdjacency(Set2);120 CPPUNIT_ASSERT( TestMolecule2->getBondCount() != 0);121 101 // TestMolecule1->Output((ofstream *)&cout); 122 102 // TestMolecule1->OutputBondsList(std::cout); … … 136 116 void CountBondsTest::BondsOfTwoTest() 137 117 { 138 CPPUNIT_ASSERT_EQUAL( 4, CountBondsOfTwo(molecules, hydrogen, oxygen) );118 CPPUNIT_ASSERT_EQUAL( 2 , CountBondsOfTwo(molecules, hydrogen, oxygen) ); 139 119 CPPUNIT_ASSERT_EQUAL( 0 , CountBondsOfTwo(molecules, hydrogen, hydrogen) ); 140 120 CPPUNIT_ASSERT_EQUAL( 0 , CountBondsOfTwo(molecules, oxygen, oxygen) ); … … 145 125 void CountBondsTest::BondsOfThreeTest() 146 126 { 147 CPPUNIT_ASSERT_EQUAL( 2, CountBondsOfThree(molecules, hydrogen, oxygen, hydrogen) );127 CPPUNIT_ASSERT_EQUAL( 1 , CountBondsOfThree(molecules, hydrogen, oxygen, hydrogen) ); 148 128 CPPUNIT_ASSERT_EQUAL( 0 , CountBondsOfThree(molecules, oxygen, hydrogen, oxygen) ); 149 129 }; 150 130 151 void OutputTestMolecule (molecule *mol, const char *name)131 void OutputTestMolecule1(molecule *mol, const char *name) 152 132 { 153 133 ofstream output(name); … … 166 146 Vector Translator; 167 147 168 //OutputTestMolecule(TestMolecule1, "testmolecule1.xyz"); 148 //OutputTestMolecule1(TestMolecule1, "testmolecule1.xyz"); 149 150 // create TestMolecule2 as copy 151 TestMolecule2 = TestMolecule1->CopyMolecule(); 152 molecules->insert(TestMolecule2); 153 CPPUNIT_ASSERT_EQUAL( TestMolecule2->getAtomCount(), 3 ); 169 154 170 155 cout << "Case 1: offset of (3,0,0), hence angles are (104.5, 0, 75.5, 180) < 30." << endl; 171 156 Translator = Vector(3,0,0); 172 TestMolecule 2->Translate(&Translator);157 TestMolecule1->Translate(&Translator); 173 158 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 174 159 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, oxygen, NULL) ); 175 //OutputTestMolecule (TestMolecule2, "testmolecule2-1.xyz");160 //OutputTestMolecule1(TestMolecule1, "testmolecule2-1.xyz"); 176 161 Translator = Vector(-3,0,0); 177 TestMolecule 2->Translate(&Translator);162 TestMolecule1->Translate(&Translator); 178 163 179 164 cout << "Case 2: offset of (0,3,0), hence angle are (14.5, 165.5, 90) < 30 (only three, because other 90 is missing due to first H01 only fulfilling H-bond criteria)." << endl; 180 165 Translator = Vector(0,3,0); 181 TestMolecule 2->Translate(&Translator);166 TestMolecule1->Translate(&Translator); 182 167 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 183 //OutputTestMolecule (TestMolecule2, "testmolecule2-2.xyz");168 //OutputTestMolecule1(TestMolecule1, "testmolecule2-2.xyz"); 184 169 Translator = Vector(0,-3,0); 185 TestMolecule 2->Translate(&Translator);170 TestMolecule1->Translate(&Translator); 186 171 187 172 cout << "Case 3: offset of (0,-3,0) and mirror, hence angle are (165.5, 90, 165.5, 90) > 30." << endl; 188 173 Translator = Vector(0,-3,0); 189 TestMolecule 2->Scale((const double ** const)&mirror);190 TestMolecule 2->Translate(&Translator);191 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 192 //OutputTestMolecule (TestMolecule2, "testmolecule2-3.xyz");174 TestMolecule1->Scale((const double ** const)&mirror); 175 TestMolecule1->Translate(&Translator); 176 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 177 //OutputTestMolecule1(TestMolecule1, "testmolecule2-3.xyz"); 193 178 Translator = Vector(0,3,0); 194 TestMolecule 2->Translate(&Translator);195 TestMolecule 2->Scale((const double ** const)&mirror);179 TestMolecule1->Translate(&Translator); 180 TestMolecule1->Scale((const double ** const)&mirror); 196 181 197 182 cout << "Case 4: offset of (2,1,0), hence angle are (78, 26.6, 102, 153.4) < 30." << endl; 198 183 Translator = Vector(2,1,0); 199 TestMolecule 2->Translate(&Translator);184 TestMolecule1->Translate(&Translator); 200 185 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 201 //OutputTestMolecule (TestMolecule2, "testmolecule2-4.xyz");186 //OutputTestMolecule1(TestMolecule1, "testmolecule2-4.xyz"); 202 187 Translator = Vector(-2,-1,0); 203 TestMolecule 2->Translate(&Translator);188 TestMolecule1->Translate(&Translator); 204 189 205 190 cout << "Case 5: offset of (0,0,3), hence angle are (90, 90, 90, 90) > 30." << endl; 206 191 Translator = Vector(0,0,3); 207 TestMolecule 2->Translate(&Translator);208 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 209 //OutputTestMolecule (TestMolecule2, "testmolecule2-5.xyz");192 TestMolecule1->Translate(&Translator); 193 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 194 //OutputTestMolecule1(TestMolecule1, "testmolecule2-5.xyz"); 210 195 Translator = Vector(0,0,-3); 211 TestMolecule 2->Translate(&Translator);196 TestMolecule1->Translate(&Translator); 212 197 213 198 cout << "Case 6: offset of (-3,0,0) and mirror, hence angle are (75.5, 180, 104.5, 180) > 30." << endl; 214 199 Translator = Vector(-3,0,0); 215 TestMolecule 2->Scale((const double ** const)&mirror);216 TestMolecule 2->Translate(&Translator);217 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 218 //OutputTestMolecule (TestMolecule2, "testmolecule2-6.xyz");200 TestMolecule1->Scale((const double ** const)&mirror); 201 TestMolecule1->Translate(&Translator); 202 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 203 //OutputTestMolecule1(TestMolecule1, "testmolecule2-6.xyz"); 219 204 Translator = Vector(3,0,0); 220 TestMolecule 2->Translate(&Translator);221 TestMolecule 2->Scale((const double ** const)&mirror);205 TestMolecule1->Translate(&Translator); 206 TestMolecule1->Scale((const double ** const)&mirror); 222 207 223 208 cout << "Case 7: offset of (3,0,0) and mirror, hence angles are (104.5, 0, 104.5, 0) < 30, but interfering hydrogens." << endl; 224 209 Translator = Vector(3,0,0); 225 TestMolecule 2->Scale((const double ** const)&mirror);226 TestMolecule 2->Translate(&Translator);227 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 228 //OutputTestMolecule (TestMolecule2, "testmolecule2-7.xyz");210 TestMolecule1->Scale((const double ** const)&mirror); 211 TestMolecule1->Translate(&Translator); 212 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 213 //OutputTestMolecule1(TestMolecule1, "testmolecule2-7.xyz"); 229 214 Translator = Vector(-3,0,0); 230 TestMolecule 2->Translate(&Translator);231 TestMolecule 2->Scale((const double ** const)&mirror);215 TestMolecule1->Translate(&Translator); 216 TestMolecule1->Scale((const double ** const)&mirror); 232 217 233 218 cout << "Case 8: offset of (0,3,0), hence angle are (14.5, 90, 14.5, 90) < 30, but interfering hydrogens." << endl; 234 219 Translator = Vector(0,3,0); 235 TestMolecule 2->Scale((const double ** const)&mirror);236 TestMolecule 2->Translate(&Translator);237 //OutputTestMolecule (TestMolecule2, "testmolecule2-8.xyz");220 TestMolecule1->Scale((const double ** const)&mirror); 221 TestMolecule1->Translate(&Translator); 222 //OutputTestMolecule1(TestMolecule1, "testmolecule2-8.xyz"); 238 223 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 239 224 Translator = Vector(0,-3,0); 240 TestMolecule 2->Translate(&Translator);241 TestMolecule 2->Scale((const double ** const)&mirror);225 TestMolecule1->Translate(&Translator); 226 TestMolecule1->Scale((const double ** const)&mirror); 242 227 243 228 delete[](mirror);
Note:
See TracChangeset
for help on using the changeset viewer.