source: src/bond.cpp@ a19d73e

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 v1.0.0
Last change on this file since a19d73e was bf3817, checked in by Frederik Heber <heber@…>, 15 years ago

Added ifdef HAVE_CONFIG and config.h include to each and every cpp file.

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