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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.6.4-cp312-cp312-manylinux_2_27_x86_64.whl (51.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.6.4-cp311-cp311-manylinux_2_27_x86_64.whl (51.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.6.4-cp310-cp310-manylinux_2_27_x86_64.whl (50.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

Details for the file snapy-2.6.4-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.6.4-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 272dfe0654414a07bc88b087a8f3b50261d7b35783296fdef35c3a8cc06e870d
MD5 f3c66f1ab9f34a7cf4db19d6c1dffae5
BLAKE2b-256 a82d183df33c2df7d35f59fd0d98cc86dae47854b41e8c5da025c1e56053e371

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.4-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 66a965e82dafc46675d2c63d19314bcb703b21dfbb98001803124afef0143f3a
MD5 15a9de0a3556493e2fdf70430a9a75f0
BLAKE2b-256 c41462ef97c3c713de12af6c2f3c1dd0e983092b2241a04c26d17589344359ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.4-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 d49d3ed675353e08e2ab3bfcbc4756a55060301e49b7d8fa80062c0188b86368
MD5 ca2905bfc9c036021bed000f14ce1362
BLAKE2b-256 217599581cd5fda83fe6b29e992b51604a775efeb681619f86b907c56ffa0b8c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.4-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c0ec70a2e67e9b06835b05cf64d99cda60a2006f034f56bd7e2fe1016a6fd629
MD5 1e511c85ad250f29a5d934bff6733fdc
BLAKE2b-256 4e55762b66b0f07f6b5f8ccefd8f50fbefd5cb5e9b6c656b1d7d1d72f49d80f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.4-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 abf286a266496d6ac7b7b56f3294c8b6cbc46d747e2fc8a795344f7ebc8cedd6
MD5 b99ad882666a904f07bd1c083ed3ec48
BLAKE2b-256 cb6aab74576e0d456e497f3481ef86fba78d70f9ae0102ff0b628752019e1a14

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.4-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 52f3008ddec4cf8b8d6b91c36a97628243dda85adc32c613b26c95430122a98a
MD5 7f036901f0942dd9fbaba263cf4bb3e5
BLAKE2b-256 adf7dfe68b5ea5c1c0d7c53d7869df6821239e76a8c87b8a09062c0e11154147

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.4-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 ecae352b1926dfe50865cfb5f737bd6e700ea274ee9e9aeefa90881126c0759d
MD5 fb7cf38a6a0099a2de2060683818c579
BLAKE2b-256 22a588221ae64270d5323bf3599713600825788b5c4fe13be28772518464d2f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.4-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c9eaefde6d1e426a0ce43c26a4b71ccb00fe686f2f9e650a68c5b93d4d84ac11
MD5 27f183eacae0918563025e4be53eb51c
BLAKE2b-256 2894175a8d10fa5b166de6568e3d64e2c56936f337e2da8e932fcd42ff192bb2

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