Cantera  2.0
atomicWeightDB.cpp
Go to the documentation of this file.
1 /**
2  * @file atomicWeightDB.cpp
3  *
4  * internal database of default atomic weights
5  *
6  */
7 
8 // Copyright 2001 California Institute of Technology
9 
10 #include <map>
11 #include <string>
12 #include <iostream>
13 using namespace std;
14 
15 namespace ckr
16 {
17 
18 static double _weights[] = {
19  1.00797, 4.0026, 6.939, 9.01220, 10.811, // H - B
20  12.01115, 14.0067, 15.9994, 18.9984, 20.183, 22.9898, // C - Na
21  24.312, 26.9815, 28.086, 30.9738, 32.064, // Mg - S
22  35.453, 39.948, 39.102, 40.08, 44.956, // Cl - Sc
23  47.9, 50.942, 51.996, 54.938, 55.847, // Ti - Fe
24  58.9332, 58.71, 63.54, 65.37, 69.72, // Co - Ga
25  72.59, 74.9216, 78.96, 79.9009, 83.8, // Ge - Kr
26  85.47, 87.62, 88.905, 91.22, 92.9064, // Rb - Nb
27  95.94, 98, 101.07, 102.906, 106.42, // Mo - Pd
28  107.868, 112.41, 114.82, 118.71, 121.75, // Ag - Sb
29  127.6, 126.905, 131.29, 132.905, 137.33, // Te - Ba
30  138.906, 140.12, 140.908, 144.24, 145, // La - Pm
31  150.36, 151.96, 157.25, 158.925, 162.5, // Sm - Dy
32  164.93, 167.26, 168.934, 173.04, 174.967, // Ho - Lu
33  178.49, 180.948, 183.85, 186.207, 190.2, // Hf - Os
34  192.22, 195.08, 196.967, 200.59, 204.383, // Ir - Tl
35  207.2, 208.98, 209, 210, 222, // Pb - Rn
36  223, 226.025, 227.028, 232.038, 231.036, // Fr - Pa
37  238.029, 237.048, 244, 243, 247, // U - Cm
38  247, 251, 252, 257, 258, // Bk - Md
39  259, 269, 2.0141, 5.45e-4, -1.0 // No - E
40 };
41 
42 
43 
44 static char _symbols[][3] = {
45  "H", "He", "Li", "Be", "B",
46  "C", "N", "O", "F", "Ne", "Na",
47  "Mg", "Al", "Si", "P", "S",
48  "Cl", "Ar", "K", "Ca", "Sc",
49  "Ti", "V", "Cr", "Mn", "Fe",
50  "Co", "Ni", "Cu", "Zn", "Ga",
51  "Ge", "As", "Se", "Br", "Kr",
52  "Rb", "Sr", "Y", "Zr", "Nb",
53  "Mo", "Tc", "Ru", "Rh", "Pd",
54  "Ag", "Cd", "In", "Sn", "Sb",
55  "Te", "I", "Xe", "Cs", "Ba",
56  "La", "Ce", "Pr", "Nd", "Pm",
57  "Sm", "Eu", "Gd", "Tb", "Dy",
58  "Ho", "Er", "Tm", "Yb", "Lu",
59  "Hf", "Ta", "W", "Re", "Os",
60  "Ir", "Pt", "Au", "Hg", "Tl",
61  "Pb", "Bi", "Po", "At", "Rn",
62  "Fr", "Ra", "Ac", "Th", "Pa",
63  "U", "Np", "Pu", "Am", "Cm",
64  "Bk", "Cf", "Ei", "Fm", "Md",
65  "No", "Lw", "D", "E", "!"
66 };
67 
68 
69 
70 /**
71  * Get table of atomic weights from the internal database.
72  * @param weights atomic symbol -> atomic weight map
73  *
74  * Example usage:
75  * @code
76  * #include "atomicWeightDB.h"
77  * ...
78  * map<string, double> atw;
79  * getDefaultAtomicWeights(atw);
80  * double copperAtomicWeight = atw["Cu"];
81  * ...
82  * @endcode
83  * Note that if the atomic weight is requested for an unknown
84  * element symbol, the value zero will be returned.
85  */
86 //void getDefaultAtomicWeights(ct::ctmap_sd& weights) {
87 void getDefaultAtomicWeights(map<string, double>& weights)
88 {
89 
90  // erase existing entries, if any
91  //weights.clear();
92  const int MAX_NUM = 200;
93  int n;
94  for (n = 0; n < MAX_NUM; n++) {
95  if (_symbols[n][0] == '!') {
96  break;
97  }
98  weights[_symbols[n]] = _weights[n];
99  }
100 }
101 
102 void writeKnownElements(ostream& s, string fmt)
103 {
104 
105  const int MAX_NUM = 200;
106  int n;
107  if (fmt == "CK") {
108  for (n = 0; n < MAX_NUM; n++) {
109  if (_symbols[n][0] == '!') {
110  break;
111  }
112  s << " " << string(_symbols[n]) << "/" << _weights[n] << "/" << endl;
113  }
114  } else if (fmt == "XML") {
115  s << "<known_elements>" << endl;
116  for (n = 0; n < MAX_NUM; n++) {
117  if (_symbols[n][0] == '!') {
118  break;
119  }
120  s << " <element>" << _symbols[n] << "<wt>"
121  << _weights[n] << "</wt></element>" << endl;
122  }
123  s << "</known_elements>" << endl;
124  }
125 }
126 }
127