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
  • 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
      
  2. Install NCCL (if enables GPU)

  • Linux (Ubuntu/Debian):
    sudo apt-get install libnccl2 libnccl-dev
    
  • Linux (CentOS/RHEL):
    sudo yum install libnccl libnccl-devel libnccl-static
    
  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.3.1-cp313-cp313-manylinux_2_27_x86_64.whl (51.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

snapy-2.3.1-cp313-cp313-macosx_15_0_arm64.whl (4.7 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.3.1-cp312-cp312-manylinux_2_27_x86_64.whl (51.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

snapy-2.3.1-cp312-cp312-macosx_15_0_arm64.whl (4.7 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.3.1-cp311-cp311-manylinux_2_27_x86_64.whl (50.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

snapy-2.3.1-cp311-cp311-macosx_15_0_arm64.whl (4.7 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.3.1-cp310-cp310-manylinux_2_27_x86_64.whl (50.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.3.1-cp310-cp310-macosx_15_0_arm64.whl (4.7 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

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

File metadata

File hashes

Hashes for snapy-2.3.1-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 21cc1a3d704ac42eb50aaa81d5e2ea88697827cac0b457d021d5f3bda5512a25
MD5 9eac5bfdc4ceff87f0b32d6113b1d840
BLAKE2b-256 3c833959d21c9ef33bd1f9ead83daf8c5551043dc03207b9fcd23900cb2f7c40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.3.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 051f1b8dd3688d5100a8c63f2346c55d07214cf51966dc878a91fdc79c95a039
MD5 cfb1d996395d0797e9fd1ca9bd3516eb
BLAKE2b-256 f91341a083b9c1b044ced165eca23496a3610201c1d2ac33222e4dc2a3192cf9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.3.1-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 794b61a9f7378c9607c7b14e014559d524a8e6b299b13a3d571baed29143916d
MD5 f317f831978c689ce6819e06485713af
BLAKE2b-256 4df4ad7d7f9f0e00ce14767b661ed1214240817d3805920d8ab598879bed0de5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.3.1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 5590da81fc59ebcbb9341f91c215f175cc58ffb54ae82aa7a8af0a01a7f348d7
MD5 3c02f53f0b4f75efb7aef4bfabb8241b
BLAKE2b-256 5caffe3a778fe30d809069647a7609f9958230a6a161c97e173c9cd8d9d2365a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.3.1-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 5b082016f9ac706c6d610e52ed997127d5f3d1f37aa03b2e3239dde0fadde6d2
MD5 e5f65e77f1c3296c2caef18cdf44630d
BLAKE2b-256 2ccdc00281b7dce88167b1cc8dc5148db1e12057768c77a7fcc6a49e98f569bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.3.1-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 6d3963b4099f0a768364e925ac31a6cbf652f66314bb8a4b4fa7e016ca05c3db
MD5 c4a840c996491b488d76de2eba8de054
BLAKE2b-256 01bd23fc2f6597c4fab2647c4d41eb40706afc515c2c3ae9b7cedcc8d2f5e8ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.3.1-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 fb3191dfdf8e682e13b319c3732e22f5bdb7f591901f39f398df81c98e8553c3
MD5 0b47191ef5b7f39882660dbc7615b583
BLAKE2b-256 ae9b7e346fe69dec2bced15d78346f6142b1d6431da73e9f8bc51dc9cfb5a720

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.3.1-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 50505e7939705fe7d6ae90221e97cb576ef25bb4e76b4dfa1f4ac3d18b0a0096
MD5 7c0b5efc0d169aa5540f23ef2f6af8b1
BLAKE2b-256 6feaca6c5238a1613a3561a66ebb6ae251e46ccc9e6b931064ba67fe36ceb9dc

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