-
Notifications
You must be signed in to change notification settings - Fork 0
/
LorenzRK_LT
27 lines (27 loc) · 1.03 KB
/
LorenzRK_LT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
%% this code is numerical integral of derivative equation
% using Runge-Kutta method. revised from R in last page of PPT
% this code together with mianLT.m are dedicated for
% <Data Assimilation> Class as a final project test withou any
% conflict of interest; Supervisor: GuoCan Wu, GCESS of BNU
% Author: Teng Li@20160702; Contact: [email protected]
%% encyclical Lorenz96 model's form:dX[j]/dt=(X[j+1]-X[j-2])*X[j-1]-X[j]+F
function lorenz = LorenzRK_LT(F, x)
% Input variables: F(8 for true state\6 for forecast) and X(physical
% virable time series); Output: integral result of X(n) using R-K
global nx
global dt
function dx = f(x)
dx(1) = (x(2) - x(nx-1))*x(nx)- x(1) + F;
dx(2) = (x(3) - x(nx))*x(1) - x(2) + F;
for j = 3:(nx -1)
dx(j) = (x(j+1) - x(j-2))*x(j-1) -x(j) + F;
dx(nx) = (x(1) - x(nx -2))*x(nx -1) -x(nx) + F;
end
dx = dx';
end
f1 = x + f(x)*dt/2;
f2 = x + f(f1)*dt/2;
f3 = x + f(f2)*dt;
f4 = x+(f(x) + f(f1)*2 + f(f2)*2 + f(f3))*dt/6;
lorenz = f4;
end