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.2-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.2-cp313-cp313-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.7.2-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.2-cp312-cp312-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.7.2-cp311-cp311-manylinux_2_27_x86_64.whl (51.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

File details

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

File metadata

File hashes

Hashes for snapy-2.7.2-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 0081f401f943494ea03e6574c7b9e95fd71fc298bac7c9d2fe39c91778b6552c
MD5 0844db337e2bb8d4ac77b097af6946b0
BLAKE2b-256 dd1bf8d1dfb7a4193d4d3440fd917ca879fc66bf76422272360a467eaf844635

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.2-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 56a5fb610c56cc01e061e12437507d76bc6b95c8929feda78f4d86b7ab99d5d3
MD5 4d80dd9b53a388bd905e6b8cbffbaaca
BLAKE2b-256 0429c6622e2419d25417c6dcefab8ea06e407b3a84b3c0914576f2bfc9858c16

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.2-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 5c85d2f7470c4f8e68928997629763ca4a4a2a7ba520e1f97884d23ec7c4d7d2
MD5 c35186b623b339ef48bf950cb0119201
BLAKE2b-256 157a7f2d47882ec091e531fa937dd85f6d14f3fc3a18d2e4fbbdfb5ad4d3140c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.2-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 823ec6d8bb84bd8455f6c244fd0be3b387be1aef4d38312c7716d13fa5be3778
MD5 4a5d87cb13fb4a9e851d72fb46ab91fb
BLAKE2b-256 045211a02e7a519b39a69bdaebf6e00cac737c95ce7798a925868c4eb864a4bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.2-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 32b42afccb9f89309f608782c528e6131633293fb8b922ced503e98b66d3c80a
MD5 25b02314222314a3a051a74017d52c2d
BLAKE2b-256 7a993cdb94810bef03adf46728e78374d3c2dc00e4ffc410855ee234fe76569d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.2-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 37b14f7bd3283789b7f7930cdd5dff097bdeb1b5bb267b642cadc3bd56b79fce
MD5 48722b23d00729adf08ae54ea635ff51
BLAKE2b-256 0a81367ae1c4b4871fe902504a38b4a926f87f7c44a040d5668526b1e358c723

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