Skip to main content

Snapy

Compressible Finite Volume Solver for Atmospheric Dynamics, Chemistry and Thermodynamics

Snapy is the dynamic core for simulating atmospheric and planetary dynamics using PyTorch tensors and GPU acceleration.

PyPI version License: MIT

Features

  • GPU-Accelerated: Built on PyTorch for efficient GPU computation
  • Flexible Interfaces: Both Python and C++ APIs available
  • Compressible Flow: Finite volume solver for atmospheric dynamics
  • Multi-platform: Support for Linux and macOS
  • NetCDF Output: Standard output format for scientific data

Installation

Quick Install (Python Interface)

The easiest way to get started is to install via pip:

pip install snapy

This will install the Python interface with pre-built binaries for Python 3.9-3.13 on Linux (x86_64) and macOS (ARM64).

Parallel run

pd-run 6 ./test_exchange.release

list listening port

lsof -i:29500

kill listening port

pkill -9 XXXXX

Requirements:

  • Python 3.9 or higher
  • PyTorch 2.10.x
  • NumPy
  • kintera >= 2.6.13

Build from Source (Advanced)

Building from source is recommended only for advanced users who need to:

  • Modify the C++ core
  • Use custom PyTorch versions
  • Access the C++ interface directly
  • Develop new features

Prerequisites:

  • CMake 3.20+
  • C++17 compatible compiler
  • Autoconf, Automake, Libtool, and pkg-config on Linux (for fetched UCX)
  • PyTorch 2.10.x with C++ libraries
  • NetCDF C library
  • kintera >= 2.6.13

Build steps:

  1. Clone the repository:
git clone https://github.com/chengcli/snapy.git
cd snapy
  1. Install dependencies:
pip install numpy "kintera>=2.6.13" torch==2.10.0

Kintera 2.6.11 introduced the compute_into solves required by this branch; 2.6.13 is the floor because the recorded test references use its exact SI gas constant (8.31446261815324 J/mol/K). The 2.6.13 wheel is on PyPI and is what CI installs; to build it from source instead, install tag v2.6.13 of chengcli/kintera first.

  1. Install NetCDF:
    • Linux (Ubuntu/Debian):
      sudo apt-get install libnetcdf-dev
      
    • macOS:
      brew install netcdf
      

UCX support is provided by the Python package commux. Install snapy's Python dependencies in the active environment before configuring; use -DUCX=OFF only when building a Gloo-only configuration.

  1. Configure and build:
cmake -B build -DCMAKE_BUILD_TYPE=Release -DNETCDF=ON
cmake --build build --parallel 3
  1. Install the Python package:
pip install .

Examples

The examples/ directory contains several working examples:

Python Examples:

  • shock.py - Sod shock tube with internal boundary
  • straka.py - Straka cold bubble convection test
  • robert.py - Robert warm bubble convection test

C++ Examples:

  • shock.cpp - Sod shock tube (C++)
  • straka.cpp - Straka cold bubble (C++)

Run a Python example:

cd examples
python shock.py

Run a C++ example (after building):

cd build/examples
./shock

See examples/README for detailed documentation on the code structure and available examples.

Configuration

Simulations are configured using YAML files that specify:

  • Grid dimensions and domain size
  • Time integration settings (RK stages, CFL number)
  • Boundary conditions
  • Output settings (frequency, variables, format)
  • Equation of state and thermodynamics

Example configuration files (.yaml) are provided alongside the examples.

Scheme choices are deck keys under dynamics:, read per block; every block of a run must make the same choice, which blocks built from one deck do:

