optframework.examples.simple_dpbe module

Simple DPBE Solver Example

This script demonstrates the basic usage of the DPBESolver class for solving Discrete Population Balance Equations (DPBE). The script provides a complete workflow from solver initialization to result visualization.

The DPBESolver is used to simulate particle size distribution (PSD) evolution over time through numerical solution of population balance equations. This approach is particularly useful for modeling particle aggregation, breakage, and other particle dynamics processes.

Workflow:
  1. Solver Initialization: Creates a DPBESolver instance with specified dimensionality (1D or 2D particle size space).

  2. Parameter Loading: By default, reads parameters from the external configuration file config/PBE_config.py which contains all necessary physical and numerical parameters.

  3. Grid and Matrix Generation: Calls p.core.full_init() to generate all computational grids and coefficient matrices required for the numerical solution.

  4. PBE Solution: Executes p.core.solve_PBE() to solve the population balance equation system and compute the time evolution of particle size distributions.

  5. Mass Conservation Check: Prints total particle volume before and after simulation to verify mass conservation, which is a critical validation for population balance models.

  6. Result Visualization: Generates multiple visualization outputs: - Final particle size distribution at the last time step - Total particle number evolution over time - Animated GIF showing PSD evolution throughout the simulation

Features:
  • Kernel Density Estimation (KDE): Optional smoothing of distribution data using KDE with Epanechnikov kernel for better visualization

  • Multi-dimensional Support: Handles both 1D and 2D particle size spaces

  • Interactive Plotting: Uses the framework’s plotting utilities for consistent and publication-ready figures

  • Animation Generation: Creates dynamic visualization of temporal evolution as GIF files

Functions:
  • visualize_distribution(): Plots particle size distribution at specified time

  • animation_distribution(): Creates animated GIF of PSD temporal evolution

  • visualize_convergence(): Displays solver convergence metrics

  • visualize_N(): Shows total particle number evolution over time

Usage:

Run the script directly to execute the complete DPBE simulation:

`python python simple_dpbe.py `

Key parameters can be modified: - dim: Dimensionality of particle size space (1 or 2) - smoothing: Enable/disable KDE smoothing for visualization

Expected Output:
  • Console output showing initialization time and mass conservation check

  • Multiple matplotlib figures displaying simulation results

  • distribution_animation.gif file containing temporal evolution animation

Dependencies:
  • numpy: Numerical computations

  • matplotlib: Plotting and animation

  • optframework.dpbe: DPBE solver implementation

  • optframework.utils: Utility functions for data processing and plotting

Note:

This script serves as a basic example for DPBE simulations and can be extended for more complex particle dynamics studies. The mass conservation check is essential for validating the numerical accuracy of the solution.

Created on Wed Apr 17 08:57:57 2024

@author: px2030

optframework.examples.simple_dpbe.visualize_distribution(t_frame=-1, axq3=None, fig=None, clr='b', q3lbl='q3')[source]
optframework.examples.simple_dpbe.animation_distribution(t_vec, fps=10)[source]
optframework.examples.simple_dpbe.visualize_convergence()[source]
optframework.examples.simple_dpbe.visualize_N()[source]