-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathelements.cpp
100 lines (92 loc) · 4.56 KB
/
elements.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "elements.h"
#include "string.h"
/* -----------------------------------------------------------------------------
* Private method, to get atomic number from element name
* -------------------------------------------------------------------------- */
int ChemElements::Name2Num(const char *ename)
{
int AtNum;
for (AtNum = 1; AtNum <= NumMax; AtNum++) if (strcmp(ename, symbol[AtNum]) == 0) break;
if (AtNum > NumMax) AtNum = 0;
return AtNum;
}
/* -----------------------------------------------------------------------------
* Private method, to get element name from atomic number
* -------------------------------------------------------------------------- */
void ChemElements::Num2Name(const int AtNum, char * ename)
{
int num = AtNum;
if (num < 0||num > NumMax) num = 0;
strcpy(ename, symbol[num]);
}
/* -----------------------------------------------------------------------------
* Private method, to get molar mass from element name
* -------------------------------------------------------------------------- */
double ChemElements::Name2Mass(const char * ename)
{
int AtNum = Name2Num(ename);
return weight[AtNum];
}
/* -----------------------------------------------------------------------------
* Private method, to get molar mass from atomic number
* -------------------------------------------------------------------------- */
double ChemElements::Num2Mass(const int AtNum)
{
int num = AtNum;
if (num < 0||num > NumMax) num = 0;
return weight[num];
}
/* -----------------------------------------------------------------------------
* Atomic weight data taken from:
* Pure Appl. Chem., Vol. 83, No. 2, pp. 359–396, 2011.
* Atomic weights of the elements 2009 (IUPAC Technical Report)
* ---------------------------------------------------------------------------*/
const int ChemElements::NumMax = 112;
const double ChemElements::weight[] = {0., // Null
1.00797, 4.0026, 6.939, 9.012182, 10.811, // H - B
12.01115, 14.0067, 15.9994, 18.9984032, 20.17976, 22.989769, // C - Na
24.30506, 26.9815386, 28.086, 30.973762, 32.064, // Mg - S
35.453, 39.948, 39.0983, 40.078, 44.955912, // Cl - Sc
47.867, 50.9415, 51.9961, 54.938045, 55.845, // Ti - Fe
58.933195, 58.6934, 63.546, 65.38, 69.723, // Co - Ga
72.63, 74.9216, 78.96, 79.904, 83.798, // Ge - Kr
85.4678, 87.62, 88.90585, 91.224, 92.90638, // Rb - Nb
95.96, 98.9062, 101.07, 102.9055, 106.42, // Mo - Pd
107.8682, 112.411, 114.818, 118.71, 121.76, // Ag - Sb
127.6, 126.90447, 131.293, 132.9054519, 137.327, // Te - Ba
138.90547, 140.116, 140.90765, 144.242, 147., // La - Pm
150.36, 151.964, 157.25, 158.92535, 162.5, // Sm - Dy
164.93032, 167.259, 168.93421, 173.054, 174.9668, // Ho - Lu
178.49, 180.94788, 183.84, 186.207, 190.23, // Hf - Os
192.217, 195.084, 196.966569, 200.59, 204.383, // Ir - Tl
207.2, 208.9804, 209., 210., 222., // Pb - Rn
223., 226.025, 227.028, 232.03806, 231.03588, // Fr - Pa
238.02891, 237.048, 244., 243., 247., // U - Cm
247., 251., 252., 257., 258., // Bk - Md
259., 260., 261.11, 262.11, 263.12, // No - Sg
262.12, 265., 266., 269., 272., 285. // Bh - Cn
};
const char ChemElements::symbol[][3] = { "X",
"H", "He", "Li", "Be", "B",
"C", "N", "O", "F", "Ne", "Na",
"Mg", "Al", "Si", "P", "S",
"Cl", "Ar", "K", "Ca", "Sc",
"Ti", "V", "Cr", "Mn", "Fe",
"Co", "Ni", "Cu", "Zn", "Ga",
"Ge", "As", "Se", "Br", "Kr",
"Rb", "Sr", "Y", "Zr", "Nb",
"Mo", "Tc", "Ru", "Rh", "Pd",
"Ag", "Cd", "In", "Sn", "Sb",
"Te", "I", "Xe", "Cs", "Ba",
"La", "Ce", "Pr", "Nd", "Pm",
"Sm", "Eu", "Gd", "Tb", "Dy",
"Ho", "Er", "Tm", "Yb", "Lu",
"Hf", "Ta", "W", "Re", "Os",
"Ir", "Pt", "Au", "Hg", "Tl",
"Pb", "Bi", "Po", "At", "Rn",
"Fr", "Ra", "Ac", "Th", "Pa",
"U", "Np", "Pu", "Am", "Cm",
"Bk", "Cf", "Es", "Fm", "Md",
"No", "Lr", "Rf", "Db", "Sg",
"Bh", "Hs", "Mt", "Ds", "Rg", "Cn"
};