Skip to main content

Avalanche simulation with Rust and WebGPU

Project description

Avalanche Simulation with Rust and WebGPU

Try it yourself!

Most modern browsers now support WebGPU (check the current status). The application has been tested on Windows, Linux, and Android, though support on mobile devices may still be limited.

You can explore one of the predefined AvaFrame examples using the dropdown menu, or upload your own Austrian GPX file to run a custom simulation.

This project was initiated to streamline the development of avalanche simulations using WebGPU, building on concepts from weBIGeo. It provides an easy way to visualize results directly in the browser.

The core has since been rewritten in Rust, with Python and WebAssembly (WASM) bindings available. The underlying model is a block-based approach without particle interactions, enabling fast initial estimates of runout distance and flow routing.

Get started with Python

pip install avalanchers[viz]

import avalanchers

sim = avalanchers.PySimulation.new()
sim.create_example("frontend/data/avaframe/avaMal.png")
sim.run()

# needs the viz option
avalanchers.plot2d(sim, "max_velocity")
avalanchers.plot3d(sim, "max_velocity")

Known Issues with Chrome

  • Chromium on Windows currently ignores the high-performance option in powerPreference WebGPU flag if you have multiple GPUs [Issue]. Options are:
    1. Run slow on integrated GPU
    2. Start Chrome with high performance gpu flag "C:\Program Files\Google\Chrome\Application\chrome.exe" --force_high_performance_gpu
    3. Activate flag in Chrome chrome://flags/#force-high-performance-gpu. I got slow runs about 50% of the time even though it actually runs on the fast GPU. Might work by now.
    4. Activate the dedicated GPU for Chrome in the system settings.

Development Setup

Windows

Install Rust Install Python

# wasm bindings
cargo install wasm-bindgen-cli
cargo install wasm-pack

# coverage
cargo install cargo-tarpaulin

# python bindings
python -m venv .venv
.venv\Scripts\Activate.ps1  
python -m pip install maturin

Linux

Install dependencies

Install Rust (WSL (2026.04.04): curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh) Install Python

sudo apt update
sudo apt install -y python3-venv python3-dev build-essential clang lld pkg-config libssl-dev

# wasm bindings
cargo install wasm-bindgen-cli
cargo install wasm-pack

# python bindings
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install maturin

Build


# cli tool
cargo build -p cli --release

# python bindings
maturin develop 
maturin build --release

# wasm bindings
wasm-pack build crates/wasm_bindings --target web --out-dir ../../frontend/js/pkg --no-opt
wasm-pack build crates/wasm_bindings --target web --out-dir ../../frontend/js/pkg --release

Run

Python

python avalanchers_example.py

Frontend

  1. Install OpenSSL
  2. Go to the project directory
  3. Start the development server: python .\frontend\dev_server.py This launches the app with caching disabled and HTTPS enabled using self-signed certificates, which are required for WebGPU support in most browsers.
  4. Open your browser and go to: https://localhost/ If you are accessing the server from another device on the same network, replace localhost with the host machine’s IP address.

Benchmarks

cargo bench -p simulation

Code Guidelines

Before pushing use:

Install pip install ruff

cargo fmt
cargo clippy -- -D warnings
cargo test -p compute_core -p data_processor -p simulation
ruff check ./python_module
pytest python_module

Data Sources

Test examples are from AvaFrame under EUPL-1.2 license

Vals data: D'Amboise Christopher J. L., Neuhauser Michael, Teich Michaela, & Fischer Jan-Thomas. (2021). Maverick-bfw/Flow_py_inputs_results: First releases (Version v1) [Data set]. Zenodo. https://doi.org/10.5281/zenodo.5154787

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.

avalanchers-0.2.0-cp37-abi3-win_amd64.whl (6.4 MB view details)

Uploaded CPython 3.7+Windows x86-64

avalanchers-0.2.0-cp37-abi3-manylinux_2_38_x86_64.whl (7.3 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.38+ x86-64

avalanchers-0.2.0-cp37-abi3-macosx_11_0_arm64.whl (6.1 MB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

File details

Details for the file avalanchers-0.2.0-cp37-abi3-win_amd64.whl.

File metadata

  • Download URL: avalanchers-0.2.0-cp37-abi3-win_amd64.whl
  • Upload date:
  • Size: 6.4 MB
  • Tags: CPython 3.7+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for avalanchers-0.2.0-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 58aa14814c9629dbfadb3d08893c912d4061c9cfe5dc47d810243264a3b33776
MD5 cb8e57a2248a9d95b95027c700b57955
BLAKE2b-256 7f43c37da6494f23fe3d5e20eb73d2cdcf22488179f27158542213873375ada6

See more details on using hashes here.

Provenance

The following attestation bundles were made for avalanchers-0.2.0-cp37-abi3-win_amd64.whl:

Publisher: release.yaml on Gro2mi/avalanchers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file avalanchers-0.2.0-cp37-abi3-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for avalanchers-0.2.0-cp37-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 f2a8e2c17ce8e69bc4e968166b720104b12ca9f226b489d16d68912aa8bb56c3
MD5 927da241194446493a86dc7c88a83615
BLAKE2b-256 6f1d17a739cd5596b9ad0ca1b97884dc4b009f87d0ee41c71498955993a25122

See more details on using hashes here.

Provenance

The following attestation bundles were made for avalanchers-0.2.0-cp37-abi3-manylinux_2_38_x86_64.whl:

Publisher: release.yaml on Gro2mi/avalanchers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file avalanchers-0.2.0-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for avalanchers-0.2.0-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 be3c164ab70d1a8e0a538a916e28586a2bb8cb3b312d8c1f7de7d580b28d44bc
MD5 df50151262d4c1faeff3b5949ed9a2fb
BLAKE2b-256 3d01e59a06ded36fd813a5b7d3581368e39c7a9aa449558cc8db6df6bc022120

See more details on using hashes here.

Provenance

The following attestation bundles were made for avalanchers-0.2.0-cp37-abi3-macosx_11_0_arm64.whl:

Publisher: release.yaml on Gro2mi/avalanchers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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