Skip to main content

Snapy

Snapy is a finite-volume atmospheric dynamics solver built on PyTorch tensors. Its C++ core and Python bindings support compressible flow with thermodynamics and chemistry from Kintera, as well as shallow-water models on Cartesian and cubed-sphere grids.

PyPI version License: MIT

Getting started

The release workflow targets CPython 3.10–3.13 on Linux x86-64 and macOS arm64. Install the Python package in an active environment with the matching PyTorch version.

python -m pip install 'torch==2.10.0' snapy

Each example pairs a YAML input deck with a driver. The deck selects the grid, numerical schemes, time integrator and outputs. The driver supplies the initial state and advances it. From the repository root, load the deck for the two-dimensional Sod shock around an embedded cylinder and construct its block in Python.

import snapy

options = snapy.MeshBlockOptions.from_yaml("examples/shock.yaml")
block = snapy.MeshBlock(options)

The shock driver sets the left and right gas states, installs the cylindrical slip wall and advances the block to t = 1. For a multi-block example, the shallow-water driver initializes each block and advances the mesh as a whole. The example decks include single-block and distributed versions of the same problem.

How V3 advances a simulation

Component Role
Mesh and MeshBlock A block owns its local grid, physics and state tensors. A mesh coordinates its blocks, their exchanges and operations that need a global reduction.
StageExecutor Schedules the operations in each integration stage. CPU and MPS execute eagerly. On CUDA, the default execution mode captures eligible stage segments per block and runs other segments eagerly.
StateStore and PrecisionPolicy The store keeps conserved state and Runge–Kutta backups in stable buffers. The policy selects storage and computation dtypes for state, fluxes, reference fields and the vertical implicit solve.
FluxRegister Tracks face fluxes, corrections and cell sources so conservation budgets can account for transport across boundaries and changes within cells.
Layout and exchange Map blocks to processes and exchange data across slab boundaries and cubed-sphere panel seams.
Output Writes requested fields and diagnostics. Restart handling lives with the mesh block.

Choosing a configuration

Start from a deck with the geometry and physics you want. For example, shock.yaml selects an ideal gas, WENO5 reconstruction, HLLC fluxes and RK3 integration. Its two output entries give primitive fields and restarts independent write intervals.

  • Set dynamics.precision to choose the block precision and integration.implicit-precision to control the vertical solve. The precision policy uses FP32 for quantities that would otherwise require FP64 on MPS.
  • Set integration.execution to auto, eager or cuda-graph. In Python, block.execution_capability(vars) reports capture eligibility for the configured block and its initialized variables.
  • Set dynamics.flux-covariance (default true) for the x2/x3 face-flux correction and dynamics.x1-mass-covariance (default false) for the reconstructed x1 velocity correction. Use the same settings on every block. The x1 correction needs at least three x1 cells per block.

The option tables document keys and defaults for geometry, layout, output, hydro and individual forcings. CMake generates their C++ readers during configuration. Physics modules such as the equations of state also read their own options.

Build and run from source

Use CMake 3.22 or newer, a C++17 compiler and the NetCDF C library. On Ubuntu, install the native build and test dependencies with the following command.

sudo apt-get install libnetcdf-dev libucx-dev nco autoconf automake libtool pkg-config

On macOS, use brew install netcdf nco. From the repository root, install the Python dependencies before configuring CMake so it can import PyTorch and generate the option readers with PyYAML.

python -m pip install numpy pyyaml wheel setuptools-scm pytest netcdf4 \
  'torch==2.10.0' 'kintera==2.6.14' 'pyharp>=2.7.17' \
  'commux>=0.1.4; platform_system == "Linux"' \
  'pinc>=0.2.0; platform_system == "Linux"'
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCUDA=OFF -DNETCDF=ON -DBUILD_TESTS=ON
cmake --build build --parallel 3
python -m pip install --no-build-isolation --no-deps .

This CPU build uses the Kintera version pinned in CI for its numerical references. Use -DCUDA=ON for a CUDA build with a compatible toolkit. Release builds place example executables and input decks in build/bin. For a quick CPU run, copy the single-block shallow-water deck and limit it to two steps. The driver writes NetCDF output in the run directory.

mkdir -p build/runs/shallow
cd build/runs/shallow
sed 's/nlim: -1/nlim: 2/' ../../bin/shallow_xy_single.yaml > shallow.yaml
../../bin/shallow_xy.release shallow.yaml
cd ../../..

Tests

ctest --test-dir build/tests --output-on-failure

Configure with -DFULL_TESTS=ON to include additional reference and decomposition cases. The test guide describes the platform-specific suites and how to test against a matching Python installation.

License and contact

Snapy is distributed under the MIT License. Contact Cheng Li at chengcli@umich.edu.

Metadata

