sarracen.SarracenDataFrame.calc_density
- SarracenDataFrame.calc_density() None
Create a new column ‘rho’ that contains particle densities.
Density for each particle is calculated according to
\[\rho = m \left( \frac{h_{\rm fact}}{h} \right)^{n_{\rm dim}}\]where \(m\) is the particle mass, \(h\) is the smoothing length, and \(h_{\rm fact}\) defines the ratio of smoothing length to particle spacing. Smoothing lengths are taken from the smoothing length column, particle masses from the mass column if present, or params if not, and hfact from params.
- Raises:
KeyError – If the hcol column does not exist or if ‘hfact’ is not in ‘params’.
ValueError – If there is no particle mass data.
Notes
For one-fluid dump files, this will calculate the total density (gas + dust) of the particle.