Models

There are 3 main types of models in ODINN.jl, iceflow models, mass balance models and machine learning models. These three families are determined by abstract types, with specific types being declared as subtypes of these abstract types to ensure compatibility through the ODINN ecosystem.

The three main types of models are gathered in a parent type Model in the following way:

ODINN.ModelFunction
Model(;
    iceflow::Union{IFM, Nothing},
    mass_balance::Union{MBM, Nothing},
    regressors::NamedTuple = (;),
    target::Union{TAR, Nothing} = nothing,
) where {IFM <: IceflowModel, MBM <: MBmodel, TAR <: AbstractTarget}

Creates a new model instance using the provided iceflow, mass balance, and machine learning components.

Arguments

  • iceflow::Union{IFM, Nothing}: The iceflow model to be used. Can be a single model or nothing.
  • mass_balance::Union{MBM, Nothing}: The mass balance model to be used. Can be a single model or nothing.
  • machine_learning::Union{MLM, Nothing}: The machine learning model to be used. Can be a single model or nothing.

Returns

  • model: A new instance of Sleipnir.Model initialized with the provided components.
source
ODINN.ModelMethod
Model(;
    iceflow::Union{IFM, Nothing},
    mass_balance::Union{MBM, Nothing},
    regressors::NamedTuple = (;),
    target::Union{TAR, Nothing} = nothing,
) where {IFM <: IceflowModel, MBM <: MBmodel, TAR <: AbstractTarget}

Creates a new model instance using the provided iceflow, mass balance, and machine learning components.

Arguments

  • iceflow::Union{IFM, Nothing}: The iceflow model to be used. Can be a single model or nothing.
  • mass_balance::Union{MBM, Nothing}: The mass balance model to be used. Can be a single model or nothing.
  • machine_learning::Union{MLM, Nothing}: The machine learning model to be used. Can be a single model or nothing.

Returns

  • model: A new instance of Sleipnir.Model initialized with the provided components.
source

Ice flow models

Ice flow models are used to solve the PDEs describing the gravitational flow of glaciers. All ice flow models must be a subtype of abstract type IceflowModel. Ice flow models are managed by the Huginn.jl package.

The main type of ice flow model used in ODINN.jl right now is a 2D Shallow Ice Approximation (SIA) model (Hutter, 1983). This is declared in the following way:

Huginn.SIA2DmodelType
SIA2Dmodel(A, C, n, Y, U, n_H, n_∇S)
SIA2Dmodel(params; A, C, n, Y, U, n_H, n_∇S)

Create a SIA2Dmodel, representing a two-dimensional Shallow Ice Approximation (SIA) model.

The SIA model describes glacier flow under the assumption that deformation and basal sliding dominate the ice dynamics. It relies on:

  • Glen's flow law for internal deformation, with flow rate factor A and exponent n,
  • A sliding law governed by coefficient C,
  • Optionally the user can provide either:
    • A specific diffusive velocity U such that D = U * H
    • A modified creep coefficient Y that takes into account the ice thickness such that D = (C + Y * 2/(n+2)) * (ρ*g)^n * H^(n_H+1) * |∇S|^(n_∇S-1) where n_H and n_∇S are optional parameters that control if the SIA should use the n law or not. This formulation is denoted as the hybrid diffusivity in the code.

This struct stores the laws used to compute these three parameters during a simulation. If not provided, default constant laws are used based on glacier-specific values.

Arguments

  • A: Law for the flow rate factor. Defaults to a constant value from the glacier.
  • C: Law for the sliding coefficient. Defaults similarly.
  • n: Law for the flow law exponent. Defaults similarly.
  • Y: Law for the hybrid diffusivity. Providing a law for Y discards the laws of A, C and n.
  • U: Law for the diffusive velocity. Defaults behavior is to disable it and in such a case it is computed from A, C and n. Providing a law for U discards the laws of A, C, n and Y.
  • n_H::F: The exponent to use for H in the SIA equation when using the Y law (hybrid diffusivity). It should be nothing when this law is not used.
  • n_∇S::F: The exponent to use for ∇S in the SIA equation when using the Y law (hybrid diffusivity). It should be nothing when this law is not used.
  • Y_is_provided::Bool: Whether the diffusivity is provided by the user through the hybrid diffusivity Y or it has to be computed from the SIA formula from A, C and n.
  • U_is_provided::Bool: Whether the diffusivity is provided by the user through the diffusive velocity U or it has to be computed from the SIA formula from A, C and n.
  • n_H_is_provided::Bool: Whether the H exponent is prescribed by the user, or the one of the n law has to be used. This flag is used only when a law for Y is used.
  • n_∇S_is_provided::Bool: Whether the ∇S exponent is prescribed by the user, or the one of the n law has to be used. This flag is used only when a law for Y is used.
  • apply_A_in_SIA::Bool: Whether the value of the A law should be computed each time the SIA is evaluated.
  • apply_C_in_SIA::Bool: Whether the value of the C law should be computed each time the SIA is evaluated.
  • apply_n_in_SIA::Bool: Whether the value of the n law should be computed each time the SIA is evaluated.
  • apply_Y_in_SIA::Bool: Whether the value of the Y law should be computed each time the SIA is evaluated.
  • apply_U_in_SIA::Bool: Whether the value of the U law should be computed each time the SIA is evaluated.
