KIDS  ver-0.0.1
KIDS : Kernel Integrated Dynamics Simulator
Loading...
Searching...
No Matches
chem.h
Go to the documentation of this file.
1
29#ifndef ELEMENTS_H
30#define ELEMENTS_H
31#include <cstring>
32#include <string>
33
34const int MAX_ELEMENTS_NUMBER = 119; // 0-th element is NU
35const int MAX_ELEMENTS_NPERIOD = 8; // 0-th period is {NU}
36
37const int N_PURE_ElEMENTS_IN_ROW[] = {0, 2, 10, 18, 36, 54, 86, 118}; // "NU" is not a pure element
38
39// clang-format off
40const char* const ELEMENTS_LABEL[] = {
41 "NU" ,
42 "H" , "HE",
43 "LI","BE", "B" ,"C" ,"N" ,"O" ,"F" ,"NE",
44 "NA","MG", "AL","SI","P" ,"S" ,"CL","AR",
45 "K" ,"CA","SC","TI","V" ,"CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR",
46 "RB","SR","Y" ,"ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","I" ,"XE",
47 "CS","BA",
48 "LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB", // Lanthanide
49 "LU","HF","TA","W" ,"RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN",
50 "FR","RA",
51 "AC","TH","PA","U" ,"NP","PU","AM","CM","BK","CF","ES","FM","MD","NO", // Actinicles
52 "LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","Og"
53};
54
55const double ELEMENTS_MASS[] = // average of isotopic atoms
56{
570.0, 1.007947, 4.0026022, 6.9412, 9.0121823,
5810.8117, 12.01078, 14.00672, 15.99943, 18.99840325,
5920.17976, 22.989769282, 24.30506, 26.98153868, 28.08553,
6030.9737622, 32.0655, 35.4532, 39.9481, 39.09831,
6140.0784, 44.9559126, 47.8671, 50.94151, 51.99616,
6254.9380455, 55.8452, 58.9331955, 58.69342, 63.5463,
6365.4094, 69.7231, 72.641, 74.921602, 78.963,
6479.9041, 83.7982, 85.46783, 87.621, 88.905852,
6591.2242, 92.906382, 95.942, 98.0, 101.072,
66102.905502, 106.421, 107.86822, 112.4118, 114.8183,
67118.7107, 121.7601, 127.603, 126.904473, 131.2936,
68132.90545192, 137.3277, 138.905477, 140.1161, 140.907652,
69144.2423, 145.0, 150.362, 151.9641, 157.253,
70158.925352, 162.5001, 164.930322, 167.2593, 168.934212,
71173.043, 174.9671, 178.492, 180.947882, 183.841,
72186.2071, 190.233, 192.2173, 195.0849, 196.9665694,
73200.592, 204.38332, 207.21, 208.980401, 210.0,
74210.0, 220.0, 223.0, 226.0, 227.0,
75232.038062, 231.035882, 238.028913, 237.0, 244.0,
76243.0, 247.0, 247.0, 251.0, 252.0,
77257.0, 258.0, 259.0, 262.0, 261.0,
78262.0, 266.0, 264.0, 277.0, 268.0,
79271.0, 272.0, 285.0, 284.0, 289.0,
80288.0, 292.0, 291.0, 294.0
81};
82
83const double ELEMENTS_MASS_NOAVG[] =
84{
850.0, 1.00782503207, 4.00260325415, 7.016004548, 9.012182201,
8611.009305406, 12.0000000000, 14.00307400478, 15.99491461956, 18.998403224,
8719.99244017542, 22.98976928087, 23.985041699, 26.981538627, 27.97692653246,
8830.973761629, 31.972070999, 34.968852682, 39.96238312251, 38.963706679,
8939.962590983, 44.955911909, 47.947946281, 50.943959507, 51.940507472,
9054.938045141, 55.934937475, 58.933195048, 57.935342907, 62.929597474,
9163.929142222, 68.925573587, 73.921177767, 74.921596478, 79.916521271,
9278.918337087, 85.910610729, 84.911789737, 87.905612124, 88.905848295,
9389.904704416, 92.906378058, 97.905408169, 98.906254747, 101.904349312,
94102.905504292, 105.903485715, 106.90509682, 113.90335854, 114.903878484,
95119.902194676, 120.903815686, 129.906224399, 126.904472681, 131.904153457,
96132.905451932, 137.905247237, 138.906353267, 139.905438706, 140.907652769,
97141.907723297, 144.912749023, 151.919732425, 152.921230339, 157.924103912,
98158.925346757, 163.929174751, 164.93032207, 165.930293061, 168.93421325,
99173.938862089, 174.940771819, 179.946549953, 180.947995763, 183.950931188,
100186.955753109, 191.96148069, 192.96292643, 194.964791134, 196.966568662,
101201.970643011, 204.974427541, 207.976652071, 208.980398734, 208.982430435,
102210.987496271, 222.017577738, 222.01755173, 228.031070292, 227.027752127,
103232.038055325, 231.03588399, 238.050788247, 237.048173444, 242.058742611,
104243.06138108, 247.07035354, 247.07030708, 251.079586788, 252.082978512,
105257.095104724, 258.098431319, 255.093241131, 260.105504, 263.112547,
106255.107398, 259.114500, 262.122892, 263.128558, 265.136151,
107281.162061, 272.153615, 283.171792, 283.176451, 285.183698,
108287.191186, 292.199786, 291.206564, 293.214670
109};
110// clang-format on
111
112namespace Elements {
113
114struct ElemInfo {
115 int znum;
116 int fmly;
117 int perd;
118 double mass;
119 std::string name;
120};
121
122inline int ELEMENTS_ZNUM(const std::string& label) {
123 std::string copylabel = label;
124 std::for_each(copylabel.begin(), copylabel.end(), [](char& c) { c = ::toupper(c); });
125 for (int i = 1; i <= MAX_ELEMENTS_NUMBER; ++i) {
126 if (strcmp(copylabel.c_str(), ELEMENTS_LABEL[i]) == 0) return i;
127 }
128 return 0;
129}
130
131inline std::string ELEMENTS_NAME(const int& znumber) {
132 return (znumber > 0 && znumber <= MAX_ELEMENTS_NUMBER) ? std::string(ELEMENTS_LABEL[znumber]) : "NULL";
133}
134
135template <typename T>
137 ElemInfo elem;
138 if (std::is_same<T, std::string>::value) {
139 elem.name = ask;
140 elem.znum = ELEMENTS_ZNUM(elem.name);
141 } else if (std::is_same<T, int>::value) {
142 elem.znum = ask;
143 elem.name = ELEMENTS_NAME(elem.znum);
144 }
145 elem.perd = 0, elem.fmly = 0;
146 for (int ip = 1; ip <= MAX_ELEMENTS_NPERIOD; ++ip) {
147 if (elem.znum <= N_PURE_ElEMENTS_IN_ROW[ip - 1] && elem.znum <= N_PURE_ElEMENTS_IN_ROW[ip]) {
148 elem.perd = ip, elem.fmly = elem.znum - N_PURE_ElEMENTS_IN_ROW[ip - 1];
149 }
150 }
151 elem.mass = ELEMENTS_MASS[elem.znum];
152 return elem;
153}
154
155}; // namespace Elements
156
157
158#endif // ELEMENTS_H
const char *const ELEMENTS_LABEL[]
Definition chem.h:40
const int MAX_ELEMENTS_NUMBER
Definition chem.h:34
const int N_PURE_ElEMENTS_IN_ROW[]
Definition chem.h:37
const double ELEMENTS_MASS[]
Definition chem.h:55
const double ELEMENTS_MASS_NOAVG[]
Definition chem.h:83
const int MAX_ELEMENTS_NPERIOD
Definition chem.h:35
std::string ELEMENTS_NAME(const int &znumber)
Definition chem.h:131
int ELEMENTS_ZNUM(const std::string &label)
Definition chem.h:122
ElemInfo & GetElemInfo(T ask)
Definition chem.h:136
std::string name
Definition chem.h:119