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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.5.1-cp312-cp312-manylinux_2_27_x86_64.whl (51.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.5.1-cp311-cp311-manylinux_2_27_x86_64.whl (50.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.5.1-cp310-cp310-manylinux_2_27_x86_64.whl (50.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.5.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.5.1-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.5.1-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 6d54685b6440566a7e68ea7431b771216de8dbf3ff78f3abfe72f4227af7b4a7
MD5 fc4657a8a777b33b3639f1ea592394a0
BLAKE2b-256 939b1138725713e3e443a41aa4b410f87b2e8774b1029424784268ec2344477b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 b7f519feb46e63adfb4a9ee69b0946ff9ae3e4125ac516bc3f8b94c06a1b45e0
MD5 995b19e6818990e50a920ed527fadd7b
BLAKE2b-256 bb280f40263b9b07759cf6efbf70be92546fe1fbabf4c92982c16b2577973b95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.1-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 6af04c09b5fe427d56fd5848eeba301c3319a80ecef7557a7515779463d7ea59
MD5 0ee99a56d249dcb959db4b212e7e36f7
BLAKE2b-256 dbedc886fed74249d255a0d51a15393d30209423eb978b203e84a3ffbe47b8fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 0e5509702aa6ab3cda0260e2e1afb8fa4305c1c94bfafd59eca55869d0e982a1
MD5 a73da2ac2d390cc4af6d2420b5d4d203
BLAKE2b-256 aed681f7329567f21003a25cb169148ecfdb1079874a3c2af41043e11f745f02

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.1-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 a7f3e8c752d9ce85560feec6225d3becad43afc88b2a8aad748cc4b950069d64
MD5 f12c5155ce6509c4492a4b3522234997
BLAKE2b-256 ab19f4c7c6b0af0ebb7f30a832fc7ae0e5d073c475ac12d26a2787689271f760

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.1-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 435c2d78e1e81ff05a75207ec174f9dc98fe67ab272acc16f0f4bf762a183a56
MD5 9c3c0663670a0d04b223a5e4826c8905
BLAKE2b-256 90bf3f4ec813b569261a4dcef49aed40e614da4f9d9160d9c441c982270195f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.1-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 c9e2ff7d3ad159dc2d2706cf78dabfd585ad31501e0a3b3d60dd9b4bee743ed8
MD5 effa9cac1166e5b5afb701cc8fdad9d0
BLAKE2b-256 f0554db88554a530684069b5f595ac73cd809affa161d2c53a8e2c24ab2d0b0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.1-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 40da72c74a74e503e6b36875de888e090de4323e8ea4d33ba41eae0ce1d85a76
MD5 8dcdfb9fde01152e4f624eefad758ba4
BLAKE2b-256 2aa699ba24286f36cbec878d893a46dcb8f29b777a38ad4aa566a3f09bd31a30

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