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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

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

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

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

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

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

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.5.5-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.5.5-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.5.5-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 28797f17f663dd7ad96ed1ca0b5b82d2d4a9d1acbb7eb2557815e8f980948f0c
MD5 e92b99520a25be69244827c6f885e0a1
BLAKE2b-256 867d44e271907565f7f9715b1f0da5408aa5d2a218bd103b9aa1b6135c6c7c0a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.5-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 b9dab1971d3ae31aa0d879c1b9552e9d48abb1c7cdd4ae8437acf0b8b11774bb
MD5 f14e76db1a03cd739349eace89248bb3
BLAKE2b-256 fe54bbfe8a1402b64f3e64ff56789fb651c4956a045355ae7ebdbc28f3c40149

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.5-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 6e2af03d7a36f6fe0d251e097fba95a3541616068c7e1900b167de75805a7c70
MD5 9f0f3cd255db160ac222fa2fce85f0b0
BLAKE2b-256 4c208fdf8c038b9125967e36752ca1994efa95a2c559739f45bc9cf3415905c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.5-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 5e0df6b93f3c22dafb947fba606162cd665deee1dcea0096d1322a4111eb8567
MD5 f231e0cb18dc187233691bc7cdc6da5f
BLAKE2b-256 7be433843c4eb711a3e904c42b6cde96aca009d7c89e55507bff05238c09ee5d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.5-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 68f76f784df32915483f2c63f67a12d7d6c98084bf9f915f08d023780131907c
MD5 34ca7ab2e711f58784e4f03f28f71f74
BLAKE2b-256 95bae5d3e8ce01debf856c1f6481d838d465127e2e7c8ef42d1629d1a3de7ecf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.5-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 3505968fb6b088f1f7a8fe2249db7ed8b690fbb96027956a3411d449942e85a6
MD5 25ca95d988f5715265c29ad655f4a16b
BLAKE2b-256 55ba2084e703dfbf227f2b4c19a1729af349b6f5b742718ab9763e88499683c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.5-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 d77b3f1223c65379fb4b4ba1bd8f5c659702a92ce88e3d2879773aaa59efd233
MD5 fe86b5695050efa0d9db3faf7b44bb5f
BLAKE2b-256 7855cdb4ad6fb15fcecad10e796a1737799ab1bf8c087f54a0cf0298e806a41f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.5-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 bc57a3dfc0fb2436793de4bd01f6ffeed1d37bc1dbb409becf8c0d053fbd12d0
MD5 eae71722ca117f4c056301a66c5e5101
BLAKE2b-256 85e06da253c31cb152685e6bdb35b066af53eb3a96a5f23535379a6e9699059c

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