This project is a simplified Python implementation of the numerical methods described in the academic paper: "Asymptotic-preserving dynamical low-rank method for the stiff nonlinear Boltzmann equation".
[Link to the paper on ScienceDirect]
The code was personally refactored from the original MATLAB research code into a structured and more accessible Python application.
The monolithic research script was reorganized into a clean, modular structure that separates distinct functionalities for improved clarity and maintainability.
dlr-boltzmann-solver/
βββ src/
β βββ collision.py # The Boltzmann collision operator
β βββ initial_conditions.py # Functions to set up problem scenarios
β βββ numerics.py # Core numerical schemes (e.g., MUSCL)
β βββ solvers.py # Main solver functions (Full and DLR)
β βββ visualization.py # Plotting and results visualization
β
βββ tests/
β βββ test_initial_conditions.py
β βββ test_numerics.py
β
βββ main.py # Main script with CLI to run simulations
βββ requirements.txt # Project dependencies
βββ README.md # This file
-
Clone the repository:
git clone <your-repo-url> cd dlr-boltzmann-solver
-
Create and activate a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install the required dependencies:
pip install -r requirements.txt
The simulation is controlled via the command line from the project's root directory.
Example 1: Run both the Full and the DLR solvers with default settings.
python main.py --methods full dlrExample 2: Run only the DLR solver with a specific rank of 8 and a max time of 0.2.
python main.py --methods dlr --rank 8 --tmax 0.2Example 3: Run the simulation for the 'shock' problem instead of the default 'sin' problem.
python main.py --problem shockOutput plots will be saved in the simulation_results/ directory.
This project uses pytest for unit testing to ensure the reliability of core numerical and setup functions.
To run the test suite, execute the following command from the root directory:
python -m pytest -vAll tests should pass, confirming that the fundamental components of the code are working as expected.
The script generates plots comparing the macroscopic quantities (density, velocity, temperature) calculated by the different methods.
