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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

snapy-2.3.0-cp313-cp313-macosx_15_0_arm64.whl (4.7 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.3.0-cp312-cp312-manylinux_2_27_x86_64.whl (50.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

snapy-2.3.0-cp312-cp312-macosx_15_0_arm64.whl (4.7 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.3.0-cp311-cp311-manylinux_2_27_x86_64.whl (50.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

snapy-2.3.0-cp311-cp311-macosx_15_0_arm64.whl (4.7 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.3.0-cp310-cp310-manylinux_2_27_x86_64.whl (50.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.3.0-cp310-cp310-macosx_15_0_arm64.whl (4.7 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

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

File metadata

File hashes

Hashes for snapy-2.3.0-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 4f4097dda200d6801d49c1d170454f8970f009c8b3ad238a6d1db964de85a789
MD5 8bb187bf13324157d9bfb64fa5bef305
BLAKE2b-256 4c8ec669f6a663bd1cc77679e2ca7af9434170c3836b261712fdeb41bf019146

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.3.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 031881085eb28d5fc5a571328d34a58b2dc651688a9bee11ff3af023862166ee
MD5 3a96da4180c8bdcfb106a364bec76c37
BLAKE2b-256 722f493e4cd076a14119e646dc7216cf0f593d83f021f5e29a959bafbf50fe46

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.3.0-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 8d25d87c46bbef8ac47e5e7dad5364a5bbe31710c3f96dee468e1105bfd1e6d3
MD5 4c0fb7bfe74312ba0f1a54cff9cf6cf4
BLAKE2b-256 b6079e7f62fc84bb57102afd06b192d07e42ba45187676362cf6c0b00349bcbf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.3.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ae6b8b07878559773cdb2f99f64a5601a525b80c065a0b46294ed31539afcfce
MD5 8e53137912178eeaf2e8b40bd3116e89
BLAKE2b-256 5208078525816d22a3217ed5bf2350961a200c8655c9c6f25caca5ed3fc442ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.3.0-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 1fd328685fb9ab5099ba7309dbc09a5fecda6e3e70d73c13963d7745b82ab43f
MD5 4b59c4cb53ed7da7c5833018a3448ee4
BLAKE2b-256 43d7512eb76ba30b54c67c79e2f7112a188618b4a25c6034b464a435fe301097

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.3.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 aed82b13d5453d4be64dea9c9f8d0473ca5a12ae952afd4baec737dbbd183eb6
MD5 6ef67f8d7879094e90a62ac59a2af9dc
BLAKE2b-256 f1ddf907c46bffa5b43cd74a8874b4e25a579f52eef9789744cf6ddc6f12707a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.3.0-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 d10e9472699992f2f169cf240762f36bc6f0ad04ac340d58a60907ff3371f26d
MD5 a7c6fad538ce2d7a40944827cf999ba5
BLAKE2b-256 7584c4bc1a674cbbf0eb121543c14e2624951b399a55adbf8ffa48d5a2647786

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.3.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 40f5d4a4e3abdcd3ec1e60d049ffdd229221334f9c626305b020e19fb6127350
MD5 f70a634988cd9204e315397c6b6c074e
BLAKE2b-256 0995c21800a5bf455c210ceb82ceb6063e5a49649dcec201a6c0da4ab5139713

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