Lorenz 96 model


The Lorenz 96 model is a dynamical system formulated by Edward Lorenz in 1996. It is defined as follows. For :
where it is assumed that and and. Here is the state of the system and is a forcing constant. is a common value known to cause chaotic behavior.
It is commonly used as a model problem in data assimilation.

Python simulation


from scipy.integrate import odeint
import matplotlib.pyplot as plt
import numpy as np
  1. These are our constants
N = 5 # Number of variables
F = 8 # Forcing
def L96:
"""Lorenz 96 model with constant forcing"""
return - np.roll) * np.roll - x + F
x0 = F * np.ones # Initial state
x0 += 0.01 # Add small perturbation to the first variable
t = np.arange
x = odeint
  1. Plot the first three variables
fig = plt.figure
ax = fig.add_subplot
ax.plot
ax.set_xlabel
ax.set_ylabel
ax.set_zlabel
plt.show

Julia simulation


using DynamicalSystems, PyPlot
PyPlot.using3D
  1. parameters and initial conditions
N = 5
F = 8.0
u₀ = F * ones
u₀ += 0.01 # small perturbation
  1. The Lorenz-96 model is predefined in DynamicalSystems.jl:
ds = Systems.lorenz96
  1. Equivalently, to define a fast version explicitly, do:
struct Lorenz96 end # Structure for size type
function where
F = p
# 3 edge cases explicitly
@inbounds dx = * x - x + F
@inbounds dx = * x - x + F
@inbounds dx = * x - x + F
# then the general case
for n in 3:
@inbounds dx = * x - x + F
end
return nothing
end
lor96 = Lorenz96 # create struct
ds = ContinuousDynamicalSystem
  1. And now evolve a trajectory
dt = 0.01 # sampling time
Tf = 30.0 # final time
tr = trajectory
  1. And plot in 3D:
x, y, z = columns
plot3D