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:
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
rngdirectly. If both are given,rngtakes 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,seedis ignored. If None andseedis 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.