# mass_density

plasmapy.formulary.misc.mass_density(density: (Unit('1 / m3'), Unit('kg / m3')), particle: , z_ratio: = 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$$ and particle 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). If density 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 a Particle or a value convertible to a Particle (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 by density and the particle. For example, if the given density is and electron density and particle is doubly ionized He, then z_ratio = -0.5. Default is 1.

Raises:
Returns:

The mass density for the plasma species represented by particle.

Return type:

Quantity

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>