Milestone 3 - ODE Solvers


Time dependent source term

As a next step, we want to incorporate the annual change of the insolation and consider a simplified EBM, where we only average the coefficients in space but not in time. We apply the area averaging to our coefficients to get

CdTAdt+A(CO2)+B TA=Ssol(t), \overline{C} \frac{d { T_A}}{d { t} } + A(CO_2) + B\, T_A = \overline{S_{sol}}(t),

where we keep the time dependence of the solar source term.

Remark: We get Ssol(t)\overline{S_{sol}}(t) by computing the area average of Ssol(x,t)=(1α(x))S(x,t)S_{sol}(x,t) = (1-\alpha(x))S(x,t) at every single time step separately.

As mentioned in the previous sections, due to the complexity of the solar forcing term, this model is somewhat difficult to solve analytically. However, this time, we take the chance to consider numerical approximation methods, so-called ODE solvers, to numerically calculate an (approximate) ODE solution to (1).

Typically, in ODE literature, a problem of the following form is considered

y(t)=f(y,t), t0,y(t=0)=y0,\begin{aligned} y' (t) &= f(y,t),~~ t \ge 0, \\ y(t=0) &= y_0, \end{aligned}

where y(t)y(t) is the unknown function we want to compute with initial conditions y0y_0 and the right-hand-side operator f(y,t)f(y,t). We can reformulate our problem (1) into this typical ODE notation for the choice

y(t)=TA(t),f(y,t)=1C(Ssol(t)AB TA).\begin{aligned} y(t) &= T_A(t), \\ f(y,t) &= \frac{1}{\overline{C}} \left( \overline{S_{sol}}(t) -A - B \, T_A \right). \end{aligned}

Remark: There is extensive knowledge on the theory on existence and uniqueness of solutions for ordinary differential equations in the literature. The existence and uniqueness of solutions for ODEs depends on the continuity properties of the right-hand-side f(y,t)f(y,t). The most famous results are the Lemma of Peano (existence of solutions) and the Lemma of Picard-Lindelöf (uniqueness of solutions). We refer the interested reader to the standard literature on ODEs.

Some examples:

Arnold, V. I. (1992). Ordinary differential equations. Springer Science & Business Media.

Butcher, J. C. (2016). Numerical methods for ordinary differential equations. John Wiley & Sons.

ODE Solvers

Comment: We emphasize that there are typically full courses dedicated to the topic of construction and analysis of numerical methods for ODEs. The focus is often on the state-of-the-art method class: the Runge–Kutta Method (implicit and explicit versions). In this course we focus on simpler methods, namely the forward and backward Euler schemes, that are sufficient in terms of efficiency for the problems we are interested in. However, we encourage the interested reader to look for more sophisticated methods and apply them for our problem and see if there is an efficiency gain possible.

The Euler method

There are many ways to derive and motivate the Euler time-integration method. We choose the idea of an approximation to the time integral when giving the integral form of the ODE solution.

Consider the ODE

y(t)=f(y,t). y'(t) = f(y,t).

Formally, the solution is given by

y(t)y(t0)=t0ty(t)dt=t0tf(y,t)dt. y(t) - y(t_0) = \int_{t_0}^t y'(t) \mathrm{d} t = \int_{t_0}^t f(y,t) \mathrm{d} t.

The problem is of course that the solution y(t)y(t) is needed to compute the right-hand-side time integral.

We first consider a discretization of the time axis into small time steps Δt\Delta t

We start with the known initial value

y(t=t0)=y0. y(t=t_0) = y_0.

To obtain the solution at the next time step, y(t1)y(t_1), we look at the integral formula

y(t1)y0=t0t1f(y,t)dt, y(t_1) - y_0 = \int_{t_0}^{t_1} f(y,t) \mathrm{d} t,

and make the simplest approximation to the integral via a rectangular quadrature rule:

We can use the left-sided rule,

y(t1)y1=y0+(t1t0)f(y0,t0), y(t_1) \approx y_1 = y_0 + (t_1 - t_0) f(y_0,t_0),

