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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.7.4-cp312-cp312-manylinux_2_27_x86_64.whl (51.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

snapy-2.7.4-cp311-cp311-manylinux_2_27_x86_64.whl (51.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

snapy-2.7.4-cp310-cp310-manylinux_2_27_x86_64.whl (50.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.7.4-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.7.4-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.7.4-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 ecaee64d1b35b7608e37e6ebc02a22db5a4ead8039ba6a9b4c2095a4532e096a
MD5 7be0b4e3088fb1d447b6a67d4338a548
BLAKE2b-256 95403b651f270ae2eeadbe4e66ec8251ea8b7214076e4e1559a4e2f8e825d5a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.4-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 fc8f7ec34b36fb871e140f1d40e3c8096f468400b991605a990d1e03a8413ecf
MD5 8020a12a96015be07eac7803b2977235
BLAKE2b-256 b1aee17f69f1e78232f75ee85f8306adce3ee99c903f9c9b26635fd524fed604

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.4-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 96ecdfb942831c436b1d1144cc68c1280857f77aea45f8e68391ea0632328cdd
MD5 baaf852ce7611e90ad04f89e174ed26f
BLAKE2b-256 412900687e159e9f95ec0d63f22037a0765e9b15b2b37d2e0ac97054a755cb7e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.4-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 f8762e5cbcb07b13cca9f62800377bf77374b0b758b99d80ed49b8aea49b1891
MD5 99756ca27796d9326d3fe453f93548ab
BLAKE2b-256 bf6ff2b1cf9f2d27335324a89c17aaa0b14a7d95c231db0a73a8dcfc0d7bc0d9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.4-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 2a8a4c520453da4fee53bcf70248f804c08294e6fdad63f5cb515c7c8d7835ca
MD5 e004ece2a5394f19d907b2620fb7f970
BLAKE2b-256 a2a4a20a552d434f1bb5bca7219e49db9e523f619b07560e42af2dd84f56e813

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.4-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 5860c7ad826ad76f1fabc896e4e596666d4dba4ce4a33ad355c96ae7677393f1
MD5 b994408ebe277766a291dfd82f2e6dc8
BLAKE2b-256 37a32de1ff2e249e8ac24aa5ea616dd0eff6e612f47d572864b700b47f534606

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