Skip to content
/ DLRA Public

Dynamical low-rank solver (Python/JAX) that approximates high-dimensional states on a rank-r manifold to reduce compute/memory while preserving accuracy; CLI, tests, and reproducible examples.

Notifications You must be signed in to change notification settings

shzhang3/DLRA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dynamical Low-Rank Solver for the Boltzmann Equation

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.


Project Structure

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

Setup and Installation

  1. Clone the repository:

    git clone <your-repo-url>
    cd dlr-boltzmann-solver
  2. Create and activate a virtual environment (recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
  3. Install the required dependencies:

    pip install -r requirements.txt

How to Run a Simulation

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 dlr

Example 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.2

Example 3: Run the simulation for the 'shock' problem instead of the default 'sin' problem.

python main.py --problem shock

Output plots will be saved in the simulation_results/ directory.


Testing 🧪

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 -v

All tests should pass, confirming that the fundamental components of the code are working as expected.


Sample Output

The script generates plots comparing the macroscopic quantities (density, velocity, temperature) calculated by the different methods.

Density Comparison

About

Dynamical low-rank solver (Python/JAX) that approximates high-dimensional states on a rank-r manifold to reduce compute/memory while preserving accuracy; CLI, tests, and reproducible examples.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages