GPU-accelerated simulation of a reaction-diffusion system in Rust, using wgpu.
The simulation can be run natively, or it can be compiled to WebAssembly and executed in a browser supporting WebGPU.
π Click here to run the simulation in your browser!
Reaction-diffusion systems model the concentration in space and time of chemical substances. As the name implies, the reagents can diffuse through space and react with each other.
The Gray Scott model is a specific reaction-diffusion system that simulates the behaviour of the following chemical reactions:
The concentration of reagents
The system is described by the following equations:
where:
-
and are the diffusion rates -
is the feed rate of substance -
is the kill rate of substance
In particular:
- The term
describes how the substances diffuse - The terms
and describe the decrement of substance and the increment of substance due to the reaction - The term
describes the replenishment of substance , as otherwise it would eventually all be consumed by the first reaction - The term
describes the diminishment of substance due to the reaction
This system of equations is then discretised so that it can be simulated on a grid of cells, where each cell has specific concentrations of