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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.4.3-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.3-cp312-cp312-macosx_15_0_arm64.whl (4.4 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.4.3-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.3-cp311-cp311-macosx_15_0_arm64.whl (4.4 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.4.3-cp310-cp310-manylinux_2_27_x86_64.whl (50.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.4.3-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.3-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.4.3-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 9dc65e109048d12561f1dcd43522fe2e034e47892fff9a45d8ae1eb154ea65f9
MD5 2fc1efd2e257255e9f846d2b2e540851
BLAKE2b-256 02d786d5bc2bdba5a109dc174dd407a8a89cac20d66ff9397c4da2efd55585a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.3-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 424b32156566cff5f82b9e22f40eb720c6549d7c67b1be95bcb0b8e5d72b4392
MD5 388206a2fd4a09671f1a89b6256f8e1d
BLAKE2b-256 29a4acf5577fbeb3218feafcf1449d455d451ad4889a690e70811d0bb7ee309b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.3-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 54427c335132139f9fd72ab288ca58a761239bcc762705b5094cdea55417733b
MD5 4c9738afa63e193826ccebb64fa26ac9
BLAKE2b-256 2e1d36d6fa61828dd57110840b4af769ee9411f6761d83f997058c091ed1de93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.3-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c0948936c70f8ca544e1f8e78e1b3c0ebfac2417476a869865701c5e221966fa
MD5 c86ac436fcf890e0edaed36689014543
BLAKE2b-256 f80a3cbe51528dce4ef23ae40ae676a6d265e0fdeb5e32062c53283b1a48f535

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.3-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 bd21c85254e008d9fbedb337c74b1b44318124da31b64e0b784730e964748e51
MD5 f93bd40c0ad3a4c73e09c199a4eff841
BLAKE2b-256 c1a445b550df53b25a02015c0be29a7f2f2a2aadf7ffe1ab6e65d69e605bf443

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.3-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 d9925f9e510e11666a7f2b53ee662c5350972aae168b086c2b080a1da0582528
MD5 fe22733b36a2e329562aca87706f936c
BLAKE2b-256 0468a74b4fd86b5f74926937640350e941d65f63efbb7824d10f0fecb7961db6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.3-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 84b38fb66fa1b02b51210e04c102ea9980834ca988e1cd1af644683a79651cbe
MD5 2baa3941988f903fc8f6ea1446629f03
BLAKE2b-256 0813cc9a47e2496c2ac1b24db2ee5759144e24fb918961b38536b344274adffa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.3-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 680ceab75e8302a2ff741e233209792026cb9211cb5633f5e406617a077a951a
MD5 4894322be41b2bf82534f47461b0b084
BLAKE2b-256 4317f6cdf6aacf703cc60b36b436979dd2882f9944e066ba4a1f6fd1a9007725

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