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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

snapy-2.5.3-cp312-cp312-manylinux_2_27_x86_64.whl (51.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

snapy-2.5.3-cp312-cp312-macosx_15_0_arm64.whl (4.4 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.5.3-cp311-cp311-manylinux_2_27_x86_64.whl (50.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

snapy-2.5.3-cp310-cp310-manylinux_2_27_x86_64.whl (50.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.5.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.5.3-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.5.3-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 34b88de9e468e5b0d403bd28f28e24327016eb0e66f654c11f3db25c173be579
MD5 57c5476609d870efbdf3727122faafc8
BLAKE2b-256 151dd2297e449b464c633611ab8b806c6e693e8c815a3b26c07222bfa8689a3a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.3-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 510c5d3efd2a493514384b6257718109f1922176e6998dadf909bd3d349e5811
MD5 9dc374a4e374be94676e45614c84fd28
BLAKE2b-256 df7022b59d2b990218207eb955a7d0958f1c89e484083b51ebc02919500e4124

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.3-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 7ab8107cf3aea2367b7f55b064fe77a297ba6d8e31ef22ecb4a2fd832de63d3f
MD5 d7f0ef48c7e4c39b214a5d07a34c8a24
BLAKE2b-256 2e82bd904ecb7057d4dd803d9edce077cec3257abb70916edfb59398a549a588

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.3-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c2e776ec0ccea90188b09099779297fceb0e50dc17ae32a1e4fd54815bdfe238
MD5 1882fe06d7b1388e36d0075fb7a116a0
BLAKE2b-256 d2625306eea5f5f4eff44c54bfc21460ddafb0dffece30e919cff2436a6c47fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.3-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 926cdf99df39d180070dd53423637a6be3644a1a6ae0e23ce872e273b0fb3507
MD5 cfb7a420130e86f17f2916573b583215
BLAKE2b-256 c9183524be2d0b5210ed1b8923d55868ce739a22afcd192dfbc48a0517b5b461

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.3-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 d6093ca502ec4189506deae40e7df9666ded722989dd0d7316e19ce93e244b44
MD5 3b03eed8c959a4ad71b00bdb40b5eb61
BLAKE2b-256 5ec2501461e21dfb6641a87ed951405e0382d0c02a6078820dd6841aee41d7e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.3-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 988b1770b72e05edfe3862dca5b79d0651896e4dafb1cd554acedd882ce06cf2
MD5 078a0be92d7f2899d0a95d3d01b543c5
BLAKE2b-256 1562aad9bbf6648968cca5541e4f63114120e0fd67796433742c462d404d7bd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.5.3-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 2af8860d27fbe0f109749f3fe6e02c9c51c8943947f34434564bfbb549ca508f
MD5 67f3e3ade5b89b04051fc145607cdcbc
BLAKE2b-256 559db79fd76d688988b388b9b091ebc7c756c4d7abcc0c831b9ff57db5cfce28

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