Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

11.2) (Exercise) Introduction to Hybrid Models: Combining Physics-Based and Machine Learning Models

Open In Colab Open In Kaggle

Q: What is a glacier from your perspective?

Aletsch Glacier Switzerland

Figure 1: Aletsch Glacier in Switzerland. Source: Le News (2017).


A modeler’s perspective: A glacier is a non-Newtonian fluid with stress-dependent viscosity, flowing from higher to lower elevations.

Introduction to Glacier Flow

Glaciers are massive bodies of ice that flow slowly under their own weight. The flow of ice in a glacier is a complex process governed by physical laws that describe how the ice deforms and moves.

Given an initial glacier geometry, the time evolution of ice thickness h(x,y,t)h(x, y, t) is determined by the mass conservation equation, which couples ice dynamics and surface mass balance (SMB) through:

∂h∂t+∇⋅(uh)=SMB,\frac{\partial h}{\partial t} + \nabla \cdot (\mathbf{u}h) = \text{SMB},

where ∇⋅\nabla \cdot denotes the divergence operator with respect to the flux (Q=uhQ = \mathbf{u}h). u\mathbf{u} is the vertically averaged horizontal ice velocity field, and SMB is the surface mass balance function, representing the integration of ice accumulation and ablation over one year.

The mass conservation equation is generic and can be applied to model glacier evolution in various applications, provided adequate SMB and ice-flow model components are available.

In the following, we primarily focus on developing an efficient numerical method to compute ice flow, as it is often the most computationally expensive component of glacier evolution models:

  • First, we will use a numerical solution to compute QQ.

  • Then, we will employ a data-driven (ML) approach to emulate ice flow.

Although state-of-the-art ML techniques, such as Physics-Informed Neural Networks (PINNs), are widely used, they typically do not conserve ice thickness to machine precision. To address this limitation, this chapter focuses on hybrid models that explicitly integrate the mass conservation equation while leveraging ML for the computationally intensive modeling of ice flow.

Numerical Solution for u

We can describe the ice-flow equations under stress, but their computational cost makes them impractical for large-scale ice-sheet modeling over long time periods. This leads us to introduce the shallow ice approximation (SIA), which is used in ice sheet models due to its simplicity and efficiency.

The SIA simplifies the full Stokes equations by assuming that the ice flow is dominated by vertical shear stresses and that horizontal stresses can be neglected. This results in an expression for the ice velocity in terms of the ice thickness gradient and the surface slope. The ice velocity u[m/a]\mathbf{u}[m/a] can be approximated as:

u=−(2An+2)(ρgsin⁡(s))nhn+1∇h.\mathbf{u} = -\left(\frac{2 A}{n+2}\right) \left(\rho g \sin(s)\right)^n h^{n+1} \nabla h.

This equation governs the horizontal velocity of ice based on the local ice thickness and slope. Substituting u\mathbf{u} into the mass conservation equation, we obtain:

∂h∂t+∇⋅(D(h,z)∂z∂x)=SMB,\frac{\partial h}{\partial t} + \nabla \cdot \left(D(h,z)\frac{\partial z}{\partial x}\right) = \text{SMB},

where

D(h,z)=fd(ρg)3h5∣∇S∣2.D(h,z) = f_d (\rho g)^3 h^5 |\nabla S|^2.
ParametersValues
ice velocity u\mathbf{u}m/am/a
physical constant fd f_d 1×10−15[Pa−3yr−1] 1 \times 10^{-15} [Pa^{-3} yr^{-1}]
ice thickness hhm
ice density ρice \rho_{\mathrm{ice}} (ρ\rho)910 kg/m3kg/m^{3}
gravitational constant g g 9.81 ms−2m s^{-2}
Glen’s flow rate factor A A MPa^{−3}a^{−1}
Glen’s law exponent n n 3
surface slope s s gradient

Note that Pa=Kg/(m⋅s2)Pa =Kg/(m⋅s^2)

This equation describes the time evolution of the ice thickness, where the velocity u\mathbf{u} is computed from the ice sheet’s surface slope and thickness. This approach provides a balance between accuracy and computational efficiency and is widely used in large-scale ice sheet models.

Boundary Conditions with No-Slip Condition at the Base

In many glacier models, we assume a no-slip condition at the base, meaning the ice velocity is zero at the bedrock. This condition is suitable for glaciers that are frozen to their beds:

u=0on the bedrock surface.\mathbf{u} = 0 \quad \text{on the bedrock surface}.

Stress-Free Surface

At the glacier surface, which is exposed to air, a stress-free boundary condition is typically applied:

σ⋅n=0on the surface,\sigma \cdot \mathbf{n} = 0 \quad \text{on the surface},

where n\mathbf{n} is the outward normal vector at the glacier surface.