or the right-sided rule,

y(t1)y1=y0+(t1t0)f(y1,t1). y(t_1) \approx y_1 = y_0 + (t_1 - t_0) f(y_1,t_1).

Now that we have an approximation for y1y_1, we can proceed analogously for y2y_2, y3y_3, \ldots

Euler (explicit):yk+1=yk+(tk+1tk)f(yk,tk)Euler (implicit):yk+1=yk+(tk+1tk)f(yk+1,tk+1).\begin{aligned} \text{Euler~(explicit):}& &y_{k+1} &= y_k + (t_{k+1} - t_k) f(y_k,t_k) \\ \text{Euler~(implicit):}& &y_{k+1} &= y_k + (t_{k+1} - t_k) f(y_{k+1},t_{k+1}). \end{aligned}

The first variant is called explicit as the new value yk+1y_{k+1} can be directly computed with the information that is known at the current time level tkt_k. The second variant is implicit as the new unknown solution yk+1y_{k+1} also appears on the right-hand side inside the function f(.,t)f(.,t). Hence, an algebraic equation needs to be solved for every time step. This equation is non-linear or linear, depending on the function f(.,t)f(.,t).

These two methods are the simplest variants of an ODE solver and are formally first-order accurate approximations (can be shown via Taylor expansion). This means that in general the solutions of the Euler methods are not exact solutions of the ODE, but have an (numerical) error. First-order accuracy means that the error of the numerical approximation depends linearly on the time-step size Δt=tk+1tk\Delta t = t_{k+1} - t_k, i.e., the error behaves like errorO(Δt1)error\sim \mathcal{O}(\Delta t^1). Hence, by decreasing the time-step size, the error gets smaller. However, at the same time, the number of time steps n_timesteps\texttt{n\_timesteps} gets larger, i.e., the amount of computations increases. As a consequence, we aim to choose the time-step size as large as possible, but small enough to obtain the desired accuracy in our numerical simulation.

Remark: It is easy to generate a second-order time-integration method based on the Euler methods. For instance, the implicit Crank–Nicolson scheme is

yk+1=yk+tk+1tk2(f(yk,tk)+f(yk+1,tk+1)), y_{k+1} = y_k + \frac{t_{k+1} - t_k}{2} \left(f(y_{k},t_{k}) + f(y_{k+1},t_{k+1}) \right),

which results when approximating the integral with a trapezoidal rule, i.e., by considering half of the explicit plus half of the implicit Euler update.

Stability of the explicit and implicit Euler methods

When deciding between the explicit or implicit Euler variants, one might get tempted to use directly the much simpler explicit Euler method: every solution can be directly computed without solving an algebraic (possibly non-linear) equation. However, the simplicity of the explicit nature comes at a hefty price: the choice of the size of Δt\Delta t is not arbitrary anymore, but needs to be small enough due to stability reasons.

As an example, let us consider the ODE

y(t)=λy(t),λC,y(0)=1,\begin{aligned} y'(t) &= \lambda y(t),& &\lambda \in \mathbb{C}, \\ y(0) &= 1, \end{aligned}

with the analytical solution y(t)=eλty(t) = e^{\lambda t}.

Since λ\lambda is a complex number, we can write it as λ=a+bi\lambda = a + b i. Therefore, we get

y(t)=eatebti=eat(cos(bt)+isin(bt)),\begin{aligned} y(t) &= e^{at} e^{bti} \\ &= e^{at} \left( \cos(bt) + i \sin(bt) \right), \end{aligned}

which shows that the real part corresponds to the amplitude of the solution (which grows in time for a>0a>0 and decreases for a<0a<0) and that the imaginary part is the oscillatory part.

We can consider a perturbed initial condition,

yδ(0)=1+δ, y_{\delta}(0) = 1+ \delta,

where δ\delta is small compared to y0=1y_0=1. The exact solution is then

yδ(t)=(1+δ)eλt. y_{\delta}(t) = (1 + \delta) e^{\lambda t}.

If we compare the two solutions,

