Distribution Strategy Tutorial¶
The representation of particle distributions is core to the simulation, but it can vary depending on what you are trying to achieve. In this tutorial, we will cover the distribution strategies currently implemented.
The distribution strategies, define how to calculate properties derived from the particle distribution. These include particle mass, radius, and total mass. All of which can have different methods depending if the distribution is mass-based, radius-based, or speciated-mass based.
We will cover the following distribution strategies:
MassBasedMovingBinRadiiBasedMovingBinSpeciatedMassMovingBin
As they are just operational strategies, they do not have any specific parameters to be set. They are just used to calculate the properties of the particles.
# In Colab uncomment the following command to install particula:
#!pip install particula[extra] --quiet
import numpy as np
import matplotlib.pyplot as plt
import particula as par
Strategy: MassBasedMovingBin¶
The MassBasedMovingBin strategy is used when the distribution is mass-based. This
means that the mass of the particles is known and the radius is calculated from the mass. The MassBasedMovingBin strategy calculates the radius of the particles using the following equation:
$$ r = \left(\frac{3m}{4\pi\rho}\right)^{1/3} $$
where $r$ is the radius of the particle, $m$ is the mass of the particle, and $\rho$ is the density of the particle.
mass_distribution = np.linspace(0, 10, 5) # kg
density = 1000 # kg/m^3
radius = par.particles.MassBasedMovingBin().get_radius(
mass_distribution, density
)
print(f"Radius of the particles: {radius} m")
total_mass = par.particles.MassBasedMovingBin().get_total_mass(
mass_distribution,
concentration=np.ones_like(mass_distribution),
density=density,
)
print(f"Total mass of the particles: {total_mass} kg")
print(f"Same as the sum*concentration: {np.sum(mass_distribution)} kg")
Radius of the particles: [0. 0.08419452 0.10607844 0.1214295 0.13365046] m Total mass of the particles: 25.0 kg Same as the sum*concentration: 25.0 kg
Builder: RadiiBasedMovingBin¶
The RadiiBasedMovingBin strategy is used when the distribution is radius-based. This means that the radius of the particles is known and the mass is calculated from the radius. The RadiiBasedMovingBin strategy calculates the mass of the particles using the following equation:
$$ m = \frac{4\pi\rho r^3}{3} $$
where $m$ is the mass of the particle, $r$ is the radius of the particle, and $\rho$ is the density of the particle.
The builder does nothing in this case, as we just have no parameters to set. We use the builder pattern here to keep the code consistent with the other strategies.
radii_distribution = np.linspace(0, 0.1, 5) # m
density = 1000 # kg/m^3
radii_strategy = par.particles.RadiiBasedMovingBinBuilder().build()
mass_distribution = radii_strategy.get_mass(radii_distribution, density)
print(f"Mass of the particles: {mass_distribution} kg")
total_mass = radii_strategy.get_total_mass(
radii_distribution,
concentration=np.ones_like(radii_distribution),
density=density,
)
print(f"Total mass of the particles: {total_mass} kg")
Mass of the particles: [0. 0.06544985 0.52359878 1.76714587 4.1887902 ] kg Total mass of the particles: 6.544984694978737 kg
Factory: SpeciatedMassMovingBin¶
The SpeciatedMassMovingBin strategy is used when the distribution is speciated-mass based. This means that the mass of the particles is known and the radius is calculated from the mass. The SpeciatedMassMovingBin has multiple species, and the mass of each species is known for that given bin or particle.
mass_distribution1 = np.linspace(0, 10, 5) # kg
mass_distribution2 = np.linspace(0, 10, 5) # kg
masses_combined = np.vstack((mass_distribution1, mass_distribution2)).T
density = np.array([1000.0, 2000.0]) # kg/m^3
speciated_mass = par.particles.DistributionFactory().get_strategy(
"speciated_mass_moving_bin"
)
radius = speciated_mass.get_radius(masses_combined, density)
print(f"Radius of the particles: {radius} m")
total_mass = speciated_mass.get_total_mass(
masses_combined,
concentration=np.ones_like(mass_distribution1),
density=density,
)
print(f"Total mass of the particles: {total_mass} kg")
Radius of the particles: [0. 0.09637866 0.1214295 0.13900208 0.15299159] m Total mass of the particles: 50.0 kg
Summary¶
In this tutorial, we covered the distribution strategies implemented in the simulation. We covered the MassBasedMovingBin, RadiiBasedMovingBin, and SpeciatedMassMovingBin strategies. These strategies are used to calculate the properties of the particles based on the distribution type.