Changeset 826e8c for src/Analysis


Ignore:
Timestamp:
Feb 22, 2012, 11:29:04 AM (13 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:
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)
Message:

Introduced new LinkedCell into BondGraph.

  • new convenience functions BondGraph::getDomain(), ::getLinkedCell(), ::getTime() to have World dependency not in header file (circular include).
  • new function BondGraph::getMaxPossibleBondDistance() where one element is given.
  • dropped BondGraph::CreateAdjacency(LC_deprecated) as functionality is better placed directly into templated version directly.
  • rewrote templated BondGraph::CreateAdjacency that now makes use of LinkedCell_View::getAllNeighbours().
  • FIX: BondGraph::CreateAdjacency() created bonds for atom's fathers, not for atoms.
  • TESTFIX: New LinkedCell construct in BondGraph::CreateAdjacency changes order of ids in adjacency file:
    • ids are now in order (unlike to before), hence we simply use the new file in the regression test.
    • this is actually a fault of the test, not of the code as order of ids is not guaranteed in the file anyway.
  • TESTFIX: Removed XFAILs from regression test Graph/SubgraphDissection- BoundaryCondition.
  • TESTFIX: CountBondsUnitTest use two molecules that are on top of each other: This causes mess with changed LinkedCell BondGraph recognition, and we even actually need just one molecule for the testing.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Analysis/unittests/CountBondsUnitTest.cpp

    rcbcda6 r826e8c  
    3333#include "Atom/atom.hpp"
    3434#include "Bond/bond.hpp"
     35#include "CodePatterns/Log.hpp"
    3536#include "Element/element.hpp"
    3637#include "Element/periodentafel.hpp"
     
    6263  CPPUNIT_ASSERT(oxygen != NULL && "could not find element oxygen");
    6364
     65  //setVerbosity(3);
     66
    6467  // construct molecule (water molecule)
    6568  TestMolecule1 = World::getInstance().createMolecule();
    66   CPPUNIT_ASSERT(TestMolecule1 != NULL && "could not create first molecule");
     69  CPPUNIT_ASSERT(TestMolecule1 != NULL && "could not create second molecule");
    6770  Walker = World::getInstance().createAtom();
    6871  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
     
    8184  TestMolecule1->AddAtom(Walker);
    8285
    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 
    10186  molecules = World::getInstance().getMolecules();
    10287  CPPUNIT_ASSERT(molecules != NULL && "could not obtain list of molecules");
    10388  molecules->insert(TestMolecule1);
    104   molecules->insert(TestMolecule2);
    105 
    106   // check that TestMolecule was correctly constructed
     89
     90  // check that TestMolecule1 was correctly constructed
    10791  CPPUNIT_ASSERT_EQUAL( TestMolecule1->getAtomCount(), 3 );
    108   CPPUNIT_ASSERT_EQUAL( TestMolecule2->getAtomCount(), 3 );
    10992
    11093  // create a small file with table
     
    11699  BG->CreateAdjacency(Set1);
    117100  CPPUNIT_ASSERT( TestMolecule1->getBondCount() != 0);
    118   World::AtomComposite Set2 = TestMolecule2->getAtomSet();
    119   BG->CreateAdjacency(Set2);
    120   CPPUNIT_ASSERT( TestMolecule2->getBondCount() != 0);
    121101//  TestMolecule1->Output((ofstream *)&cout);
    122102//  TestMolecule1->OutputBondsList(std::cout);
     
    136116void CountBondsTest::BondsOfTwoTest()
    137117{
    138   CPPUNIT_ASSERT_EQUAL( 4 , CountBondsOfTwo(molecules, hydrogen, oxygen) );
     118  CPPUNIT_ASSERT_EQUAL( 2 , CountBondsOfTwo(molecules, hydrogen, oxygen) );
    139119  CPPUNIT_ASSERT_EQUAL( 0 , CountBondsOfTwo(molecules, hydrogen, hydrogen) );
    140120  CPPUNIT_ASSERT_EQUAL( 0 , CountBondsOfTwo(molecules, oxygen, oxygen) );
     
    145125void CountBondsTest::BondsOfThreeTest()
    146126{
    147   CPPUNIT_ASSERT_EQUAL( 2 , CountBondsOfThree(molecules, hydrogen, oxygen, hydrogen) );
     127  CPPUNIT_ASSERT_EQUAL( 1 , CountBondsOfThree(molecules, hydrogen, oxygen, hydrogen) );
    148128  CPPUNIT_ASSERT_EQUAL( 0 , CountBondsOfThree(molecules, oxygen, hydrogen, oxygen) );
    149129};
    150130
    151 void OutputTestMolecule(molecule *mol, const char *name)
     131void OutputTestMolecule1(molecule *mol, const char *name)
    152132{
    153133  ofstream output(name);
     
    166146  Vector Translator;
    167147
    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 );
    169154
    170155  cout << "Case 1: offset of (3,0,0), hence angles are (104.5, 0, 75.5, 180) < 30." << endl;
    171156  Translator  = Vector(3,0,0);
    172   TestMolecule2->Translate(&Translator);
     157  TestMolecule1->Translate(&Translator);
    173158  CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
    174159  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, oxygen, NULL) );
    175   //OutputTestMolecule(TestMolecule2, "testmolecule2-1.xyz");
     160  //OutputTestMolecule1(TestMolecule1, "testmolecule2-1.xyz");
    176161  Translator = Vector(-3,0,0);
    177   TestMolecule2->Translate(&Translator);
     162  TestMolecule1->Translate(&Translator);
    178163
    179164  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;
    180165  Translator = Vector(0,3,0);
    181   TestMolecule2->Translate(&Translator);
     166  TestMolecule1->Translate(&Translator);
    182167  CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
    183   //OutputTestMolecule(TestMolecule2, "testmolecule2-2.xyz");
     168  //OutputTestMolecule1(TestMolecule1, "testmolecule2-2.xyz");
    184169  Translator = Vector(0,-3,0);
    185   TestMolecule2->Translate(&Translator);
     170  TestMolecule1->Translate(&Translator);
    186171
    187172  cout << "Case 3: offset of (0,-3,0) and mirror, hence angle are (165.5, 90, 165.5, 90) > 30." << endl;
    188173  Translator = Vector(0,-3,0);
    189   TestMolecule2->Scale((const double ** const)&mirror);
    190   TestMolecule2->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");
    193178  Translator = Vector(0,3,0);
    194   TestMolecule2->Translate(&Translator);
    195   TestMolecule2->Scale((const double ** const)&mirror);
     179  TestMolecule1->Translate(&Translator);
     180  TestMolecule1->Scale((const double ** const)&mirror);
    196181
    197182  cout << "Case 4: offset of (2,1,0), hence angle are (78, 26.6, 102, 153.4) < 30." << endl;
    198183  Translator = Vector(2,1,0);
    199   TestMolecule2->Translate(&Translator);
     184  TestMolecule1->Translate(&Translator);
    200185  CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
    201   //OutputTestMolecule(TestMolecule2, "testmolecule2-4.xyz");
     186  //OutputTestMolecule1(TestMolecule1, "testmolecule2-4.xyz");
    202187  Translator = Vector(-2,-1,0);
    203   TestMolecule2->Translate(&Translator);
     188  TestMolecule1->Translate(&Translator);
    204189
    205190  cout << "Case 5: offset of (0,0,3), hence angle are (90, 90, 90, 90) > 30." << endl;
    206191  Translator = Vector(0,0,3);
    207   TestMolecule2->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");
    210195  Translator = Vector(0,0,-3);
    211   TestMolecule2->Translate(&Translator);
     196  TestMolecule1->Translate(&Translator);
    212197
    213198  cout << "Case 6: offset of (-3,0,0) and mirror, hence angle are (75.5, 180, 104.5, 180) > 30." << endl;
    214199  Translator = Vector(-3,0,0);
    215   TestMolecule2->Scale((const double ** const)&mirror);
    216   TestMolecule2->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");
    219204  Translator = Vector(3,0,0);
    220   TestMolecule2->Translate(&Translator);
    221   TestMolecule2->Scale((const double ** const)&mirror);
     205  TestMolecule1->Translate(&Translator);
     206  TestMolecule1->Scale((const double ** const)&mirror);
    222207
    223208  cout << "Case 7: offset of (3,0,0) and mirror, hence angles are (104.5, 0, 104.5, 0) < 30, but interfering hydrogens." << endl;
    224209  Translator = Vector(3,0,0);
    225   TestMolecule2->Scale((const double ** const)&mirror);
    226   TestMolecule2->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");
    229214  Translator = Vector(-3,0,0);
    230   TestMolecule2->Translate(&Translator);
    231   TestMolecule2->Scale((const double ** const)&mirror);
     215  TestMolecule1->Translate(&Translator);
     216  TestMolecule1->Scale((const double ** const)&mirror);
    232217
    233218  cout << "Case 8: offset of (0,3,0), hence angle are (14.5, 90, 14.5, 90) < 30, but interfering hydrogens." << endl;
    234219  Translator = Vector(0,3,0);
    235   TestMolecule2->Scale((const double ** const)&mirror);
    236   TestMolecule2->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");
    238223  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
    239224  Translator = Vector(0,-3,0);
    240   TestMolecule2->Translate(&Translator);
    241   TestMolecule2->Scale((const double ** const)&mirror);
     225  TestMolecule1->Translate(&Translator);
     226  TestMolecule1->Scale((const double ** const)&mirror);
    242227
    243228  delete[](mirror);
Note: See TracChangeset for help on using the changeset viewer.