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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

snapy-2.4.1-cp313-cp313-macosx_15_0_arm64.whl (4.4 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.4.1-cp312-cp312-manylinux_2_27_x86_64.whl (50.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

snapy-2.4.1-cp312-cp312-macosx_15_0_arm64.whl (4.4 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.4.1-cp311-cp311-manylinux_2_27_x86_64.whl (50.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

snapy-2.4.1-cp311-cp311-macosx_15_0_arm64.whl (4.4 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.4.1-cp310-cp310-manylinux_2_27_x86_64.whl (50.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.4.1-cp310-cp310-macosx_15_0_arm64.whl (4.4 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

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

File metadata

File hashes

Hashes for snapy-2.4.1-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 05e4b0245bf5dea72c80c9aec79a4a98ebfbb8a7494be546e0579691e6315e80
MD5 72373126a78f56e959de8fae0a64038d
BLAKE2b-256 a78de0ab33c1a58fe577718518c8e8930d9e8ebaa30b08fff399097c51c0d66d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 3f8e32f28a149035a67bb7e0e891249fdf7eb6fe3bd7e04d5157072198df40fd
MD5 a4d821d94464e28b98505bd10e6c1b33
BLAKE2b-256 ad500ac792574ba074839fda7a044e20e0687506f3f2a7ebed31a962d70b232a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.1-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 0b82e4f1064330beedec4a6326f593593f8ea25a4f997b227d6ae56302785945
MD5 1ec4aadf11ae36dbd0ae61f55926f5d4
BLAKE2b-256 e20f72bfb6fe5740d56582c87b4828e8f2196da9351bc40e243d5cbb18dbabdb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 2603be8eadf2ff0576c0d1571f23838ae0bda3a9dd485da958a27be755cbb346
MD5 4e414498395c9b47354f8c769b90b382
BLAKE2b-256 3a0d6ef24d82cd684136730476b3f3376225a3b283e4e54813e642a543b15327

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.1-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 84399e3a991e5c626a2a2ffe7c7b1ba826ab5247e5e8ede5ea76038a87c1a47b
MD5 36ed73e1e636c13d059546b4ce39dea9
BLAKE2b-256 863b52cb53a79fe78f731bf5bd5d7dcab1ba8417af1b596de443bc54e8ad46c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.1-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 39b67eb58009bbba20ab7e2c0a6a4949c83fb8859a25ff1bf5d6283ab606b190
MD5 eb6ffa21fc0296fe402620e87ac46551
BLAKE2b-256 487d442516ec75fbb78b7eb8e5b3462934b4480eaac50af921856a31d9b948f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.1-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 7657779e54baaa0fcbcd26261352b561359fbf74d35f25a1b407e5de302be805
MD5 d92a808269d7c49170e0f4cba09ad11e
BLAKE2b-256 ca4dcc4c9df473205ea7c56342e58f157d4dd9058207d4fd9eb01c05ffad55ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.1-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c577442efae7f1b6bb1df800e0089d1cd71668e816a3e11c1b5ed6c53cd868a2
MD5 17f48542126d8b80f7355e0e0a7da5cd
BLAKE2b-256 f06f034daa60973c93f4935d1a14ded61599b62b601de480a836d55d26131646

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