pyfracval.particle_generation#

Functions for generating primary particle radii.

Module Contents#

pyfracval.particle_generation.random_normal_custom()[source]#

Generates a normally distributed random number using the Ziggurat method as implemented in numpy, which is generally preferred over custom acceptance-rejection methods unless specific properties are needed.

pyfracval.particle_generation.lognormal_pp_radii(rp_gstd, rp_g, n, seed=None, truncate=True)[source]#

Generate N random radii from a lognormal distribution.

Parameters:
  • rp_gstd (float) – Geometric standard deviation of the distribution (must be >= 1.0). If 1.0, generates monodisperse particles.

  • rp_g (float) – Geometric mean radius of the distribution (must be > 0).

  • n (int) – Number of radii to generate.

  • seed (int | None, optional) – Random seed for reproducibility, by default None.

  • truncate (bool, optional) – Use the FracVAL 2*sigma truncate version

Returns:

A 1D NumPy array of N generated radii.

Return type:

np.ndarray

Raises:

ValueError – If rp_g is not positive.

Notes

Uses numpy.random.lognormal. The underlying normal distribution’s parameters are mu=log(rp_g) and sigma=log(rp_gstd). The original Fortran code included optional truncation at approximately +/- 2 geometric standard deviations; this is not enabled by default here.