source: src/Bond/bond.cpp@ 111387

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 111387 was 129204, checked in by Frederik Heber <heber@…>, 14 years ago

Moved bond.* to Bond/, new class GraphEdge which contains graph parts of bond.

  • enums Shading and EdgeType are now part of GraphEdge, hence bigger change in the code where these are used.
  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/** \file Bond.cpp
9 *
10 * Function implementations for the classes BondLeaf, BondTree and bond.
11 *
12 */
13
14// include config.h
15#ifdef HAVE_CONFIG_H
16#include <config.h>
17#endif
18
19#include "CodePatterns/MemDebug.hpp"
20
21#include "CodePatterns/Log.hpp"
22#include "CodePatterns/Verbose.hpp"
23#include "atom.hpp"
24#include "Bond/bond.hpp"
25#include "element.hpp"
26
27
28/***************************************** Functions for class bond ********************************/
29
30/** Empty Constructor for class bond.
31 */
32bond::bond() :
33 leftatom(NULL),
34 rightatom(NULL),
35 HydrogenBond(0),
36 BondDegree(0),
37 nr(-1)
38{};
39
40/** Constructor for class bond, taking right and left bond partner
41 * \param *left left atom
42 * \param *right right atom
43 * \param degree bond degree
44 * \param number increasing index
45 */
46bond::bond(atom *left, atom *right, const int degree, const int number) :
47 leftatom(left),
48 rightatom(right),
49 HydrogenBond(0),
50 BondDegree(degree),
51 nr(number)
52{
53 if ((left != NULL) && (right != NULL)) {
54 if ((left->getType() != NULL) && (left->getType()->getAtomicNumber() == 1))
55 HydrogenBond++;
56 if ((right->getType() != NULL) && (right->getType()->getAtomicNumber() == 1))
57 HydrogenBond++;
58 }
59};
60
61/** Empty Destructor for class bond.
62 */
63bond::~bond()
64{
65 // remove this node from the list structure
66 if (leftatom != NULL)
67 leftatom->UnregisterBond(this);
68 if (rightatom != NULL)
69 rightatom->UnregisterBond(this);
70};
71
72ostream & operator << (ostream &ost, const bond &b)
73{
74 ost << "[" << b.leftatom->getName() << " <" << b.BondDegree << "(H" << b.HydrogenBond << ")>" << b.rightatom->getName() << "]";
75 return ost;
76};
77
78/** Get the other atom in a bond if one is specified.
79 * \param *Atom the pointer to the one atom
80 * \return pointer to the other atom in the bond, NULL if no match (indicates something's wrong with the bond)
81 */
82atom * bond::GetOtherAtom(const ParticleInfo * const Atom) const
83{
84 if(leftatom == Atom)
85 return rightatom;
86 if(rightatom == Atom)
87 return leftatom;
88 DoeLog(1) && (eLog()<< Verbose(1) << "Bond " << *this << " does not contain atom " << *Atom << "!" << endl);
89 return NULL;
90};
91
92
93/** Checks if an atom exists in a bond.
94 * \param *ptr pointer to atom
95 * \return true if it is either bond::leftatom or bond::rightatom, false otherwise
96 */
97bool bond::Contains(const ParticleInfo * const ptr)
98{
99 return ((leftatom == ptr) || (rightatom == ptr));
100};
101
102/** Checks if an atom exists in a bond.
103 * \param Nr index of atom
104 * \return true if it is either bond::leftatom or bond::rightatom, false otherwise
105 */
106bool bond::Contains(const int number)
107{
108 return ((leftatom->getNr() == number) || (rightatom->getNr() == number));
109};
110
111/** Calculates the bond length.
112 * \return |a - b| with a = bond::leftatom and b = bond::rightatom.
113 */
114double bond::GetDistance() const
115{
116 return (leftatom->distance(*rightatom));
117};
118
119/** Calculates the bond length.
120 * \return |a - b|^2 with a = bond::leftatom and b = bond::rightatom.
121 */
122double bond::GetDistanceSquared() const
123{
124 return (leftatom->DistanceSquared(*rightatom));
125};
Note: See TracBrowser for help on using the repository browser.