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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.6.1-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.1-cp312-cp312-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.6.1-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.1-cp311-cp311-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.6.1-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.1-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.1-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.6.1-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 2dacc2e7a9700bdf96d29fcd5caf6c7178bfb15b2cef652fadfba4e1b1cf5212
MD5 79e062f8c771d6bd8bdad70732c311cc
BLAKE2b-256 8cf69d91d065e11a76010b1ef29c3f17254170d191cdb7b74058b925567537de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 7518d11916a2711bf2db885c6b6cbcf407451be2556a20491efde0be40e20966
MD5 b703382c522bbd3fe816a508517f281e
BLAKE2b-256 853cac9e8161c8e81975520786d72e9de2215efefacb99f7bc069d67f5efd717

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.1-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 e985924d457e4f4623d73283e9f542918bc18fa8ee45ebd9b6f8ded9368f8c0f
MD5 db848dd87596d60145bf89a800764a9c
BLAKE2b-256 4e472ced79c555c2ab18489b7443d6457be26baccf13d716845e8b6addc1b8c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 68d93481b799d5afbd910dcd5aa8cd40ebdeb4dc75dc21cadfb1a570302e49bd
MD5 b5206164010af766b89f698122be48fe
BLAKE2b-256 4193f92109441e5bc423e139be61b0b1121d652f0238ed626b079947aeaeb921

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.1-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 b99c213c3d530b28fda600be8ad89d5eba763497dcd57b0cc408885a140bf3b7
MD5 457133a95403ff9bb541e754eefc29fa
BLAKE2b-256 305731b62cdce69dba0d68f8c5d224d48ec2e5bc5e735943ecac5bf5373aa646

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.1-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 343bf1cd0ce1e560bd4c13fd75b1a765ddda54cc9e2f5f7a5e57f5a6a55fc223
MD5 f0a6d222a853a29f2c4cb68f6c456936
BLAKE2b-256 ecbb9f1b2634cdb3f6615c2e9c739cee3e9e19a05f5b2e3871fe08be65d0be80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.1-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 50f8a27c52097869345b6899977b8d38d209272da9230e99e37b196cbd254c83
MD5 0e320a26dcd2ee53cdfb41ca004e8156
BLAKE2b-256 bde02d1c74e4631e58f87214ba6a6da32a04b57d89214b3829b5fdac5dcce2df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.6.1-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 014ba040bda7e9967893f75a036cf4c0f865d4d2aecad071f333e54e0005515e
MD5 01deeb322ab36a1d0a440498ed784094
BLAKE2b-256 8a089235aaad7e12d0a50c12ecc4ecdfac2a020f45b5825dbc169fc2a109bf95

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