Release files for snapy 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for snapy 3.1.0
File Actions
snapy-3.1.0-cp313-cp313-manylinux_2_27_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ x86-64 Details for snapy-3.1.0-cp313-cp313-manylinux_2_27_x86_64.whl
snapy-3.1.0-cp313-cp313-macosx_15_0_arm64.whl CPython 3.13 CPython 3.13 macOS 15.0+ ARM64 Details for snapy-3.1.0-cp313-cp313-macosx_15_0_arm64.whl
snapy-3.1.0-cp312-cp312-manylinux_2_27_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.27+ x86-64 Details for snapy-3.1.0-cp312-cp312-manylinux_2_27_x86_64.whl
snapy-3.1.0-cp312-cp312-macosx_15_0_arm64.whl CPython 3.12 CPython 3.12 macOS 15.0+ ARM64 Details for snapy-3.1.0-cp312-cp312-macosx_15_0_arm64.whl
snapy-3.1.0-cp311-cp311-manylinux_2_27_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.27+ x86-64 Details for snapy-3.1.0-cp311-cp311-manylinux_2_27_x86_64.whl
snapy-3.1.0-cp311-cp311-macosx_15_0_arm64.whl CPython 3.11 CPython 3.11 macOS 15.0+ ARM64 Details for snapy-3.1.0-cp311-cp311-macosx_15_0_arm64.whl
snapy-3.1.0-cp310-cp310-manylinux_2_27_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.27+ x86-64 Details for snapy-3.1.0-cp310-cp310-manylinux_2_27_x86_64.whl
snapy-3.1.0-cp310-cp310-macosx_15_0_arm64.whl CPython 3.10 CPython 3.10 macOS 15.0+ ARM64 Details for snapy-3.1.0-cp310-cp310-macosx_15_0_arm64.whl

Total release size: 337.4 MB

Release files / snapy-3.1.0-cp313-cp313-manylinux_2_27_x86_64.whl

Download URL snapy-3.1.0-cp313-cp313-manylinux_2_27_x86_64.whl
Size 78.9 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64
SHA-256 checksum
How to use checksums
e41875a7734f14b1c5e5b4f234fc2c4a159e1a80787dff51130dab74946b3be4
BLAKE2b-256 checksum
How to use checksums
138a3dc996ad9e6ac8b514a4cc038e06a79e8b74f19cddade88e849498c56d85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / snapy-3.1.0-cp313-cp313-macosx_15_0_arm64.whl

Download URL snapy-3.1.0-cp313-cp313-macosx_15_0_arm64.whl
Size 5.7 MB
Tags CPython 3.13 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
775b991c83de5d546a75643b3b49126ca1fcce9335f9a55fc34ce3a119179624
BLAKE2b-256 checksum
How to use checksums
b3d4e5200a8e568e52c1a65dcfba6cf133da2a441a0b416428c21cf66304df9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / snapy-3.1.0-cp312-cp312-manylinux_2_27_x86_64.whl

Download URL snapy-3.1.0-cp312-cp312-manylinux_2_27_x86_64.whl
Size 78.9 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64
SHA-256 checksum
How to use checksums
a2c2b7a53fdae334b76cb009932e1951a0ca71bdb0d1d1fa7cf2fe2f1c755cd6
BLAKE2b-256 checksum
How to use checksums
4c405cc8884cfb3305617a81a9a6672a9e27422eee2471b3ef8b3061c6e9818f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / snapy-3.1.0-cp312-cp312-macosx_15_0_arm64.whl

Download URL snapy-3.1.0-cp312-cp312-macosx_15_0_arm64.whl
Size 5.7 MB
Tags CPython 3.12 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
6ffe7547c8899a7ba58c67d73a2d66313d0d6eec51f17cc74a7fc4dbf0514dbf
BLAKE2b-256 checksum
How to use checksums
583ce0b0495345480158716dbd78157344fbf2e7ad2a9c896a0865e567bfd0ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / snapy-3.1.0-cp311-cp311-manylinux_2_27_x86_64.whl

Download URL snapy-3.1.0-cp311-cp311-manylinux_2_27_x86_64.whl
Size 78.6 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64
SHA-256 checksum
How to use checksums
04233e35413cfe94379b675947f2c5fd4078e9c44c8e3ca6840a6725e264c7bf
BLAKE2b-256 checksum
How to use checksums
85d8e1d5cc46cf06f957ebbaa41e912f687ceaecc98b7f5be64c04b8f390f9fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / snapy-3.1.0-cp311-cp311-macosx_15_0_arm64.whl

Download URL snapy-3.1.0-cp311-cp311-macosx_15_0_arm64.whl
Size 5.7 MB
Tags CPython 3.11 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
a493dfde360e98452b64d45d44c283eb440b2870b99c6c79ce81aa52be55d0b8
BLAKE2b-256 checksum
How to use checksums
5a26aae8a125bd6697ef2b78dbc73165b081d3cba4008a282b9faa403ac41a65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / snapy-3.1.0-cp310-cp310-manylinux_2_27_x86_64.whl

Download URL snapy-3.1.0-cp310-cp310-manylinux_2_27_x86_64.whl
Size 78.4 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64
SHA-256 checksum
How to use checksums
581aebb061ece55efe705aaddcfe857a8025e9aa239596961ca5f339fd8e719b
BLAKE2b-256 checksum
How to use checksums
06441958eb2264b0eb4e322f6961a71e964535a2d948a6ca0b7ebfedbbbc1123
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / snapy-3.1.0-cp310-cp310-macosx_15_0_arm64.whl

Download URL snapy-3.1.0-cp310-cp310-macosx_15_0_arm64.whl
Size 5.7 MB
Tags CPython 3.10 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
7a4b6ff409397eab0810e1ec0c2692cf6800aaa7b43405d92d9c79a7b01d65ee
BLAKE2b-256 checksum
How to use checksums
027a72a18c2ccb5f5f874d9ac2788a2b5a06845e8e3d6d6726e6ed17dc126214
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for snapy 3.1.0

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.

Release history Release notifications | RSS feed

This release

3.1.0 This release

8 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page