ParticleLike

plasmapy.particles.particle_class.ParticleLike

An object is particle-like if it can be identified as an instance of Particle or CustomParticle, or cast into one.

When used as a type hint annotation, ParticleLike indicates that an argument should represent a physical particle. Particle-like objects can include strings, integers, or instances of the Particle or CustomParticle classes.

Notes

Real world particles are typically represented as instances of the Particle class in PlasmaPy.

>>> from plasmapy.particles import Particle
>>> Particle("proton")
Particle("p+")

All Particle instances, and objects that can be cast into Particle instances, are particle-like.

  • Elements

    An element may also be represented by a string that contains the atomic symbol (case-sensitive) or the name of the element, or an integer representing the atomic number. The element iron can be represented as "Fe", "iron", "Iron", 26, or Particle("Fe").

  • Isotopes

    An isotope may be represented by a string that contains an atomic symbol or element name, followed by a hyphen and the mass number (with no spaces in between). The isotope 56Fe can be represented as "Fe-56", "iron-56", or Particle("Fe-56"). 1H can be represented by "protium", 2H can be represented by "D" or "deuterium", and 3H can be represented by "T" or "tritium".

  • Ions

    An ion or ionic level may be represented by a string that contains a representation of an element or isotope, followed by charge information. For example, "He 1+", "He+", "helium 1+", and "He II" all represent singly ionized helium.

    Charge information is typically separated from the element or isotope by a space, and given as an integer paired with a plus or minus sign. The sign can either precede or follow the integer (e.g., "Fe 0+" or "Fe +0"). The charge information can also be given as a series of plus signs or of minus signs that immediately follow the element or isotope (e.g., "Fe++" for Fe2+).

    Ions can also be represented using Roman numeral notation, where the Roman numeral indicates the charge number plus one (e.g., "H I" represents H0+ and "He-4 II" represents 4He1+).

    D1+ can also be represented by "deuteron", T1+ can be represented by "triton", and 4He2+ can be represented by "alpha".

  • Special particles

    A special particle may be represented by a string that contains the name of the particle (case-insensitive) or a standard symbol for it (case-sensitive). A neutron can be represented as "n" or "neutron"; a proton can be represented as "p+", "p", or "Proton"; and an electron can be represented by "e-", "e", or "ELECTRON".

  • Custom particles

    CustomParticle instances are particle-like because particle properties are provided in physical units.

Note

DimensionlessParticle instances are not particle-like because, without normalization information, they do not uniquely identify a physical particle.

Examples

Using ParticleLike as a type hint annotation indicates that an argument or variable should represent a physical particle.

>>> from plasmapy.particles import ParticleLike, Particle
>>> def is_electron(particle: ParticleLike):
...     return particle == Particle("e-")

alias of Union[str, numbers.Integral, plasmapy.particles.particle_class.Particle, plasmapy.particles.particle_class.CustomParticle]