optframework.pbm.pbm_base module
Created on Fri Jan 10 15:13:27 2025
@author: px2030
- class optframework.pbm.pbm_base.PBMSolver(dim, t_total=601, t_write=100, t_vec=None, load_attr=True, config_path=None)[source]
Bases:
BaseSolver
Population Balance Model (PBM) solver using the Method of Moments.
This class implements a moment-based approach to solve Population Balance Equations (PBE) for particle systems undergoing agglomeration and/or breakage processes. Unlike discrete methods that track the full particle size distribution, the Method of Moments tracks only the statistical moments of the distribution, making it computationally more efficient while providing information about mean sizes, total concentrations, and distribution width.
The solver supports both 1D (single component) and 2D (two-component) systems, making it suitable for modeling processes like flocculation, crystallization, magnetic separation, and other particle population dynamics.
Key Features: - Method of Moments for computational efficiency - Support for 1D and 2D particle systems - Configurable agglomeration and breakage kernels - Integration with visualization and post-processing tools - Flexible initial distribution shapes (normal, gamma, lognormal, beta, monodisperse) - Advanced quadrature methods (GQMOM) for moment reconstruction
The solver integrates moment equations of the form: dμₖ/dt = Birth terms - Death terms where μₖ represents the k-th moment of the particle size distribution.
Parameters
- dimint
Dimension of the PBE problem (1 for single component, 2 for two components)
- t_totalint, optional
Total simulation time in seconds (default: 601)
- t_writeint, optional
Output time interval in seconds (default: 100)
- t_vecarray-like, optional
Custom time vector for simulation output points
- load_attrbool, optional
Whether to load attributes from configuration file (default: True)
- config_pathstr, optional
Path to configuration file (default: uses PBM_config.py)
Attributes
- n_orderint
Order parameter where n_order×2 is the total number of moments tracked
- momentsndarray
Array storing moment values over time
- indicesndarray
Moment indices for 2D systems (k,l pairs for μₖₗ)
- corePBMCore
Core computation module for moment initialization and PBE solving
- postPBMPost
Post-processing module for analysis and data extraction
- quick_testPBMQuickTest
Testing module for convergence and validation studies
- trapz_2d(NDF1, NDF2, x1, x2, k, l)[source]
Perform 2D trapezoidal integration for moment calculation.
Computes the integral ∫∫ x1^k × x2^l × NDF1(x1) × NDF2(x2) dx1 dx2 using the trapezoidal rule for 2D moment initialization.
Parameters
- NDF1numpy.ndarray
First normalized distribution function
- NDF2numpy.ndarray
Second normalized distribution function
- x1numpy.ndarray
x-coordinates for NDF1
- x2numpy.ndarray
x-coordinates for NDF2
- kint
Power for x1 coordinate
- lint
Power for x2 coordinate
Returns
- float
Result of the 2D trapezoidal integration
- normalize_mom()[source]
Normalize moments by scaling with maximum x-coordinate.
Creates dimensionless normalized moments for numerical stability and comparison purposes. Sets moments_norm and moments_norm_factor arrays.
- set_tol(moments)[source]
Set integration tolerance arrays based on initial moment values.
Calculates absolute and relative tolerance arrays for ODE integration to ensure numerical stability across different moment magnitudes.
Parameters
- momentsnumpy.ndarray
Initial moment values for tolerance scaling
- create_ndf(distribution='normal', x_range=(0, 100), points=1000, **kwargs)[source]
Create a normalized distribution function (probability density function).
Generates various types of probability density functions for initial particle size distribution setup in moment calculations.
Parameters
- distributionstr, optional
Type of distribution: “normal”, “gamma”, “lognormal”, “beta”, “mono” (default: “normal”)
- x_rangetuple, optional
Range of the variable (start, end) (default: (0, 100))
- pointsint, optional
Number of discretization points (default: 1000)
- **kwargs
Distribution-specific parameters:
normal: mean, std_dev
gamma: shape, scale
lognormal: mean, sigma
beta: a, b
mono: size
Returns
- tuple
(x, ndf) where x is coordinate array and ndf is distribution values
Raises
- ValueError
If distribution type is unsupported or x_range is invalid for distribution
- NDF_approx(x, nodes, weights, width=0.1)[source]
Approximate normalized distribution function using sum of Gaussian kernels.
Creates smooth approximation of delta functions or discrete distributions using weighted Gaussian distributions, useful for GQMOM reconstruction.
Parameters
- xnumpy.ndarray
Points where function is evaluated
- nodesnumpy.ndarray
Positions of distribution peaks
- weightsnumpy.ndarray
Weights of distribution peaks
- widthfloat, optional
Standard deviation of Gaussian kernels (default: 1e-1)
Returns
- numpy.ndarray
Approximated distribution function values