key default what it does
flux-covariance true the x2/x3 face-flux covariance correction (#289, docs/derivations/289-covariance-x3-curved.md)
x1-mass-covariance false subtract the x1 rho-w covariance from the reconstructed cell velocity; needs at least 3 x1 cells per block

They replace the environment switches SNAP_FLUX_COVARIANCE and SNAP_X1_MASS_COVARIANCE, which are no longer read. Defaults are the same whether options come from a deck without the key or are built in code: EOS floors density-floor: 1.e-6, pressure-floor: 1.e-3, temperature-floor: 20.; a riemann-solver without type is hllc.

Development

Testing

Run tests after building:

cd build/tests
ctest --output-on-failure

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

Metadata

Release files for snapy 3.0.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.0.0
File Actions
snapy-3.0.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.0.0-cp313-cp313-manylinux_2_27_x86_64.whl
snapy-3.0.0-cp313-cp313-macosx_15_0_arm64.whl CPython 3.13 CPython 3.13 macOS 15.0+ ARM64 Details for snapy-3.0.0-cp313-cp313-macosx_15_0_arm64.whl
snapy-3.0.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.0.0-cp312-cp312-manylinux_2_27_x86_64.whl
snapy-3.0.0-cp312-cp312-macosx_15_0_arm64.whl CPython 3.12 CPython 3.12 macOS 15.0+ ARM64 Details for snapy-3.0.0-cp312-cp312-macosx_15_0_arm64.whl
snapy-3.0.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.0.0-cp311-cp311-manylinux_2_27_x86_64.whl
snapy-3.0.0-cp311-cp311-macosx_15_0_arm64.whl CPython 3.11 CPython 3.11 macOS 15.0+ ARM64 Details for snapy-3.0.0-cp311-cp311-macosx_15_0_arm64.whl
snapy-3.0.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.0.0-cp310-cp310-manylinux_2_27_x86_64.whl
snapy-3.0.0-cp310-cp310-macosx_15_0_arm64.whl CPython 3.10 CPython 3.10 macOS 15.0+ ARM64 Details for snapy-3.0.0-cp310-cp310-macosx_15_0_arm64.whl

Total release size: 318.2 MB

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

Download URL snapy-3.0.0-cp313-cp313-manylinux_2_27_x86_64.whl
Size 74.5 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64
SHA-256 checksum
How to use checksums
a20e3bafe4c04f91634e15640942ed01a0a5105c7bc1a8f9569ad76476c1ce70
BLAKE2b-256 checksum
How to use checksums
1a7ccc3e174ae1f514b7f628499d8e902af89e94c8cd03dff0a139ab20609ae6
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.0-cp313-cp313-macosx_15_0_arm64.whl

Download URL snapy-3.0.0-cp313-cp313-macosx_15_0_arm64.whl
Size 5.3 MB
Tags CPython 3.13 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
820e02c5da67fffa928cc03c841b42bb06e7f0d5e5b323a85c1b29295d4d9b71
BLAKE2b-256 checksum
How to use checksums
3b155c5be794c754e088f3a2b34a1931da8dbeefcf054ceceab7e937bb3b8b77
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.0-cp312-cp312-manylinux_2_27_x86_64.whl

Download URL snapy-3.0.0-cp312-cp312-manylinux_2_27_x86_64.whl
Size 74.4 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64
SHA-256 checksum
How to use checksums
90903fcbac8f3a0a29f2c2f634a0709a69149e68b4ddda72d257b8c889579eab
BLAKE2b-256 checksum
How to use checksums
07f62c91b894abd5a6c6e7ce8575c1d092938e08ee84a3baf11793b0cbcf729d
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.0-cp312-cp312-macosx_15_0_arm64.whl

Download URL snapy-3.0.0-cp312-cp312-macosx_15_0_arm64.whl
Size 5.3 MB
Tags CPython 3.12 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
381b996ffbe444cfcbd058c36f70f596f36d738af0a939ac8dc0b44cd3ec8ac7
BLAKE2b-256 checksum
How to use checksums
c385146d5d00f0cf4b9252fbae471fc2beecd8795c68ce94fb752c7663fb060c
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.0-cp311-cp311-manylinux_2_27_x86_64.whl

Download URL snapy-3.0.0-cp311-cp311-manylinux_2_27_x86_64.whl
Size 74.2 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64
SHA-256 checksum
How to use checksums
13218272b6a64a0f25efaf6a1d72f5ecc163d7e840dbfcabbe9c4160b91403b7
BLAKE2b-256 checksum
How to use checksums
7a664466a0b40607052eb13e3a02dc0c93d0b03d28cbebee63a68bc89799dd34
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.0-cp311-cp311-macosx_15_0_arm64.whl

Download URL snapy-3.0.0-cp311-cp311-macosx_15_0_arm64.whl
Size 5.3 MB
Tags CPython 3.11 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
5055e0c74b8087eeacfb638118f2ce66d5c1ec3401f2a71f340d2d04a0285be8
BLAKE2b-256 checksum
How to use checksums
7fa9d28060439fcf6cef06c9c842715c3693f0cad84d3664fb2fbf3b2a7c9e3b
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.0-cp310-cp310-manylinux_2_27_x86_64.whl

Download URL snapy-3.0.0-cp310-cp310-manylinux_2_27_x86_64.whl
Size 74.0 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64
SHA-256 checksum
How to use checksums
1a2bced065b64913e84b9f607f80477c712f907812fe79e3449e52f1d409ead7
BLAKE2b-256 checksum
How to use checksums
661ce4b72ec04c66f945a4c0647c3bcae50fcece6d84d85c014f5b73b6c8bd97
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.0-cp310-cp310-macosx_15_0_arm64.whl

Download URL snapy-3.0.0-cp310-cp310-macosx_15_0_arm64.whl
Size 5.3 MB
Tags CPython 3.10 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
f36e1610457fe681522a8b04ffc7831dc30be3f5650691f4a095c23c495429bd
BLAKE2b-256 checksum
How to use checksums
82dd32d4254c3a4bdc806a393ad7f22268df54fb44029370ac0bf0a3d6dc63dc
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.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.0.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