source: src/atom_atominfo.cpp@ 5e99bc

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 5e99bc was 9184bd, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Added a method that allows querying the mass of an atom directly

  • allows replacement of atom->getType()->getMass() with simpler atom->getMass()
  • Property mode set to 100644
File size: 3.8 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/*
9 * atom_atominfo.cpp
10 *
11 * Created on: Oct 19, 2009
12 * Author: heber
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include "Helpers/MemDebug.hpp"
21
22#include "periodentafel.hpp"
23#include "World.hpp"
24#include "element.hpp"
25#include "atom_atominfo.hpp"
26
27/** Constructor of class AtomInfo.
28 */
29AtomInfo::AtomInfo() :
30 AtomicElement(NULL)
31{};
32
33/** Copy constructor of class AtomInfo.
34 */
35AtomInfo::AtomInfo(const AtomInfo &_atom) :
36 AtomicPosition(_atom.AtomicPosition),
37 AtomicElement(_atom.AtomicElement)
38{};
39
40AtomInfo::AtomInfo(const VectorInterface &_v) :
41 AtomicPosition(_v.getPosition()),
42 AtomicElement(NULL)
43{};
44
45/** Destructor of class AtomInfo.
46 */
47AtomInfo::~AtomInfo()
48{
49};
50
51const element *AtomInfo::getType() const
52{
53 return AtomicElement;
54}
55
56const double& AtomInfo::operator[](size_t i) const
57{
58 return AtomicPosition[i];
59}
60
61const double& AtomInfo::at(size_t i) const
62{
63 return AtomicPosition.at(i);
64}
65
66void AtomInfo::set(size_t i, const double value)
67{
68 AtomicPosition.at(i) = value;
69}
70
71const Vector& AtomInfo::getPosition() const
72{
73 return AtomicPosition;
74}
75
76void AtomInfo::setType(const element* _type) {
77 AtomicElement = _type;
78}
79
80void AtomInfo::setType(const int Z) {
81 const element *elem = World::getInstance().getPeriode()->FindElement(Z);
82 setType(elem);
83}
84
85double AtomInfo::getMass() const{
86 return getType()->getMass();
87}
88
89void AtomInfo::setPosition(const Vector& _vector)
90{
91 AtomicPosition = _vector;
92 //cout << "AtomInfo::setPosition: " << getType()->symbol << " at " << getPosition() << endl;
93}
94
95const VectorInterface& AtomInfo::operator+=(const Vector& b)
96{
97 AtomicPosition += b;
98 return *this;
99}
100
101const VectorInterface& AtomInfo::operator-=(const Vector& b)
102{
103 AtomicPosition -= b;
104 return *this;
105}
106
107Vector const AtomInfo::operator+(const Vector& b) const
108{
109 Vector a(AtomicPosition);
110 a += b;
111 return a;
112}
113
114Vector const AtomInfo::operator-(const Vector& b) const
115{
116 Vector a(AtomicPosition);
117 a -= b;
118 return a;
119}
120
121double AtomInfo::distance(const Vector &point) const
122{
123 return AtomicPosition.distance(point);
124}
125
126double AtomInfo::DistanceSquared(const Vector &y) const
127{
128 return AtomicPosition.DistanceSquared(y);
129}
130
131double AtomInfo::distance(const VectorInterface &_atom) const
132{
133 return _atom.distance(AtomicPosition);
134}
135
136double AtomInfo::DistanceSquared(const VectorInterface &_atom) const
137{
138 return _atom.DistanceSquared(AtomicPosition);
139}
140
141VectorInterface &AtomInfo::operator=(const Vector& _vector)
142{
143 AtomicPosition = _vector;
144 return *this;
145}
146
147void AtomInfo::ScaleAll(const double *factor)
148{
149 AtomicPosition.ScaleAll(factor);
150}
151
152void AtomInfo::ScaleAll(const Vector &factor)
153{
154 AtomicPosition.ScaleAll(factor);
155}
156
157void AtomInfo::Scale(const double factor)
158{
159 AtomicPosition.Scale(factor);
160}
161
162void AtomInfo::Zero()
163{
164 AtomicPosition.Zero();
165}
166
167void AtomInfo::One(const double one)
168{
169 AtomicPosition.One(one);
170}
171
172void AtomInfo::LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors)
173{
174 AtomicPosition.LinearCombinationOfVectors(x1,x2,x3,factors);
175}
176
177const AtomInfo& operator*=(AtomInfo& a, const double m)
178{
179 a.Scale(m);
180 return a;
181}
182
183AtomInfo const operator*(const AtomInfo& a, const double m)
184{
185 AtomInfo copy(a);
186 copy *= m;
187 return copy;
188}
189
190AtomInfo const operator*(const double m, const AtomInfo& a)
191{
192 AtomInfo copy(a);
193 copy *= m;
194 return copy;
195}
196
197std::ostream & AtomInfo::operator << (std::ostream &ost) const
198{
199 return (ost << getPosition());
200}
201
202std::ostream & operator << (std::ostream &ost, const AtomInfo &a)
203{
204 ost << a;
205 return ost;
206}
207
Note: See TracBrowser for help on using the repository browser.