jaxdem.utils.dispersity#

Utility functions to assign radius disperisty.

Functions

allocate_counts(N, count_ratios, *[, ...])

Convert population fractions into integer counts that sum exactly to N.

get_polydisperse_radii(N[, count_ratios, ...])

Construct a polydisperse set of particle radii from population and size ratios.

jaxdem.utils.dispersity.allocate_counts(N: int, count_ratios: Sequence[float], *, ensure_each_size_nonzero: bool = True) ndarray[source][source]#

Convert population fractions into integer counts that sum exactly to N.

Uses a “largest remainder” method (Hamilton apportionment).

If ensure_each_size_nonzero is True, enforces count >= 1 for each species (requires N >= num_species).

jaxdem.utils.dispersity.get_polydisperse_radii(N: int, count_ratios: Sequence[float] = (0.5, 0.5), size_ratios: Sequence[float] = (1.0, 1.4), small_radius: float = 0.5, ensure_size_nonzero: bool = False) Array[source][source]#

Construct a polydisperse set of particle radii from population and size ratios.

Parameters:
  • N (int) – Total number of particles.

  • count_ratios (array-like of float) – Population fractions for each size class (will be normalized to sum to 1).

  • size_ratios (array-like of float) – Radius multipliers for each size class, relative to the smallest size. For example, size_ratios=[1.0, 1.4] means the large particles have radius 1.4x the small particles (before normalization by min(size_ratios)).

  • small_radius (float) – The absolute radius corresponding to the smallest size class (must be > 0).

  • ensure_size_nonzero (bool) – If True, enforce that each size class has at least one particle (requires N >= number of sizes).

Returns:

1D array of length N containing the radii for each particle.

Return type:

jax.Array