Changeset e5ad5c for src


Ignore:
Timestamp:
Apr 26, 2010, 3:42:45 PM (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:
ee7e25
Parents:
e138de
Message:

BUGFIX: BondGraphUnitTest was not working.

Changes:

  • atoms are now carbon, not hydrogen
  • added covalent and van-der-Waals radii to element creation
  • FIX: carbon now has Z = 2.
  • added test case for NULL BondTable (i.e. from covalent radii)

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

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/molecule_graph.cpp

    re138de re5ad5c  
    147147        for (LC->n[2] = 0; LC->n[2] < LC->N[2]; LC->n[2]++) {
    148148          const LinkedNodes *List = LC->GetCurrentCell();
    149           //Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
     149//          Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
    150150          if (List != NULL) {
    151151            for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    152152              Walker = AtomMap[(*Runner)->nr];
    153               //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
     153//              Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
    154154              // 3c. check for possible bond between each atom in this and every one in the 27 cells
    155155              for (n[0] = -1; n[0] <= 1; n[0]++)
     
    157157                  for (n[2] = -1; n[2] <= 1; n[2]++) {
    158158                    const LinkedNodes *OtherList = LC->GetRelativeToCurrentCell(n);
    159                     //Log() << Verbose(2) << "Current relative cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
     159//                    Log() << Verbose(2) << "Current relative cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
    160160                    if (OtherList != NULL) {
    161161                      for (LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {
    162162                        if ((*OtherRunner)->nr > Walker->nr) {
    163163                          OtherWalker = AtomMap[(*OtherRunner)->nr];
    164                           //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
     164//                          Log() << Verbose(0) << "Current other Atom is " << *OtherWalker << "." << endl;
     165                          const double distance = OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size);
     166//                          Log() << Verbose(1) << "Checking distance " << distance << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
    165167                          (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
    166                           const double distance = OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size);
    167168                          const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance);
    168                           if ((OtherWalker->father->nr > Walker->father->nr) && (status)) { // create bond if distance is smaller
    169                             //Log() << Verbose(1) << "Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "." << endl;
    170                             AddBond(Walker->father, OtherWalker->father, 1); // also increases molecule::BondCount
     169//                          Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl;
     170                          if (OtherWalker->father->nr > Walker->father->nr) {
     171                            if (status) { // create bond if distance is smaller
     172//                              Log() << Verbose(1) << "Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "." << endl;
     173                              AddBond(Walker->father, OtherWalker->father, 1); // also increases molecule::BondCount
     174                            } else {
     175//                              Log() << Verbose(1) << "Not Adding: distance too great." << endl;
     176                            }
    171177                          } else {
    172                             //Log() << Verbose(1) << "Not Adding: Wrong label order or distance too great." << endl;
     178//                            Log() << Verbose(1) << "Not Adding: Wrong order of labels." << endl;
    173179                          }
    174180                        }
  • src/unittests/bondgraphunittest.cpp

    re138de re5ad5c  
    1919#include "bondgraph.hpp"
    2020#include "element.hpp"
     21#include "log.hpp"
    2122#include "molecule.hpp"
    2223#include "periodentafel.hpp"
     
    4142  hydrogen = new element;
    4243  hydrogen->Z = 1;
     44  hydrogen->CovalentRadius = 0.23;
     45  hydrogen->VanDerWaalsRadius = 1.09;
    4346  strcpy(hydrogen->name, "hydrogen");
    4447  strcpy(hydrogen->symbol, "H");
    4548  carbon = new element;
    46   carbon->Z = 1;
     49  carbon->Z = 2;
     50  carbon->CovalentRadius = 0.68;
     51  carbon->VanDerWaalsRadius = 1.7;
    4752  strcpy(carbon->name, "carbon");
    4853  strcpy(carbon->symbol, "C");
     
    5762  TestMolecule = new molecule(tafel);
    5863  Walker = new atom();
    59   Walker->type = hydrogen;
     64  Walker->type = carbon;
    6065  Walker->node->Init(1., 0., 1. );
    6166  TestMolecule->AddAtom(Walker);
    6267  Walker = new atom();
    63   Walker->type = hydrogen;
     68  Walker->type = carbon;
    6469  Walker->node->Init(0., 1., 1. );
    6570  TestMolecule->AddAtom(Walker);
    6671  Walker = new atom();
    67   Walker->type = hydrogen;
     72  Walker->type = carbon;
    6873  Walker->node->Init(1., 1., 0. );
    6974  TestMolecule->AddAtom(Walker);
    7075  Walker = new atom();
    71   Walker->type = hydrogen;
     76  Walker->type = carbon;
    7277  Walker->node->Init(0., 0., 0. );
    7378  TestMolecule->AddAtom(Walker);
     
    7782
    7883  // create a small file with table
     84  dummyname = new string("dummy.dat");
    7985  filename = new string("test.dat");
    8086  ofstream test(filename->c_str());
     
    9197  remove(filename->c_str());
    9298  delete(filename);
     99  delete(dummyname);
    93100  delete(BG);
    94101
     
    112119/** UnitTest for BondGraphTest::ConstructBondGraph().
    113120 */
    114 void BondGraphTest::ConstructGraphTest()
     121void BondGraphTest::ConstructGraphFromTableTest()
    115122{
    116123  atom *Walker = TestMolecule->start->next;
     
    118125  CPPUNIT_ASSERT( TestMolecule->end != Walker );
    119126  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
     127  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
     128  CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
     129};
     130
     131/** UnitTest for BondGraphTest::ConstructBondGraph().
     132 */
     133void BondGraphTest::ConstructGraphFromCovalentRadiiTest()
     134{
     135  atom *Walker = TestMolecule->start->next;
     136  atom *Runner = TestMolecule->end->previous;
     137  CPPUNIT_ASSERT( TestMolecule->end != Walker );
     138  CPPUNIT_ASSERT_EQUAL( false , BG->LoadBondLengthTable(*dummyname) );
    120139  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
    121140  CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
  • src/unittests/bondgraphunittest.hpp

    re138de re5ad5c  
    2323    CPPUNIT_TEST_SUITE( BondGraphTest) ;
    2424    CPPUNIT_TEST ( LoadTableTest );
    25     CPPUNIT_TEST ( ConstructGraphTest );
     25    CPPUNIT_TEST ( ConstructGraphFromTableTest );
     26    CPPUNIT_TEST ( ConstructGraphFromCovalentRadiiTest );
    2627    CPPUNIT_TEST_SUITE_END();
    2728
     
    3031      void tearDown();
    3132      void LoadTableTest();
    32       void ConstructGraphTest();
     33      void ConstructGraphFromTableTest();
     34      void ConstructGraphFromCovalentRadiiTest();
    3335
    3436private:
     
    4143      BondGraph *BG;
    4244      string *filename;
     45      string *dummyname;
    4346};
    4447
Note: See TracChangeset for help on using the changeset viewer.