Skip to content

Commit b849181

Browse files
committed
Initial Commit of KS
Simple 1D Chaotic test problem that is significantly better understood than Lorenz '96
1 parent f47e3e8 commit b849181

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
classdef Canonical < otp.kuramotosivashinsky.KuramotoSivashinskyProblem
2+
3+
methods
4+
function obj = Canonical(varargin)
5+
6+
p = inputParser;
7+
addParameter(p, 'Size', 64, @isscalar);
8+
addParameter(p, 'L', 25, @isscalar);
9+
10+
parse(p, varargin{:});
11+
12+
s = p.Results;
13+
14+
n = s.Size;
15+
16+
17+
params.n = n;
18+
params.l = s.L;
19+
20+
x = linspace(0, 10*pi, n + 1);
21+
22+
u0 = 4*cos(x(1:end-1)).';
23+
24+
tspan = [0, 100];
25+
26+
obj = obj@otp.kuramotosivashinsky.KuramotoSivashinskyProblem(tspan, u0, params);
27+
end
28+
end
29+
end
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
classdef KuramotoSivashinskyProblem < otp.Problem
2+
3+
methods
4+
function obj = KuramotoSivashinskyProblem(timeSpan, y0, parameters)
5+
obj@otp.Problem('Kuramoto Sivashinsky Problem', [], timeSpan, y0, parameters);
6+
end
7+
end
8+
9+
methods (Access = protected)
10+
function onSettingsChanged(obj)
11+
n = obj.Parameters.n;
12+
l = obj.Parameters.l;
13+
14+
domain = [-l, l];
15+
D = otp.utils.pde.D(n, domain, 'C');
16+
L = otp.utils.pde.laplacian(n, domain, 1, 'C');
17+
18+
obj.Rhs = otp.Rhs(@(t, u) otp.kuramotosivashinsky.f(t, u, D, L), ...
19+
otp.Rhs.FieldNames.Jacobian, @(t, u) otp.kuramotosivashinsky.jac(t, u, D, L));
20+
21+
end
22+
23+
function validateNewState(obj, newTimeSpan, newY0, newParameters)
24+
validateNewState@otp.Problem(obj, ...
25+
newTimeSpan, newY0, newParameters)
26+
27+
otp.utils.StructParser(newParameters) ...
28+
.checkField('n', 'scalar', 'integer', 'finite', 'positive') ...
29+
.checkField('l', 'scalar', 'integer', 'finite', 'positive');
30+
end
31+
end
32+
end

src/+otp/+kuramotosivashinsky/f.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function du = f(~, u, D, L)
2+
3+
du = - L*(L*u + u) - u.*(D*u);
4+
5+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function j = jac(~, u, D, L)
2+
3+
j = -L*L - L - spdiags(u, 0, numel(u), numel(u))*D - spdiags(D*u, 0, numel(u), numel(u));
4+
5+
end

0 commit comments

Comments
 (0)