source: src/Bond/bond.cpp@ 1363de

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 Candidate_v1.7.0 Candidate_v1.7.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 1363de was 129204, checked in by Frederik Heber <heber@…>, 15 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
RevLine 
[bcf653]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
[129204]8/** \file Bond.cpp
[14de469]9 *
10 * Function implementations for the classes BondLeaf, BondTree and bond.
11 *
12 */
13
[bf3817]14// include config.h
15#ifdef HAVE_CONFIG_H
16#include <config.h>
17#endif
18
[ad011c]19#include "CodePatterns/MemDebug.hpp"
[112b09]20
[ad011c]21#include "CodePatterns/Log.hpp"
22#include "CodePatterns/Verbose.hpp"
[e41951]23#include "atom.hpp"
[129204]24#include "Bond/bond.hpp"
[f66195]25#include "element.hpp"
26
[14de469]27
28/***************************************** Functions for class bond ********************************/
29
30/** Empty Constructor for class bond.
31 */
[97b825]32bond::bond() :
33 leftatom(NULL),
34 rightatom(NULL),
35 HydrogenBond(0),
36 BondDegree(0),
[129204]37 nr(-1)
[97b825]38{};
[14de469]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 */
[97b825]46bond::bond(atom *left, atom *right, const int degree, const int number) :
47 leftatom(left),
48 rightatom(right),
49 HydrogenBond(0),
50 BondDegree(degree),
[129204]51 nr(number)
[14de469]52{
53 if ((left != NULL) && (right != NULL)) {
[83f176]54 if ((left->getType() != NULL) && (left->getType()->getAtomicNumber() == 1))
[ce5ac3]55 HydrogenBond++;
[83f176]56 if ((right->getType() != NULL) && (right->getType()->getAtomicNumber() == 1))
[ce5ac3]57 HydrogenBond++;
[14de469]58 }
59};
60
61/** Empty Destructor for class bond.
62 */
63bond::~bond()
[d557374]64{
[14de469]65 // remove this node from the list structure
[266237]66 if (leftatom != NULL)
67 leftatom->UnregisterBond(this);
68 if (rightatom != NULL)
[d557374]69 rightatom->UnregisterBond(this);
[14de469]70};
71
[fb73b8]72ostream & operator << (ostream &ost, const bond &b)
[14de469]73{
[68f03d]74 ost << "[" << b.leftatom->getName() << " <" << b.BondDegree << "(H" << b.HydrogenBond << ")>" << b.rightatom->getName() << "]";
[14de469]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 */
[fb73b8]82atom * bond::GetOtherAtom(const ParticleInfo * const Atom) const
[14de469]83{
84 if(leftatom == Atom)
85 return rightatom;
86 if(rightatom == Atom)
87 return leftatom;
[58ed4a]88 DoeLog(1) && (eLog()<< Verbose(1) << "Bond " << *this << " does not contain atom " << *Atom << "!" << endl);
[14de469]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 */
[fb73b8]97bool bond::Contains(const ParticleInfo * const ptr)
[14de469]98{
99 return ((leftatom == ptr) || (rightatom == ptr));
100};
101
102/** Checks if an atom exists in a bond.
[5309ba]103 * \param Nr index of atom
[14de469]104 * \return true if it is either bond::leftatom or bond::rightatom, false otherwise
105 */
[fa40b5]106bool bond::Contains(const int number)
[14de469]107{
[735b1c]108 return ((leftatom->getNr() == number) || (rightatom->getNr() == number));
[14de469]109};
110
[b9947d]111/** Calculates the bond length.
112 * \return |a - b| with a = bond::leftatom and b = bond::rightatom.
113 */
114double bond::GetDistance() const
115{
[d74077]116 return (leftatom->distance(*rightatom));
[b9947d]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{
[d74077]124 return (leftatom->DistanceSquared(*rightatom));
[b9947d]125};
Note: See TracBrowser for help on using the repository browser.