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.
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 Sod shock-tube deck and construct its block in Python.
import snapy
options = snapy.MeshBlockOptions.from_yaml("examples/shock.yaml")
block = snapy.MeshBlock(options)
The shock driver shows how to set the left and right gas states, initialize the block and advance Runge–Kutta stages. 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.precisionto choose the block precision andintegration.implicit-precisionto control the vertical solve. The precision policy uses FP32 for quantities that would otherwise require FP64 on MPS. - Set
integration.executiontoauto,eagerorcuda-graph. In Python,block.execution_capability(vars)reports capture eligibility for the configured block and its initialized variables. - Set
dynamics.flux-covariance(defaulttrue) for the x2/x3 face-flux correction anddynamics.x1-mass-covariance(defaultfalse) 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.0.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 337.4 MB
Release files / snapy-3.0.13-cp313-cp313-manylinux_2_27_x86_64.whl
| Download URL | snapy-3.0.13-cp313-cp313-manylinux_2_27_x86_64.whl |
|---|---|
| Size | 79.1 MB |
| Tags | CPython 3.13 Linux glibc 2.27+ x86-64 |
|
SHA-256 checksum How to use checksums |
74296aa5b84ad936379307279d85dbe27d6b52c929171ff8e375a7bf8bc341d7
|
|
BLAKE2b-256 checksum How to use checksums |
3c34b85e651b11de9b41eed50312cbba8a1790e4093afb94dde58d1691eb9253
|
| 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.0.13-cp313-cp313-macosx_15_0_arm64.whl
| Download URL | snapy-3.0.13-cp313-cp313-macosx_15_0_arm64.whl |
|---|---|
| Size | 5.4 MB |
| Tags | CPython 3.13 macOS 15.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
a394f7d7cb3538002e1393355fe67cbb4a317842f68fc5f54103bfa6837d3b36
|
|
BLAKE2b-256 checksum How to use checksums |
4f27fedf45ac45e452a5027b0bcf5d2c73205319510ca833486546b079a37199
|
| 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.0.13-cp312-cp312-manylinux_2_27_x86_64.whl
| Download URL | snapy-3.0.13-cp312-cp312-manylinux_2_27_x86_64.whl |
|---|---|
| Size | 79.1 MB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 |
|
SHA-256 checksum How to use checksums |
d5cea035efdc7977825c9eae13e9ab63a3879f26307f6626294c19ba7e157ab9
|
|
BLAKE2b-256 checksum How to use checksums |
6edbf3b93b0128c949425578cac2e01627214426e445fdb56d0d8e2a5353744f
|
| 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.0.13-cp312-cp312-macosx_15_0_arm64.whl
| Download URL | snapy-3.0.13-cp312-cp312-macosx_15_0_arm64.whl |
|---|---|
| Size | 5.4 MB |
| Tags | CPython 3.12 macOS 15.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
dfacc498649b4217d290e1c6166968fdcc38dff6ff5e94d271ae98d3cc0e6618
|
|
BLAKE2b-256 checksum How to use checksums |
12e7a2100d512db393cec5cdf0613382ce13ce54b12ca927d1e054a554f3c0ea
|
| 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.0.13-cp311-cp311-manylinux_2_27_x86_64.whl
| Download URL | snapy-3.0.13-cp311-cp311-manylinux_2_27_x86_64.whl |
|---|---|
| Size | 78.8 MB |
| Tags | CPython 3.11 Linux glibc 2.27+ x86-64 |
|
SHA-256 checksum How to use checksums |
f04a86c3ed05a3e13c1c5d24e3a34009f22eba9e1621353214804c7382ec70f8
|
|
BLAKE2b-256 checksum How to use checksums |
4214378f5657da36b7b8de249e855a4f646e2133e39dce77f84bbd90e48a4680
|
| 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.0.13-cp311-cp311-macosx_15_0_arm64.whl
| Download URL | snapy-3.0.13-cp311-cp311-macosx_15_0_arm64.whl |
|---|---|
| Size | 5.4 MB |
| Tags | CPython 3.11 macOS 15.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
9afeb36b6e38378cf3e39f78dc317c73e8816a85711195adebfccfb7c76a5138
|
|
BLAKE2b-256 checksum How to use checksums |
d731d2947630e1796115e5b1cfd2d1f4851a8e8d3a102fb931bba85859b26bd1
|
| 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.0.13-cp310-cp310-manylinux_2_27_x86_64.whl
| Download URL | snapy-3.0.13-cp310-cp310-manylinux_2_27_x86_64.whl |
|---|---|
| Size | 78.7 MB |
| Tags | CPython 3.10 Linux glibc 2.27+ x86-64 |
|
SHA-256 checksum How to use checksums |
9ca9c99aeff6596e71ab405655df409299ef3f30f3183014a37b40f84fe85848
|
|
BLAKE2b-256 checksum How to use checksums |
06b84cbf95ca80f46ab99744c90fd11fad3f1ec5c84d490d56beb7f6f1a9d248
|
| 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.0.13-cp310-cp310-macosx_15_0_arm64.whl
| Download URL | snapy-3.0.13-cp310-cp310-macosx_15_0_arm64.whl |
|---|---|
| Size | 5.4 MB |
| Tags | CPython 3.10 macOS 15.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
fb92ded56d3f0b4a8c12558b1739c2a87d4db3680a044ac932e9128cce35c6b7
|
|
BLAKE2b-256 checksum How to use checksums |
cce5cb5d3ab7adca03ec7eae0103b2b95eec19460e6112106a2c4939164c672f
|
| 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.0.13
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.