API

PINNConfig(; kwargs...)

Training hyperparameters for the Physics-Informed Neural Network solver.

The initial condition is enforced exactly via a hard constraint decomposition (no IC loss term or IC collocation points needed).

Keyword Arguments

  • hidden_dims::Vector{Int} - Hidden layer sizes (default [64, 64, 64])
  • activation::Symbol - Activation function (default :tanh)
  • n_interior::Int - PDE collocation points (default 5000)
  • n_boundary::Int - Boundary condition points (default 500)
  • lambda_pde::Float64 - PDE loss weight (default 1.0)
  • lambda_bc::Float64 - BC loss weight (default 1.0)
  • lambda_data::Float64 - Data loss weight (default 1.0)
  • learning_rate::Float64 - Adam learning rate (default 1e-3)
  • max_epochs::Int - Maximum training epochs (default 10000)
  • resample_every::Int - Resample collocation points every N epochs (default 500)

Examples

config = PINNConfig(hidden_dims=[128, 128], max_epochs=10000)
PINNSolution

Trained PINN model. Callable as sol(t, x, y) to evaluate the level set function.

Fields

  • model - Lux neural network chain
  • parameters - Trained parameters (ComponentArray)
  • state - Lux model state
  • config::PINNConfig - Training configuration
  • loss_history::Vector{Float64} - Loss at each epoch
  • domain::NamedTuple - (tspan, xspan, yspan, phi_scale) for input normalization
  • grid_ic - Initial condition grid (for hard IC constraint decomposition)

Examples

phi = sol(10.0, 500.0, 500.0)  # evaluate at t=10, x=500, y=500
predict_on_grid(sol::PINNSolution, grid::LevelSet.LevelSetGrid, t)

Evaluate the trained PINN on every cell center of grid at time t. Returns a matrix of phi values with the same dimensions as grid.

Requires Lux to be loaded (triggers package extension).

predict_on_grid!(grid::LevelSet.LevelSetGrid, sol::PINNSolution, t)

In-place version of predict_on_grid: updates grid.phi and grid.t.

Requires Lux to be loaded (triggers package extension).

train_pinn(grid::LevelSet.LevelSetGrid, model, tspan; config=PINNConfig(), observations=nothing)

Train a Physics-Informed Neural Network to solve the fire spread level set PDE.

The PINN learns a function phi_theta(x, y, t) satisfying:

dphi/dt + F(x,y,t)|nabla phi| = 0

where F is the spread rate from the FireSpreadModel.

Requires Lux to be loaded (triggers package extension).

Arguments

  • grid - LevelSetGrid providing domain geometry and initial condition
  • model - Callable model(t, x, y) -> spread_rate (e.g. FireSpreadModel)
  • tspan - Time interval (t_start, t_end)
  • config - PINNConfig with training hyperparameters
  • observations - Optional (t, x, y, phi) tuple of observation data

Returns

A PINNSolution callable as sol(t, x, y).

Examples

sol = train_pinn(grid, model, (0.0, 50.0))
sol(25.0, 500.0, 500.0)  # evaluate at any point