cupyturbo — 2D Turbulence Simulation (NumPy / CuPy)
cupyturbo is a small playground Direct Numerical Simulation (DNS) code for
2D Homogeneous, Incompressible Turbulence, structurally ported from a legacy FORTRAN 77 implementation.
It supports:
- NumPy for CPU runs
- CuPy (optional) for GPU acceleration on CUDA devices (e.g. RTX 3090)
The solver mirrors the original structure:
- PAO-style random-field initialization
- 3/2 de-aliasing in spectral space
- Crank–Nicolson time integration
Installation
Using uv (recommended)
From the project root:
uv sync
uv run python -m cupyturbo.dns_main
This creates a virtual environment and installs the project and its dependencies from pyproject.toml.
Using plain pip
From a cloned repo:
python -m venv .venv
source .venv/bin/activate # on Windows: .venv\Scripts\activate
pip install -e .
python -m cupyturbo.dns_main
The DNS with NumPy (256 x 256)
Full CLI
python -m cupyturbo.dns_simulator N Re K0 STEPS CFL BACKEND
Where:
- N — grid size (e.g. 256, 512)
- Re — Reynolds number (e.g. 10000)
- K0 — peak wavenumber of the energy spectrum
- STEPS — number of time steps
- CFL — target CFL number (e.g. 0.75)
- BACKEND — "cpu", "gpu", or "auto"
Examples:
# CPU run (NumPy)
python -m cupyturbo.dns_simulator 256 10000 10 1001 0.75 cpu
# Auto-select backend (GPU if CuPy + CUDA are available)
python -m cupyturbo.dns_simulator 256 10000 10 1001 0.75 auto
Enabling GPU with CuPy (CUDA 13.1)
On a CUDA machine (e.g. RTX 3090):
-
Check that the driver/CUDA are available:
nvidia-smi | head -n 3 -
Install CuPy into the uv environment:
uv sync uv pip install cupy -
Verify that CuPy sees the GPU:
uv run python -c "import cupy as cp; x = cp.arange(5); print(x, x.device)" -
Run in GPU mode:
uv run python -m cupyturbo.dns_simulator 256 10000 10 1001 0.75 gpu
Or let the backend auto-detect:
uv run python -m cupyturbo.dns_simulator 256 10000 10 1001 0.75 auto
The DNS with CuPy (4096 x 4096)
Profiling
cProfile (CPU)
python -m cProfile -o dns_simulator.prof -m cupyturbo.dns_simulator
Inspect the results:
python -m pstats dns_simulator.prof
# inside pstats:
sort time
stats 20
GUI profiling with SnakeViz
Install SnakeViz:
uv pip install snakeviz
Visualize the profile:
snakeviz dns_simulator.prof
Memory & CPU profiling with Scalene (GUI)
Install Scalene:
uv pip install scalene
Run with GUI report:
scalene -m cupyturbo.dns_simulator 256 10000 10 201 0.75 cpu
Memory & CPU profiling with Scalene (CLI only)
For a terminal-only summary:
scalene --cli --cpu -m cupyturbo.dns_simulator 256 10000 10 201 0.75 cpu
Project layout (key modules)
-
cupyturbo/dns_main.py
PyQt6 GUI viewer; displays DNS fields (U, V, ω, kinetic) in real time. -
cupyturbo/dns_simulator.py
Headless CLI DNS solver:- PAO initialization (dns_pao_host_init)
- FFT helpers (vfft_full_*)
- STEP2A, STEP2B, STEP3
- CFL-based time-step control (compute_cflm, next_dt)
-
cupyturbo/dns_wrapper.py
Thin wrapper for programmatic use.
one-liner
curl -LsSf https://astral.sh/uv/install.sh | sh
uv cache clean mannetroll-cupyturbo
uv run --python 3.13 --with mannetroll-cupyturbo==0.1.4 python -m cupyturbo.dns_main
License
Copyright © Mannetroll See the project repository for license details.
Metadata
Release files for mannetroll-cupyturbo 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mannetroll_cupyturbo-0.1.4.tar.gz | 29.5 kB | Without provenance | Details for mannetroll_cupyturbo-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mannetroll_cupyturbo-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for mannetroll_cupyturbo-0.1.4-py3-none-any.whl |
Total release size: 58.8 kB
Release files / mannetroll_cupyturbo-0.1.4.tar.gz
| Download URL | mannetroll_cupyturbo-0.1.4.tar.gz |
|---|---|
| Size | 29.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b0bef7b3e42f25a475dfb4aa58ba68a94eceadcab3fae0228cedb22d82d2fe95
|
|
BLAKE2b-256 checksum How to use checksums |
578427034a67cfd4ee4f9c600849ff0db60031157e1c98a8181181b7c88bf304
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / mannetroll_cupyturbo-0.1.4-py3-none-any.whl
| Download URL | mannetroll_cupyturbo-0.1.4-py3-none-any.whl |
|---|---|
| Size | 29.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4096ecebce35e06cf5bac51006b04adf1a570a8637385bcbef3b7fdc2a91c0ce
|
|
BLAKE2b-256 checksum How to use checksums |
0a0ccf4004e6a841947538cdb7b16cae182312bfa752ff8905c0f84d7f3ab5e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Security for mannetroll-cupyturbo 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.