GPU-accelerated SPH neighbor search and operators built with NVIDIA Warp and PyTorch
Project description
compressibleSPH
A GPU-oriented Python package for compressible Smoothed Particle Hydrodynamics (SPH) experiments and benchmarks.
The project is organized around reusable builders for simulation configuration, interchangeable SPH schemes, adaptive time integration, case setup helpers, and export/import utilities for trajectories and postprocessing.
What This Package Implements
Core SPH Schemes
The package currently exposes three compressible SPH schemes via CompressibleSPHScheme:
MonaghanCompSPHCRKSPH
Scheme dispatch is handled by buildScheme(...) in src/compressibleSPH/schemes/builder.py.
Kernels
Kernel selection is part of SimulationConfig.kernel (type KernelFunctions, imported from sphWarpCore).
The parser helper parseKernelFunctions(...) accepts any kernel enum name exposed by your installed sphWarpCore version.
Integrators
Time integration is selected with SimulationConfig.integrationScheme (type IntegrationSchemeType, from integrators).
The helper buildConfig(...) returns both:
- a configured
SimulationConfig - the integrator object from
getIntegrator(...)
Spatial Operators and Support Modes
Simulation configuration includes selectable operator and support modes:
supportMode(SupportScheme)gradientMode(GradientScheme)laplacianMode(LaplacianScheme)samplingScheme(SamplingScheme)
Viscosity Switches
ViscositySwitch includes:
Balsara1995Colagrossi2004CullenDehnen2010CullenHopkinsMorrisMonaghan1997Rosswog2000NoneSwitch
Adaptive Support Schemes
AdaptiveSupportScheme includes:
NoSchemeMonaghanOwen
Energy Schemes
EnergyScheme includes:
equalWorkPdVdiminishingmonotonichybridCRK
I/O and Reproducibility Utilities
The package provides trajectory/state serialization utilities:
prepExport(...)exportSimulationSystem(...)importSimulationSystem(...)importConfigs(...)
These write/read HDF5 state data and JSON config metadata for reproducible runs.
Package Layout
src/compressibleSPH/configurations/: simulation and scheme configuration dataclasses/builderssrc/compressibleSPH/schemes/: scheme implementations and scheme buildersrc/compressibleSPH/systems/: state/system containerssrc/compressibleSPH/modules/: runtime modules (for example timestep support)src/compressibleSPH/sample/: sampling utilitiessrc/compressibleSPH/caseUtils/: case setup helpers used by examplessrc/compressibleSPH/io.py: export/import and parsing helpersexamples/compressible/: benchmark notebooks and generated media
Environment Setup
Recommended setup uses a dedicated conda environment and editable installs for backend repositories.
1) Create and prepare conda environment
conda create -n 'warp' python=3.13
conda activate warp
conda install -c anaconda ipykernel -y
conda install nvidia/label/cuda-13.0.0::cuda-toolkit cudnn
pip install toml scipy numba tqdm h5py matplotlib ipywidgets ipympl imageio scikit-image imageio_ffmpeg seaborn pandas
pip install warp-lang torch
2) Clone backend repositories
git clone https://github.com/wi-re/integrators
git clone https://github.com/wi-re/sphPlotting
git clone https://github.com/wi-re/warpSPH
3) Install backends in editable mode
cd integrators && pip install -e . && cd ..
cd sphPlotting && pip install -e . && cd ..
cd warpSPH && pip install -e . && cd ..
Current status: cloning and editable installs are the accepted setup path for now.
Quick Start
If you are running directly from this repository, ensure src is on your Python path:
export PYTHONPATH="$PWD/src:$PYTHONPATH"
Minimal usage pattern:
import torch
from compressibleSPH import *
# Build global simulation config + integrator
config, integrator = buildConfig(
dim=1,
dt=1e-3,
adaptiveDt=True,
cflFactor=0.3,
)
# Pick an SPH scheme
scheme = CompressibleSPHScheme.CRKSPH
SimulationSystem, SimulationState, SimulationConfig, SimulationUpdate, fn, export_fn, import_fn = buildScheme(scheme)
# Build scheme-specific config
schemeConfig = SimulationConfig()
schemeConfig.gamma = 5.0 / 3.0
# Case setup is typically done with helpers in compressibleSPH.caseUtils
Compressible Examples
A full gallery page with previews and embedded videos is available at:
Table of Cases
| Case | Notebook | Preview (PNG) | Video (MP4) |
|---|---|---|---|
| 01. Sod Shock Tube (1D) | 01-Sod_Shock_Tube_1D.ipynb | MP4 | |
| 02. Linear Wave | 02-Linear_Wave.ipynb | MP4 | |
| 03. Kidder Isentropic Compression | 03-Kidder_Isentropic_Compression.ipynb | MP4 | |
| 04. Noh Implosion | 04-Noh_Implosion.ipynb | MP4 | |
| 05. Woodward-Colella Double Blastwave | 05-Woodward_Colella.ipynb | MP4 | |
| 06. Sedov-Taylor Blastwave (1D) | 06-Sedov_Taylor_Blastwave_1D.ipynb | MP4 | |
| 07. Sedov-Taylor Blastwave (2D) | 07-Sedov_Taylor_Blastwave_2D.ipynb | MP4 | |
| 08. Hydrostatic | 08-Hydrostatic.ipynb | MP4 | |
| 09. Gresho-Chan Vortex | 09-Gresho_Chan_Vortex.ipynb | MP4 | |
| 10. Yee Vortex | 10-Yee_Vortex.ipynb | MP4 | |
| 11. Shearing Noh Implosion (2D) | 11-Shearing_Noh_Implosion_2D.ipynb | MP4 | |
| 12. Kelvin-Helmholtz | 12-Kelvin-Helmholtz.ipynb | MP4 | |
| 13. Rayleigh-Taylor | 13-Rayleigh_Taylor.ipynb | MP4 | |
| 14. Triple Point (Equal Resolution) | 14-Triple_point.ipynb | MP4 | |
| 15. Triple Point (Equal Mass) | 15-Triple_point_equalMass.ipynb |
Precision Note (Notebook Workflows)
In the example notebooks, floating-point precision is configured early in the import/setup cell. If precision is changed (for example float32 to float64), restart the Jupyter kernel before rerunning.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file warpsph-0.3.0.tar.gz.
File metadata
- Download URL: warpsph-0.3.0.tar.gz
- Upload date:
- Size: 202.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a731a772b4d4cea125928efd15262b14a2aacd5496d6863cfdf3104b84768d1
|
|
| MD5 |
e912299d7fda2ffbd46133abed5b0860
|
|
| BLAKE2b-256 |
62f7fde12b2e3fb18cbc78ec8ed3f981910d9cdf02dde948b5b15b0d816b4c54
|
File details
Details for the file warpsph-0.3.0-py3-none-any.whl.
File metadata
- Download URL: warpsph-0.3.0-py3-none-any.whl
- Upload date:
- Size: 322.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51b336c628a1294ac77e5f76afc0bae7d60bb210b3bd758898612f34a02c797f
|
|
| MD5 |
5d7eb8737c1d7a857dd0ac2d28898a2b
|
|
| BLAKE2b-256 |
d13c5eebeaec499fc3fc62ba90d6474508a4f927d068525373f7040549ec3731
|