IonizationStateCollectionο
- class plasmapy.particles.ionization_state_collection.IonizationStateCollection(
- inputs: dict[str,
- ~numpy.ndarray] | list | tuple,
- *,
- T_e: ~typing.Annotated[~astropy.units.quantity.Quantity,
- Unit("K")] = <Quantity nan K>,
- abundances: dict[str,
- float] | None = None,
- log_abundances: dict[str,
- float] | None = None,
- n0: ~typing.Annotated[~astropy.units.quantity.Quantity,
- Unit("1 / m3")] = <Quantity nan 1 / m3>,
- tol: float = 1e-15,
- kappa: float = inf,
Bases:
objectDescribe the ionization state distributions of multiple elements or isotopes.
- Parameters:
inputs (
list,tuple, ordict) β Alistortupleof elements or isotopes (ifT_eis provided); alistofIonizationStateinstances; adictwith elements or isotopes as keys and andarrayof ionic fractions as the values; or adictwith elements or isotopes as keys andQuantityinstances with units of number density.abundances (
dict, keyword-only, optional) β AdictwithParticleLikeobjects used as the keys and the corresponding relative abundance as the values. The values must be positive real numbers.log_abundances (
dict, keyword-only, optional) β AdictwithParticleLikeobjects used as the keys and the corresponding base 10 logarithms of their relative abundances as the values. The values must be real numbers.n0 (
Quantity, keyword-only, optional) β The number density normalization factor corresponding to the abundances. The number density of each element is the product of its abundance andn0.T_e (
Quantity, keyword-only, optional) β The electron temperature in units of temperature or thermal energy per particle.kappa (
float, keyword-only, optional) β The value of kappa for a kappa distribution function.tol (
floatorinteger, keyword-only, default:1e-15) β The absolute tolerance used byisclosewhen testing normalizations and making comparisons.
- Raises:
ParticleError β If this class cannot be instantiated.
See also
Examples
>>> import astropy.units as u >>> from plasmapy.particles import IonizationStateCollection >>> states = IonizationStateCollection( ... {"H": [0.5, 0.5], "He": [0.95, 0.05, 0]}, ... T_e=1.2e4 * u.K, ... n0=1e15 * u.m**-3, ... abundances={"H": 1, "He": 0.08}, ... ) >>> states.ionic_fractions {'H': array([0.5, 0.5]), 'He': array([0.95, 0.05, 0. ])}
The number densities are given by the ionic fractions multiplied by the abundance and the number density scaling factor
n0.>>> states.number_densities["H"] <Quantity [5.e+14, 5.e+14] 1 / m3> >>> states["He"] = [0.4, 0.59, 0.01]
To change the ionic fractions for a single element, use item assignment.
>>> states = IonizationStateCollection(["H", "He"]) >>> states["H"] = [0.1, 0.9]
Item assignment will also work if you supply number densities.
>>> states["He"] = [0.4, 0.6, 0.0] * u.m**-3 >>> states.ionic_fractions["He"] array([0.4, 0.6, 0. ]) >>> states.number_densities["He"] <Quantity [0.4, 0.6, 0. ] 1 / m3>
Notes
No more than one of
abundancesandlog_abundancesmay be specified.If the value provided during item assignment is a
Quantitywith units of number density that retains the total element density, then the ionic fractions will be set proportionately.When making comparisons between
IonizationStateCollectioninstances,nanvalues are treated as equal. Equality tests are performed to within a tolerance oftol.Attributes Summary
The electron temperature.
The elemental abundances.
A
listof the elements and isotopes whose ionization states are being kept track of.A
dictcontaining the ionic fractions for each element and isotope.The ΞΊ parameter for a kappa distribution function for electrons.
A
dictwith atomic or isotope symbols as keys and the base 10 logarithms of the relative abundances as the corresponding values.The number density scaling factor.
The electron number density under the assumption of quasineutrality.
A
dictcontaining the number densities for the elements and/or isotopes composing the collection.The absolute tolerance for comparisons.
Methods Summary
average_ion(*[,Β include_neutrals,Β ...])Return a
CustomParticlerepresenting the mean particle included across all ionization states.Normalize the ionic fractions so that the sum for each element equals one.
summarize([minimum_ionic_fraction])Print quicklook information.
Attributes Documentation
- T_eο
The electron temperature.
- abundancesο
The elemental abundances.
- base_particlesο
A
listof the elements and isotopes whose ionization states are being kept track of.
- ionic_fractionsο
A
dictcontaining the ionic fractions for each element and isotope.The keys of this
dictare the symbols for each element or isotope. The values will bendarrayobjects containing the ionic fractions for each ionization level corresponding to each element or isotope.
- kappaο
The ΞΊ parameter for a kappa distribution function for electrons.
The value of
kappamust be greater than1.5in order to have a valid distribution function. Ifkappaequalsinf, then the distribution function reduces to a Maxwellian.
- log_abundancesο
A
dictwith atomic or isotope symbols as keys and the base 10 logarithms of the relative abundances as the corresponding values.
- n0ο
The number density scaling factor.
- n_eο
The electron number density under the assumption of quasineutrality.
- number_densitiesο
A
dictcontaining the number densities for the elements and/or isotopes composing the collection.
- tolο
The absolute tolerance for comparisons.
Methods Documentation
- average_ion( ) CustomParticle[source]ο
Return a
CustomParticlerepresenting the mean particle included across all ionization states.By default, this method will use the weighted mean to calculate the properties of the
CustomParticle, where the weights for each ionic level is given by its ionic fraction multiplied by the abundance of the base element or isotope. Ifuse_rms_chargeoruse_rms_massisTrue, then this method will return the root mean square of the charge or mass, respectively.- Parameters:
include_neutrals (
bool, keyword-only, default:True) β IfTrue, include neutrals when calculating the mean values of the different particles. IfFalse, exclude neutrals.use_rms_charge (
bool, keyword-only, default:False) β IfTrue, use the root-mean-square charge instead of the mean charge.use_rms_mass (
bool, keyword-only, default:False) β IfTrue, use the root-mean-square mass instead of the mean mass.
- Raises:
ParticleError β If the abundance of any of the elements or isotopes is not defined and the
IonizationStateCollectioninstance includes more than one element or isotope.- Return type:
Examples
>>> states = IonizationStateCollection( ... {"H": [0.1, 0.9], "He": [0, 0.1, 0.9]}, abundances={"H": 1, "He": 0.1} ... ) >>> states.average_ion() CustomParticle(mass=2.12498...e-27 kg, charge=1.5876...e-19 C) >>> states.average_ion( ... include_neutrals=False, ... use_rms_charge=True, ... use_rms_mass=True, ... ) CustomParticle(mass=2.633...e-27 kg, charge=1.805...e-19 C)
- normalize() None[source]ο
Normalize the ionic fractions so that the sum for each element equals one.
- summarize(minimum_ionic_fraction: float = 0.01) None[source]ο
Print quicklook information.
- Parameters:
minimum_ionic_fraction (
float, default:0.01) β If the ionic fraction for a particular ionization state is below this level, then information for it will not be printed.
Examples
>>> import astropy.units as u >>> states = IonizationStateCollection( ... {"H": [0.1, 0.9], "He": [0.95, 0.05, 0.0]}, ... T_e=12000 * u.K, ... n0=3e9 * u.cm**-3, ... abundances={"H": 1.0, "He": 0.1}, ... kappa=3.4, ... ) >>> states.summarize() IonizationStateCollection instance for: H, He ---------------------------------------------------------------- H 0+: 0.100 n_i = 3.00e+14 m**-3 T_i = 1.20e+04 K H 1+: 0.900 n_i = 2.70e+15 m**-3 T_i = 1.20e+04 K ---------------------------------------------------------------- He 0+: 0.950 n_i = 2.85e+14 m**-3 T_i = 1.20e+04 K He 1+: 0.050 n_i = 1.50e+13 m**-3 T_i = 1.20e+04 K ---------------------------------------------------------------- n_e = 2.71e+15 m**-3 T_e = 1.20e+04 K kappa = 3.40 ----------------------------------------------------------------