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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

snapy-2.8.6-cp312-cp312-manylinux_2_27_x86_64.whl (57.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

snapy-2.8.6-cp311-cp311-manylinux_2_27_x86_64.whl (57.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

snapy-2.8.6-cp310-cp310-manylinux_2_27_x86_64.whl (57.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

File details

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

File metadata

File hashes

Hashes for snapy-2.8.6-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 86643707a92225847fa8b8e3a518081eca68bf4e737ab42e9038bb1f0d0ba11c
MD5 7858b90259a937a994d7f2388d783d9e
BLAKE2b-256 beaa0dac5a33ad874fb421f29ccd4328889cdc6a4f3ab9735030517217cd895a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.8.6-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 a35a1148784bd0c5ce43932c0a253194ade263abe0d20fe1dc63c34ae9bbbe31
MD5 d21f01558d9f42f8f22d3024ff2238ad
BLAKE2b-256 cf12a4125c9a4130a9b5af487e6d7d0e99d43cb000f3ce944546c98f0fe985a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.8.6-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 c9971bd8ae97a65f2e59fbd8d38cbbde053b8dc28f34319bafa1cb25f516012d
MD5 36130c9a6a216da6a55fe0c9f17477d0
BLAKE2b-256 80437005d011f35cbeff4f6e3bad84bec9ff0fa9f410cc4fc88dec202212f7a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.8.6-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 7fd544b77ecdda370da50c99ed4dc68a4570c5534ccfdb1631c55c04eb207b0c
MD5 7a1701b593e87b86a677cb66de35b1bf
BLAKE2b-256 fcae3989cb8c3b84a5a77afac0868f2e91227d40762e229484d5a0a1f869c19e

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