This tutorial covers the fundamental components of an Elmfire.jl simulation.
The FireState Structure
The FireState is the central data structure that holds all simulation state:
usingElmfireusingPlots# Create a fire statestate =FireState{Float64}(100, 100, 30.0)println("Grid dimensions: $(state.ncols) x $(state.nrows)")println("Cell size: $(state.cellsize) ft")println("Padding: $(state.padding) cells")println("Phi array size: ", size(state.phi))
Grid dimensions: 100 x 100
Cell size: 30.0 ft
Padding: 2 cells
Phi array size: (104, 104)
Key Fields
Field
Type
Description
phi
Matrix{T}
Level set field (negative = burned)
burned
BitMatrix
Boolean burned map
time_of_arrival
Matrix{T}
When each cell burned (-1 = unburned)
spread_rate
Matrix{T}
Spread rate at burn time (ft/min)
fireline_intensity
Matrix{T}
Intensity at burn time (kW/m)
flame_length
Matrix{T}
Flame length at burn time (ft)
Fuel Models
Fuel models describe the physical properties of vegetation that affect fire behavior:
# Create the standard fuel tablefuel_table =create_standard_fuel_table(Float64)# Get a specific fuel modelfm =get_fuel_model(fuel_table, 1, 60) # FBFM01 at live moisture class 60println("Fuel Model: ", fm.name)println("Fuel bed depth: ", fm.delta, " ft")println("1-hr load: ", fm.W0[1], " lb/ft²")println("Dead fuel extinction moisture: ", fm.mex_dead)
Fuel Model: FBFM01
Fuel bed depth: 1.0 ft
1-hr load: 0.034 lb/ft²
Dead fuel extinction moisture: 0.12
Standard Fuel Models
The 13 original FBFM models plus 40 additional Scott & Burgan models are included:
# List available fuel modelsfuel_ids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]names = [get_fuel_model(fuel_table, id, 60).name for id in fuel_ids]for (id, name) inzip(fuel_ids, names)println("FBFM$id: $name")end
state =FireState{Float64}(100, 100, 30.0)# Single point ignitionignite!(state, 50, 50, 0.0) # (x, y, time)# Or use world coordinates# ignite_point!(state, 1500.0, 1500.0, 0.0) # (x_ft, y_ft, time)# Or ignite a circle# ignite_circle!(state, 50, 50, 3.0, 0.0) # (cx, cy, radius_cells, time)
Step 4: Run Simulation
weather =ConstantWeather{Float64}(wind_speed_mph=10.0, wind_direction=270.0, M1=0.06, M10=0.08, M100=0.10, MLH=0.60, MLW=0.90)simulate_uniform!( state,1, # Fuel model ID fuel_table, weather,10.0, # Slope (degrees)180.0, # Aspect (degrees)0.0, # Start time60.0; # End time dt_initial =1.0, # Initial timestep target_cfl =0.9, # CFL target dt_max =10.0# Maximum timestep)println("Burned area: ", round(get_burned_area_acres(state), digits=2), " acres")