SIMbyom function derivatives.m (the model in ODEs)

Syntax: dX = derivatives(t,X,par,c,glo)

This function calculates the derivatives for the model system. It is linked to the script file byom_sim_lorenz.m. As input, it gets:

Time t and scenario name c are handed over as single numbers by call_deri.m (you do not have to use them in this function). Output dX (as vector) provides the differentials for each state at t.

Copyright (c) 2012-2021, Tjalling Jager, all rights reserved.
This source code is licensed under the MIT-style license found in the
LICENSE.txt file in the root directory of BYOM.

Contents

Start

function dX = derivatives(t,X,par,c,glo)

Unpack states

The state variables enter this function in the vector X. Here, we give them a more handy name.

x = X(1); % state 1
y = X(2); % state 2
z = X(3); % state 3

Unpack parameters

The parameters enter this function in the structure par. The names in the structure are the same as those defined in the byom script file. The 1 between parentheses is needed as each parameter has 5 associated values (probably not needed for the SIMbyom package).

sig  = par.sig(1);   % sigma
rho  = par.rho(1);   % rho
bet  = par.bet(1);   % beta

Calculate the derivatives

This is the actual model, specified as a system of three ODEs:

$$ \frac{dx}{dt} = \sigma (y-x) $$

$$ \frac{dy}{dt} = x (\rho-z) -y $$

$$ \frac{dz}{dt} = xy-\beta z $$

dx = sig*(y-x);
dy = x*(rho-z)-y;
dz = x*y-bet*z;

dX = [dx;dy;dz]; % collect all derivatives in one vector dX