import numpy as np def model_density_distribution(r_bins: np.ndarray, M: float = 5, a: float = 5) -> np.ndarray: """ Generate a density distribution for a spherical galaxy model, as per the Hernquist model. Parameters: - r_bins: The radial bins to calculate the density distribution for. - M: The total mass of the galaxy. - a: The scale radius of the galaxy. See https://doi.org/10.1086%2F168845 for more information. """ rho = M / (2 * np.pi) * a / (r_bins * (r_bins + a)**3) return rho def model_particle_count(r_bins: np.ndarray, M: float = 5, a: float = 5, mi: float = 1) -> np.ndarray: rho = model_density_distribution(r_bins, M, a) v_shells = 4/3 * np.pi * (r_bins[1:]**3 - r_bins[:-1]**3) v_shells = np.insert(v_shells, 0, 4/3 * np.pi * r_bins[0]**3) n_shells = rho * v_shells / mi return n_shells