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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.6.0-cp312-cp312-manylinux_2_27_x86_64.whl (51.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

snapy-2.6.0-cp312-cp312-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.6.0-cp311-cp311-manylinux_2_27_x86_64.whl (51.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

snapy-2.6.0-cp311-cp311-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.6.0-cp310-cp310-manylinux_2_27_x86_64.whl (50.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.6.0-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.6.0-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.6.0-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 057feda29f3321b6bef560db35bc2c0bf77ea9fec880a55352c4ebd3fe73eef9
MD5 2009f02e0be05a1baa2e662cf8abdba3
BLAKE2b-256 b45457da6c366bed377b24466cd57ad853b758335329aed572ea7c39776af382

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 e1a5d23220e7df40b5d3dce340093748f37b6ffcdcf180b8f5544c59a2b9937a
MD5 95ba7c93f10002646efeb11a4191734c
BLAKE2b-256 c91f5bc956ff1e33af04e93dd43c411de905f65d2cea05e5097a8542de5ea0f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.0-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 ed5f456a4fc00d60dff305c7dd6cf59768a25d6853bfbe34320d9da1877a182e
MD5 b96da75028a6f832492faad9aaecc320
BLAKE2b-256 0670f9cca88614e408a3528e72ddf7d98bf5ff150347d2cab7a63dc02b2598c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 eff86aec47d47811c1c591d85463410367a2e1bef37df4b67af1d6058979891f
MD5 ab6a5a66ac1227c19f881ecb56afc65a
BLAKE2b-256 3bde5a2e0c509570c80fccafa38a598f7348202a7696bfbf0846f2b8fe2b4a74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.0-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 9e442d15a7ddb35701c9377b361684a905ba32b159b917a7ba1e085a05fdd42f
MD5 3e5f0d895a9accbe5c08b1932dfa9341
BLAKE2b-256 d9792b33b18edb221b0b4ff0c059221a2be74ea599b1c3e1c1dea21cb26396d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 4a35dab225865d83d52308eab049ae9470f9a844b6592a1be06940c9f3249bf9
MD5 d66739395e17137b1df8e908c8dba82a
BLAKE2b-256 46473e09bf9875b971174f4bbe9d58e8e4e89442ac29695311b2d182b0896129

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.0-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 0c373b6ada55cc86f04ab7e8de6ea226410c47ecd845e067a9799eac5ad7e09f
MD5 a7e8aaa44ac65c4f585e35505bb35477
BLAKE2b-256 8d4b3c4c82ef283d5660ef4fa2d949d69229ecea36fb80f7d4f3bb3114a200f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ca895b8ccab8784ebfa6c4fd9880d19c32e8eb48d6986d51503b563e2705ea71
MD5 606d5bdd18f67706a8cb996cecad3998
BLAKE2b-256 683b11c7dfbc49ed1e406d8ca2f0e31a79c8e0208936341e262baa36a2510367

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