Changeset 3738f0 for src/bondgraph.cpp
- Timestamp:
- Mar 1, 2011, 12:49:28 PM (15 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, Candidate_v1.7.0, 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:
- 0cbad2
- Parents:
- ce5f05
- git-author:
- Frederik Heber <heber@…> (02/26/11 00:10:05)
- git-committer:
- Frederik Heber <heber@…> (03/01/11 12:49:28)
- File:
-
- 1 edited
-
src/bondgraph.cpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/bondgraph.cpp
rce5f05 r3738f0 25 25 #include "bond.hpp" 26 26 #include "bondgraph.hpp" 27 #include "Box.hpp" 27 28 #include "element.hpp" 28 29 #include "CodePatterns/Info.hpp" 30 #include "CodePatterns/Log.hpp" 31 #include "CodePatterns/Range.hpp" 29 32 #include "CodePatterns/Verbose.hpp" 30 #include "CodePatterns/Log.hpp"31 33 #include "molecule.hpp" 32 34 #include "parser.hpp" 33 35 #include "periodentafel.hpp" 34 36 #include "LinearAlgebra/Vector.hpp" 37 #include "World.hpp" 38 #include "WorldTime.hpp" 35 39 36 40 const double BondGraph::BondThreshold = 0.4; //!< CSD threshold in bond check which is the width of the interval whose center is the sum of the covalent radii … … 40 44 max_distance(0), 41 45 IsAngstroem(IsA) 42 {} ;46 {} 43 47 44 48 BondGraph::~BondGraph() … … 47 51 delete(BondLengthMatrix); 48 52 } 49 } ;53 } 50 54 51 55 bool BondGraph::LoadBondLengthTable(std::istream &input) … … 57 61 // allocate MatrixContainer 58 62 if (BondLengthMatrix != NULL) { 59 DoLog(1) && (Log() << Verbose(1) << "MatrixContainer for Bond length already present, removing." << endl);63 LOG(1, "MatrixContainer for Bond length already present, removing."); 60 64 delete(BondLengthMatrix); 61 65 } … … 64 68 // parse in matrix 65 69 if ((input.good()) && (status = TempContainer->ParseMatrix(input, 0, 1, 0))) { 66 DoLog(1) && (Log() << Verbose(1) << "Parsing bond length matrix successful." << endl);70 LOG(1, "Parsing bond length matrix successful."); 67 71 } else { 68 72 DoeLog(1) && (eLog()<< Verbose(1) << "Parsing bond length matrix failed." << endl); … … 87 91 } 88 92 return status; 89 }; 90 91 bool BondGraph::CreateAdjacencyForMolecule(molecule * const mol) 92 { 93 Info FunctionInfo(__func__); 94 bool status = true; 95 96 if (mol->empty()) // only construct if molecule is not empty 97 return false; 98 99 SetMaxDistanceToMaxOfCovalentRadii(mol); 100 mol->CreateAdjacencyList(max_distance, IsAngstroem, &BondGraph::getMinMaxDistance, this); 101 102 return status; 103 }; 93 } 104 94 105 95 double BondGraph::GetBondLength(int firstZ, int secondZ) … … 113 103 return (BondLengthMatrix->Matrix[0][firstZ][secondZ]); 114 104 } 115 }; 116 117 double BondGraph::SetMaxDistanceToMaxOfCovalentRadii(const molecule * const mol) 118 { 119 Info FunctionInfo(__func__); 120 max_distance = 0.; 121 122 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 123 if ((*iter)->getType()->getCovalentRadius() > max_distance) 124 max_distance = (*iter)->getType()->getCovalentRadius(); 125 } 126 max_distance *= 2.; 127 max_distance += BondThreshold; 128 129 return max_distance; 130 }; 105 } 131 106 132 107 double BondGraph::getMaxDistance() const … … 142 117 MaxDistance = MinDistance + BondThreshold; 143 118 MinDistance -= BondThreshold; 144 } ;119 } 145 120 146 121 void BondGraph::BondLengthMatrixMinMaxDistance(const BondedParticle * const Walker, const BondedParticle * const OtherWalker, double &MinDistance, double &MaxDistance, bool IsAngstroem) … … 152 127 MaxDistance = MinDistance + BondThreshold; 153 128 MinDistance -= BondThreshold; 154 } ;129 } 155 130 156 131 void BondGraph::getMinMaxDistance(const BondedParticle * const Walker, const BondedParticle * const OtherWalker, double &MinDistance, double &MaxDistance, bool IsAngstroem) … … 164 139 } 165 140 } 141 142 void BondGraph::CreateAdjacency(LinkedCell &LC) 143 { 144 atom *Walker = NULL; 145 atom *OtherWalker = NULL; 146 int n[NDIM]; 147 double MinDistance, MaxDistance; 148 Box &domain = World::getInstance().getDomain(); 149 150 unsigned int BondCount = 0; 151 // 3a. go through every cell 152 LOG(3, "INFO: Celling ... "); 153 for (LC.n[0] = 0; LC.n[0] < LC.N[0]; LC.n[0]++) 154 for (LC.n[1] = 0; LC.n[1] < LC.N[1]; LC.n[1]++) 155 for (LC.n[2] = 0; LC.n[2] < LC.N[2]; LC.n[2]++) { 156 const TesselPointSTLList *List = LC.GetCurrentCell(); 157 LOG(2, "Current cell is " << LC.n[0] << ", " << LC.n[1] << ", " << LC.n[2] << " with No. " << LC.index << " containing " << List->size() << " points."); 158 if (List != NULL) { 159 for (TesselPointSTLList::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 160 Walker = dynamic_cast<atom*>(*Runner); 161 ASSERT(Walker != NULL, 162 "BondGraph::CreateAdjacency() - Tesselpoint that was not an atom retrieved from LinkedNode"); 163 LOG(2, "INFO: Current Atom is " << *Walker << "."); 164 // 3c. check for possible bond between each atom in this and every one in the 27 cells 165 for (n[0] = -1; n[0] <= 1; n[0]++) 166 for (n[1] = -1; n[1] <= 1; n[1]++) 167 for (n[2] = -1; n[2] <= 1; n[2]++) { 168 const TesselPointSTLList *OtherList = LC.GetRelativeToCurrentCell(n); 169 if (OtherList != NULL) { 170 LOG(3, "INFO: Current relative cell is " << LC.n[0] << ", " << LC.n[1] << ", " << LC.n[2] << " with No. " << LC.index << " containing " << List->size() << " points."); 171 for (TesselPointSTLList::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) { 172 if ((*OtherRunner) > Walker) { // just to not add bonds from both sides 173 OtherWalker = dynamic_cast<atom*>(*OtherRunner); 174 ASSERT(OtherWalker != NULL, 175 "BondGraph::CreateAdjacency() - TesselPoint that was not an atom retrieved from LinkedNode"); 176 getMinMaxDistance(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem); 177 const double distance = domain.periodicDistanceSquared(OtherWalker->getPosition(),Walker->getPosition()); 178 LOG(2, "INFO: Checking distance " << distance << " against typical bond length of [" << MinDistance * MinDistance << "," << MaxDistance * MaxDistance << "]."); 179 const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance); 180 LOG(3, "INFO: MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "."); 181 if (OtherWalker->father > Walker->father ) { // just to not add bonds from both sides 182 if (status) { // create bond if distance is smaller 183 LOG(1, "ACCEPT: Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "."); 184 bond * Binder = new bond(Walker->father, OtherWalker->father, 1); 185 Walker->father->RegisterBond(WorldTime::getTime(), Binder); 186 OtherWalker->father->RegisterBond(WorldTime::getTime(), Binder); 187 BondCount++; 188 } else { 189 LOG(1, "REJECT: Squared distance " 190 << distance << " is out of covalent bounds [" 191 << MinDistance*MinDistance << "," 192 << MaxDistance * MaxDistance << "]."); 193 } 194 } else { 195 LOG(5, "REJECT: Not Adding: Wrong order of father's."); 196 } 197 } else { 198 LOG(5, "REJECT: Not Adding: Wrong order."); 199 } 200 } 201 } 202 } 203 } 204 } 205 } 206 LOG(1, "I detected " << BondCount << " bonds in the molecule."); 207 }
Note:
See TracChangeset
for help on using the changeset viewer.
