Skip to main content

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:

  • Monaghan
  • CompSPH
  • CRKSPH

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:

  • Balsara1995
  • Colagrossi2004
  • CullenDehnen2010
  • CullenHopkins
  • MorrisMonaghan1997
  • Rosswog2000
  • NoneSwitch

Adaptive Support Schemes

AdaptiveSupportScheme includes:

  • NoScheme
  • Monaghan
  • Owen

Energy Schemes

EnergyScheme includes:

  • equalWork
  • PdV
  • diminishing
  • monotonic
  • hybrid
  • CRK

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/builders
  • src/compressibleSPH/schemes/: scheme implementations and scheme builder
  • src/compressibleSPH/systems/: state/system containers
  • src/compressibleSPH/modules/: runtime modules (for example timestep support)
  • src/compressibleSPH/sample/: sampling utilities
  • src/compressibleSPH/caseUtils/: case setup helpers used by examples
  • src/compressibleSPH/io.py: export/import and parsing helpers
  • examples/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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

warpsph-0.3.2.tar.gz (203.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

warpsph-0.3.2-py3-none-any.whl (319.2 kB view details)

Uploaded Python 3

File details

Details for the file warpsph-0.3.2.tar.gz.

File metadata

  • Download URL: warpsph-0.3.2.tar.gz
  • Upload date:
  • Size: 203.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for warpsph-0.3.2.tar.gz
Algorithm Hash digest
SHA256 b3cca84a98e1ba59c5cca93d0d9cab0d7bc6a07b567d4a696f367a1ca18d905a
MD5 652c4f7d618d2e87c28d0cab0c9ef768
BLAKE2b-256 fb0b7ab39664f0518e810c42286e7826959a35336945904da00a4c7057dbaf7e

See more details on using hashes here.

File details

Details for the file warpsph-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: warpsph-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 319.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for warpsph-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3a29e4b6069b3056e82f293dd5180c5fa4d0559b0ddd2fad557c8fd8970f8c89
MD5 9837d051380438753192ccb6447603ed
BLAKE2b-256 a4cb052ac868e090b2f888b928beb68f12d0f06a971727154f108f5c36b9fc98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page