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

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

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

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-1.3.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (41.1 MB view details)

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

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

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-1.3.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (40.9 MB view details)

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

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

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-1.3.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (40.7 MB view details)

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

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

Uploaded CPython 3.10macOS 15.0+ ARM64

snapy-1.3.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (40.7 MB view details)

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

snapy-1.3.0-cp39-cp39-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

File details

Details for the file snapy-1.3.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for snapy-1.3.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a6588cb346a56431711b0fdd7919daa6c98e53b0c4cf784b3e3aad551be3ca25
MD5 cfd4590cd4b27fbb609c43e339e43d49
BLAKE2b-256 a54288d3bf39b0fa5e4d0a8d1e7bd18a5c9023b98a83bb3e1e63e2387ced2f27

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.3.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 48219306739007475f40221f02e926389bcee7cccb3045c58c6797f1b3056e6f
MD5 32a432160ad7c5906b8a1de04dc19166
BLAKE2b-256 e81ff10077295a5b9f76c0b58c130ff2ab6643b22e1bb4468f8cda65b25c1225

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.3.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f9d5ed7d7ce4f68e71a9e0d65fdd90b72224b92737c37d78325d864e0a9ebbaa
MD5 47fa5ca6ba29cfee272bd4592bcf0314
BLAKE2b-256 0c960b724b7aefa4eec7da2eb759cbc0561a6a3bb12c471659b3c749640cc614

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.3.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 6247c1991900fad80cfcbe2773ff3000a265dd7cef52ef09a4987f307c5a502d
MD5 f369a9a9975cda0531541a9bc7560036
BLAKE2b-256 de4a19db778e436b4b4deace6ea38fd91ecfe3facd6e2334163f8d5dbcdd8b64

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.3.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e8b427cd8c3bdd97c3816b3d374fcc33242093ea20af0c900f3ec0908388fbcb
MD5 ca33b3a7063040b9a83245bce67e6438
BLAKE2b-256 50419bf524bc07e9d7acb38a32d7d1eebf1389afc09d552bc25dbaed10a330d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.3.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 bf948df9cc82175274b06a95426448ceff8c12c8c9a72eaedf1107ce68c0fe9e
MD5 74cdb5c0e0ee08c8441fd4e5ec48a7e6
BLAKE2b-256 f8a659264b5551b6eb809fdc3af3b2466ee01862bc0c0efe814777b52851d62d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.3.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0b24e529c439a9d69f836104b0c2b86a71bd01e5ab5538458377abe5d77fe94a
MD5 04b520f91ed88e3640616df65f5cbe08
BLAKE2b-256 5183fd81b73fc0ca5bfdeccfc1b7624ac710648708d198c17022a78b4f0e0aaa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.3.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 0a7d06331bbf1932d3edd75e05d8f0b0e123befd079da7b019fe79286d20c945
MD5 195b7df6350422d21bd43a2f49dc8564
BLAKE2b-256 90e56b110f4033d7822a1f6bac4c5dd05b003115f7f4d269116225743dfcad84

See more details on using hashes here.

File details

Details for the file snapy-1.3.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for snapy-1.3.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 48cdb7bc9c92201c030df3151a83d158b71cac9e8c7ec3f0fb6cc620e12f9e34
MD5 4faefcda4d0717ef39c9a01e2ef0cbd3
BLAKE2b-256 83af02bf930121bbeb739cd22ee34686a033fec982959583d41e630f50083cdd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.3.0-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c0cf3a879b1845eb3aad23cace52b518518aa70f57590dbbd51d5a7982b76f15
MD5 922e53fb314d048414c463ad5d4920ab
BLAKE2b-256 df79bb89f626abde3884030c83989850a2623b125f136193e778e9985c18645c

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