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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.4.0-cp312-cp312-manylinux_2_27_x86_64.whl (50.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.4.0-cp311-cp311-manylinux_2_27_x86_64.whl (50.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.4.0-cp310-cp310-manylinux_2_27_x86_64.whl (50.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.4.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.4.0-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.4.0-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 fb7c7c04880121e1de71eb7c3717f3f40a540a785c08f0ca09d853bb227a6370
MD5 ad1b20abc920a8fa61355425b9e15ed3
BLAKE2b-256 103ed8b9504b4d476c8cf634630d015239a850d341b76209512e3e728b2b4d5a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 f31a8860599f4afc894c9dbee0f195290f51ec5702282b3b91cda4756b816cf6
MD5 76cadc0b4c662c57ade40fb52aa9304e
BLAKE2b-256 1fdc02e589b515e5f84c5b229f37aaa64391323d3b174ede402a1621fbc84b03

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.0-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 5776dde8e680887dc7ecdc2ed4eb91210a5cf55ffb5c8619a75444f2f1d367b0
MD5 bd5b59f2e7727bb2073ea233d59b24aa
BLAKE2b-256 04816db32a6ad9ad6205faa3e0d1a5a4a8db3d622c7102276dec5d26dcbab910

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 fdfdb57f696ba5ee5c96a932b5d220f023954a6a0dfe1db002474460bc653837
MD5 6e0b2caee0bd26188388612a5fad65d7
BLAKE2b-256 103c5d01cb6698430496b5077d16d1b5bf08ac2083e27847db3706c062729dce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.0-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 45402edc94bb23e98b3b3f78800dc4000d0e199b4a881a10124841c5d48e2fc0
MD5 fe86bced090427acef79ab2a9fc99e0c
BLAKE2b-256 156c0f2529837230933f0a27f9c1ed766976fe4bb71eb7429bbf6e6a86d52c88

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1e911ce7f7557ba8509a3c458b0d8be59cd9fabc663be5faa1ea87dacc852512
MD5 682330ef8750203e1b5eb774ce6c712c
BLAKE2b-256 8be7941a28cccacdb08f6a33448a9c2999ac01bc86b92085b22a65ab7a22d9a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.0-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 34ca0d1a83c84f5aa64167de4f11196fdaea2ce31a5742ba145831a680207860
MD5 ccf48442684aa5688497a437f3dc70d1
BLAKE2b-256 2b8a5b712ad296accc4149462f4073151d17de11a912f910baccadf99fc7cfed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 207ebeb2a8d66965159170d9495aa1e6b371b843863ee5f8625ee78ecbe610d9
MD5 7cb3d391e7b4de022762d0351bef25ff
BLAKE2b-256 184e4663852f1143868727876a6e12f6d7ce0697a4f5958dbe65890e31b95e40

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