The SpreadModel module provides composable, differentiable components for driving level set fire simulations. Instead of manually constructing a spread rate matrix F, you build a FireSpreadModel from pluggable wind, moisture, and terrain components — each a callable (t, x, y) struct.
M =FuelClasses(d1=0.06, d10=0.07, d100=0.08, herb=0.0, wood=0.0)model =FireSpreadModel( SHORT_GRASS,UniformWind(speed=8.0),UniformMoisture(M),FlatTerrain())# Evaluate spread rate at a single pointmodel(0.0, 100.0, 100.0)
Spatially varying fuel moisture that responds to fire-induced drying. As the fire front approaches, radiative heat dries unburned fuel ahead of the front. The 1-hr dead fuel moisture (d1) varies spatially while other size classes remain constant.
The level set grid and all simulation operations support Float32 for reduced memory and potentially faster computation. To create a Float32 simulation, pass Float32 values to all constructors:
Note
The LevelSetGrid constructor determines its element type via promote_type on all keyword arguments (dx, dy, x0, y0). The defaults are Float64, so you must pass Float32 values for all of them — e.g. LevelSetGrid(200, 200, dx=30f0, x0=0f0, y0=0f0).
usingBenchmarkToolsfunctionrun_simulation(::Type{T}, n=200) where T grid =LevelSetGrid(n, n, dx=T(30), x0=zero(T), y0=zero(T))ignite!(grid, T(3000), T(3000), T(50)) F =fill(T(10), size(grid))for _ in1:100advance!(grid, F, T(0.5))endreinitialize!(grid) gridendb64 =@benchmarkrun_simulation(Float64)b32 =@benchmarkrun_simulation(Float32)nothing
| Metric | Float64 | Float32 | Ratio |
|--------|---------|---------|-------|
| Median time | 32.58 ms | 23.39 ms | 1.39x |
| Memory | 32.7 MiB | 16.3 MiB | 2.00x |
References
Rothermel, R.C. (1972). A Mathematical Model for Predicting Fire Spread in Wildland Fuels. Res. Paper INT-115, USDA Forest Service.
Osher, S. & Sethian, J.A. (1988). Fronts propagating with curvature-dependent speed. J. Computational Physics, 79(1), 12-49.