TBTK
Atom.h
Go to the documentation of this file.
1 /* Copyright 2017 Kristofer Bj√∂rnson
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
23 #ifndef COM_DAFER45_TBTK_ATOM
24 #define COM_DAFER45_TBTK_ATOM
25 
26 #include "TBTK/UnitHandler.h"
27 
28 #include <string>
29 
30 namespace TBTK{
31 
32 class Atom{
33 public:
35  Atom(unsigned int atomicNumber);
36 
38  ~Atom();
39 
41  unsigned int getAtomicNumber() const;
42 
44  std::string getSymbol() const;
45 
47  std::string getName() const;
48 
50  double getStandardWeight() const;
51 
53  static const Atom& getAtomByNumber(unsigned int atomicNumber);
54 
56  static const Atom& getAtomBySymbol(const std::string &symbol);
57 
59  static const Atom& getAtomByName(const std::string &name);
60 
62  static const Atom &Hydrogen;
63  static const Atom &Helium;
64  static const Atom &Lithium;
65  static const Atom &Beryllium;
66  static const Atom &Boron;
67  static const Atom &Carbon;
68  static const Atom &Nitrogen;
69  static const Atom &Oxygen;
70  static const Atom &Fluorine;
71  static const Atom &Neon; //10
72  static const Atom &Sodium;
73  static const Atom &Magnesium;
74  static const Atom &Aluminium;
75  static const Atom &Silicon;
76  static const Atom &Phosphorus;
77  static const Atom &Sulfur;
78  static const Atom &Chlorine;
79  static const Atom &Argon;
80  static const Atom &Potassium;
81  static const Atom &Calcium; //20
82  static const Atom &Scandium;
83  static const Atom &Titanium;
84  static const Atom &Vanadium;
85  static const Atom &Chromium;
86  static const Atom &Manganese;
87  static const Atom &Iron;
88  static const Atom &Cobalt;
89  static const Atom &Nickel;
90  static const Atom &Copper;
91  static const Atom &Zinc; //30
92  static const Atom &Gallium;
93  static const Atom &Germanium;
94  static const Atom &Arsenic;
95  static const Atom &Selenium;
96  static const Atom &Bromine;
97  static const Atom &Krypton;
98  static const Atom &Rubidium;
99  static const Atom &Strontium;
100  static const Atom &Yttrium;
101  static const Atom &Zirconium; //40
102  static const Atom &Niobium;
103  static const Atom &Molybdenum;
104  static const Atom &Technetium;
105  static const Atom &Ruthenium;
106  static const Atom &Rhodium;
107  static const Atom &Palladium;
108  static const Atom &Silver;
109  static const Atom &Cadmium;
110  static const Atom &Indium;
111  static const Atom &Tin; //50
112  static const Atom &Antimony;
113  static const Atom &Tellurium;
114  static const Atom &Iodine;
115  static const Atom &Xenon;
116  static const Atom &Caesium;
117  static const Atom &Barium;
118  static const Atom &Lanthanum;
119  static const Atom &Cerium;
120  static const Atom &Praseodymium;
121  static const Atom &Neodymium; //60
122  static const Atom &Promethium;
123  static const Atom &Samarium;
124  static const Atom &Europium;
125  static const Atom &Gadolinium;
126  static const Atom &Terbium;
127  static const Atom &Dysprosium;
128  static const Atom &Holmium;
129  static const Atom &Erbium;
130  static const Atom &Thulium;
131  static const Atom &Ytterbium; //70
132  static const Atom &Lutetium;
133  static const Atom &Hafnium;
134  static const Atom &Tantalum;
135  static const Atom &Tungsten;
136  static const Atom &Rhenium;
137  static const Atom &Osmium;
138  static const Atom &Iridium;
139  static const Atom &Platinum;
140  static const Atom &Gold;
141  static const Atom &Mercury; //80
142  static const Atom &Thallium;
143  static const Atom &Lead;
144  static const Atom &Bismuth;
145  static const Atom &Polonium;
146  static const Atom &Astatine;
147  static const Atom &Radon;
148  static const Atom &Francium;
149  static const Atom &Radium;
150  static const Atom &Actinium;
151  static const Atom &Thorium; //90
152  static const Atom &Protactinium;
153  static const Atom &Uranium;
154  static const Atom &Neptunium;
155  static const Atom &Plutonium;
156  static const Atom &Americium;
157  static const Atom &Curium;
158  static const Atom &Berkelium;
159  static const Atom &Californium;
160  static const Atom &Einsteinium;
161  static const Atom &Fermium; //100
162  static const Atom &Mendelevium;
163  static const Atom &Nobelium;
164  static const Atom &Lawrencium;
165  static const Atom &Rutherfordium;
166  static const Atom &Dubnium;
167  static const Atom &Seaborgium;
168  static const Atom &Bohrium;
169  static const Atom &Hassium;
170  static const Atom &Meitnerium;
171  static const Atom &Darmstadtium; //110
172  static const Atom &Roentgenium;
173  static const Atom &Copernicium;
174  static const Atom &Nihonium;
175  static const Atom &Flerovium;
176  static const Atom &Moscovium;
177  static const Atom &Livermorium;
178  static const Atom &Tennessine;
179  static const Atom &Oganesson;
180 
182  static const Atom &H;
183  static const Atom &He;
184  static const Atom &Li;
185  static const Atom &Be;
186  static const Atom &B;
187  static const Atom &C;
188  static const Atom &N;
189  static const Atom &O;
190  static const Atom &F;
191  static const Atom &Ne; //10
192  static const Atom &Na;
193  static const Atom &Mg;
194  static const Atom &Al;
195  static const Atom &Si;
196  static const Atom &P;
197  static const Atom &S;
198  static const Atom &Cl;
199  static const Atom &Ar;
200  static const Atom &K;
201  static const Atom &Ca; //20
202  static const Atom &Sc;
203  static const Atom &Ti;
204  static const Atom &V;
205  static const Atom &Cr;
206  static const Atom &Mn;
207  static const Atom &Fe;
208  static const Atom &Co;
209  static const Atom &Ni;
210  static const Atom &Cu;
211  static const Atom &Zn; //30
212  static const Atom &Ga;
213  static const Atom &Ge;
214  static const Atom &As;
215  static const Atom &Se;
216  static const Atom &Br;
217  static const Atom &Kr;
218  static const Atom &Rb;
219  static const Atom &Sr;
220  static const Atom &Y;
221  static const Atom &Zr; //40
222  static const Atom &Nb;
223  static const Atom &Mo;
224  static const Atom &Tc;
225  static const Atom &Ru;
226  static const Atom &Rh;
227  static const Atom &Pd;
228  static const Atom &Ag;
229  static const Atom &Cd;
230  static const Atom &In;
231  static const Atom &Sn; //50
232  static const Atom &Sb;
233  static const Atom &Te;
234  static const Atom &I;
235  static const Atom &Xe;
236  static const Atom &Cs;
237  static const Atom &Ba;
238  static const Atom &La;
239  static const Atom &Ce;
240  static const Atom &Pr;
241  static const Atom &Nd; //60
242  static const Atom &Pm;
243  static const Atom &Sm;
244  static const Atom &Eu;
245  static const Atom &Gd;
246  static const Atom &Tb;
247  static const Atom &Dy;
248  static const Atom &Ho;
249  static const Atom &Er;
250  static const Atom &Tm;
251  static const Atom &Yb; //70
252  static const Atom &Lu;
253  static const Atom &Hf;
254  static const Atom &Ta;
255  static const Atom &W;
256  static const Atom &Re;
257  static const Atom &Os;
258  static const Atom &Ir;
259  static const Atom &Pt;
260  static const Atom &Au;
261  static const Atom &Hg; //80
262  static const Atom &Tl;
263  static const Atom &Pb;
264  static const Atom &Bi;
265  static const Atom &Po;
266  static const Atom &At;
267  static const Atom &Rn;
268  static const Atom &Fr;
269  static const Atom &Ra;
270  static const Atom &Ac;
271  static const Atom &Th; //90
272  static const Atom &Pa;
273  static const Atom &U;
274  static const Atom &Np;
275  static const Atom &Pu;
276  static const Atom &Am;
277  static const Atom &Cm;
278  static const Atom &Bk;
279  static const Atom &Cf;
280  static const Atom &Es;
281  static const Atom &Fm; //100
282  static const Atom &Md;
283  static const Atom &No;
284  static const Atom &Lr;
285  static const Atom &Rf;
286  static const Atom &Db;
287  static const Atom &Sg;
288  static const Atom &Bh;
289  static const Atom &Hs;
290  static const Atom &Mt;
291  static const Atom &Ds; //110
292  static const Atom &Rg;
293  static const Atom &Cn;
294  static const Atom &Nh;
295  static const Atom &Fl;
296  static const Atom &Mc;
297  static const Atom &Lv;
298  static const Atom &Ts;
299  static const Atom &Og;
300 private:
302  unsigned int atomicNumber;
303 
305  static constexpr unsigned int totalNumAtoms = 118;
306 
308  static std::string symbols[];
309 
311  static std::string names[];
312 
314  static double standardWeights[];
315 
317  static Atom atoms[];
318 };
319 
320 inline unsigned int Atom::getAtomicNumber() const{
321  return atomicNumber;
322 }
323 
324 inline std::string Atom::getSymbol() const{
325  return symbols[atomicNumber];
326 }
327 
328 inline std::string Atom::getName() const{
329  return names[atomicNumber];
330 }
331 
332 inline double Atom::getStandardWeight() const{
334  standardWeights[atomicNumber],
335  UnitHandler::MassUnit::u
336  );
337 }
338 
339 inline const Atom& Atom::getAtomByNumber(unsigned int atomicNumber){
340  if(atomicNumber > totalNumAtoms)
341  return atoms[0];
342  else
343  return atoms[atomicNumber];
344 }
345 
346 inline const Atom& Atom::getAtomBySymbol(const std::string &symbol){
347  for(unsigned int n = 1; n <= totalNumAtoms; n++)
348  if(symbols[n].compare(symbol) == 0)
349  return atoms[n];
350 
351  return atoms[0];
352 }
353 
354 inline const Atom& Atom::getAtomByName(const std::string &name){
355  for(unsigned int n = 1; n <= totalNumAtoms; n++)
356  if(names[n].compare(name) == 0)
357  return atoms[n];
358 
359  return atoms[0];
360 }
361 
362 }; //End namespace TBTK
363 
364 #endif
std::string getName() const
Definition: Atom.h:328
static const Atom & H
Definition: Atom.h:182
double getStandardWeight() const
Definition: Atom.h:332
Handles conversions between different units.
Atom(unsigned int atomicNumber)
static const Atom & getAtomByNumber(unsigned int atomicNumber)
Definition: Atom.h:339
static const Atom & Hydrogen
Definition: Atom.h:62
static double convertMassDtN(double mass, MassUnit unit)
static const Atom & getAtomByName(const std::string &name)
Definition: Atom.h:354
unsigned int getAtomicNumber() const
Definition: Atom.h:320
std::string getSymbol() const
Definition: Atom.h:324
Definition: ModelFactory.h:35
Definition: Atom.h:32
static const Atom & getAtomBySymbol(const std::string &symbol)
Definition: Atom.h:346