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

Utility function to merge two possible inputs for particle charge.

Aliases: rho_

  • 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 (Particle, optional) – Representation of the particle species (e.g., 'p' for protons, 'D+' for deuterium, or 'He-4 +1' for singly ionized helium-4). If no charge state information is provided, then the particles are assumed to be singly charged. A particle is required if using a number density (1/m^3) for the density parameter.
  • 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.

Return type:



>>> 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>