mass_density
- plasmapy.formulary.misc.mass_density(density: (Unit('1 / m3'), Unit('kg / m3')), particle: str | Integral | Particle | CustomParticle | Quantity, z_ratio: Real | None = 1)[source]
Calculate the mass density from a number density.
\[\rho = \left| \frac{Z_{s}}{Z_{particle}} \right| n_{s} m_{particle} = | Z_{ratio} | n_{s} m_{particle}\]where \(m_{particle}\) is the particle mass, \(n_{s}\) is a number density for plasma species \(s\), \(Z_{s}\) is the charge number of species \(s\), and \(Z_{particle}\) is the charge number of
particle
. For example, if the electron density is given for \(n_s\) andparticle
is a doubly ionized atom, then \(Z_{ratio} = -1 / 2\).Aliases:
rho_
- Parameters:
density (
Quantity
) – Either a particle number density (in units of m-3 or equivalent) or a mass density (in units of kg / m3 or equivalent). Ifdensity
is a mass density, then it will be passed through and returned without modification.particle (
Particle
) – The particle for which the mass density is being calculated for. Must be aParticle
or a value convertible to aParticle
(e.g.,'p'
for protons,'D+'
for deuterium, or'He-4 +1'
for singly ionized helium-4).z_ratio (
int
,float
, optional) – The ratio of the charge numbers corresponding to the plasma species represented bydensity
and theparticle
. For example, if the givendensity
is and electron density andparticle
is doubly ionizedHe
, thenz_ratio = -0.5
. Default is1
.
- Raises:
UnitTypeError – If the
density
does not have units equivalent to a number density or mass density.TypeError – If
density
is not of typeQuantity
, or convertible.TypeError – If
particle
is not of type or convertible toParticle
.ValueError – If
density
is negative.
- Returns:
The mass density for the plasma species represented by
particle
.- Return type:
Examples
>>> import astropy.units as u >>> mass_density(1 * u.m ** -3, 'p') <Quantity 1.67262...e-27 kg / m3> >>> mass_density(4 * u.m ** -3, 'D+') <Quantity 1.33743...e-26 kg / m3> >>> mass_density(2.e12 * u.cm ** -3, 'He') <Quantity 1.32929...e-08 kg / m3> >>> mass_density(2.e12 * u.cm ** -3, 'He', z_ratio=0.5) <Quantity 6.64647...e-09 kg / m3> >>> mass_density(1.0 * u.g * u.m ** -3, "") <Quantity 0.001 kg / m3>