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

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

snapy-1.2.1-cp313-cp313-macosx_15_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-1.2.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (40.4 MB view details)

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

snapy-1.2.1-cp312-cp312-macosx_15_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-1.2.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (40.2 MB view details)

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

snapy-1.2.1-cp311-cp311-macosx_15_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-1.2.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (40.0 MB view details)

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

snapy-1.2.1-cp310-cp310-macosx_15_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

snapy-1.2.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (40.0 MB view details)

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

snapy-1.2.1-cp39-cp39-macosx_15_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

File details

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

File metadata

File hashes

Hashes for snapy-1.2.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 75338f5b7c0d83d9e0b0f2bb8f6f2b060639d3f7f7d02b018cbdb796a54a31af
MD5 c9bbe391938758c0dcd8a7a0e4b4acd3
BLAKE2b-256 e99e810e21f40bc9364d7fe23e5443d04cc1a1dd938f501dfda6192294983a2a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.2.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 8726808092a173517c309dd896381ed91aff65efd7bbcf9b5f792994c9cdb7ce
MD5 335c80f89c1bd5a013cf82aa12922132
BLAKE2b-256 5fc6ada30de68cb13f6a4375c5bbd6cc36c9b35dbe04dddb7f362c0787c10cda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.2.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9817651eec436b1895a28508caca21fb692f122b519289bbe6f4ec6258d1ac76
MD5 845c4a565559c514e5bfc4b50690ba56
BLAKE2b-256 b78b77d4e7b1feda1158e611f4873a5dcefb7c16e081f0acce361ca9434074e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.2.1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 019d0319d419e2ffefc73b7826da176e28c58d2d825bd7c7b70270c81f2be174
MD5 cdb01003e93c976d2da9d21f64849080
BLAKE2b-256 4ab684ebfae96af8f5682b4c10981e9713414fc33bf6e9b16079d2b5689cb20c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.2.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a754e499447c1d03ffb9d98a00d71394459fa7580b8736cdf1c9b26bfdd21d5f
MD5 3609027cc7d53b1bfdca63c4c346b742
BLAKE2b-256 228a2fd030c8f34ac873ddeac3f29c2adaf0a22c4997c4a3404f1c2529e87281

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.2.1-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 876364c3bc7389102fe77014fb8d162024d61c537b115f723bf13014aec22dd7
MD5 d32596a0edee5f0e9d13509d1c1e9402
BLAKE2b-256 45421640a0a969ec8f8a9d1c873471b72674aba4e374874cf3dce29da17b3098

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.2.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cc407f122758a562b533992d09559b9be12d5ae59dba53cea0ae933aeb7c548f
MD5 e51969d7d52b4a181ae3a3130bd06248
BLAKE2b-256 b7fcc4e3de74d6da04fca8a01a382279d03f588dcc1b12a94e902b550a511471

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.2.1-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1bf1812f58f09107473064d46d272aa8a3bb0030612989e9e0885cd79f610b99
MD5 f102990be418d0408059629b6a532fbf
BLAKE2b-256 e2e703fbd21dbde27bb8c3d45871cb92d8ad575ce50391ce1dddda57ca658ab8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.2.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 106d92a3a4cd68c8f3926530e085c600e87d430afc86dec08dabdb1158734227
MD5 c10d829f8ca9f9d37295787dbe8dc7e4
BLAKE2b-256 3d2cb32b479e3d06bc5be32618ab9de0ff1ef51b9a93e852ff7931158599e0c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-1.2.1-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 df4afae9daf9c1fdfcc7ba2c7df1b369cba265c798084918967024267e22cd3b
MD5 bc495c812ebd7f231479a755384aa4fa
BLAKE2b-256 c925601e1fd5da049ac5ad406de12c2212acca602357860a84dbb62b10255120

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