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

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

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

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

snapy-2.4.6-cp311-cp311-manylinux_2_27_x86_64.whl (50.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

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

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

snapy-2.4.6-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.6-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for snapy-2.4.6-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 2ffd227226cd27a1abd8745551486240d6c8ce493821c94dbc5648e421e1facc
MD5 58cdebb44269706c001109b567c405b0
BLAKE2b-256 97a2bac7cb6b5e9a0860eab21696ad233572ecd0c523a511280ad880fc7002e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.6-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ab52f52dc346ff54a45ad8fe4e121a2687475e7a15030c98413745780b6759a1
MD5 0aeabe1485a9a8cac3de1b36757bfd02
BLAKE2b-256 d37ffe25907ab1217e54a73a8a7e80d5e02a56b86a0ae38cbd925ee377336d28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.6-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 146880ba603bb462418cc215f110e107f0ced7b0ec3ab1013f25626ef28c777d
MD5 86f27e0da61664770729b8a5a4206205
BLAKE2b-256 d24ff5bbfd10a209ce030466d1ba8a19431e91d756781f2889ca6c1a2e814b9f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.6-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 a4d73b97975bf6e038e83e2dc4fb9342173a90b97b37a8188bad97f51fd49710
MD5 62933d79d9308bec2764aa2188b1e6b8
BLAKE2b-256 0ab8b7bc8d0432058cd8779c5f19e3296b93a10102e2840a607aded823db55d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.6-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 de2209ff4e20951b7bb21414d6a8c9eb68fa2b47e47f7f9b96cf606f8d4c0fef
MD5 e4aba0421a9f986d401fd8269b7af455
BLAKE2b-256 bc4fbd166559a4bdc5b29af8373afada310b8326bb3ac9589ad0a06021664cd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.6-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 38438f897d333a83c80b9a599705bb1232dda7e0baf05db3559cb3d425ff3b2d
MD5 5b51639b3b8383e5e8f593ede203a86b
BLAKE2b-256 7b1a45bb46f51878d6ad2fe67bb11898c7b2335d3634ed88158bd95a84b65777

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.6-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 5604a8fd66ad3fda60372292ba4905814a940c51e928e0c4b19aafe8d6356eaa
MD5 2d6814e7627378fbd3e57d01bdb5568e
BLAKE2b-256 f1ef35a678865ccc8b1a1a0c4733a8bb4db196c7d0724c772cfddca766245b01

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapy-2.4.6-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 82c4470640bb309adc6d9efbe4e9e02a2a84afa9709f465812fbb1bfbb505927
MD5 b6278009979a047b5454406c54fa447a
BLAKE2b-256 311791f606dac6f72934532c20cbc2ead534f1ab1709e6257d622bcda8f8f6fc

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