aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/SpeciesPhysicalProperties.cpp
blob: 118db98f2c203e7976e0480fea03ed465bb04ab5 (plain) (blame)
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
/* Copyright 2021 Luca Fedeli Maxence Thevenet
 *
 * This file is part of WarpX.
 *
 * License: BSD-3-Clause-LBNL
 */
#include "SpeciesPhysicalProperties.H"

#include "Utils/WarpXConst.H"

#include <AMReX_AmrCore.H>

#include <limits>
#include <map>
#include <string>

using namespace species;

namespace {
    struct Properties
    {
        amrex::Real mass;
        amrex::Real charge;
    };

    const auto string_to_species = std::map<std::string, PhysicalSpecies>{
        {"unspecified", PhysicalSpecies::unspecified},
        {"electron"   , PhysicalSpecies::electron},
        {"positron"   , PhysicalSpecies::positron},
        {"muon"       , PhysicalSpecies::muon},
        {"antimuon"   , PhysicalSpecies::antimuon},
        {"photon"     , PhysicalSpecies::photon},
        {"neutron"    , PhysicalSpecies::neutron},
        {"hydrogen"   , PhysicalSpecies::hydrogen},
        {"hydrogen1"  , PhysicalSpecies::hydrogen1},
        {"protium"    , PhysicalSpecies::hydrogen1},
        {"hydrogen2"  , PhysicalSpecies::hydrogen2},
        {"deuterium"  , PhysicalSpecies::hydrogen2},
        {"hydrogen3"  , PhysicalSpecies::hydrogen3},
        {"tritium"    , PhysicalSpecies::hydrogen3},
        {"proton"     , PhysicalSpecies::proton},
        {"helium"     , PhysicalSpecies::helium},
        {"helium3"    , PhysicalSpecies::helium3},
        {"helium4"    , PhysicalSpecies::helium4},
        {"alpha"      , PhysicalSpecies::alpha},
        {"lithium"    , PhysicalSpecies::lithium},
        {"lithium6"   , PhysicalSpecies::lithium6},
        {"lithium7"   , PhysicalSpecies::lithium7},
        {"beryllium"  , PhysicalSpecies::beryllium},
        {"beryllium9"  , PhysicalSpecies::beryllium9},
        {"boron"      , PhysicalSpecies::boron},
        {"boron10"    , PhysicalSpecies::boron10},
        {"boron11"    , PhysicalSpecies::boron11},
        {"carbon"     , PhysicalSpecies::carbon},
        {"carbon12"   , PhysicalSpecies::carbon12},
        {"carbon13"   , PhysicalSpecies::carbon13},
        {"carbon14"   , PhysicalSpecies::carbon14},
        {"nitrogen"   , PhysicalSpecies::nitrogen},
        {"nitrogen14" , PhysicalSpecies::nitrogen14},
        {"nitrogen15" , PhysicalSpecies::nitrogen15},
        {"oxygen"     , PhysicalSpecies::oxygen},
        {"oxygen16"   , PhysicalSpecies::oxygen16},
        {"oxygen17"   , PhysicalSpecies::oxygen17},
        {"oxygen18"   , PhysicalSpecies::oxygen18},
        {"fluorine"   , PhysicalSpecies::fluorine},
        {"fluorine19" , PhysicalSpecies::fluorine19},
        {"neon"       , PhysicalSpecies::neon},
        {"neon20"     , PhysicalSpecies::neon20},
        {"neon21"     , PhysicalSpecies::neon21},
        {"neon22"     , PhysicalSpecies::neon22},
        {"aluminium"  , PhysicalSpecies::aluminium},
        {"argon"      , PhysicalSpecies::argon},
        {"copper"     , PhysicalSpecies::copper},
        {"xenon"      , PhysicalSpecies::xenon},
        {"gold"       , PhysicalSpecies::gold},
    };

