source: src/bond.cpp@ 5f612ee

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
Last change on this file since 5f612ee was 58ed4a, checked in by Frederik Heber <heber@…>, 15 years ago

Log() and eLog() are prepended by a DoLog()/DoeLog() construct.

  • Most of the run time (95%) is spent on verbosity that it is discarded anyway due to a low verbosity setting. However, the operator << is evaluated from the right-hand side, hence the whole message is constructed and then thrown away.
  • DoLog() and DoeLog() are new functions that check the verbosity beforehand and are used as follows: DoLog(2) && (Log() << verbose(2) << "message" << endl);

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

  • Property mode set to 100644
File size: 3.6 KB
RevLine 
[14de469]1/** \file bond.cpp
2 *
3 * Function implementations for the classes BondLeaf, BondTree and bond.
4 *
5 */
6
[e41951]7#include "atom.hpp"
[357fba]8#include "bond.hpp"
[f66195]9#include "element.hpp"
10#include "lists.hpp"
11
[14de469]12
13/***************************************** Functions for class bond ********************************/
14
15/** Empty Constructor for class bond.
16 */
[70ff32]17bond::bond() : leftatom(NULL), rightatom(NULL), previous(NULL), next(NULL), HydrogenBond(0), BondDegree(0), nr(-1), Cyclic(false), Type(Undetermined), Used(white)
[14de469]18{
19};
20
21/** Constructor for class bond, taking right and left bond partner
22 * \param *left left atom
23 * \param *right right atom
24 * \param degree bond degree
25 * \param number increasing index
26 */
[fb73b8]27bond::bond(atom *left, atom *right, const int degree, const int number) : leftatom(left), rightatom(right), previous(NULL), next(NULL), HydrogenBond(0), BondDegree(degree), nr(number), Cyclic(false), Type(Undetermined), Used(white)
[14de469]28{
29 if ((left != NULL) && (right != NULL)) {
[ce5ac3]30 if ((left->type != NULL) && (left->type->Z == 1))
31 HydrogenBond++;
32 if ((right->type != NULL) && (right->type->Z == 1))
33 HydrogenBond++;
[14de469]34 }
35};
36
37/** Empty Destructor for class bond.
38 */
39bond::~bond()
40{
41 // remove this node from the list structure
[266237]42 if (leftatom != NULL)
43 leftatom->UnregisterBond(this);
44 if (rightatom != NULL)
45 rightatom->UnregisterBond(this);
46 unlink(this);
[14de469]47};
48
[fb73b8]49ostream & operator << (ostream &ost, const bond &b)
[14de469]50{
51 ost << "[" << b.leftatom->Name << " <" << b.BondDegree << "(H" << b.HydrogenBond << ")>" << b.rightatom->Name << "]";
52 return ost;
53};
54
55/** Get the other atom in a bond if one is specified.
56 * \param *Atom the pointer to the one atom
57 * \return pointer to the other atom in the bond, NULL if no match (indicates something's wrong with the bond)
58 */
[fb73b8]59atom * bond::GetOtherAtom(const ParticleInfo * const Atom) const
[14de469]60{
61 if(leftatom == Atom)
62 return rightatom;
63 if(rightatom == Atom)
64 return leftatom;
[58ed4a]65 DoeLog(1) && (eLog()<< Verbose(1) << "Bond " << *this << " does not contain atom " << *Atom << "!" << endl);
[14de469]66 return NULL;
67};
68
69
70/** Returns whether vertex was used in DFS.
71 * \return bond::Used
72 */
73enum Shading bond::IsUsed()
74{
75 return Used;
76};
77
78/** Checks if an atom exists in a bond.
79 * \param *ptr pointer to atom
80 * \return true if it is either bond::leftatom or bond::rightatom, false otherwise
81 */
[fb73b8]82bool bond::Contains(const ParticleInfo * const ptr)
[14de469]83{
84 return ((leftatom == ptr) || (rightatom == ptr));
85};
86
87/** Checks if an atom exists in a bond.
88 * \param nr index of atom
89 * \return true if it is either bond::leftatom or bond::rightatom, false otherwise
90 */
[fa40b5]91bool bond::Contains(const int number)
[14de469]92{
[fa40b5]93 return ((leftatom->nr == number) || (rightatom->nr == number));
[14de469]94};
95
96/** Masks vertex as used in DFS.
97 * \return bond::Used, false if bond was already marked used
98 */
[fb73b8]99bool bond::MarkUsed(const enum Shading color) {
[14de469]100 if (Used == black) {
[58ed4a]101 DoeLog(1) && (eLog()<< Verbose(1) << "Bond " << this << " was already marked black!." << endl);
[14de469]102 return false;
103 } else {
104 Used = color;
105 return true;
106 }
107};
108
109/** Resets used flag in DFS.
110 * \return bond::Used
111 */
112void bond::ResetUsed() {
113 Used = white;
114};
[b9947d]115
116/** Calculates the bond length.
117 * \return |a - b| with a = bond::leftatom and b = bond::rightatom.
118 */
119double bond::GetDistance() const
120{
121 return (leftatom->node->Distance(rightatom->node));
122};
123
124/** Calculates the bond length.
125 * \return |a - b|^2 with a = bond::leftatom and b = bond::rightatom.
126 */
127double bond::GetDistanceSquared() const
128{
129 return (leftatom->node->DistanceSquared(rightatom->node));
130};
Note: See TracBrowser for help on using the repository browser.