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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.7.0-cp312-cp312-manylinux_2_27_x86_64.whl (51.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.7.0-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.0-cp311-cp311-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.7.0-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.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.7.0-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.7.0-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 43381cd57983fdab79099b5f5f38dc56a4e05d5a7db1b53430cd6768cba8e06e
MD5 8a17342bba6de1c6e6116bd8659b236e
BLAKE2b-256 384d0411e869e969a02771b9d792cfcf99de3fa97e1dfb5959ec78d2a2d4a75c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 db80f15aef2196eca88dfd24977ba7a42dfe8cdfc811ba0d664ed31b464eff8f
MD5 776b20c359f5bf46f8abefbe9c06e257
BLAKE2b-256 c0ea23dfd0fdecf08aee878b5179c97cc7d6a4c7af85b29249ef638f6bdb0653

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.0-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 f0375e98756acf08f3c7f5a85b913723e5a6eb4be9de44d6bde20170bee2bf60
MD5 c7c782c28befdfa1bceded7778936390
BLAKE2b-256 4a09cc161d08f6043477f9cac60f0f90d321aec7441e33d473077d641a49ac80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 dc202d3e60db15660ab4667839b116f14ff1cddf3c6b82bb0643f95da27f7dda
MD5 c8fdc45aca230382aaefca99e5abcdea
BLAKE2b-256 609b7c19f0676f3d5e897b02d457c5c5ee4fb350f0f1ad2eeb7899bfe6b29f6a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.0-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 3afd079ad2b016f1f4a3c77d31e45027f349d3b69285471ef665b97d2ad0504b
MD5 98b6091065607a704705dd0766c3dcd4
BLAKE2b-256 f7680886b2399cd7aad384c4c2564afd5930bbfd55842bec87f5b24b20203a4c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 8b576a61672e58128d288fb076cd4324d8fa642e06cd6afdb46345d80f508d5e
MD5 fa9a68e789c9d528195faedff67b19a2
BLAKE2b-256 888b535f39adcf1c459e051199086623524b26aae20b085f28d0989673b8d949

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.0-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 99b7495a7a46d8ed929e671bb5952b63cd8cfe6697a47448e611897a7ffbe740
MD5 5e4e331843150a0622e510fa8f280d9d
BLAKE2b-256 f40280c40800123e3f33e17eb9191bf94a27d0094f2d12f4bcca482891274b4e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.7.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 2c82b00d15d55ccd4e267bb5cde531adf7ce5740d354d46537b001b9da15948c
MD5 419a10facf96f1a6c4ec4f41d044a81e
BLAKE2b-256 2ddb4bff054289b3ce8357befd34cc8329b638235c9911a9cdada2804b117827

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