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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

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

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

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

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

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

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.4.5-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.4.5-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.4.5-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 e68e5bc79fbce12439ca31001f7de954f81b1e71fcd9bc59fcae205cf970a8c2
MD5 3a8929dd2e15438217e78e42f381eab1
BLAKE2b-256 2a48a14e65b7b503e7716e7963743499093d530d0421deb2301819309402dfec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.5-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 05f8a53314b2a16edfec74765ad2e9daf84223765bf3a14e1dd77321b67c990f
MD5 65132dd63d6fad077fbc65686ef28ccc
BLAKE2b-256 45ebecfa2a0101b952a4081a5ecadb93ed607f1ca418224725fceacdb1a366b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.5-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 4e3720d6ac7f32b00f214e21019fe40bedb681e9f35e35d0ab6c364fbbcdd505
MD5 7244c46fbb5ff3465fa1a7c99077a530
BLAKE2b-256 50fe9b7cf5376321f35c62e6b5b396c9469bd2be837792e1767cb8d125d7f757

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.5-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 e034521ea29b3ef5c53fd6e8805058912adb2fb1c896b4f4a488ac8b54e73249
MD5 020f600c0b32dd701959a6b115dee6c6
BLAKE2b-256 91a3a7ba2188796337267532f40e7615c371fa4eda9da95d28ce4a79d2373250

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.5-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 5ccd195fb20d55b7449906a96b7ab3bb963b2c6b751ddc7bc1def303d429adff
MD5 ace677b2a9fc80b506c2593e05c4270c
BLAKE2b-256 c9e7791c936a37cde0fe68f2703644e49e342ca6a2c1d5ef6669c27b5498feb9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.5-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 6494f3e3bc2dcc8230a08b35bfb58d55dba237d95c9b9cb91cbb7a9296ecb390
MD5 cb9a4a0f14052e1cf6c6526174c5c4d9
BLAKE2b-256 7b066f8e8cf86bf5a9b7bf7a813a7f4246c8e34aad9689b62e98858bad3121e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.5-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 484751d382ff04ece4b564d8c522792e6aae9a8bedad1db4ae19662c408e4862
MD5 74c29175c69d6bace74c4a508192126d
BLAKE2b-256 892daab2d085b4e3065f10dab7ee06502c7e96e7d0d9f94713fd511875b85c6b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.5-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 24f30e4b98eb895cb3fe0a3161e96ef4c84af5a81abef18f50658a8900e7e019
MD5 fd99f207f99f36e8ba98b867289f6fd8
BLAKE2b-256 20c45743c1932897b1421654e960a08926d249e9282e87a37bdf2ecc83993a96

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