cminject.calc package¶
Efficient code for calculating any kind of complex formula that is relevant to some physics model in the framework. Code that lives here should be optimized–manually and automatically–wherever possible.
- cminject.calc.erf_vec_1d(a)¶
A 1D vectorized version of the error function, implemented in terms of math.erf. Mainly exists so we can call it for a 1D vector from other Numba-optimized functions, since Numba lacks support for scipy.special.erf.
- Parameters
a – A 1D array of float64, to calculate erf component-wise for.
- Returns
The component-wise application of erf to a.
- cminject.calc.is_finite(x: float)¶
Like np.isfinite for a single floating point value (much faster). Returns True if x is not equal to +inf, -inf and if x is not NaN.
- Parameters
x – The number to check.
- Returns
True if x is finite, False otherwise.
Submodules¶
cminject.calc.fluid_flow module¶
Calculation code for models of forces exerted on particles by flowing fluids.
- cminject.calc.fluid_flow.a_brown_roth(p, m_f, T_f, T_p, r_p, m_p, dt, n)¶
Returns a random (Brownian) acceleration with a spectral intensity as described in Roth2020, depending on particle and fluid properties at a certain position.
- Parameters
p – The pressure at the point.
m_f – The mass of a single particle of the fluid.
T_f – The temperature of the fluid.
T_p – The temperature of the particle.
r_p – The radius of the particle.
m_p – The mass of the particle.
dt – The numerical time-step.
n – The number of spatial dimensions.
- Returns
An (n,)-shaped np.array containing the acceleration components in each spatial dimension.
- cminject.calc.fluid_flow.a_brown_stokes(mu, T_f, r_p, rho_p, Cc, dt, n)¶
Acceleration for Brownian motion in a Stokes flow, according to Li and Ahmadi.
- Parameters
mu – The dynamic viscosity of the fluid.
T_f – The temperature of the fluid.
r_p – The radius of the particle.
rho_p – The density of the particle.
Cc – A slip correction factor.
dt – The time step.
n – The number of dimensions to generate an acceleration for.
- Returns
The acceleration vector.
- cminject.calc.fluid_flow.a_roth(p, delta_v, m_f, T_f, T_p, r_p, m_p)¶
Acceleration for a microscopic force for aerosol transport described in Roth2020.
- Parameters
p – The pressure of the fluid.
delta_v – The velocity difference (v_fluid - v_particle).
m_f – The mass of a single particle of the fluid.
T_f – The temperature of the fluid.
T_p – The temperature of the particle.
r_p – The radius of the particle.
m_p – The mass of the particle.
- Returns
The acceleration vector.
- cminject.calc.fluid_flow.a_stokes(delta_v, mu, r_p, m_p, Cc)¶
Acceleration for a Stokes flow at a single point, 6*pi*mu*r_p*delta_v / (m_p * Cc).
- Parameters
delta_v – The velocity difference (v_fluid - v_particle) at that point.
mu – The dynamic viscosity of the fluid.
r_p – The radius of the particle.
m_p – The mass of the particle.
Cc – A slip correction factor.
- Returns
The acceleration according to Stokes.
- cminject.calc.fluid_flow.slip_correction_4k(p, r_p, T, ss)¶
- cminject.calc.fluid_flow.slip_correction_hutchins(mu, p, r_p, T_f, m_f, ss)¶
Slip correction for a spherical particle in a fluid according to: D. K. Hutchins, M. H. Harper, R. L. Felder, Slip correction measurements for solid spherical particles by modulated dynamic light scattering, Aerosol Sci. Techn. 22 (2) (1995) 202–218. doi:10.1080/02786829408959741.
- Parameters
mu – The dynamic viscosity of the fluid.
p – The pressure of the fluid.
r_p – The radius of the particle.
T_f – The temperature of the fluid.
m_f – The mass of a single particle of the fluid.
ss – A multiplicative correction factor.
- Returns
The slip correction factor according to Hutchins.