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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

snapy-2.1.2-cp313-cp313-macosx_15_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.1.2-cp312-cp312-manylinux_2_27_x86_64.whl (45.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

snapy-2.1.2-cp312-cp312-macosx_15_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.1.2-cp311-cp311-manylinux_2_27_x86_64.whl (45.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

snapy-2.1.2-cp311-cp311-macosx_15_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.1.2-cp310-cp310-manylinux_2_27_x86_64.whl (45.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.1.2-cp310-cp310-macosx_15_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

snapy-2.1.2-cp39-cp39-manylinux_2_27_x86_64.whl (45.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64

snapy-2.1.2-cp39-cp39-macosx_15_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

File details

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

File metadata

File hashes

Hashes for snapy-2.1.2-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 d1c722f5d0a65ffc349ece5c1d39687a4b42399467aa759c5079e3754e7a7ef9
MD5 e9f843c3b507ab9eb520bf28a5997663
BLAKE2b-256 8d2bdcb9b19190cb0766a2c81bcb5b57cc4620c293acb7f8fefe540baa9c153a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.1.2-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 f9bc34dc8110e189b02a337295270b07518cef7f49d00e04cd3379b1b244d18e
MD5 f1d4d59ae384b2bb051873b8f2a48cdf
BLAKE2b-256 6268922076f61726ad4060976d33da74587da90f4119a19ca9c816e8a7fea9cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.1.2-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 4b2b169edbe8ec5d55ab6d0ed3534f80b8c8a48c9a4e2aba93a745db71d64260
MD5 1a1c48ece927106cd4d1d1ead0b3418b
BLAKE2b-256 0f65f3a0595c17efd87d7472137aeeb3616d17bdb7e21e11e5474629ce0e364f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.1.2-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 99ae7c318a6ea75e5b09754a26fe98bad02760c2d4c922a1ff6cfa1b14177638
MD5 70352f35e7e8605e2cdba4ff5acc8a39
BLAKE2b-256 9759508be0e5ffaf8f4567f443febd9c7d84f4c666d6c35dc3789183e296ee8f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.1.2-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 dd3e95cd2d3f46234184d176ba6a854c1326fe8bdbacb002382fcd41548e944d
MD5 a14e26c3138d4b6dd98f59fef5dbbeb8
BLAKE2b-256 d8d7bd4cc87d38dee3ca5eeeabf2d7deb42846f1a06bd176894d35cdcf0ff968

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.1.2-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 254106cff5fab048a028089d2243ce20e09e6bba9bc2abf73b29a02d2caefb3b
MD5 954373935d5364a39b4d4a838024194d
BLAKE2b-256 af5033ea057a10b3b5852bc742102ccc304c11b1bc896922eee2bbb86d0c6405

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.1.2-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 dcb06a8f825dfb21768a9bc06488976cbb782986aff1b971064b5d5b0d54d7af
MD5 e47b8b3a3e3dde2584fed0965d411e22
BLAKE2b-256 ce16b374fb9112e767afdf30f6f086624ad73b60795c13c2daeaed0c9003f753

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.1.2-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 99dd7485f1e4d3d65faf623fd51445e7258ea40332ab0726d1e3b0d15159891f
MD5 065d9e3ba914a7a92a2aad7307289d34
BLAKE2b-256 fcb12ffba99ee15bd46ab3c5ae2a1a590852314808e94f2e68bc5d1008131d66

See more details on using hashes here.

File details

Details for the file snapy-2.1.2-cp39-cp39-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.1.2-cp39-cp39-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 ca78ff66a3c6f61401d5b0a89007c42a71b4802d1b2db3605f3f1abd6cd2b2f7
MD5 5ccdfd64378efff6c5afd3a7779b9f4c
BLAKE2b-256 dbc8eb5fb5fc7954310e80d93223ea4d3b7c4466f89326a20a24c16d695a980c

See more details on using hashes here.

File details

Details for the file snapy-2.1.2-cp39-cp39-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for snapy-2.1.2-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 e1f114e7e78f4c4a9e85eab7e6690adf058fd31675a8b929bd0a1fbc72ed38d0
MD5 5930a1150ff5cc65ccaa4be27f714ebc
BLAKE2b-256 dccd339d1d25e4854018ae1cab49b1b027c1d5510fb4079a7fe0bb1e26fa4db5

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