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.
