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-1.4.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (43.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-1.4.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (43.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-1.4.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (43.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-1.4.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (43.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

snapy-1.4.1-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-1.4.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for snapy-1.4.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c5a1802cbd6679304cf13299e5b59f245b3f3f2a5ba2aa542f28d2737603ebd5
MD5 7c7a92d75b02342e8c8d417adce412c8
BLAKE2b-256 aa6e3b088fcbf443270789504681346d9d43ea20cf5e9be2882692e0438728bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.4.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1a8105871c48ee8c0679ad1fbe94385b12262126663079e6f02ebab6548c7688
MD5 955b1abd58f1c237e488a8694a734c20
BLAKE2b-256 c4353bf862ddc2aa96c7f6a8296d501ff89289a652254b6bddcfe4b683fcc003

See more details on using hashes here.

File details

Details for the file snapy-1.4.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for snapy-1.4.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0cd1150b8aa96e4fcad135e54bcaff4ba774ccfd729bc3c62f3fa369968069b6
MD5 01c10c1bb1340d65387e3b459e57e98e
BLAKE2b-256 c5a8307da4b1a2a709f4bfb6995d65226ae505512eb1967df244486c67be61e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.4.1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 f2a84aed272c4e276efcf92d388add50a637c36cdf5c8a68cfe6277d9970c213
MD5 38d7212bac32db2dcbf92c1eb78fcabd
BLAKE2b-256 33caa4a31cda2c2f57be20165cd3df67981c1cd20be09032c43207cabca8a5df

See more details on using hashes here.

File details

Details for the file snapy-1.4.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for snapy-1.4.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 80d77d17a97a72e51444f8e8eb622d03fea796a5f9b919f7720df44d88e72eca
MD5 e943b0bbda48545485d394c4eb1f909d
BLAKE2b-256 b7e564ae653283f154b68f1c0ba97d77d17a7b4a3ee5cd2898c5d724e33756da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.4.1-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 19c2f4f983a50ec904db57f5cbb24bad296fba18a9d3dcdfe421ae99346591a7
MD5 a18fd69a3a88437993b0211321113b96
BLAKE2b-256 b18bdf6f6381324d5a44afc40aac5c59e151a4fde6ac04e0044d6a680df0eb05

See more details on using hashes here.

File details

Details for the file snapy-1.4.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for snapy-1.4.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d3c70f23497dfc19403a444e99debde9c97b0db0c22d925113cafa9590934f9b
MD5 c6ba9c414d90332fc9799534f17db65e
BLAKE2b-256 737f9a472eaa3c9b59c6acb200b5abe3fb55684bc3ffb6f42eb05091f357dfa6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.4.1-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 de17ac5734805d9326a8956f52c9fdbddb039bf11537bacb0afbde2c7d8aaaa8
MD5 62116f62515ab29dce48d0128c8bd66f
BLAKE2b-256 350be16f7802156fd17f4fdd25011d92134c4da3664d89539a2822800f6d2d0d

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