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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

snapy-2.2.0-cp313-cp313-macosx_15_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.2.0-cp312-cp312-manylinux_2_27_x86_64.whl (48.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

snapy-2.2.0-cp312-cp312-macosx_15_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.2.0-cp311-cp311-manylinux_2_27_x86_64.whl (48.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

snapy-2.2.0-cp311-cp311-macosx_15_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.2.0-cp310-cp310-manylinux_2_27_x86_64.whl (48.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.2.0-cp310-cp310-macosx_15_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

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

File metadata

File hashes

Hashes for snapy-2.2.0-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 e36c8e096fddd65ffadb74dcb20e22ca156ae2da58c55b29c5f481285bc4c086
MD5 cebd4b2a130142d5c8df02bc89743e06
BLAKE2b-256 4ae9ee4d2ab094e57798d71c59869afaea425f1b839f4f55449817d599c64f19

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.2.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 50bc055e8b555b4e1658d0818d495666168d18d16ac1ba79fbc9b286c8233779
MD5 68cb98536e7cacef7e858a688c74d98c
BLAKE2b-256 68e6dddc5f41c115c70a3810b1452071dc2785aaba0594a2d26b8d1dee1f6dbb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.2.0-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 5c3860c744ce2bf0889e510e9b898c81e9dfe888cc3cb7d37407a084838e05e8
MD5 64b8b66bcbe42263179859cacbd3bad4
BLAKE2b-256 85c95e44fabd84a6ff4bb1cecf640b344627d1c546e7cf2170df103ce0904076

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.2.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 e089a76d6da43c9b5fa8d5f5c914ddb4cbdfb054f102412711275b217dd8822d
MD5 493fee41ce9db0245519c340e54273d0
BLAKE2b-256 2c6caf1d6efc087532e8a03fc1d7f7c9c0b8c6ebabbd604e4dde4bfeb5367545

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.2.0-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 b87bd65af838dd173b1609a93ef848adc09a4c0f14bfe7dd3d14cd5ebb419c92
MD5 6ffcc020bab58d39f17c401a9b78df8b
BLAKE2b-256 96c65b4669915c32196a55084750af6dd256abee05f8b35440585e79a5293937

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.2.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 0dab630e04272d9491f1154d5ff9ff83dc593ab33cb8b79f5bbfe9e85ebfb117
MD5 03728f6868acbaa02a635f90e8764035
BLAKE2b-256 a648fbdc6f138b6256b9949abd0777a51b0eb4809c04814e25d0a47a075e4daf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.2.0-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 fc8e15ce17f346b27d5cb315bf2babfc4d78be6743d2881b85873515bdd4d9c4
MD5 7ad9d85956cd15ff63a658adc9703b65
BLAKE2b-256 cb62d936e1e64215b48cb4b6a591cba2d035672e3135f2ba0123631a7365591e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.2.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 392d0cfea8d914d0c4d723649bea2af44cb40adbf1bc4a951ee9211911af9193
MD5 eaaf366ed329f873304b81e7d0ab652f
BLAKE2b-256 ab09abd1b1249c46eb6cfb4614a9e7113bfd9bd274420ff236d86ab02bb763b9

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