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] once pypi upload works. For now use the released wheel.

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")

Test examples are from AvaFrame under EUPL-1.2 license

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, follow guide: https://rust-lang.org/tools/install/ 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, follow guide: https://rust-lang.org/tools/install/ (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

  1. Install module
  2. See python avalanchers_example.py

Frontend

  1. Go to this directory
  2. Start server with python .\frontend\dev_server.py for disabled cache and a secure connection with self signed certs which are needed to use WebGPU (except for localhost where python -m http.server 8000 works as well)
  3. Open Browser on https://localhost/index.html or https://localhost/index.html?debug=vscode for debugging mode or replace localhost with IP if accessing from another device.

Code Guidelines

Before pushing use:

Install pip install ruff

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

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.1.0-cp37-abi3-win_amd64.whl (6.3 MB view details)

Uploaded CPython 3.7+Windows x86-64

avalanchers-0.1.0-cp37-abi3-manylinux_2_38_x86_64.whl (7.1 MB view details)

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

avalanchers-0.1.0-cp37-abi3-macosx_11_0_arm64.whl (6.0 MB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: avalanchers-0.1.0-cp37-abi3-win_amd64.whl
  • Upload date:
  • Size: 6.3 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.1.0-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 69fd3125618d791bf1aad2dac233c00e99d6d178e63fe4745ed1f4b3ac26c93f
MD5 8007eeb839e81d6ab58dd96c25532e53
BLAKE2b-256 f949dd759aaa7b149acbf7efacb797da8c3c3888cdc84817d49742f181f0fffd

See more details on using hashes here.

Provenance

The following attestation bundles were made for avalanchers-0.1.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.1.0-cp37-abi3-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for avalanchers-0.1.0-cp37-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 43aa26bf49ff33a7a50c354c1e581a8a32a4bebaaa4e8825357cb6b68a01d6d4
MD5 b94694801fc3b70a223215d62676313b
BLAKE2b-256 0d071d5b647c094c8fd4f6a8d78d337808dd3dbfdb7db05163ab30b81d4495b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for avalanchers-0.1.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.1.0-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for avalanchers-0.1.0-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5b59e50b23ba6a34bc3a9064a2e7c186a0f64f1b0564fb8aa3868f657a4dca7b
MD5 422c09144f6678db63915f4d1dd72762
BLAKE2b-256 b469fa930fbcca411023bea198a0eccf1592f40c9f49e8b413a09f234c49d3fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for avalanchers-0.1.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