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

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.5.4-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.4-cp312-cp312-macosx_15_0_arm64.whl (4.4 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.5.4-cp311-cp311-manylinux_2_27_x86_64.whl (50.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.5.4-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.4-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.4-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.5.4-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 e82028ce01cf705f7caffbb709f2ba9f6d958ad04d2ad499ff7a64aebf935da7
MD5 cb5806b03a972af93d6d410d056562ba
BLAKE2b-256 f7f6ffcaceef8dd7c32867d306f8e8e64385385fce41a2cde5853dd9e57bc952

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.4-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 3a53856d2cdb4d68bb539b7e3b07c00aa6ba2cd9622d706537ecbebb0a0bec90
MD5 6d7d267099b07dd6eefed92937522858
BLAKE2b-256 9f29090e6b2ad13679a641c0f749178fb364a063d888c605600b75a30aadd686

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.4-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 11fe689d79b8002056361271b250d85ed8191c4027dd36c58c9bbb56ab5b0553
MD5 677439b66029f047c90b44ca8eae7ec2
BLAKE2b-256 d1a7dd896802925b38d1cabb47d253673d17aaaa006ebf9f14346fd09534f566

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.4-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 b69b03a7e150b9cfe773bf69693d4dbfbd5af47fd92b837eb53b0ca72e62e51f
MD5 605a5ccf4ff861901cc34ced61ca366b
BLAKE2b-256 4c881cc4f84ee03698b25ea8962300e5f8baa487d4b3f0e64314c902f183f663

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.4-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 3594c35cd1826d81947f18224268258add7695ee3728cf5ee84a043e0bcb3b45
MD5 98fb43c5a6b3ee74a36518d471598d18
BLAKE2b-256 ca2e1938e05f3d1232ec755a6bd939f7453f2a862bcb7cadcc1fc062bdc9c0ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.4-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 2a9e7fe94d1d92ca6c31382d56b3f04a802c18b9eeb98d1688fa1197f3744698
MD5 f783c787eb69b4bd171fd377d34a3071
BLAKE2b-256 ac42c7bfd8cf84a42ea44596d0b1db46586d2cba0844a7f75668df9eb1f6dd94

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.4-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 cded2eca09931a4ef78b00b3f6c9feeac51054954c88adcf95019a10a122ffcc
MD5 9b65bb569b1c63b48cad51ab66a4b771
BLAKE2b-256 3b4e2c7fa0693c68dd3c653d5a1733fbe1d086aec5492b5ef5ab1041d58bcc85

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.4-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 a9d5bb0e84e79d73553a3f649f50ea28dddc06ca97130fcfa91c958d4b00a7b6
MD5 8969ede38bdb82747668abc9dc44d9be
BLAKE2b-256 cebfae7adac03a1131fc656554fabef768b4c4615c49909cee0e3d075cea9cc7

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