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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

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

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

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

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

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

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.5.0-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.5.0-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.5.0-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 8762a35f321a3ffe81579a226dd18740c2c275623b7fecce69408bf3078f0a00
MD5 78a1abd076e57c550b2a949451d38fdd
BLAKE2b-256 45a246722cdc78989f319af7377bea5b72ccba453de3a4ca5946e1a902dc12f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 fd4c016832fda658d40749bde242cf151c7350ec3debce7326ec312ace763477
MD5 b796f71cfa0fcbc690e039b972cd48a2
BLAKE2b-256 f0e738eccabca3c0c6316126c3169eb44da018b8cd05a869e2ec78d81beb55a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.0-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 8aaabed8715b72a27f5708fb4a16dea75a1a918bf5694e158534ef27a54883c9
MD5 599f0ec8e467985b0c20bce4adf629be
BLAKE2b-256 0ee0b8bcfc96f416408c16d5a5dffd21c4e5bac41198f5fa0b6c32ddc00d325e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 e9e9543c901b585c1564233551dfc5d73a9800279e1a44b19191dbf77d3eccda
MD5 e28d86dce4ce26467da3ac2545893f3b
BLAKE2b-256 600a7581eb1bc2542ffce188fb46d2e14b51fd7ea112fcafdd804633790b7520

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.0-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 f7051d90a33629ad50d723cf8c9894e2a18b1b93821afc45104f6dcac4e4b8f9
MD5 39a52d24114fc6fa8f0f7aede7c84301
BLAKE2b-256 2bc68a39faacd8abaf8fff6ed644ef36be204d0a952272664a1f5c71c51ec8ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 e74a6b2acd73ec18564c7b48d4eddf97e25fc6b514aecfa8c64f0b287d2b1e39
MD5 bb5fa57b31a396df508f0f173a296452
BLAKE2b-256 c7a537565dc1377e640c53baf639d38707abe00a5304d8b320db8db9901d5505

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.0-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 f5392c5b4b141de2a971cbfc2598e9b2bc5280fe9b329648e95f2dea78b5ccac
MD5 59a5806f64a9c8557206117a16f69892
BLAKE2b-256 f2c54694656383fbc95f229ee873ab769887fe090cbe1e8b8a3c8f79d6fcd2d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 3d996fa442bab16be2af9c286c33b8a583d8b8b3e892f4cff2c060b51875b660
MD5 e012a78341257741b079bcde0154ae77
BLAKE2b-256 81a4258e20b96b76caab5f43242ecf4a062248cbeec4b5dd2c501d1972d94c47

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