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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.9.2-cp312-cp312-manylinux_2_27_x86_64.whl (59.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.9.2-cp311-cp311-manylinux_2_27_x86_64.whl (59.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.9.2-cp310-cp310-manylinux_2_27_x86_64.whl (59.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.9.2-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.9.2-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.9.2-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 1de9c25909ddbfa7d0f4f80872488d2172a67b25168703068fdf48fed4ee804d
MD5 83d90f6a7bd566630a3fdf867575bf30
BLAKE2b-256 8c746a5b5e24c145ed3b452d438fc08fb534d260820fd5d9f7fc260a34b1a31d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.9.2-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 d5d1099861dc51b2388d04df8179fd58e767d5c69b1b15dcc235fa70e0fe72c7
MD5 e71bddcaf4f75a597164c9433132e015
BLAKE2b-256 e3b547578fed3cb3c575cb6dde247131db8fe3363f4fd496af103d35eab9e3df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.9.2-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 035fd1d26542643d8bbae29a36aa00f7edcb528b5f2af52d545f362c7fc2f323
MD5 e18fef5951a3a8695d34c9c5ea406971
BLAKE2b-256 e31fa1f4f474f1f5e3fa5ec4063bd96b590ececcc04190c929c1f6dea46ecc9d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.9.2-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 101e761a97138aafbcf78a475eadda26a2e0e6bdbe63a6fe15ec10c00477bb3c
MD5 931bee102fa167f499d963dde71d40d4
BLAKE2b-256 dfd6510a16c136d00806350c6f785f886cba2de814cac9cfe811d33e62247e90

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.9.2-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 03f15f9b63ba932d1b7c3851c8de7a0bd572350f0329913b28cd28b8a331ae3f
MD5 fd44c933acd3b2503a5e020369ba7b82
BLAKE2b-256 874e0295c859ac1169cc5bfa3fa7950cc8a36e99a8796db9ee977014eb3d7395

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.9.2-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 54c9b337503d5571f954fd043b8da7c68762034ab0c100189dfabd9f1c2fef88
MD5 4d671f0d1035769f3d1285fcd10cf527
BLAKE2b-256 fec5077f0801ec52fe38068ed0389f6fe49c0e8e28f803a915ba372d4d267ed6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.9.2-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 048e011cad706272ba6070b4584150dbd817445cc9f3f1bf330a33a0f9b75f41
MD5 e6fd9db492c4f602a37d44b9bbe10569
BLAKE2b-256 958cd8675047676f0008ed7338b68b9a19ef26c54dcde9a1783b1ddc814e15bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.9.2-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 6ecf0a3bde3223f775d39b7a6214666c8cd1cef4e247998a57d80592d3a4724c
MD5 61002089e685bc92d1e205b5e63e5fa0
BLAKE2b-256 b2604791813c89be6ca18dc613d4bf4753786794c5ae25f9f915a511bda66f04

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