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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

snapy-2.1.4-cp313-cp313-macosx_15_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.1.4-cp312-cp312-manylinux_2_27_x86_64.whl (45.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

snapy-2.1.4-cp312-cp312-macosx_15_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.1.4-cp311-cp311-manylinux_2_27_x86_64.whl (45.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

snapy-2.1.4-cp311-cp311-macosx_15_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.1.4-cp310-cp310-manylinux_2_27_x86_64.whl (45.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.1.4-cp310-cp310-macosx_15_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

snapy-2.1.4-cp39-cp39-manylinux_2_27_x86_64.whl (45.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64

snapy-2.1.4-cp39-cp39-macosx_15_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

File details

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

File metadata

File hashes

Hashes for snapy-2.1.4-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 cd6ba00f3409d843af52cdd7b8fb7fe5e391b9c96180151fee1ad2db24d7f9a1
MD5 a9124c2f8dce4531b95539024d1f3811
BLAKE2b-256 e785e4270582ae18404bc47bd05fd47a52087ceb82af048596e40c28ba0a5060

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.1.4-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ef98118fb547454870b44dc5447e3943352535274497a989d7c597e067b08e59
MD5 6129c8d8c2472d508125d419d043e1ed
BLAKE2b-256 fd5710c314bfb97fc4435a8e837cafbca0e7276b47bef322b3ab814f13f0957e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.1.4-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 bdd35ce68c2542fd5d466f14f1ab47d76550bc66a6c8e9f1af5a561b9633bdea
MD5 1b830fcde01f35faf5cc305e94952783
BLAKE2b-256 9caf9b8a3f544069d078a8f4991da56829f09c4c14e277e5860bd7fcf2e5879b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.1.4-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ab52ae943fc1ac00d97ea4b66d4231cfd14db44ece4a36c21ee85aaec61ec595
MD5 ed44835828ffda8e16cc1c6dc61f49f3
BLAKE2b-256 ea53c91b4a2facb983fdee405175d3647e63bae8c79acc9e80915e713c88af6d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.1.4-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 7968640eff96a1a53fabd0e452b04da01eb3ecda8a3d4ce40633a9e65bb4f29a
MD5 ab6b4b61f93c61c2c5de79b8f10c09a9
BLAKE2b-256 9fae64f7b5d8e25fb76164fb9c3c93d2c765ef4c9ea827e1c776f8ad1a0c7906

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.1.4-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 8e51530cc0679df44e79e274c3505d5d1ec42a1eb585b167b1c0f868bb66be0b
MD5 d355e75cb6f46fd8883b6f2ed1c957f8
BLAKE2b-256 00c96d4cba6614b3a5084be523d7956bfdfd0cb23b752837b7aa7d1f1f9a70f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.1.4-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 f6221073caf5ed9b0c8d6add749b05b2d0476211e39657b469f9a847c77f69d1
MD5 2f67340ab024a105e06861b8869d8908
BLAKE2b-256 b3cb8cc0b91b411d695d1601c3425280da90e18c11774373b4bc97861b1955d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.1.4-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 de19d1c75c0df0f7b1a275519162871fda25001b61c3f2893645c30b0b075dca
MD5 3c108f3639452ce3c12a5946271ae93f
BLAKE2b-256 ada6a7dbb57a3502159eb370952f60309cb8702b0010832f8e671a855811f5c6

See more details on using hashes here.

File details

Details for the file snapy-2.1.4-cp39-cp39-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.1.4-cp39-cp39-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 68e581616392e2d6a7e87220ed9737b1bb55223be9e9dc55821e536057b7425c
MD5 e95d6a492d0d78401da5dab6f10fafc0
BLAKE2b-256 0ae886ba48992947abd7dc33043abcb85a09d253c5effd085c0d9e54b98abcab

See more details on using hashes here.

File details

Details for the file snapy-2.1.4-cp39-cp39-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for snapy-2.1.4-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1a79398ee80bfd2be238db3a09d531fe01cfad3b496a253606ef045488321dac
MD5 d73802acbed241695d7e4ea707d2adb9
BLAKE2b-256 77f331ff7bf282c19e307f6dba1819ad21e6ebb21390bc78729bb92fd3534b3b

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