A robust Python implementation for solving Population Balance Equations (PBEs) using the Quadrature Method of Moments (QMOM).
This repository provides an easy-to-use implementation of QMOM to simulate the time evolution of the number density function (NDF) of a general phase-space variable
This code has been developed by Mohamed Amine Bouguezzoul during the course of his graduate degree at Polytechnique Montréal, under the supervision of Bianca Viggiano, Bruno Blais, and Fabian Denner. This code is under the copyright of its developers and made available as open-source software under the terms of the MIT License.
The codebase is organized into the following modules:
| File Name | Type | Key Responsibility |
|---|---|---|
QMOM.ipynb |
📓 Driver | The main simulation hub. Considering the generic single phase-space dimension |
Wheeler.py |
🧠 Core | Implements the Adaptive Wheeler Algorithm. Converts statistical moments into quadrature nodes and weights via the Jacobi matrix. |
ssp_rk_solver.py |
⏱️ Solver | A Strong Stability Preserving (SSP) Runge-Kutta solver. Ensures moment realizability using adaptive time-stepping and log-convexity checks. |
flux_calculator.py |
⚙️ Utility | Computes the numerical flux (RHS of the transport equation) for both growth (0th order) and aggregation (1st order) processes. |
testing_utils.py |
🧪 Test | Generates "ground truth" data using Monte Carlo sampling from normal distributions. |
Instead of tracking the full number density function
Tip
The Closure Problem: The growth term often depends on higher moments (e.g., if
The QMOM Solution: We approximate the NDF as a sum of Dirac deltas (quadrature approximation):
The Wheeler.py module solves the inverse problem: Given moments
It constructs a recursive relationship using the Chebyshev algorithm to build a tridiagonal Jacobi Matrix (
-
Nodes (
$\xi_i$ ): Eigenvalues of$J_n$ . -
Weights (
$w_i$ ): Derived from the first component of the eigenvectors.
A major challenge in moment methods is ensuring the moments remain realizable (i.e., they correspond to a valid, non-negative probability distribution).
Important
Realizability Check:
The ssp_rk_solver.py module enforces the log-convexity condition during every time step:
In QMOM.ipynb, you define the particle growth law inside the particle_dynamics function:
def particle_dynamics(t, nodes_flat):
# Example: Size-dependent growth rate dx/dt = x^2
dxidt = xi**2
return dxidtYou can set the initial distribution using a multivariate normal approximation in the notebook:
mu = np.ones(dim) # Mean
cov = np.eye(dim) # Covariance
initial_moments = ... # Calculated via MC_multinormal_momentsThe flux_calculator.py allows for different physical processes:
zeroth_order_local_flux: Used for standard growth, diffusion, and nucleation (processes affecting single particles).first_order_local_flux: Used for aggregation or collision (processes involving particle pairs).
The simulation uses an SSP-RK3 scheme. This is slower than standard RK4 but is strictly required to maintain physical moment sets.
# From QMOM.ipynb
sol_y = ssp_rk.ssp_rk_solver(
lambda t, m: compute_flux(t, m, N),
[t, t+dt],
current_moments
)The notebook automatically generates comparison plots between the Monte Carlo (MC) ground truth and the QMOM approximation.
- MC (Green Squares): Computed by tracking 1000+ individual particles.
-
QMOM (Blue Triangles): Computed by evolving just the first
$2N$ moments.
Results are saved to the QMOM_output directory.
The animation below demonstrates the accuracy of the Quadrature Method of Moments (QMOM) compared to the "ground truth" Monte Carlo (MC) method.
It visualizes the time evolution of the first 12 moments for a particle population undergoing non-linear size-dependent growth, governed by the law:
What to look for:
- Green Squares (MC): The reference solution derived from tracking discrete particles.
- Blue Triangles (QMOM): The moment-based approximation.
-
The Effect of Nodes (
$N$ ): Watch how the QMOM solution (Blue) snaps onto the Monte Carlo solution (Green) as the number of quadrature nodes ($N$ ) increases.- With low
$N$ , the approximation struggles to capture higher-order moments. - As
$N$ increases, the "Blue Triangles" align perfectly with the "Green Squares," validating that increasing the number of nodes allows QMOM to accurately capture the complex evolution of the distribution.
- With low
- Marchisio & Fox (2013) — Comprehensive textbook mainly focusing on QMOM and its derivatives
- Nguyen et al. (2016) — The appendix contains the SSP-RK solver adapted to the moment integration
