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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.0.1-cp312-cp312-manylinux_2_27_x86_64.whl (45.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.0.1-cp311-cp311-manylinux_2_27_x86_64.whl (45.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.0.1-cp310-cp310-manylinux_2_27_x86_64.whl (44.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.10macOS 15.0+ ARM64

snapy-2.0.1-cp39-cp39-manylinux_2_27_x86_64.whl (44.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64

snapy-2.0.1-cp39-cp39-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

File details

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

File metadata

File hashes

Hashes for snapy-2.0.1-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 f4671d985de0382d4dc4fb1ca680250a9b846192265a544a9e96a87536995f1d
MD5 1fdd72285d3fe3b2a2f9d134eb5afde1
BLAKE2b-256 72058629939048f1b8647f23b398dcf57c912d5ced3290ef686e031a73ff7935

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.0.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 71c5f6e3d865c53c694bfc7c31dfa62c5ef18d56688613e1140a32c5b3e4546e
MD5 8dbf722fe403546314ea06c27039a642
BLAKE2b-256 fa58216cbdcba157bc4073e0bc3694c3b78c7ec4fb2ddbc23307a7a58a4fe447

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.0.1-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 6bd227afcf6003d5f2b70e441279b3a2f7961b633ebff8feb4bf1fa90d23195c
MD5 715592fad82dc0ba9e2c81ee933c9c9d
BLAKE2b-256 4bdf4aab1e7a9f538a5c2404f6b4b932508a48b6ccea9efef1deef729f99a367

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.0.1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 d2d59579f31e07c3fd0a2434236b2b6bf12134d6699a677fd37ff363c72d7612
MD5 98b3206f098e1b66c061e18a7f65fcb2
BLAKE2b-256 4f87c28f7c31c65446e42292c7cbfa72ae634f3568ef93ae627627e96a7d1b18

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.0.1-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 704c9bea56a7e5c7f060bc397ebb247703cfecad20a5ef69ba2424a49c0d2666
MD5 1b31f14db91be413f5c2151a157d2d8d
BLAKE2b-256 6d4716dd8e80904cdd56e254584b7582748107e7df5c128df6a38d108c833667

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.0.1-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 42bb34edd017fa0b5ce283294e6e3747cfd1ee0d0d2e15020826f78e569aa965
MD5 0af95529b62adc133d4e524a3acd1f70
BLAKE2b-256 87d2e85966c710a77c5b0ae99ff655975059e90347d5f99eb20d3fcfd7b0b3bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.0.1-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 abad00522420b757546aa52bb73eb27898abd664ccf2c0507304bea03f333d63
MD5 6489426a0cb00bd373c018e90826be9b
BLAKE2b-256 e73881dce5c735daf8106f28208709f007cd8a2773d42f8096a87bb8408b0456

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.0.1-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 84e169ab68694edbd34df94c76e54e2f9fd181e3b05c1d71e32d9229c2e82f7d
MD5 d30dca7074fe7cffde593d8c0039dfb8
BLAKE2b-256 756aff1653162aa80312298e197c02632c2f99bba0a3fb035caa265320f07fb2

See more details on using hashes here.

File details

Details for the file snapy-2.0.1-cp39-cp39-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.0.1-cp39-cp39-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 77439aaff9c1341b003467d18eed1ee60f6cebd5ab1855684e86394b2f675af8
MD5 f7f2f276bd0c28eead8fdb1b2b039582
BLAKE2b-256 25028b1f0c30de5a131fd3b88944f2918fbbdf9c14d1a47d365344bbd356f1f7

See more details on using hashes here.

File details

Details for the file snapy-2.0.1-cp39-cp39-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for snapy-2.0.1-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 de1bf7cc2bd0a5df63bcb39b55e1033a0bb5be654c7449268d0482278355897e
MD5 84a351d6164125df2e6747b5b6efbbb7
BLAKE2b-256 9be57fb12f5fa70cffb73cf9daaae15abe63d9a1949b2bb771fb36b52d3604fa

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