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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.4.4-cp312-cp312-manylinux_2_27_x86_64.whl (51.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.4.4-cp311-cp311-manylinux_2_27_x86_64.whl (50.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.4.4-cp310-cp310-manylinux_2_27_x86_64.whl (50.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

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

File metadata

File hashes

Hashes for snapy-2.4.4-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 83d2ba6a7019e023bdb76eae59c5bf1f733f49c1763707fd3234b7d943ae3453
MD5 d3cedb2c67288bd89a0c8d188bff67c5
BLAKE2b-256 ff17fe58e9f5c06c867f268a2b871c690d950087405c9a8e4bd0f02b67d272c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.4-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 94740033fda4606f417c324333ebd25c7afd0e48c70f4cc04fef13ef433b0c69
MD5 0e75c8bfb83f1666324f78c9681dcd9f
BLAKE2b-256 94063859650df961d30ad4e0f8c87d5bda44582704c436a0fcf74c18059e51d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.4-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 7166225a27ea78a36d18f1250e95e0b9fe18dc55b60c27dbbb677e7ee21a9fb9
MD5 29647b04efd18a70f0ec4fc98f515089
BLAKE2b-256 86d4b7ac119e7dc83aebe3b1e0185b1e618d6f96a1f0a45c99f7c05997f63549

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.4-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 84e8f91dea9557005390778390182595d0e83b87111a7cc9c2afbb7381a9558c
MD5 69704fe7c16034af3149bda0331fca5f
BLAKE2b-256 159a7c8402d5dad369b0e66bab4469a6e7eceeb30b02ac722916efb198cb1a95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.4-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 1ed5a24a99bdd57ec440b374127cb977e1d58d99cc9ac0b2b737e20579aea1ff
MD5 5f5f3d43e93c56cd23778109f725b7ad
BLAKE2b-256 de658eec9f503011a119d4a8a173df07e8886940a8ed85532720cc632956267f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.4-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 bd534520778e2ebc7e791db502bad9a0d907b5cce3a5f9275549df4a92b6b388
MD5 d02293793ca1a00459e954ddd60a65ef
BLAKE2b-256 9efadd55db788d07c143447bbcf5c7be207865665a5593d39dd1e0bec9ef4f06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.4-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 2c9d5ee19baba90d0260664c2cd01b1c251607386dfa8cb4a3ad38e24698f483
MD5 c09b17da30ab167945029920184402d4
BLAKE2b-256 ad8e042f80599a0a5675f3afdb9cdf93e9a8300c6448c7831e1a967781977d81

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.4-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 3682bb9c60d6875bfc9c6a54f96f0f1efd6c53c72f33fc804c6ae8c981879663
MD5 fb699378c03359ae4ff9f880ba4a1475
BLAKE2b-256 9e7100d7710fbd8867055ac13b68bde960755a306b2496d56334e0fc3de4d5cf

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