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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.4.2-cp312-cp312-manylinux_2_27_x86_64.whl (50.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.4.2-cp311-cp311-manylinux_2_27_x86_64.whl (50.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.4.2-cp310-cp310-manylinux_2_27_x86_64.whl (50.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.4.2-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.2-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.4.2-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 2459f302001206e72e4145a6818fd1b141368cb8279505b12c44e62660b8a0b3
MD5 3af121d77fba7bbb3df3da945e59c733
BLAKE2b-256 cf79b8440176850bd24652de90b5b00e7a7b456bc6efd006149c9d0c15a2f3c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.2-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 d4d515b9fb3d2687be557455ce1df33bb202378380c396cbc3e4bd79292fe35e
MD5 23b37b2640f40917ee483196f3efa0ed
BLAKE2b-256 304b88faeea7ee14d36c132cdebf860bfd5f8de70c8c29cf8539afaf4176ee13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.2-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 0d3813cff5b7b807f365e959724b83768f4317537de431f06110a700c94fae50
MD5 1a5b74013f926791f0bad686c76af426
BLAKE2b-256 7f3d8d8f46f3f0535f1b754d22684844d9bb6d83b726a942b4138f0322286fdb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.2-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 dbcc5525c417e32723cd7a68eaf22f2e9dd0ccd957e785e02449cf77dc1609da
MD5 03a65085caf01d4e0f719db96d34449e
BLAKE2b-256 e46d9b21e0cf376e0bde64b89167fab1b134755cd2b7d57b1fcf9e1aee769895

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.2-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 1fcb5bb2c2a3b21c3ffc339ad33588398bd6c0490cf08db339f56f514804c640
MD5 323cf08e60db8ff14a92f2482ee28563
BLAKE2b-256 d70491302c18abc983655b67252ac29e7bee05f7b56765324d39511a2b40069f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.2-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 8b1058a84d7aed247a9978a48efe7cb14742cb027311a663aa4fc32d94e0e8d7
MD5 45a0431915acf8f8e9f0f71a5ae03e9d
BLAKE2b-256 1e209b896a01a7d2879e8526120afb1fba909efb3de5b8e7cac7948b5b4cb053

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.2-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 d6b95719fa681cf7659435b325e3afef8e3b3756a7485a0143b0fd2e053b1a94
MD5 bd3d255e0d982aef08c0b255f676ee53
BLAKE2b-256 d1232c3880bd29da06ca8b22af0ad42065b236302ff2de604833182a35d7b80a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.2-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 6de8cbe18a60d5c71d453f6452e345ae93a0e7047f6cd7ceef1e7ddcb03da907
MD5 57490cd9015ffeb693634b1e9db311ed
BLAKE2b-256 8d985683df7a81a1dfe0efb7766855ac00eeb89d3f910a3d13f17df461ac57c2

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