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.7-cp313-cp313-manylinux_2_27_x86_64.whl (64.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

snapy-2.8.7-cp312-cp312-manylinux_2_27_x86_64.whl (64.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

snapy-2.8.7-cp311-cp311-manylinux_2_27_x86_64.whl (64.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

snapy-2.8.7-cp310-cp310-manylinux_2_27_x86_64.whl (64.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

File details

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

File metadata

File hashes

Hashes for snapy-2.8.7-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 90a886f1ffb605b1454e979ae44c4b87eeb1a273fd0c19e78f3047ec48ffee4a
MD5 70e86362ce353a62c12857abbffe7358
BLAKE2b-256 d25dc84caf9a53fb912387d088067c4818b1527b3b2bb8ffa1cda98352dbbda6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.8.7-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 44df51fab42c09c8fee01d4a918ba659067a19bc69a499db93c088392aecae58
MD5 fa75200f24e59e84ece52ef1a97bdc28
BLAKE2b-256 9222f33818bc5d6063a86a3faa1d4fe164ba25383c7b16c73c4c4c674dea29af

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.8.7-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 c17bf44deb6b58e2344a457cc6649f9816cfbcb104d3aa5f710a0d7d8be63713
MD5 b3be6c569df66432ef1b4e9171364e95
BLAKE2b-256 68124abb63ee3481a9a6fbf83de9a9a17887d07766eea0995add6ca5264b9a96

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.8.7-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 61354b8a8a54abf768cfc50b7f7855fbb5c033a9b07b80c44497033648ae77d6
MD5 003bf8fcd1f1aa5b8150636ff0594901
BLAKE2b-256 9a4d501e468b5aaa8355b2230082a256aaf3f265fe62c08d0c1f2ca61a99bd06

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