⚠️ Note: The previous code snippet took a while to execute, confirming the computational cost of traditional numerical models.

Q: Which is the most expensive part of solving the mass conservation equation?
The most expensive part is the calculation of u/D .

Introduction to Hybrid Modeling

Hybrid models combine traditional physics-based models (model-based, MB) with machine learning (ML) to leverage the strengths of both approaches. In purely physics-based models, system dynamics are governed by known equations, but these models often require detailed domain knowledge and can be limited by the availability of precise parameters. Machine learning, by contrast, can model complex systems without relying on such parameters, making it particularly useful for data-rich but theory-poor domains. However, ML models may struggle to generalize beyond the data they are trained on and can sometimes produce results that violate known physical laws.

Q: How can hybrid models overcome these limitations?

Hybrid modeling addresses these limitations by incorporating physics-informed constraints, embedding known physical equations into machine learning models, or combining the outputs of both approaches. The goal is to create models that are more accurate and robust, particularly in cases with limited data or imperfect physical models. By fusing physics with data-driven methods, hybrid models can handle sparse datasets, correct ML predictions that violate physical laws, and produce interpretable results across a wide range of applications.

Q: How can we make our simulations run faster?
We can replace the calculation of u with an emulator. The emulator takes as input the state of the medium (glacier thickness, slope of the glacier, etc.) and calculates the velocity field ( u ) for the corresponding time step.

Emulating Ice Flow with Machine Learning

The Instructed Glacier Model (IGM) uses a convolutional neural network (CNN) to predict ice flow, trained on data from traditional models such as hybrid SIA+SSA or Stokes models. This approach replaces the computationally expensive ice flow component with a significantly faster emulator, enabling simulations that are up to 1000 times faster while maintaining over 90% fidelity.

Overview of the Machine Learning Approach

A simple version of the IGM can be built using the following steps:

  1. Input Variables: The ML model takes ice thickness and surface slope gradients as inputs:

    {h(x,y),∂s∂x,∂s∂y}.\left\{ h(x,y), \frac{\partial s}{\partial x}, \frac{\partial s}{\partial y} \right\}.
  2. Training: A convolutional neural network (CNN) is trained on a dataset generated from high-order glacier flow models.

  3. Prediction: Once trained, the emulator predicts the vertically averaged ice flow components u and v based on the input variables.

The input and output fields are 2D grid rasters:

RNx×Ny×3→RNx×Ny×2.\mathbb{R}^{N_x \times N_y \times 3} \rightarrow \mathbb{R}^{N_x \times N_y \times 2}.

Q: What is another advantage of the hybrid model (besides making faster models)?
Hybrid models can be beneficial in theory-poor domains where we do not know the equations governing system dynamics. However, sufficient data is required, and care must be taken to ensure the model is generalizable. A potential pitfall, when there is insufficient data or a lack of caution, is overfitting.

Helper Functions You Do Not Need to Know

These functions are auxiliary tools used in the notebook to handle common tasks like loading data, scaling fields, augmenting data, and visualizing results. They simplify the workflow but are not the focus of this exercise.

Functions to Prepare the Data for the Model

These functions handle the preprocessing and preparation of data to ensure it is ready for model training. They include steps such as scaling, stacking input and output fields, splitting datasets, and augmenting the data to improve training outcomes.

Data augmentation

This script is intended for demonstration purposes; however, the available dataset is limited. To enhance its effectiveness, what strategies would you recommend for augmenting the data?

Start working on the CNN model

Sequential(
  (0): Conv2d(3, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
  (1): ReLU()
  (2): Dropout(p=0.1, inplace=False)
  (3): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
  (4): ReLU()
  (5): Dropout(p=0.1, inplace=False)
  (6): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
  (7): ReLU()
  (8): Dropout(p=0.1, inplace=False)
  (9): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
  (10): ReLU()
  (11): Dropout(p=0.1, inplace=False)
  (12): Conv2d(32, 2, kernel_size=(1, 1), stride=(1, 1))
)
Total parameters: 28,706

Implementing the Hybrid Model

For the hybrid model, we will implement the mass conservation equation using a numerical scheme. The main difference from the first approach is how we calculate u(x, y). Instead of deriving it directly, we use the emulator trained earlier and plug it into the mass conservation equation to compute the flux.

To perform each iteration of the numerical scheme, we will need two helper functions: compute_divflux() and compute_gradient_tf().

Remember that the velocity field u primarily depends on the slope and thickness of the glacier.

Helper functions for the hybrid model

Run the hybrid model

⚡ Note how much faster the hybrid model is?

Q: What are some disadvantages of hybrid models?

  • Boundary conditions are difficult to implement.

  • The model is only as good as the data it is trained on.

Q: What are some other fields where we can use Hybrid Models?

  • 1.

  • 2.