API Reference
Types
ChargedParticles.AbstractParticle — TypeAbstractParticleAbstract type representing any particle in plasma physics.
ChargedParticles.CustomParticle — TypeCustomParticle <: AbstractParticleA particle with user-defined mass and charge.
Fields
mass: The mass of the particle (can be any numeric type or Unitful quantity)charge_number: Integer representing the charge statesymbol: Optional symbol identifier (defaults to nothing)
Examples
CustomParticle(1.67e-27u"kg", 1) # A particle with proton-like mass and +1 charge
CustomParticle(2.0u"GeV", -1, :custom) # A custom particle with specified symbolChargedParticles.Particle — TypeParticle <: AbstractChargeParticleImplementation type for charged particles.
Fields
symbol::Symbol: Chemical symbol or particle identifier (e.g., :Fe, :e, :μ)charge_number::Int: Number of elementary charges (can be negative)mass_number::Int: Total number of nucleons (protons + neutrons). If not provided, defaults to the most common isotope mass number
Notes
- Mass number : For elementary particles like electrons and muons,
mass_numberis 0 - Charge number : electrical charge in units of the elementary charge, usually denoted as z. https://en.wikipedia.org/wiki/Charge_number
Examples
Particle(:Fe, 2) # Creates Fe²⁺ with default mass number
# output
Fe²⁺ChargedParticles.Particle — MethodParticle(p::AbstractParticle)Create a particle from another particle implementation, optionally specifying mass number and charge to override.
Examples
p = Particle("Fe2+")
p2 = Particle(p; mass_numb=54, z=3) # Creates a new instance with same propertiesChargedParticles.SParticle — TypeSParticle{z, Z, A} <: AbstractParticleA type-parameterized implementation of a particle.
Type Parameters
z::Integer: The charge number (number of elementary charges)Z::Integer: The atomic number (number of protons)A::Integer: The mass number (total number of nucleons)
Constructors
SParticle{z,Z,A}() / SParticle{z,Z,A}: Construct a particleSParticle(p::AbstractParticle): Convert any AbstractParticle to an SParticle
All parameters must be integers. The type ensures this at construction time.
Examples
# Create a proton (H+)
proton = SParticle(1, 1, 1)
# Create an alpha particle (He2+)
alpha = SParticle{2,2,4}()Constructors
ChargedParticles.particle — Functionparticle(str::AbstractString; mass_numb=nothing, z=nothing, typed=false)Create a particle from a string representation.
Arguments
str::AbstractString: String representation of the particlemass_numb: Optional mass number overridez: Optional charge number overridetyped: If true, creates a type-parameterized SParticle instead of a regular Particle
String Format Support
- Element symbols:
"Fe","He" - Isotopes:
"Fe-56","D" - Ions:
"Fe2+","H-" - Common aliases:
"electron","proton","alpha","mu-"
Examples
# Elementary particles
electron = particle("e-")
muon = particle("mu-")
positron = particle("e+")
# Ions and isotopes
proton = particle("H+")
alpha = particle("He2+")
deuteron = particle("D+")
iron56 = particle("Fe-56")particle(sym::Symbol)Create a particle from its symbol representation.
Examples
# Elementary particles
electron = particle(:e)
muon = particle(:muon)
proton = particle(:p)particle(atomic_number::Int; mass_numb=nothing, z=0, typed=false)Create a particle from its atomic number with optional mass number and charge state.
Arguments
atomic_number::Int: The atomic number (number of protons)mass_numb=nothing: Optional mass number (total number of nucleons)z=0: Optional charge number (in elementary charge units)typed=false: If true, creates a type-parameterized SParticle instead of a regular Particle
Examples
# Basic construction
iron = particle(26) # Iron
u = particle(92) # Uranium
# With mass number and charge
fe56_3plus = particle(26, mass_numb=56, z=3) # Fe-56³⁺
he4_2plus = particle(2, mass_numb=4, z=2) # ⁴He²⁺ (alpha particle)See also: particle(::AbstractString)
ChargedParticles.proton — FunctionCreate a proton
ChargedParticles.electron — FunctionCreate an electron
Properties
ChargedParticles.mass — FunctionRetrieve the mass of an element isotope.
Return the mass of the particle
ChargedParticles.charge — FunctionReturn the electric charge of the particle in elementary charge units
ChargedParticles.atomic_number — Functionatomic_number(p::AbstractParticle)Return the atomic number (number of protons) of the particle.
Examples
```julia fe = particle("Fe") println(atomic_number(fe)) # 26
e = electron() println(atomic_number(e)) # 0
ChargedParticles.mass_number — Functionmass_number(p::AbstractParticle)Return the mass number (total number of nucleons) of the particle.
Examples
fe56 = particle("Fe-56")
println(mass_number(fe56)) # 56
e = electron()
println(mass_number(e)) # 0Type Checking
ChargedParticles.is_ion — Functionis_ion(p::AbstractParticle)Check if the particle is an ion (has non-zero charge and is not an elementary particle).
Examples
julia> is_ion(Particle("Fe3+"))
true
julia> is_ion(Particle("Fe"))
false
julia> is_ion(electron())
falseChargedParticles.is_chemical_element — Functionis_chemical_element(p::AbstractParticle)Check if the particle is a chemical element.
Examples
julia> is_chemical_element(Particle("Fe"))
true
julia> is_chemical_element(electron())
falseChargedParticles.is_default_isotope — Functionis_default_isotope(p::AbstractParticle)Check if the particle is the default isotope of its element.
Examples
julia> is_default_isotope(Particle("Fe-56"))
true
julia> is_default_isotope(Particle("Fe-57"))
falseChargedParticles.is_proton — Functionis_proton(p::AbstractParticle)Check if the particle is a proton (has symbol 'H', charge +1, and mass number 1).
Examples
julia> ChargedParticles.is_proton(proton())
true
julia> ChargedParticles.is_proton(electron())
falseChargedParticles.is_electron — Functionis_electron(p::AbstractParticle)Check if the particle is an electron (has symbol 'e', charge -1, and electron mass).
Examples
julia> ChargedParticles.is_electron(electron())
true
julia> ChargedParticles.is_electron(proton())
falseConstants
ChargedParticles.PARTICLE_ALIASES — ConstantPARTICLE_ALIASESDictionary of common particle aliases and their corresponding (symbol, charge, mass_number) tuples.
Each entry maps a string alias to a tuple of (symbol, charge, mass_number)