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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.0.0-cp312-cp312-manylinux_2_27_x86_64.whl (41.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.0.0-cp311-cp311-manylinux_2_27_x86_64.whl (41.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

snapy-2.0.0-cp311-cp311-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.0.0-cp310-cp310-manylinux_2_27_x86_64.whl (41.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.0.0-cp310-cp310-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

snapy-2.0.0-cp39-cp39-manylinux_2_27_x86_64.whl (41.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64

snapy-2.0.0-cp39-cp39-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

File details

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

File metadata

File hashes

Hashes for snapy-2.0.0-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 a37020b3a505851b688691ab26884725fe5499c5a509fcfbee91ce72d3905464
MD5 c789192b63ae8e76e981dc63c5584681
BLAKE2b-256 07a91c689a41e7b41992cf0fb2939336851c51501fa8664d784f11d6fd72aaf1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.0.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 9b45e68bd306f4a6cdcbf54326de7479f0fb546621c11b0b1357f192dfc49817
MD5 4f51180c22b1e4acd206673c1e58d482
BLAKE2b-256 0d6a140252624b11e3cf8a6bf55670fbb3f61ed9690b0ac3be894164cffe8a6a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.0.0-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 afaceadd4126c4c25b2610b00aba6ce71827448320a940668ee56f42f03cfc8a
MD5 ac5fe46dffec364d86b86b6baaec5ccf
BLAKE2b-256 7d2f96045d75187f2f0d869e65034f4a7c293a12e0ff437c5114e8653f4faa2e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.0.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 67df40478334764ae0d92d0fefe5dc424e94f634ba9d41a5878e19b4d25db6b5
MD5 bd6de0ca159b6327a961b5c00d5f1c36
BLAKE2b-256 3133250e20ebffd717b41a8f7fd430074313c5545d9bf55580a44dba3afc3719

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.0.0-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 920838c00ae68da79a65cdff4e0bf8794f4878d7ca06247356b117c92c7fdfea
MD5 1b11f3bba9fb6984fc5257f9a0b58fce
BLAKE2b-256 680b463b3eb3555da7982581f25a8629b04953e600425208489aacc76a956fb2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.0.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 de7109c8459b762ed0e2e8a99372cbb4dcc7586d7c9ca4509556b15bbc97dc67
MD5 8f4a8be95297fcf5bd80328b585aeada
BLAKE2b-256 7b238168a7bb543b9e2983f034c9363a58ba28564496e4a6cef38af77b5a53cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.0.0-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 e14a4a2b98d15ef0c04e37d7cb1f1e471625c65808c9774c0bb8672f391ab435
MD5 3dd797bafdf41144993a38ac48f34d7e
BLAKE2b-256 08964d8725dffdd1ea771ca5d313c5e877d0ba6a372b37561d7deee653e06998

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.0.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 bd8e634c22eadcda83b2d16db5b20f68df4b149b71e9de5e106a9da73b3a8ebc
MD5 10cb290892d8d4b56ec360a2f7ec9df9
BLAKE2b-256 ddae164759965f95a0cda698b0c5ca5c17c637ba1ce14fe0495d5f3a5f530133

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.0.0-cp39-cp39-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 f169785702160ac9d7c72c6a2e7cc25ed14016329100ab5ab42216432faafd77
MD5 a2cc23fb9fc3e43fe5571fc88903a112
BLAKE2b-256 eea2f1a2122ff85348ec06c7b8134e5aba20e51ab233b4fa3be0644e5ed89a3a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.0.0-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 9b9692db2ac1cddbd25d6ce7cea91c2535e20f1e982c86aa63607340528f9d8e
MD5 14147454faa7530efe021f64ff6ba09b
BLAKE2b-256 cbe1cdfe477475c4b1728c20e403b593106483021ae3c107ccd4a7a6b34a6cc5

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