source: src/bond.cpp@ 5b4605

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 5b4605 was 8f4df1, checked in by Frederik Heber <heber@…>, 15 years ago

Merge branch 'AtomicPositionEncapsulation' into stable

Conflicts:

src/Actions/AtomAction/ChangeElementAction.cpp
src/Actions/WorldAction/RemoveSphereOfAtomsAction.cpp
src/Makefile.am
src/UIElements/TextUI/TextDialog.cpp
src/analysis_correlation.hpp
src/atom.cpp
src/atom_atominfo.hpp
src/bond.cpp
src/boundary.cpp
src/molecule_geometry.cpp
src/tesselation.cpp
src/tesselationhelpers.cpp
src/triangleintersectionlist.cpp
src/unittests/Makefile.am

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