1 | /*
|
---|
2 | * Project: MoleCuilder
|
---|
3 | * Description: creates and alters molecular systems
|
---|
4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
---|
6 | */
|
---|
7 |
|
---|
8 | /** \file element.cpp
|
---|
9 | *
|
---|
10 | * Function implementations for the class element.
|
---|
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 <iomanip>
|
---|
22 | #include <fstream>
|
---|
23 |
|
---|
24 | #include "CodePatterns/Assert.hpp"
|
---|
25 | #include "CodePatterns/Log.hpp"
|
---|
26 | #include "element.hpp"
|
---|
27 |
|
---|
28 | using namespace std;
|
---|
29 |
|
---|
30 | /************************************* Functions for class element **********************************/
|
---|
31 |
|
---|
32 | /** Constructor of class element.
|
---|
33 | */
|
---|
34 | element::element() :
|
---|
35 | mass(0),
|
---|
36 | CovalentRadius(0),
|
---|
37 | Electronegativity(0.),
|
---|
38 | VanDerWaalsRadius(0),
|
---|
39 | Z(0),
|
---|
40 | period(""),
|
---|
41 | group(""),
|
---|
42 | block(""),
|
---|
43 | Valence(0),
|
---|
44 | NoValenceOrbitals(0),
|
---|
45 | name(""),
|
---|
46 | symbol("")
|
---|
47 | {
|
---|
48 | for (size_t i =0; i<3;++i)
|
---|
49 | color[i] = (unsigned char)0;
|
---|
50 | for (size_t i =0; i<3;++i)
|
---|
51 | HBondDistance[i] = 0.;
|
---|
52 | for (size_t i =0; i<3;++i)
|
---|
53 | HBondAngle[i] = 0.;
|
---|
54 | };
|
---|
55 |
|
---|
56 | element::element(const element &src) :
|
---|
57 | mass(src.mass),
|
---|
58 | CovalentRadius(src.CovalentRadius),
|
---|
59 | Electronegativity(src.Electronegativity),
|
---|
60 | VanDerWaalsRadius(src.VanDerWaalsRadius),
|
---|
61 | Z(src.Z),
|
---|
62 | period(src.period),
|
---|
63 | group(src.group),
|
---|
64 | block(src.block),
|
---|
65 | Valence(src.Valence),
|
---|
66 | NoValenceOrbitals(src.NoValenceOrbitals),
|
---|
67 | name(src.name),
|
---|
68 | symbol(src.symbol)
|
---|
69 | {
|
---|
70 | for (size_t i =0; i<3;++i)
|
---|
71 | color[i] = src.color[i];
|
---|
72 | for (size_t i =0; i<3;++i)
|
---|
73 | HBondDistance[i] = src.HBondDistance[i];
|
---|
74 | for (size_t i =0; i<3;++i)
|
---|
75 | HBondAngle[i] = src.HBondAngle[i];
|
---|
76 | }
|
---|
77 |
|
---|
78 | /** Destructor of class element.
|
---|
79 | */
|
---|
80 | element::~element() {};
|
---|
81 |
|
---|
82 | element &element::operator=(const element &src){
|
---|
83 | if(this!=&src){
|
---|
84 | mass=src.mass;
|
---|
85 | CovalentRadius=src.CovalentRadius;
|
---|
86 | Electronegativity=src.Electronegativity;
|
---|
87 | VanDerWaalsRadius=src.VanDerWaalsRadius;
|
---|
88 | Z=src.Z;
|
---|
89 | period = src.period;
|
---|
90 | group = src.group;
|
---|
91 | block = src.block;
|
---|
92 | Valence=src.Valence;
|
---|
93 | NoValenceOrbitals=src.NoValenceOrbitals;
|
---|
94 | for (size_t i =0; i<3;++i)
|
---|
95 | color[i] = src.color[i];
|
---|
96 | for (size_t i =0; i<3;++i)
|
---|
97 | HBondDistance[i] = src.HBondDistance[i];
|
---|
98 | for (size_t i =0; i<3;++i)
|
---|
99 | HBondAngle[i] = src.HBondAngle[i];
|
---|
100 | name=src.name;
|
---|
101 | symbol=src.symbol;
|
---|
102 | }
|
---|
103 | return *this;
|
---|
104 | }
|
---|
105 |
|
---|
106 | atomicNumber_t element::getNumber() const{
|
---|
107 | return Z;
|
---|
108 | }
|
---|
109 |
|
---|
110 | double element::getMass() const
|
---|
111 | {
|
---|
112 | return mass;
|
---|
113 | }
|
---|
114 |
|
---|
115 | double element::getCovalentRadius() const
|
---|
116 | {
|
---|
117 | return CovalentRadius;
|
---|
118 | }
|
---|
119 |
|
---|
120 | const unsigned char * element::getColor() const
|
---|
121 | {
|
---|
122 | return color;
|
---|
123 | }
|
---|
124 |
|
---|
125 | double element::getElectronegativity() const
|
---|
126 | {
|
---|
127 | return Electronegativity;
|
---|
128 | }
|
---|
129 |
|
---|
130 | double element::getVanDerWaalsRadius() const
|
---|
131 | {
|
---|
132 | return VanDerWaalsRadius;
|
---|
133 | }
|
---|
134 |
|
---|
135 | int element::getAtomicNumber() const
|
---|
136 | {
|
---|
137 | return Z;
|
---|
138 | }
|
---|
139 |
|
---|
140 | double element::getValence() const
|
---|
141 | {
|
---|
142 | return Valence;
|
---|
143 | }
|
---|
144 |
|
---|
145 | int element::getNoValenceOrbitals() const
|
---|
146 | {
|
---|
147 | return NoValenceOrbitals;
|
---|
148 | }
|
---|
149 |
|
---|
150 | double element::getHBondDistance(const size_t i) const
|
---|
151 | {
|
---|
152 | ASSERT((i<3), "Access to element::HBondDistance out of bounds.");
|
---|
153 | return HBondDistance[i];
|
---|
154 | }
|
---|
155 |
|
---|
156 | double element::getHBondAngle(const size_t i) const
|
---|
157 | {
|
---|
158 | ASSERT((i<3), "Access to element::HBondAngle out of bounds.");
|
---|
159 | return HBondAngle[i];
|
---|
160 | }
|
---|
161 |
|
---|
162 | const string &element::getSymbol() const{
|
---|
163 | return symbol;
|
---|
164 | }
|
---|
165 |
|
---|
166 | void element::setSymbol(const std::string &temp)
|
---|
167 | {
|
---|
168 | symbol = temp;
|
---|
169 | }
|
---|
170 |
|
---|
171 | const std::string &element::getName() const{
|
---|
172 | return name;
|
---|
173 | }
|
---|
174 |
|
---|
175 | void element::setName(const std::string &temp)
|
---|
176 | {
|
---|
177 | name = temp;
|
---|
178 | }
|
---|
179 |
|
---|
180 | /** Comparison operator for stub of Element.
|
---|
181 | *
|
---|
182 | * @param other other instance to compare to
|
---|
183 | * @return true if all member variables have the same contents.
|
---|
184 | */
|
---|
185 | bool element::operator==(const element &other) const
|
---|
186 | {
|
---|
187 | if (mass != other.mass) return false;
|
---|
188 | if (CovalentRadius != other.CovalentRadius) return false;
|
---|
189 | if (Electronegativity != other.Electronegativity) return false;
|
---|
190 | if (VanDerWaalsRadius != other.VanDerWaalsRadius) return false;
|
---|
191 | if (Z != other.Z) return false;
|
---|
192 | if (period != other.period) return false;
|
---|
193 | if (group != other.group) return false;
|
---|
194 | if (block != other.block) return false;
|
---|
195 | if (Valence != other.Valence) return false;
|
---|
196 | if (NoValenceOrbitals != other.NoValenceOrbitals) return false;
|
---|
197 | for (size_t i = 0; i < 3; ++i)
|
---|
198 | if (HBondDistance[i] != other.HBondDistance[i]) return false;
|
---|
199 | for (size_t i = 0; i < 3; ++i)
|
---|
200 | if (HBondAngle[i] != other.HBondAngle[i]) return false;
|
---|
201 | for (size_t i = 0; i < 3; ++i)
|
---|
202 | if (color[i] != other.color[i]) return false;
|
---|
203 | if (name != other.name) return false;
|
---|
204 | if (symbol != other.symbol) return false;
|
---|
205 | return true;
|
---|
206 | }
|
---|
207 |
|
---|
208 | std::ostream &operator<<(std::ostream &ost,const element &elem){
|
---|
209 | ost << elem.getName() << "(" << elem.getNumber() << ")";
|
---|
210 | return ost;
|
---|
211 | }
|
---|
212 |
|
---|