Changeset 388049
- Timestamp:
- Apr 1, 2010, 1:49:25 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, 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:
- fe238c
- Parents:
- 62c9c0
- git-author:
- Frederik Heber <heber@…> (04/01/10 12:42:07)
- git-committer:
- Frederik Heber <heber@…> (04/01/10 13:49:25)
- Location:
- src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/analysis_bonds.cpp
r62c9c0 r388049 9 9 #include "atom.hpp" 10 10 #include "bond.hpp" 11 #include "element.hpp" 12 #include "info.hpp" 11 13 #include "log.hpp" 12 14 #include "molecule.hpp" … … 79 81 } 80 82 }; 83 84 85 /** Counts the number of hydrogen bridge bonds. 86 * With \a *InterfaceElement an extra element can be specified that identifies some boundary. 87 * Then, counting is for the h-bridges that connect to interface only. 88 * \param *molecules molecules to count bonds 89 * \param *InterfaceElement or NULL 90 */ 91 int CountHydrogenBridgeBonds(MoleculeListClass *molecules, element * InterfaceElement = NULL) 92 { 93 Info FunctionInfo(__func__); 94 atom *Walker = NULL; 95 atom *Runner = NULL; 96 Vector OHBond; 97 Vector OOBond; 98 int count = 0; 99 bool InterfaceFlag = false; 100 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) { 101 Walker = (*MolWalker)->start; 102 while (Walker->next != (*MolWalker)->end) { 103 Walker = Walker->next; 104 for (MoleculeList::const_iterator MolRunner = molecules->ListOfMolecules.begin();MolRunner != MolWalker; MolRunner++) { 105 Runner = (*MolRunner)->start; 106 while (Runner->next != (*MolRunner)->end) { 107 Runner = Runner->next; 108 if ((Runner != Walker) && (Walker->type->Z == 8) && (Runner->type->Z == 8)) { 109 // check distance 110 const double distance = Runner->x.DistanceSquared(&Walker->x); 111 if ((distance > MYEPSILON) && (distance < HBRIDGEDISTANCE*HBRIDGEDISTANCE)) { // distance >0 means different atoms 112 InterfaceFlag = (InterfaceElement == NULL); 113 // on other atom(Runner) we check for bond to interface element 114 for (BondList::const_iterator BondRunner = Runner->ListOfBonds.begin(); ((!InterfaceFlag) && (BondRunner != Runner->ListOfBonds.end())); BondRunner++) { 115 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Runner); 116 InterfaceFlag = InterfaceFlag || (OtherAtom->type == InterfaceElement); 117 } 118 if (InterfaceFlag) { 119 // on this element (Walker) we check for bond to hydrogen, i.e. part of water molecule 120 for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) { 121 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker); 122 if (OtherAtom->type->Z == 1) { 123 // check angle 124 OHBond.CopyVector(&OtherAtom->x); 125 OHBond.SubtractVector(&Walker->x); 126 OOBond.CopyVector(&Runner->x); 127 OOBond.SubtractVector(&Walker->x); 128 const double angle = OHBond.Angle(&OOBond); 129 if (angle < M_PI*(30./180.)) { 130 DoLog(1) && (Log() << Verbose(1) << Walker->Name << ", " << OtherAtom->Name << " and " << Runner->Name << " have a hydrogen bridge bond with " << sqrt(distance) << " and at angle " << (180./M_PI)*angle << " degrees." << endl); 131 count++; 132 break; 133 } 134 } 135 } 136 } 137 } 138 } 139 } 140 } 141 } 142 } 143 return count; 144 } 145 146 /** Counts the number of bonds between two given elements. 147 * \param *molecules list of molecules with all atoms 148 * \param *first pointer to first element 149 * \param *second pointer to second element 150 * \return number of found bonds (\a *first-\a *second) 151 */ 152 int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second) 153 { 154 atom *Walker = NULL; 155 int count = 0; 156 157 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) { 158 Walker = (*MolWalker)->start; 159 while (Walker->next != (*MolWalker)->end) { 160 Walker = Walker->next; 161 if ((Walker->type == first) || (Walker->type == second)) { // first element matches 162 for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) { 163 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker); 164 if (((OtherAtom->type == first) || (OtherAtom->type == second)) && (Walker->nr < OtherAtom->nr)) { 165 count++; 166 DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl); 167 } 168 } 169 } 170 } 171 } 172 return count; 173 }; 174 175 /** Counts the number of bonds between three given elements. 176 * Note that we do not look for arbitrary sequence of given bonds, but \a *second will be the central atom and we check 177 * whether it has bonds to both \a *first and \a *third. 178 * \param *molecules list of molecules with all atoms 179 * \param *first pointer to first element 180 * \param *second pointer to second element 181 * \param *third pointer to third element 182 * \return number of found bonds (\a *first-\a *second-\a *third, \a *third-\a *second-\a *first, respectively) 183 */ 184 int CountBondsOfThree(MoleculeListClass * const molecules, const element * const first, const element * const second, const element * const third) 185 { 186 int count = 0; 187 bool MatchFlag[2]; 188 bool result = false; 189 atom *Walker = NULL; 190 const element * ElementArray[2]; 191 ElementArray[0] = first; 192 ElementArray[1] = third; 193 194 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) { 195 Walker = (*MolWalker)->start; 196 while (Walker->next != (*MolWalker)->end) { 197 Walker = Walker->next; 198 if (Walker->type == second) { // first element matches 199 for (int i=0;i<2;i++) 200 MatchFlag[i] = false; 201 for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) { 202 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker); 203 for (int i=0;i<2;i++) 204 if ((!MatchFlag[i]) && (OtherAtom->type == ElementArray[i])) { 205 MatchFlag[i] = true; 206 break; // each bonding atom can match at most one element we are looking for 207 } 208 } 209 result = true; 210 for (int i=0;i<2;i++) // gather results 211 result = result && MatchFlag[i]; 212 if (result) { // check results 213 count++; 214 DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << "-" << third->name << " bond found at " << *Walker << "." << endl); 215 } 216 } 217 } 218 } 219 return count; 220 }; -
src/analysis_bonds.hpp
r62c9c0 r388049 18 18 #endif 19 19 20 /*********************************************** defines ***********************************/ 21 22 #define HBRIDGEDISTANCE 3.5 //!< HBridge distance from PCCP Vol 10. 4802-4813 20 23 21 24 /****************************************** forward declarations *****************************/ 22 25 23 26 class element; 27 class MoleculeListClass; 24 28 class molecule; 25 29 … … 29 33 void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, element *type1, element *type2, double &Min, double &Mean, double &Max); 30 34 35 int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, element * InterfaceElement); 36 int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second); 37 int CountBondsOfThree(MoleculeListClass * const molecules, const element * const first, const element * const second, const element * const third); 38 31 39 #endif /* ANALYSIS_BONDS_HPP_ */ -
src/bondgraph.cpp
r62c9c0 r388049 171 171 } 172 172 }; 173 174 /** Counts the number of hydrogen bridge bonds.175 * With \a *InterfaceElement an extra element can be specified that identifies some boundary.176 * Then, counting is for the h-bridges that connect to interface only.177 * \param *molecules molecules to count bonds178 * \param *InterfaceElement or NULL179 */180 int CountHydrogenBridgeBonds(MoleculeListClass *molecules, element * InterfaceElement = NULL)181 {182 Info FunctionInfo(__func__);183 atom *Walker = NULL;184 atom *Runner = NULL;185 Vector OHBond;186 Vector OOBond;187 int count = 0;188 bool InterfaceFlag = false;189 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {190 Walker = (*MolWalker)->start;191 while (Walker->next != (*MolWalker)->end) {192 Walker = Walker->next;193 for (MoleculeList::const_iterator MolRunner = molecules->ListOfMolecules.begin();MolRunner != molecules->ListOfMolecules.end(); MolRunner++) {194 Runner = (*MolRunner)->start;195 while (Runner->next != (*MolRunner)->end) {196 Runner = Runner->next;197 if ((Runner != Walker) && (Walker->type->Z == 8) && (Runner->type->Z == 8)) {198 // check distance199 const double distance = Runner->x.DistanceSquared(&Walker->x);200 if ((distance > MYEPSILON) && (distance < HBRIDGEDISTANCE*HBRIDGEDISTANCE)) { // distance >0 means different atoms201 InterfaceFlag = (InterfaceElement == NULL);202 // on other atom(Runner) we check for bond to interface element203 for (BondList::const_iterator BondRunner = Runner->ListOfBonds.begin(); ((!InterfaceFlag) && (BondRunner != Runner->ListOfBonds.end())); BondRunner++) {204 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Runner);205 InterfaceFlag = InterfaceFlag || (OtherAtom->type == InterfaceElement);206 }207 if (InterfaceFlag) {208 // on this element (Walker) we check for bond to hydrogen, i.e. part of water molecule209 for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {210 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);211 if (OtherAtom->type->Z == 1) {212 // check angle213 OHBond.CopyVector(&OtherAtom->x);214 OHBond.SubtractVector(&Walker->x);215 OOBond.CopyVector(&Runner->x);216 OOBond.SubtractVector(&Walker->x);217 const double angle = OHBond.Angle(&OOBond);218 if (angle < M_PI*(30./180.)) {219 DoLog(1) && (Log() << Verbose(1) << Walker->Name << ", " << OtherAtom->Name << " and " << Runner->Name << " have a hydrogen bridge bond with " << sqrt(distance) << " and at angle " << (180./M_PI)*angle << " degrees." << endl);220 count++;221 break;222 }223 }224 }225 }226 }227 }228 }229 }230 }231 }232 return count;233 }234 235 /** Counts the number of bonds between two given elements.236 * \param *molecules list of molecules with all atoms237 * \param *first pointer to first element238 * \param *second pointer to second element239 * \return number of found bonds (\a *first-\a *second)240 */241 int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second)242 {243 atom *Walker = NULL;244 int count = 0;245 246 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {247 Walker = (*MolWalker)->start;248 while (Walker->next != (*MolWalker)->end) {249 Walker = Walker->next;250 if ((Walker->type == first) || (Walker->type == second)) { // first element matches251 for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {252 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);253 if (((OtherAtom->type == first) || (OtherAtom->type == second)) && (Walker->nr < OtherAtom->nr)) {254 count++;255 DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl);256 }257 }258 }259 }260 }261 return count;262 };263 264 /** Counts the number of bonds between three given elements.265 * Note that we do not look for arbitrary sequence of given bonds, but \a *second will be the central atom and we check266 * whether it has bonds to both \a *first and \a *third.267 * \param *molecules list of molecules with all atoms268 * \param *first pointer to first element269 * \param *second pointer to second element270 * \param *third pointer to third element271 * \return number of found bonds (\a *first-\a *second-\a *third, \a *third-\a *second-\a *first, respectively)272 */273 int CountBondsOfThree(MoleculeListClass * const molecules, const element * const first, const element * const second, const element * const third)274 {275 int count = 0;276 bool MatchFlag[2];277 bool result = false;278 atom *Walker = NULL;279 const element * ElementArray[2];280 ElementArray[0] = first;281 ElementArray[1] = third;282 283 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {284 Walker = (*MolWalker)->start;285 while (Walker->next != (*MolWalker)->end) {286 Walker = Walker->next;287 if (Walker->type == second) { // first element matches288 for (int i=0;i<2;i++)289 MatchFlag[i] = false;290 for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {291 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);292 for (int i=0;i<2;i++)293 if ((!MatchFlag[i]) && (OtherAtom->type == ElementArray[i])) {294 MatchFlag[i] = true;295 break; // each bonding atom can match at most one element we are looking for296 }297 }298 result = true;299 for (int i=0;i<2;i++) // gather results300 result = result && MatchFlag[i];301 if (result) { // check results302 count++;303 DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << "-" << third->name << " bond found at " << *Walker << "." << endl);304 }305 }306 }307 }308 return count;309 }; -
src/bondgraph.hpp
r62c9c0 r388049 23 23 24 24 #define BONDTHRESHOLD 0.4 //!< CSD threshold in bond check which is the width of the interval whose center is the sum of the covalent radii 25 #define HBRIDGEDISTANCE 3.5 //!< HBridge distance from PCCP Vol 10. 4802-481326 25 27 26 /****************************************** forward declarations *****************************/ 28 27 29 28 class molecule; 30 class MoleculeListClass;31 29 class periodentafel; 32 30 class MatrixContainer; … … 55 53 }; 56 54 57 int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, element * InterfaceElement);58 int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second);59 int CountBondsOfThree(MoleculeListClass * const molecules, const element * const first, const element * const second, const element * const third);60 61 55 #endif /* BONDGRAPH_HPP_ */ -
src/builder.cpp
r62c9c0 r388049 52 52 #include <cstring> 53 53 54 #include "analysis_bonds.hpp" 54 55 #include "analysis_correlation.hpp" 55 56 #include "atom.hpp" -
src/unittests/CountBondsUnitTest.cpp
r62c9c0 r388049 17 17 #include <cstring> 18 18 19 #include "analysis_bonds.hpp" 19 20 #include "atom.hpp" 20 21 #include "bond.hpp"
Note:
See TracChangeset
for help on using the changeset viewer.