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

Uploaded CPython 3.13macOS 15.0+ ARM64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.7.1-cp311-cp311-manylinux_2_27_x86_64.whl (51.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

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

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.7.1-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.7.1-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.7.1-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 3972497f42a586ea91d768eaf4adade9f25dd480afd8d6fe285f4ed74224699e
MD5 62209ff43c90b79750f5f4bcfc04f765
BLAKE2b-256 01471380f7e3aab2f8cf814448da8b263b492975517b74d21a0a3a82d368d4cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 87b93260bf94c5720110eaa813ff0b9786b555be07ded2305b82608a3900d0bb
MD5 440e8a8131447e76920f43e013f5344f
BLAKE2b-256 082fd52c1d593fc051e03ca8570ddc2640669c31ea91c9d3dd910817b01c9b83

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.1-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 1da3d860044a5c143644617436c90c9ac2d2777b80ac34e9b74bfd86ced56ef8
MD5 d441020a492108a8e34f95393f81749d
BLAKE2b-256 cec13be7ebe8e22aeb11963584f4767ca2540fdc19ef2d0597e157ded4b9f549

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 d54da59304ee34bc8adf48c8a5b7f0a658a5d1223542e4ebf11b358fb8b4b511
MD5 058fb26c74db9dad70d51f8002cbfd87
BLAKE2b-256 d88503210f051b027a77c056c17e5216b2a571ea8e0e61cb4ec2700445711d80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.1-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 a47094a3df48a82362312240f2912cc6b2c55f42cc33bf9a202e0226a0f65622
MD5 8a996b1f3ed92eacafc875d7f0cbe381
BLAKE2b-256 26b80fead8a07ea63c596f6a6ffbd0089d12689a5be739755dbde9cbf176dd96

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.1-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c7d48c64a914f3bf331989a5b22e7def900a1416c25b598def046fd19077e7b4
MD5 3bf57c0a1d676fda82be4d4bdcfbf324
BLAKE2b-256 1227d92de82143a26d60e5c4034a23db7bc1cf6e9265afcef635718bab9fc523

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.1-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 1af862b822d49dfec876b5c174516bc9729099d15d59bc732d75e10f03d1664f
MD5 ceabbf55c674c1610afab59d18d5e893
BLAKE2b-256 e0a2f26e431117eeea472bc432506791251b3990ff13b98b98bf206fb6b4db23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.1-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 e7c073c31a572c8cbed75a91f90218c981edabb04554ca1cb13a1c6101b1fd6a
MD5 5bcd958c68328bf80a47c2ff8de27291
BLAKE2b-256 66ff988012d4c88463726cc795687d8f0c82006ac6a257c737c268d8adb77032

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