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

Uploaded CPython 3.13macOS 15.0+ ARM64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.5.2-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.2-cp311-cp311-macosx_15_0_arm64.whl (4.4 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.5.2-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.2-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.2-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.5.2-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 feb19991de5e8d88c87f5fe5313d8d88ec7d6cf1748738eb7a2b496cac1630f8
MD5 cbf92f63f8834f9e1cdb79042f29753b
BLAKE2b-256 a40f5315fc8e0d863dbcd7b64a2edc8e29688f08622ecaae33c467aac814e89f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.2-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 f9b9f64953306dfeecb9af5ddc94944616c6c79b9b322cba0754b5c0c99b568e
MD5 c3579837dcf34359ede20d8c6bae864d
BLAKE2b-256 94ad9665924c7f394e9475ccf25f8a1d76e6b3a572ce53faf847f1d4167b0ea4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.2-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 78affafa67e2e5f82781f50b746be47ea117d8efcf9f4026a0c14babf52003b7
MD5 de6ca3bd3507537c4ff5d8ef841fff23
BLAKE2b-256 98eae10b292522da8bdb6d96d823698bac6cf6629ee2b36e4ad991c8b097f76c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.2-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 55ae22e17ac59c9da72bb3b14861679b17b5d445c62f23bb5788eab727770d35
MD5 fb1e7d8bec345d11f5df7c08195f7609
BLAKE2b-256 59943d0795a6f76a7de0e52057aa48ed81d5e017e54bc2a5c05fea5e5097374d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.2-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 1530fbeb05f8a96d0fa0c0964a9efd2fabd13db7ee96457cfe56acfa0f0b0e21
MD5 8bfcb29067db42af6e60278b68f14771
BLAKE2b-256 029c2f8436a097db556d8566cc195583f5cfd055839511c64d1d583a4d609b15

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.2-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 300a4672dad0538d86d1c646bb6008b0d2fd88081e111d0c99f1e4f95ccdecf8
MD5 e2da30b00d4b308749c80a36b193c142
BLAKE2b-256 c7d9f6980cbb79dede33b6e59d3ba45d03742ec968942d2b8c0c3d330af4aa2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.2-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 a240072a59397adebf3aed871be7ff304ee261f77c2aec752524ff7071be4bd8
MD5 8ea4aaa5fccd5545910401c6f7adcda0
BLAKE2b-256 c70b5eebf9b1c5b6e5fa5382c654b454fbb03fe6a59f27438a0910dbc2ab5776

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.2-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 875ee96ece07a85ffab286ea465e5c06e1b8f0452ec0b56bfd0c527bb807e8f5
MD5 b39d8dae83f70cae7733ab7825b75b6d
BLAKE2b-256 12290840998d735d20360a3d3b18d0ebfa6a4a1e53adaed6bee1baa90256633f

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