    const auto species_to_string = std::map<PhysicalSpecies, std::string>{
        {PhysicalSpecies::unspecified, "unspecified"},
        {PhysicalSpecies::electron   , "electron"},
        {PhysicalSpecies::positron   , "positron"},
        {PhysicalSpecies::muon       , "muon"},
        {PhysicalSpecies::antimuon   , "antimuon"},
        {PhysicalSpecies::photon     , "photon"},
        {PhysicalSpecies::neutron    , "neutron"},
        {PhysicalSpecies::hydrogen   , "hydrogen"},
        {PhysicalSpecies::hydrogen1  , "hydrogen1"},
        {PhysicalSpecies::hydrogen2  , "hydrogen2"},
        {PhysicalSpecies::hydrogen3  , "hydrogen3"},
        {PhysicalSpecies::proton     , "proton"},
        {PhysicalSpecies::helium     , "helium"},
        {PhysicalSpecies::helium3    , "helium3"},
        {PhysicalSpecies::helium4    , "helium4"},
        {PhysicalSpecies::alpha      , "alpha"},
        {PhysicalSpecies::lithium    , "lithium"},
        {PhysicalSpecies::lithium6   , "lithium6"},
        {PhysicalSpecies::lithium7   , "lithium7"},
        {PhysicalSpecies::beryllium  , "beryllium"},
        {PhysicalSpecies::beryllium9 , "beryllium9"},
        {PhysicalSpecies::boron      , "boron"},
        {PhysicalSpecies::boron10    , "boron10"},
        {PhysicalSpecies::boron11    , "boron11"},
        {PhysicalSpecies::carbon     , "carbon"},
        {PhysicalSpecies::carbon12   , "carbon12"},
        {PhysicalSpecies::carbon13   , "carbon13"},
        {PhysicalSpecies::carbon14   , "carbon14"},
        {PhysicalSpecies::nitrogen   , "nitrogen"},
        {PhysicalSpecies::nitrogen14 , "nitrogen14"},
        {PhysicalSpecies::nitrogen15 , "nitrogen15"},
        {PhysicalSpecies::oxygen     , "oxygen"},
        {PhysicalSpecies::oxygen16   , "oxygen16"},
        {PhysicalSpecies::oxygen17   , "oxygen17"},
        {PhysicalSpecies::oxygen18   , "oxygen18"},
        {PhysicalSpecies::fluorine   , "fluorine"},
        {PhysicalSpecies::fluorine19 , "fluorine19"},
        {PhysicalSpecies::neon       , "neon"},
        {PhysicalSpecies::neon20     , "neon20"},
        {PhysicalSpecies::neon21     , "neon21"},
        {PhysicalSpecies::neon22     , "neon22"},
        {PhysicalSpecies::aluminium  , "aluminium"},
        {PhysicalSpecies::argon      , "argon"},
        {PhysicalSpecies::copper     , "copper"},
        {PhysicalSpecies::xenon      , "xenon"},
        {PhysicalSpecies::gold       , "gold"}
    };

    constexpr auto quiet_NaN = std::numeric_limits<amrex::Real>::quiet_NaN();

