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

Uploaded CPython 3.13macOS 15.0+ ARM64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.6.2-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.2-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.2-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.6.2-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 f4bcb98fcd569c1ada296d83f22e15195cfc13b82f11b34bd9f6e3a045d9aebd
MD5 944fe144d6635c9093f158beeb9333be
BLAKE2b-256 a691a88c021c3c6f30cee1197932f5a6befb723bbd5d75f32166404c759b3207

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.2-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 b1c4f017159d8c23baf60357944f1c83c77bd77aa9995b94052cf9407f38e135
MD5 0d2ba649220d2ad2f063013f94ea5ece
BLAKE2b-256 b017019375aabde67f7c690a723452e1729051619fd363914e89f551c567880a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.2-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 9c3c77b8af3ca3d0c2dbc7e22da16a2be200ba138ae02e77035d9cfa1558d7d9
MD5 ce0ee9f5adbe379a748888d13d6b102f
BLAKE2b-256 bb42d62a15fdf7239dd97e6ffcd242308a22a6b9af23d030ed2e1546ef429f3f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.2-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 5d15705c056fc87c027f1b18a6c72f8ea65f08acc02bf8759a5a1c681c1b9daf
MD5 e88284d6d0c97bfe65dcc4b47c1bdee8
BLAKE2b-256 e5122c61fcbc4c719d5f84fb01d4964a693765716826b172255155f02d7c80c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.2-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 3d21af7688561aa426746b243e8460477e18281069ab20bb05af85ce41b8c8e1
MD5 a49a1714ffa46aebb8779e7a87f41886
BLAKE2b-256 261cbf193a02c972a2f6cdc795c47676e426e8d0bc540971c20bd69c583f0840

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.2-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ee2001768158b00dc8532591a7897bcf1affbbe86fe5d43ca9bbab7ca5146de4
MD5 0506cfecf65f3ca2a108938b36e18bd7
BLAKE2b-256 4ee81e3c369906b535daa38b8753b8e180789635387aecbed055142dadaf4ade

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.2-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 fc9abc508d8b2406b28692dde9db06b99f269b2a3cbbe8c0dc7f70ba799901b0
MD5 3ee8568b98ba6984c9ede0db94173214
BLAKE2b-256 65b2ba0c23dfbce392a80470cc958f7066566baac0c947be6d28600ae5a0f413

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.2-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 f862504fb60e44bfb890faa0cd8fe22335635d334b72de363858b37f1c3e45a1
MD5 60011ac5a7e13042173f33abe7fab053
BLAKE2b-256 751bdc0b86240d8f2abc57b29a0cba248e7b8f143a21614fed0d0b017cc7d441

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