source

When a simulation will be run in ODINN.jl using an ice flow model, its related equation will be solved using OrdinaryDiffEq.jl. The related equation to a SIA2Dmodel is declared in its related util functions. These equations need to be defined in-place (to reduce memory allocations and ensure maximum performance, see example below). This is both compatible with the forward runs and with the reverse pass differentiated using Enzyme.jl.

Huginn.SIA2D!Function
SIA2D!(
    dH::Matrix{R},
    H::Matrix{R},
    simulation::SIM,
    t::R,
    θ,
) where {R <:Real, SIM <: Simulation}

Simulates the evolution of ice thickness in a 2D shallow ice approximation (SIA) model. Works in-place.

Arguments

  • dH::Matrix{R}: Matrix to store the rate of change of ice thickness.
  • H::Matrix{R}: Matrix representing the ice thickness.
  • simulation::SIM: Simulation object containing model parameters and state.
  • t::R: Current simulation time.
  • θ: Parameters of the laws to be used in the SIA. Can be nothing when no learnable laws are used.

Details

This function updates the ice thickness H and computes the rate of change dH using the shallow ice approximation in 2D. It retrieves necessary parameters from the simulation object, enforces positive ice thickness values, updates glacier surface altimetry and computes surface gradients. It then applies the necessary laws that are not updated via callbacks (A, C, n or U depending on the use-case) and computes the flux components, and flux divergence.

Notes

  • The function operates on a staggered grid for computing gradients and fluxes.
  • Surface elevation differences are capped using upstream ice thickness to impose boundary conditions.
  • The function modifies the input matrices dH and H in-place.

See also SIA2D

source

Mass balance models

(Surface) Mass balance models are used to simulate the simplified thermodynamics of the forcing of the atmosphere on glaciers. As per ice flow models, all specific mass balance models needs to be a subtype of the abstract type MBmodel. Mass balance models are managed by Muninn.jl. For now, we have simple temperature-index models, with either one or two degree-day factors (DDFs) (Hock, 2003):

Muninn.TImodel1Type
TImodel1{F <: AbstractFloat}

A structure representing a temperature index model with degree-day factor and accumulation factor.

Keyword arguments

  • DDF::F: Degree-day factor, which is a coefficient used to convert temperature into melt.
  • acc_factor::F: Accumulation factor, which is a coefficient used to adjust the accumulation of mass.

Type Parameters

  • F: A subtype of AbstractFloat representing the type of the factors.
source
Muninn.TImodel1Method
TImodel1(params::Sleipnir.Parameters; DDF::F = 7.0/1000.0, acc_factor::F = 1.0/1000.0) where {F <: AbstractFloat}

Create a temperature index model with one degree-day factor (DDF) with the given parameters.

Arguments

  • params::Sleipnir.Parameters: The simulation parameters.
  • DDF::F: Degree-day factor (default is 7.0/1000.0).
  • acc_factor::F: Accumulation factor (default is 1.0/1000.0).

Returns

  • TI1_model: An instance of TImodel1 with the specified parameters.
source

Surface mass balance models are run in DiscreteCallbacks from OrdinaryDiffEq.jl, which enable the safe execution during the solving of a PDE in specificly prescribed time steps determined in the stepsfield in Sleipnir.SimulationParameters.

We soon plan to add compatibility with neural networks coming from the MassBalanceMachine, which should become the de facto surface mass balance model in the ODINN.jl ecosystem.

Regressors

Regressors (e.g. machine learning models) are used in the context of Universal Differential Equations (UDEs, Rackauckas et al., 2020) to parametrize or learn specific parts of differential equations. Machine Learning models are managed by ODINN.jl. Virtually all available regressors in Julia can be used inside ODINN, but they need to be correctly interfaced. Here is an example of a simple neural network (multilayer perceptron) using Lux.jl:

ODINN.NeuralNetworkType
NeuralNetwork{
    ChainType <: Lux.Chain,
    ComponentVectorType <: ComponentVector,
    NamedTupleType <: NamedTuple,
} <: MLmodel

Feed-forward neural network.

Fields

  • architecture::ChainType: Flux.Chain neural network architecture
  • θ::ComponentVectorType: Neural network parameters
  • st::NamedTupleType: Neural network status
source

In order to parametrize a given variable inside an (ice flow) model, one can do it via the regressors keyword in Model:

nn_model = NeuralNetwork(params)
A_law = LawA(nn_model, params)
model = Model(
    iceflow = SIA2Dmodel(params; A=A_law),
    mass_balance = TImodel1(params; DDF=6.0/1000.0, acc_factor=1.2/1000.0),
    regressors = (; A=nn_model)
)