yδ(t)y(t)=δeλt, |y_{\delta}(t) - y(t)| = |\delta e^{\lambda t}|,

we see that only for non-positive real parts, a0a \le 0, the difference stays small in time even when considering a small δ\delta perturbation. The problem is called stable for Re(λ)=a0\text{Re}(\lambda) = a \le 0. We want to have numerical methods that are numerically stable when solving stable problems!

If we apply first the explicit Euler formula to solve the problem, we get

yk+1=yk+Δtλyk=(1+Δtλ)yk.\begin{aligned} y_{k+1} &= y_k + \Delta t \lambda y_k \\ &= (1 + \Delta t \lambda) y_k. \end{aligned}

If we look at the amplitude of the numerical solution we obtain

yk+1=1+Δtλyk, |y_{k+1}| = |1 + \Delta t \lambda| |y_k|,

which shows that 1+Δtλ|1 + \Delta t \lambda| is the amplification factor of the explicit Euler method. We can investigate for which values of Δt\Delta t this factor is smaller than 11 to obtain:

We need that the product (Δtλ)(\Delta t \lambda) is within the marked red circle to keep the numerical amplification factor smaller than 11!

The red circle defines the numerical stability region of the explicit Euler method and indicates that for guaranteed numerical stability, the size of Δt\Delta t is limited.

Example: Consider the ODE y(t)=1000 y(t)y(0)=1.\begin{aligned} y'(t) &= -1000\, y(t) \\ y(0) &= 1. \end{aligned}

The red circle stability area gives a maximum time step size of Δtmax=1500\Delta t_{\max} = \frac{1}{500}, which shows that the time-step size can get very low for large values of λ\lambda. Such problems are sometimes also referred to as stiff problems.

The advantage of the explicit Euler method is the simplicity and the computationally cheap algorithm. The downside is that the size of the time step can be very low due to numerical stability issues.

If we consider now the implicit Euler method for our simple ODE (12), we obtain

yk+1=yk+λΔtyk+1yk+1=yk1λΔt.\begin{aligned} y_{k+1} &= y_k + \lambda \Delta t y_{k+1} \\ y_{k+1} &= \frac{y_k}{1- \lambda \Delta t}. \end{aligned}

In this simple case, we can directly solve the implicit equation!

The amplification factor is now 11λΔt\left| \frac{1}{1- \lambda \Delta t} \right|, which gives the stability region of the implicit Euler method:

This shows that the implicit Euler scheme is stable for all values of λΔt\lambda \Delta t, except for the ones inside the blue circle. In particular, the scheme is unconditionally stable for all choices of Δt\Delta t in case Re(λ)=a0\text{Re}(\lambda) = a \le 0.

Hence, the big advantage of the implicit variant is that Δt\Delta t can be chosen arbitrarily regarding the stability and only needs to be chosen for accuracy reasons.

Remark: Depending on the stiffness of the ODE problem and the computational complexity of the implicit equation, either the explicit or implicit method is more efficient.

Temporal equilibrium simulation

In conclusion, we have now all the tools available to solve our time dependent area-averaged EBM with either explicit or implicit Euler in time.

The only open question is how we can reach equilibrium in time for our simulation. We need to realize that the source term is periodic in time (with a period of one year). Hence, we are looking for a numerical solution that changes within the year, but then repeats itself for every following year afterwards. Once we have reached such an annual state, we consider that our simulation of the climate system has reached equilibrium and no further change of the annual temperature will occur unless the problem definition (e.g. the parametrizations) is changed again.

In practice, we have to compare the yearly temperature solutions with each other, until the difference from one year to the next is smaller than a given tolerance. Among the different choices of norms to compute the yearly solutions, the simplest option is to compute the Euclidean norm of the data vectors in time.


Created by Gregor Gassner and Andrés Rueda-Ramírez with contributions by Simone Chiocchetti, Daniel Bach, Sophia Horak, Philipp Baasch, Benjamin Bolm, Erik Faulhaber, and Luca Sommer. Last modified: April 02, 2026. Website built with Franklin.jl and the Julia programming language.