Skip to content

7.1 Internal Variability: Climate Model Simulation Using the Lorenz Model

Learning Objectives

In this section, you will learn:

  • how an idealized climate model is organized,
  • how internal variability arises from deterministic equations,
  • how to configure and execute a climate model experiment,
  • how model spin-up and restart files are used in climate simulations,
  • how to visualize model output using time-series and three-dimensional plots, and
  • how a control simulation provides the foundation for later predictability and climate-change experiments.

Concept

The Lorenz model is one of the simplest dynamical systems that exhibits chaotic behavior and has been widely used to study atmospheric predictability. Although the model consists of only three variables, it reproduces one of the most fundamental characteristics of the climate system: internal variability.

Rather than treating the Lorenz model simply as a set of differential equations, we organize it using the same workflow employed by comprehensive climate models. This framework will be used throughout the remaining chapters to investigate predictability, ensemble forecasting, data assimilation, seasonal variability, and climate change.

The climate state is decomposed into two components,

\[ \mathbf{X} = \mathbf{X}_{int} + \mathbf{X}_{ext}, \]

where

  • Internal variability (\(\mathbf{X}_{int}\)) is generated by the Lorenz model.
  • External forcing (\(\mathbf{X}_{ext}\)) represents prescribed forcing such as the seasonal cycle or long-term climate change.

In this section, we perform a control simulation, in which the external forcing is set to zero,

\[ \mathbf{X}_{ext}=0. \]

Consequently, all variability originates from the nonlinear Lorenz dynamics.

Later sections will introduce external forcing by prescribing additional forcing tendencies while leaving the Lorenz model unchanged.


Model / Equations

Climate Model Structure

The climate model follows the workflow shown below.

Experiment configuration
        │
        ▼
Model initialization
        │
        ▼
Time integration
        │
        ├── Internal tendency (Lorenz model)
        ├── External forcing tendency
        ▼
Update model state
        │
        ├── Restart files
        ├── Model output
        ▼
Diagnostics and visualization

This workflow resembles the structure used by comprehensive climate models such as CESM and WRF.

The model consists of three primary files:

File Purpose
run_model_climate-v3.sh Defines experiment settings, directories, and model parameters.
Lmodel_climate-v3.py Performs numerical integration of the Lorenz climate model.
fig-timeseries_climate-v1.py Reads model output and visualizes the simulation results.

The climate state is expressed as

\[ \mathbf{X} = \mathbf{X}_{int} + \mathbf{X}_{ext}. \]

The internal component evolves according to the Lorenz model,

\[ \frac{d\mathbf{X}_{int}}{dt} = \mathbf{F}_{int} (\mathbf{X}_{int}), \]

while the externally forced component evolves according to

\[ \frac{d\mathbf{X}_{ext}}{dt} = \mathbf{F}_{ext}. \]

The total climate state becomes

\[ \boxed{ \mathbf{X} = \mathbf{X}_{int} + \mathbf{X}_{ext}. } \]

During this chapter,

\[ \mathbf{F}_{ext}=0, \]

so the model simulates internal variability only.

Later chapters will prescribe nonzero external forcing to represent seasonal variability and long-term climate change.


Lorenz Equations

The internal tendency is computed from the Lorenz equations,

\[ \frac{dX}{dt} = -\sigma X+\sigma Y, \]
\[ \frac{dY}{dt} = -XZ+\rho X-Y, \]
\[ \frac{dZ}{dt} = XY-\beta Z. \]

The default parameter values are

  • \(\sigma=10\)
  • \(\rho=28\)
  • \(\beta=8/3\)

These equations produce deterministic but chaotic behavior, allowing the model to generate irregular climate fluctuations without any random forcing.


Model Configuration

The climate model is configured through the shell script run_model_climate-v3.sh, which specifies the experiment settings before the model is executed. Similar configuration files are used in comprehensive climate models such as CESM and WRF, allowing different experiments to be performed without modifying the model source code.

The experiment settings include:

Parameter Description
REST Restart option. False starts a new simulation from the initial condition, while True continues from a previously saved restart file.
TSTR Start time of the simulation.
TEND End time of the simulation.
TSTEP Time interval between restart files and model output.
RDIR Directory for restart files.
RFILE Restart file name.
ODIR Directory for model output.
OUTPUTF Output file name.
AMP_X External forcing amplitude applied to the \(X\) variable.
AMP_Y External forcing amplitude applied to the \(Y\) variable.
AMP_Z External forcing amplitude applied to the \(Z\) variable.
DEBUG_OUTPUT When False, only the total climate state (\(X\), \(Y\), and \(Z\)) is written to the output files. When True, the internal and externally forced components are also saved for diagnostic purposes.

For this section, the model performs a control simulation with no external forcing,

AMP_X="0.0"
AMP_Y="0.0"
AMP_Z="0.0"

Consequently, all variability originates from the Lorenz model and represents internal variability.

The external forcing amplitudes will be modified in later sections to investigate the effects of the seasonal cycle and long-term climate change.

By separating the experiment configuration from the model source code, the same climate model can be used for many different numerical experiments simply by changing a few parameters in the shell script.


Running the Model

After configuring the experiment in run_model_climate-v3.sh, execute the model using

./run_model_climate-v3.sh

or

bash run_model_climate-v3.sh

The shell script automatically

  1. generates the executable Python model from the template,
  2. runs the climate model simulation,
  3. saves restart files,
  4. saves model output files, and
  5. removes the temporary executable model.

After the simulation finishes, the directory structure is

