The plasmapy.particles subpackage contains functions to access basic particle data and classes to represent particles.
from plasmapy.particles import *
from plasmapy.particles.particle_class import valid_categories
There are several functions that provide information about different particles that might be present in a plasma. The input of these functions is a representation of a particle, such as a string for the atomic symbol or the element name.
atomic_number("Fe")
We can provide a number that represents the atomic number.
element_name(26)
We can also provide standard symbols or the names of particles.
is_stable("e-")
charge_number("proton")
The symbols for many particles can even be used directly, such as for an alpha particle. To create an "α" in a Jupyter notebook, type \alpha
and press tab.
particle_mass("α")
We can represent isotopes with the atomic symbol followed by a hyphen and the mass number. In this example, half_life returns the time in seconds as a Quantity from astropy.units.
half_life("C-14")
We typically represent an ion in a string by putting together the atomic symbol or isotope symbol, a space, the charge number, and the sign of the charge.
charge_number("Fe-56 13+")
Functions in plasmapy.particles are quite flexible in terms of string inputs representing particles. An input is particle-like if it can be transformed into a Particle.
particle_mass("iron-56 +13")
particle_mass("iron-56+++++++++++++")
Most of these functions take additional arguments, with Z
representing the charge number of an ion and mass_numb
representing the mass number of an isotope. These arguments are often keyword-only to avoid ambiguity.
particle_mass("Fe", Z=13, mass_numb=56)
Up until now, we have been using functions that accept representations of particles and then return particle properties. With the Particle class, we can create objects that represent physical particles.
proton = Particle("p+")
electron = Particle("electron")
iron56_nuclide = Particle("Fe", Z=26, mass_numb=56)
Particle properties can be accessed via attributes of the Particle class.
proton.mass
electron.charge
electron.charge_number
iron56_nuclide.binding_energy
electron.antiparticle
We can also use the tilde operator on a Particle to get its antiparticle.
~proton
deuterium = Particle("D 0+")
deuterium.ionize()
When provided with a number, these methods tell how many bound electrons to add or remove.
alpha = Particle("alpha")
alpha.recombine(2)
If the inplace
keyword is set to True
, then the Particle will be replaced with the new particle.
argon = Particle("Ar 0+")
argon.ionize(inplace=True)
print(argon)
Sometimes we want to use a particle with custom properties. For example, we might want to represent an average ion in a multi-species plasma. For that we can use CustomParticle.
from astropy import constants as const
from astropy import units as u
custom_particle = CustomParticle(9.27e-26 * u.kg, 13.6 * const.e.si, symbol="Fe 13.6+")
Many of the attributes of CustomParticle are the same as in Particle.
custom_particle.mass
custom_particle.charge
custom_particle.symbol
If we do not include one of the physical quantities, it gets set to nan (not a number) in the appropriate units.
CustomParticle(9.27e-26 * u.kg).charge
CustomParticle objects are not yet able to be used by many of the functions in plasmapy.formulary, but are expected to become compatible with them in a future release of PlasmaPy. Similarly, CustomParticle objects are not able to be used by the functions in plasmapy.particles that require that the particle be real.
The ParticleList class is a container for Particle and CustomParticle objects.
iron_ions = ParticleList(["Fe 12+", "Fe 13+", "Fe 14+"])
By using a ParticleList, we can access the properties of multiple particles at once.
iron_ions.mass
iron_ions.charge
iron_ions.symbols
We can also create a ParticleList by adding Particle and/or CustomParticle objects together.
proton + electron + custom_particle
We can use molecule to create a CustomParticle based on a chemical formula. The first argument to molecule is a string that represents a chemical formula, except that the subscript numbers are not given as subscripts. For example, water is "H2O"
.
water = molecule("H2O")
water.symbol
The properties of the molecule are found automatically.
water.mass
acetic_acid_anion = molecule("CH3COOH 1-")
acetic_acid_anion.charge
The categories attribute of a Particle provides a set of the categories that the Particle belongs to.
muon = Particle("muon")
muon.categories
The is_category() method lets us determine if a Particle belongs to one or more categories.
muon.is_category("lepton")
electron.is_category(require="lepton", exclude="baryon", any_of={"boson", "fermion"})
All valid particle categories are included in valid_categories.
print(valid_categories)
The is_category() method of ParticleList returns a list
of boolean values which correspond to whether or not each particle in the list meets the categorization criteria.
particles = ParticleList(["e-", "p+", "n"])
particles.is_category(require="lepton")
When we need a dimensionless representation of a particle, we can use the DimensionlessParticle class.
dimensionless_particle = DimensionlessParticle(mass=0.000545, charge=-1)
The properties of dimensionless particles may be accessed by its attributes.
dimensionless_particle.mass
dimensionless_particle.charge
Because a DimensionlessParticle does not uniquely describe a physical particle, it cannot be contained in a ParticleList.
We can use plasmapy.particles to calculate the energy of a nuclear reaction using the >
operator.
deuteron = Particle("D+")
triton = Particle("T+")
alpha = Particle("α")
neutron = Particle("n")
energy = deuteron + triton > alpha + neutron
energy.to("MeV")
If the nuclear reaction is invalid, then an exception is raised that states the reason why.
%xmode minimal
deuteron + triton > alpha + 3 * neutron