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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.6.3-cp312-cp312-manylinux_2_27_x86_64.whl (51.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.6.3-cp311-cp311-manylinux_2_27_x86_64.whl (51.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.6.3-cp310-cp310-manylinux_2_27_x86_64.whl (50.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

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

File metadata

File hashes

Hashes for snapy-2.6.3-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 33d6b41d62e8aa6459e3b78421eb23b9ef0f25c241a1d466aa7d65a011877dbf
MD5 436c50aa7cc357de5dc2f357700ecdc9
BLAKE2b-256 f97e63a8caa20d83ecaefa2737a6e64b692d760a6b34f3de23193fd830c79db6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.3-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 9b3399d69528813f5c0634d59240ea27702935c12694525d8181d0234c6c9ebc
MD5 eafdddc0be6299ee44a450e919403d11
BLAKE2b-256 e37922e951bc68dee57f8a1fcf83f87689f8ae27eebc8056b3d82127191bb586

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.3-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 ebeaa599497e44e16548c99c6128becdb40d096347ba8a0033eee70542b1c6e1
MD5 d961e1c8b3d5d563efb669e5bdaf52d2
BLAKE2b-256 58e312e02662b3c77b4230e7f6b1e6fef1c50750fbfdf2460d7130da5809110d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.3-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 b3af612a150145cabd78b562d5ac303708a13033ed6417a1f354ca8c46093333
MD5 757080b871fa11e41e93f0ae8f47a99a
BLAKE2b-256 84d732e08a3a28dbf483b0901712c26207d152d5ad535698110a127b0dce71a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.3-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 2867b1335103650e9ac3f08e51493cecb29b8a5c1b87be71e9bf2301bc61491f
MD5 f355c49b7ac2d18df1457dfc4ae6615e
BLAKE2b-256 8a04184cc2aa652d115a7fd21a45e6161810c1ab8f53b45d7d54ef0d311f3c93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.3-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1d5bfda93b28cda58739e77e29f2342a752b3fe7669c2ded2e71f93d1fbd2a14
MD5 b7f3c445a5c3963ff711d91ccb9d2154
BLAKE2b-256 99be402954c42dd3469a6c05e5cebf501344640d6dfb7c7b15acfa94f318a3e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.3-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 614952b1a224a9fe285e87e9f660095022a9c3458cf9972423851aecbcc5b1f6
MD5 ba8ac1f39273026219b14ebaaa4b2a7f
BLAKE2b-256 6a02c81ecfb7630a69e0a52b7e479b83c61367acff716452dfb5852239f34f5c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.3-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 b9cf8caad932106a2b3232fde08c53ff6bed50b6fd0682746766e8cc1fb6b28a
MD5 7d6fab1ee79af3be584e6c80a8718b85
BLAKE2b-256 0915e13e8e204b9df25cfeb823a80b953d0c30d7cd2c8ee3371783cdb8953273

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