Model_src-v3.0/
├── figures/
├── out/
├── rest/
├── Lmodel_climate-v3.py
└── run_model_climate-v3.sh

where

  • out/ contains the model output used for analysis and visualization,
  • rest/ stores restart files that allow the simulation to continue from a previous state, and
  • figures/ contains scripts for plotting and analyzing the model output.

Sample Code

The source code for this section is provided as the compressed archive

Download the archive and extract it using

tar -xzvf Model_src-v3.0.tar.gz

This creates the directory

Model_src-v3.0/
├── figures/
│   ├── fig-lorenz_3d_animation.py
│   └── fig-timeseries_climate.py
├── Lmodel_climate-v3.py
└── run_model_climate-v3.sh

The individual source files are also available below.

File Description
run_model_climate-v3.sh Configures the numerical experiment and executes the climate model.
Lmodel_climate-v3.py Source code of the Lorenz climate model, including the internal dynamics and external forcing framework.
fig-timeseries_climate.py Generates time-series plots of the Lorenz variables \(X\), \(Y\), and \(Z\).
fig-lorenz_3d_animation.py Generates a three-dimensional animation of the Lorenz attractor.

The same source code will be reused throughout the remaining chapters. Subsequent sections will modify the experiment configuration and external forcing while keeping the overall model structure unchanged.


Exercise

Step 1. Install NetCDF Utilities and Create a Model Experiment

The Lorenz climate model writes its output in NetCDF format, which is the standard file format used by most weather and climate models.

First, install the NetCDF package in your Conda environment if necessary.

conda activate env_psc6125

conda install -c conda-forge netcdf4

Verify that the installation was successful,

which ncdump

or

ncdump -h

Next, create a new experiment directory for this section,

mkdir Model_EXP7_1

Copy the model source code into the experiment directory,

cp -r ../Model_src-v3.0/* Model_EXP7_1/

Move into the experiment directory,

cd Model_EXP7_1

Verify that the directory structure is

Model_EXP7_1/
├── figures/
├── Lmodel_climate-v3.py
└── run_model_climate-v3.sh

All model output, restart files, and figures generated in this section will be stored in this experiment directory.


Step 2. Model Spin-Up

A climate model is typically integrated through an initial spin-up period so that the model adjusts from its prescribed initial condition toward its own internal state.

Open run_model_climate-v3.sh and set

REST="False"

TSTR="0"
TEND="60"

Run the model,

./run_model_climate-v3.sh

or

bash run_model_climate-v3.sh

After the simulation finishes, verify that the model has created the following directories:

out/
rest/

Inspect the contents,

ls out

ls rest

Next, examine one of the model output files using ncdump,

ncdump out/out.0000.nc

The output should list the dimensions and variables stored in the NetCDF file.

Similarly, inspect one of the restart files,

ncdump rest/restart.0060.nc

Compare the variables contained in the two files.

Questions

  • What variables are stored in the model output file?
  • What variables are stored in the restart file?
  • Why does the restart file contain fewer variables than the model output file?
  • Why is a spin-up period necessary?
  • Why are restart files created during the integration?

Step 3. Continuous Model Run

Next, continue the simulation from the restart files generated during the spin-up.

Open run_model_climate-v3.sh and modify the following settings,

REST="True"

TSTR="60"
TEND="120"

Run the model again,

./run_model_climate-v3.sh

Inspect the updated output files,

ls out

ls rest

Examine the last restart file,

ncdump rest/restart.0120.nc

Questions

  • Does the simulation continue smoothly from the previous run?
  • Why is restarting a simulation more efficient than beginning from the initial condition every time?
  • Why are restart capabilities essential for long climate simulations?

Step 4. Visualize the Control Simulation

Move to the figures directory,

cd figures

First, generate the time-series figure,

python fig-timeseries_climate-v1.py

Next, create a quick 3-D animation of the Lorenz attractor,

python fig-lorenz_3d_animation-v1.py

The default setting only plots the first part of the simulation:

TSTR = 0
TEND = 20

FRAME_SKIP = 100
HOLD_FRAMES = 10

This setting is useful for quickly checking whether the script works.

After confirming that the animation runs correctly, modify the time range to show the full simulation:

TSTR = 0
TEND = 120

FRAME_SKIP = 100
HOLD_FRAMES = 80

Run the script again:

python fig-lorenz_3d_animation-v1.py

The script prints progress while writing the animation file, for example:

Writing frame   25/201

Questions:

  • What shape does the trajectory form in three-dimensional phase space?
  • Does the trajectory repeat exactly?
  • How does the 3-D view help interpret internal variability?
  • Why is it useful to first test the script with a shorter time range?

Key Points

  • The Lorenz model provides a simple representation of internal climate variability.
  • The climate model separates the numerical model, experiment configuration, and visualization scripts into different files.
  • A control simulation is performed by setting the external forcing amplitudes to zero.
  • Climate models typically require an initial spin-up period before scientific analysis begins.
  • Restart files allow long simulations to continue efficiently without restarting from the initial condition.
  • NetCDF is the standard output format used by weather and climate models.
  • Time-series and three-dimensional visualizations reveal the chaotic evolution of the Lorenz attractor.
  • The same climate model framework will be reused throughout the remaining chapters by modifying only the experiment configuration and external forcing.

Homework

Submit the following files generated during the exercises:

  1. A time-series figure (.png) showing the evolution of the Lorenz variables \(X\), \(Y\), and \(Z\).

  2. A three-dimensional animation (.mp4) of the Lorenz attractor.