# mass_density¶

plasmapy.formulary.mass_density(density: [Unit("1 / m3"), Unit("kg / m3")], particle: Optional[str] = None, z_mean: Optional[numbers.Real] = None) -> Unit("kg / m3")

Utility function to merge two possible inputs for particle charge.

Aliases: rho_

Parameters: density (Quantity) – Either a particle density (number of particles per unit volume, in units of 1/m^3) or a mass density (in units of kg/m^3 or equivalent). particle (str, optional) – Representation of the particle species (e.g., 'p' for protons, 'D+' for deuterium, or 'He-4 +1' for singly ionized helium-4), which defaults to electrons. If no charge state information is provided, then the particles are assumed to be singly charged. z_mean (float) – An optional float describing the average ionization of a particle species. ValueError – If the density has units inconvertible to either a particle density or a mass density, or if you pass in a number density without a particle. The mass density calculated from all the provided sources of information. Quantity

Examples

>>> from astropy import units as u
>>> mass_density(1 * u.m ** -3,'p')
<Quantity 1.67353...e-27 kg / m3>
>>> mass_density(4 * u.m ** -3,'D+')
<Quantity 1.33779...e-26 kg / m3>