-
Notifications
You must be signed in to change notification settings - Fork 306
/
_special_particles.py
300 lines (247 loc) · 9.19 KB
/
_special_particles.py
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
299
300
"""
Classes, sets, and dictionaries to store data and taxonomy information
for special particles.
"""
__all__ = [
"antiparticles",
"create_particles_dict",
"data_about_special_particles",
"particle_zoo",
"ParticleZoo",
"special_ion_masses",
]
import astropy.constants as const
import astropy.units as u
import numpy as np
from plasmapy.particles import _elements
class ParticleZoo:
"""
Create an object with taxonomy information for special particles.
The `~plasmapy.particles._special_particles._ParticleZooClass._taxonomy_dict`
attribute contains the name of each classification (e.g.,
``'lepton'``, ``'baryon'``, ``'matter'``, etc.) as the keys and a
set of particle symbol strings of the particles belonging to that
classification.
The attributes of this class provide sets of strings representing
particles in the corresponding category.
Examples
--------
>>> particle_zoo_ = ParticleZoo()
>>> 'e-' in particle_zoo_.leptons
True
>>> 'nu_e' in particle_zoo_.antineutrinos
False
>>> 'mu+' in particle_zoo_.antiparticles
True
"""
def __init__(self):
leptons = {"e-", "mu-", "tau-", "nu_e", "nu_mu", "nu_tau"}
antileptons = {"e+", "mu+", "tau+", "anti_nu_e", "anti_nu_mu", "anti_nu_tau"}
baryons = {"p+", "n"}
antibaryons = {"p-", "antineutron"}
particles = leptons | baryons
antiparticles = antileptons | antibaryons
fermions = leptons | antileptons | baryons | antibaryons
bosons = set()
neutrinos = {lepton for lepton in leptons if "nu" in lepton}
antineutrinos = {antilepton for antilepton in antileptons if "nu" in antilepton}
self._taxonomy_dict = {
"lepton": leptons,
"antilepton": antileptons,
"baryon": baryons,
"antibaryon": antibaryons,
"fermion": fermions,
"boson": bosons,
"neutrino": neutrinos,
"antineutrinos": antineutrinos,
"matter": particles,
"antimatter": antiparticles,
}
@property
def leptons(self) -> set[str]:
"""Return all leptons, excluding antileptons."""
return self._taxonomy_dict["lepton"]
@property
def antileptons(self) -> set[str]:
"""Return all antileptons."""
return self._taxonomy_dict["antilepton"]
@property
def baryons(self) -> set[str]:
"""Return all baryons, excluding antibaryons."""
return self._taxonomy_dict["baryon"]
@property
def antibaryons(self) -> set[str]:
"""Return all antibaryons."""
return self._taxonomy_dict["antibaryon"]
@property
def fermions(self) -> set[str]:
"""Return all fermions."""
return self._taxonomy_dict["fermion"]
@property
def bosons(self) -> set[str]:
"""Return all bosons."""
return self._taxonomy_dict["boson"]
@property
def neutrinos(self) -> set[str]:
"""Return all neutrinos."""
return self._taxonomy_dict["neutrino"]
@property
def antineutrinos(self) -> set[str]:
"""Return all antineutrinos."""
return self._taxonomy_dict["antineutrinos"]
@property
def particles(self) -> set[str]:
"""Return all particles, excluding antiparticles."""
return self._taxonomy_dict["matter"]
@property
def antiparticles(self) -> set[str]:
"""Return all antiparticles."""
return self._taxonomy_dict["antimatter"]
@property
def everything(self) -> set[str]:
"""Return all particles and antiparticles."""
return self._taxonomy_dict["matter"] | self._taxonomy_dict["antimatter"]
particle_zoo = ParticleZoo()
particle_zoo.__doc__ = """
Data container for representations of "special" particles, like leptons
and baryons.
An instance of `~plasmapy.particles._special_particles.ParticleZoo`.
"""
def create_particles_dict() -> dict[str, dict]:
"""
Create a dictionary of dictionaries that contains physical
information for particles and antiparticles that are not elements or
ions.
The keys of the top-level dictionary are the standard particle
symbols. The values of the top-level dictionary are dictionaries for
each particle or antiparticle with strings such as ``'name'``,
``'mass'``, and ``'spin'`` as the keys and the corresponding atomic
properties as symbols.
"""
symbols_and_names = [
("e-", "electron"),
("e+", "positron"),
("mu-", "muon"),
("mu+", "antimuon"),
("tau-", "tau"),
("tau+", "antitau"),
("nu_e", "electron neutrino"),
("anti_nu_e", "electron antineutrino"),
("nu_mu", "muon neutrino"),
("anti_nu_mu", "muon antineutrino"),
("nu_tau", "tau neutrino"),
("anti_nu_tau", "tau antineutrino"),
("p+", "proton"),
("p-", "antiproton"),
("n", "neutron"),
("antineutron", "antineutron"),
]
particles = {particle: {} for particle in particle_zoo.everything}
for symbol, name in symbols_and_names:
particles[symbol]["name"] = name
for fermion in particle_zoo.fermions:
particles[fermion]["spin"] = 0.5
for boson in particle_zoo.bosons: # coverage: ignore
particles[boson]["spin"] = 0
for lepton in particle_zoo.leptons:
particles[lepton]["class"] = "lepton"
particles[lepton]["lepton number"] = 1
particles[lepton]["baryon number"] = 0
if lepton not in particle_zoo.neutrinos:
particles[lepton]["charge number"] = -1
else:
particles[lepton]["charge number"] = 0
for antilepton in particle_zoo.antileptons:
particles[antilepton]["class"] = "antilepton"
particles[antilepton]["lepton number"] = -1
particles[antilepton]["baryon number"] = 0
if antilepton not in particle_zoo.antineutrinos:
particles[antilepton]["charge number"] = 1
else:
particles[antilepton]["charge number"] = 0
for baryon in particle_zoo.baryons:
particles[baryon]["class"] = "baryon"
particles[baryon]["lepton number"] = 0
particles[baryon]["baryon number"] = 1
for antibaryon in particle_zoo.antibaryons:
particles[antibaryon]["class"] = "antibaryon"
particles[antibaryon]["lepton number"] = 0
particles[antibaryon]["baryon number"] = -1
for particle in particle_zoo.leptons | particle_zoo.antileptons:
if "e" in particle:
particles[particle]["generation"] = 1
elif "mu" in particle:
particles[particle]["generation"] = 2
elif "tau" in particle:
particles[particle]["generation"] = 3
for particle in particle_zoo.leptons | particle_zoo.antileptons:
if "nu" not in particle:
if "e" in particle:
particles[particle]["mass"] = const.m_e
elif "mu" in particle:
particles[particle]["mass"] = 1.883_531_594e-28 * u.kg
particles[particle]["half-life"] = 2.1969811e-6 * u.s
elif "tau" in particle:
particles[particle]["mass"] = 3.167_47e-27 * u.kg
particles[particle]["half-life"] = 2.906e-13 * u.s
# Setting the neutrino mass to None reminds us that, while neutrinos
# are not massless, we only have upper limits on what the neutrino
# mass actually is.
for particle in particle_zoo.neutrinos | particle_zoo.antineutrinos:
particles[particle]["mass"] = None
special_attributes = {
"p+": {
"element": "H",
"atomic number": 1,
"mass number": 1,
"element name": "hydrogen",
"isotope": "H-1",
"ion": "p+",
"mass": const.m_p,
"charge number": 1,
"periodic table": _elements.PeriodicTable(
group=1, period=1, block="s", category="nonmetal"
),
},
"p-": {"mass": const.m_p, "charge number": -1},
"n": {"mass": const.m_n, "half-life": 881.5 * u.s, "charge number": 0},
"antineutron": {
"mass": const.m_n,
"half-life": 881.5 * u.s,
"charge number": 0,
},
}
for particle in special_attributes:
particles[particle] = {**special_attributes[particle], **particles[particle]}
for particle in particle_zoo.everything:
if "half-life" not in particles[particle]:
particles[particle]["half-life"] = np.inf * u.s
for particle in particle_zoo.particles:
particles[particle]["antimatter"] = False
for antiparticle in particle_zoo.antiparticles:
particles[antiparticle]["antimatter"] = True
return particles
data_about_special_particles = create_particles_dict()
special_ion_masses = {
"p+": const.m_p,
"D 1+": 3.343583719e-27 * u.kg,
"T 1+": 5.007356665e-27 * u.kg,
}
antiparticles = {
"p+": "p-",
"n": "antineutron",
"e-": "e+",
"mu-": "mu+",
"tau-": "tau+",
"nu_e": "anti_nu_e",
"nu_mu": "anti_nu_mu",
"nu_tau": "anti_nu_tau",
"p-": "p+",
"antineutron": "n",
"e+": "e-",
"mu+": "mu-",
"tau+": "tau-",
"anti_nu_e": "nu_e",
"anti_nu_mu": "nu_mu",
"anti_nu_tau": "nu_tau",
}