Skip to main content

Compressible Finite Volume Solver for Atmospheric Dynamics, Chemistry and Thermodynamics

Project description

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.7.x
  • NumPy
  • kintera >= 1.1.5

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.7.x with C++ libraries
  • NetCDF C library
  • kintera >= 1.1.5

Build steps:

  1. Clone the repository:
git clone https://github.com/chengcli/snapy.git
cd snapy
  1. Install dependencies:
pip install numpy kintera torch==2.7.1
  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.

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

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

snapy-2.8.1-cp313-cp313-manylinux_2_27_x86_64.whl (51.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

snapy-2.8.1-cp313-cp313-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.8.1-cp312-cp312-manylinux_2_27_x86_64.whl (51.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

snapy-2.8.1-cp312-cp312-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.8.1-cp311-cp311-manylinux_2_27_x86_64.whl (51.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

snapy-2.8.1-cp311-cp311-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.8.1-cp310-cp310-manylinux_2_27_x86_64.whl (51.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.8.1-cp310-cp310-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

Details for the file snapy-2.8.1-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.8.1-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 ef77e6b95cb2cefd597b3e47f52caba4a7b3a5c8c78707bd67a5551a5f5436c8
MD5 82dabd722e73409f60098c20fbd77900
BLAKE2b-256 0c11e343539d41c4cfefb5b8189dcbace3d4e67f04964a82b2d7077e04abab82

See more details on using hashes here.

File details

Details for the file snapy-2.8.1-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for snapy-2.8.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 dd19aec8ea26f0ec0b9d262473010bca8ad6d8e72b40d1c61d446e622e4fab67
MD5 829b5c088c14553609334e3b87e06b3c
BLAKE2b-256 081aa2b83a538f5bfc10ef78e2b67c5a1e3865d105f064f9a3b2917a4d13a0f3

See more details on using hashes here.

File details

Details for the file snapy-2.8.1-cp312-cp312-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.8.1-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 b28bbc2d130362d8bb621179d616f5424493b6e2a0e290ae3b811c8771009bfc
MD5 8a536f7fc470b1f2f170b7ddbc5ff269
BLAKE2b-256 e1007e42c05767c4988cf1fb385045a265831e7435c1859bb29b8e1f3ea0c34a

See more details on using hashes here.

File details

Details for the file snapy-2.8.1-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for snapy-2.8.1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1b90efbde28632920e8691fcf6fc7cc7cf831d738745764d2a37b99c0a734a5f
MD5 bcf381653917b287a7b49ff8728e906a
BLAKE2b-256 8eeaf8b234b93410737c20a3ad85ef1d9eea02708d922a017406ad40a540ac73

See more details on using hashes here.

File details

Details for the file snapy-2.8.1-cp311-cp311-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.8.1-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 7fd7e0c8d14e6221a2b5d410ad56ae9a7a361ca18ab42056384cdd84ef2face9
MD5 e4d5fdc507b3a3a707ecfa0adbcd9403
BLAKE2b-256 a6dfbe370a5e5214f50d08dc7578c7d24eeec35222f8448d9d290586d1ad1063

See more details on using hashes here.

File details

Details for the file snapy-2.8.1-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for snapy-2.8.1-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 33507f904ba9b16c9c60459c8258a8f3699d6596ad2d651f666debbf85fdf4c6
MD5 88b8daaad1fb5d4b6c6dff6941ce0b47
BLAKE2b-256 edbc40e13562c4e1d2e2450db1050c9061451349e8aebbc164b50e6ca964a2ac

See more details on using hashes here.

File details

Details for the file snapy-2.8.1-cp310-cp310-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.8.1-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 bc3aca9921d13700d89a8147d0a11af1174e1daf57ee5bd24559b76511bf1be5
MD5 1bb7fa08635fd05a8102ebf2dead5be9
BLAKE2b-256 fc6871413cf28f4d97603c7e38a5a30f9b490a2d2a88b8ef6e82eea0b4322d04

See more details on using hashes here.

File details

Details for the file snapy-2.8.1-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for snapy-2.8.1-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 41ac64aa3f59596c974a1970939e47a34d508908256fb01b0d2db35783f682b1
MD5 2329db199675f21552df7c7b19ab9bac
BLAKE2b-256 407d6108c8ee05139e1d10a2d9e617dd91ae522a6c93cd8cdbcd924039f236a3

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