pyfracval.particle_generation#

Functions for generating primary particle radii.

Module Contents#

pyfracval.particle_generation.random_normal_custom(rng=None)[source]#

Draw a single standard normal variate.

Parameters:

rng (numpy.random.Generator | None, optional) – Random number generator to use. If None, a fresh default generator is created.

Returns:

A single sample from the standard normal distribution.

Return type:

float

Notes

This uses numpy.random.Generator.standard_normal(), which relies on NumPy’s normal sampling implementation.

pyfracval.particle_generation.lognormal_pp_radii(rp_gstd, rp_g, n, seed=None, truncate=True, rng=None)[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) – Deprecated. Prefer passing rng directly. If both are given, rng takes precedence.

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

  • rng (np.random.Generator | None, optional) – A NumPy Generator instance (e.g. np.random.default_rng(seed)). If provided, seed is ignored. If None and seed is also None, a fresh Generator is created.

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.Generator.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.