# mass_density¶

plasmapy.formulary.parameters.mass_density(density: [Unit("1 / m3"), Unit("kg / m3")], particle: Union[plasmapy.particles.particle_class.Particle, str], z_ratio: Optional[numbers.Real] = 1) -> Unit("kg / m3")

Calculates 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 integer charge of species $$s$$, and $$Z_{particle}$$ is the integer charge 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/m^3$$ 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 integer charges 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. UnitTypeError – If the density does not have units equivalent to a number density or mass density. TypeError – If density is not of type Quantity, or convertible. TypeError – If particle is not of type or convertible to Particle. TypeError – If z_ratio is not of type int or float. ValueError – If density is negative. The mass density for the plasma species represented by particle. 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>