    // The atomic mass data below is from this NIST page
    // https://physics.nist.gov/cgi-bin/Compositions/stand_alone.pl?ele=&ascii=ascii2&isotype=some
    const
    std::map<PhysicalSpecies,Properties> species_to_properties
    {
        {PhysicalSpecies::unspecified, Properties{
            quiet_NaN,
            quiet_NaN}},
        {PhysicalSpecies::electron, Properties{
            PhysConst::m_e,
            -PhysConst::q_e}},
        {PhysicalSpecies::positron, Properties{
            PhysConst::m_e,
            PhysConst::q_e}},
        {PhysicalSpecies::muon, Properties{
            amrex::Real(206.7682830) * PhysConst::m_e,
            -PhysConst::q_e}},
        {PhysicalSpecies::antimuon, Properties{
            amrex::Real(206.7682830) * PhysConst::m_e,
            PhysConst::q_e}},
        {PhysicalSpecies::photon, Properties{
            amrex::Real(0.0),
            amrex::Real(0.0)}},
        {PhysicalSpecies::neutron, Properties{
            amrex::Real(1.0013784193052508) * PhysConst::m_p,
            amrex::Real(0.0)}},
        {PhysicalSpecies::proton, Properties{
             PhysConst::m_p,
             PhysConst::q_e}},
        {PhysicalSpecies::hydrogen, Properties{
             amrex::Real(1.00797) * PhysConst::m_u,
             amrex::Real(1) * PhysConst::q_e}},
        {PhysicalSpecies::hydrogen1, Properties{
             amrex::Real(1.00782503223) * PhysConst::m_u,
             amrex::Real(1) * PhysConst::q_e}},
        {PhysicalSpecies::hydrogen2, Properties{
             amrex::Real(2.01410177812) * PhysConst::m_u,
             amrex::Real(1) * PhysConst::q_e}},
        {PhysicalSpecies::hydrogen3, Properties{
             amrex::Real(3.0160492779) * PhysConst::m_u,
             amrex::Real(1) * PhysConst::q_e}},
        {PhysicalSpecies::helium, Properties{
             amrex::Real(4.002602) * PhysConst::m_u,
             amrex::Real(2) * PhysConst::q_e}},
        {PhysicalSpecies::helium3, Properties{
             amrex::Real(3.0160293201) * PhysConst::m_u,
             amrex::Real(2) * PhysConst::q_e}},
        {PhysicalSpecies::helium4, Properties{
             amrex::Real(4.00260325413) * PhysConst::m_u,
             amrex::Real(2) * PhysConst::q_e}},
        {PhysicalSpecies::alpha, Properties{
             amrex::Real(4.00260325413) * PhysConst::m_u - amrex::Real(2) * PhysConst::m_e,
             amrex::Real(2) * PhysConst::q_e}},
        {PhysicalSpecies::lithium, Properties{
             amrex::Real(6.967) * PhysConst::m_u,
             amrex::Real(3) * PhysConst::q_e}},
        {PhysicalSpecies::lithium6, Properties{
             amrex::Real(6.0151228874) * PhysConst::m_u,
             amrex::Real(3) * PhysConst::q_e}},
        {PhysicalSpecies::lithium7, Properties{
             amrex::Real(7.0160034366) * PhysConst::m_u,
             amrex::Real(3) * PhysConst::q_e}},
        {PhysicalSpecies::beryllium, Properties{
             amrex::Real(9.0121831) * PhysConst::m_u,
             amrex::Real(4) * PhysConst::q_e}},
        {PhysicalSpecies::beryllium9, Properties{
             amrex::Real(9.012183065) * PhysConst::m_u,
             amrex::Real(4) * PhysConst::q_e}},
        {PhysicalSpecies::boron, Properties{
             amrex::Real(10.813) * PhysConst::m_u,
             amrex::Real(5) * PhysConst::q_e}},
        {PhysicalSpecies::boron10, Properties{
             amrex::Real(10.01293695) * PhysConst::m_u,
             amrex::Real(5) * PhysConst::q_e}},
        {PhysicalSpecies::boron11, Properties{
             amrex::Real(11.00930536) * PhysConst::m_u,
             amrex::Real(5) * PhysConst::q_e}},
        {PhysicalSpecies::carbon, Properties{
             amrex::Real(12.0106) * PhysConst::m_u,
             amrex::Real(6) * PhysConst::q_e}},
        {PhysicalSpecies::carbon12, Properties{
             amrex::Real(12.0000000) * PhysConst::m_u,
             amrex::Real(6) * PhysConst::q_e}},
        {PhysicalSpecies::carbon13, Properties{
             amrex::Real(13.00335483507) * PhysConst::m_u,
             amrex::Real(6) * PhysConst::q_e}},
        {PhysicalSpecies::carbon14, Properties{
             amrex::Real(14.0032419884) * PhysConst::m_u,
             amrex::Real(6) * PhysConst::q_e}},
        {PhysicalSpecies::nitrogen, Properties{
             amrex::Real(14.00685) * PhysConst::m_u,
             amrex::Real(7) * PhysConst::q_e}},
        {PhysicalSpecies::nitrogen14, Properties{
             amrex::Real(14.00307400443) * PhysConst::m_u,
             amrex::Real(7) * PhysConst::q_e}},
        {PhysicalSpecies::nitrogen15, Properties{
             amrex::Real(15.00010889888) * PhysConst::m_u,
             amrex::Real(7) * PhysConst::q_e}},
        {PhysicalSpecies::oxygen, Properties{
             amrex::Real(15.9994) * PhysConst::m_u,
             amrex::Real(8) * PhysConst::q_e}},
        {PhysicalSpecies::oxygen16, Properties{
             amrex::Real(15.99491461957) * PhysConst::m_u,
             amrex::Real(8) * PhysConst::q_e}},
        {PhysicalSpecies::oxygen17, Properties{
             amrex::Real(16.99913175650) * PhysConst::m_u,
             amrex::Real(8) * PhysConst::q_e}},
        {PhysicalSpecies::oxygen18, Properties{
             amrex::Real(17.99915961286) * PhysConst::m_u,
             amrex::Real(8) * PhysConst::q_e}},
        {PhysicalSpecies::fluorine, Properties{
             amrex::Real(18.998403163) * PhysConst::m_u,
             amrex::Real(9) * PhysConst::q_e}},
        {PhysicalSpecies::fluorine19, Properties{
             amrex::Real(18.99840316273) * PhysConst::m_u,
             amrex::Real(9) * PhysConst::q_e}},
        {PhysicalSpecies::neon, Properties{
             amrex::Real(20.1797) * PhysConst::m_u,
             amrex::Real(10) * PhysConst::q_e}},
        {PhysicalSpecies::neon20, Properties{
             amrex::Real(19.9924401762) * PhysConst::m_u,
             amrex::Real(10) * PhysConst::q_e}},
        {PhysicalSpecies::neon21, Properties{
             amrex::Real(20.993846685) * PhysConst::m_u,
             amrex::Real(10) * PhysConst::q_e}},
        {PhysicalSpecies::neon22, Properties{
             amrex::Real(21.991385114) * PhysConst::m_u,
             amrex::Real(10) * PhysConst::q_e}},
        {PhysicalSpecies::aluminium, Properties{
             amrex::Real(26.98153853) * PhysConst::m_u,
             amrex::Real(13) * PhysConst::q_e}},
        {PhysicalSpecies::argon, Properties{
             amrex::Real(39.948) * PhysConst::m_u,
             amrex::Real(18) * PhysConst::q_e}},
        {PhysicalSpecies::copper, Properties{
             amrex::Real(63.546) * PhysConst::m_u,
             amrex::Real(29) * PhysConst::q_e}},
        {PhysicalSpecies::xenon, Properties{
             amrex::Real(131.293) * PhysConst::m_u,
             amrex::Real(54) * PhysConst::q_e}},
        {PhysicalSpecies::gold, Properties{
             amrex::Real(196.966569) * PhysConst::m_u,
             amrex::Real(79) * PhysConst::q_e}},
    };
}

namespace species
{
    std::optional<PhysicalSpecies> from_string(const std::string& species)
    {
        const auto phys_spec = string_to_species.find(species);
        return (phys_spec != string_to_species.end())?
            std::make_optional(phys_spec->second) : std::nullopt;
    }

    amrex::Real get_charge (const PhysicalSpecies& ps)
    {
        return species_to_properties.at(ps).charge;
    }

    amrex::Real get_mass (const PhysicalSpecies& ps)
    {
        return species_to_properties.at(ps).mass;
    }

    std::string get_name (const PhysicalSpecies& ps)
    {
        return species_to_string.at(ps);
    }
}