source: src/bond.cpp@ fc1b24

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 fc1b24 was 717e0c, checked in by Frederik Heber <heber@…>, 15 years ago

Verbosity corrected for ERROR and WARNING

  • present ERROR and WARNING prefixes removed and placed by eLog() and respective Verbosity().
  • -v... is scanned for number of 'v's and verbosity is set accordingly
  • standard verbosity is now 0.

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

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/** \file bond.cpp
2 *
3 * Function implementations for the classes BondLeaf, BondTree and bond.
4 *
5 */
6
7#include "atom.hpp"
8#include "bond.hpp"
9#include "element.hpp"
10#include "lists.hpp"
11
12
13/***************************************** Functions for class bond ********************************/
14
15/** Empty Constructor for class bond.
16 */
17bond::bond() : leftatom(NULL), rightatom(NULL), previous(NULL), next(NULL), HydrogenBond(0), BondDegree(0), nr(-1), Cyclic(false), Type(Undetermined), Used(white)
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 */
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)
28{
29 if ((left != NULL) && (right != NULL)) {
30 if ((left->type != NULL) && (left->type->Z == 1))
31 HydrogenBond++;
32 if ((right->type != NULL) && (right->type->Z == 1))
33 HydrogenBond++;
34 }
35};
36
37/** Empty Destructor for class bond.
38 */
39bond::~bond()
40{
41 // remove this node from the list structure
42 if (leftatom != NULL)
43 leftatom->UnregisterBond(this);
44 if (rightatom != NULL)
45 rightatom->UnregisterBond(this);
46 unlink(this);
47};
48
49ostream & operator << (ostream &ost, const bond &b)
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 */
59atom * bond::GetOtherAtom(const ParticleInfo * const Atom) const
60{
61 if(leftatom == Atom)
62 return rightatom;
63 if(rightatom == Atom)
64 return leftatom;
65 eLog() << Verbose(1) << "Bond " << *this << " does not contain atom " << *Atom << "!" << endl;
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 */
82bool bond::Contains(const ParticleInfo * const ptr)
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 */
91bool bond::Contains(const int number)
92{
93 return ((leftatom->nr == number) || (rightatom->nr == number));
94};
95
96/** Masks vertex as used in DFS.
97 * \return bond::Used, false if bond was already marked used
98 */
99bool bond::MarkUsed(const enum Shading color) {
100 if (Used == black) {
101 eLog() << Verbose(1) << "Bond " << this << " was already marked black!." << endl;
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};
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.