Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/+otp/+kuramotosivashinsky/+presets/Canonical.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
classdef Canonical < otp.kuramotosivashinsky.KuramotoSivashinskyProblem

methods
function obj = Canonical(varargin)

p = inputParser;
addParameter(p, 'Size', 64, @isscalar);
addParameter(p, 'L', 25, @isscalar);
Comment thread
AndreyAPopov marked this conversation as resolved.
Outdated

parse(p, varargin{:});

s = p.Results;

n = s.Size;


params.n = n;
params.l = s.L;

x = linspace(0, 10*pi, n + 1);

u0 = 4*cos(x(1:end-1)).';

tspan = [0, 100];

obj = obj@otp.kuramotosivashinsky.KuramotoSivashinskyProblem(tspan, u0, params);
end
end
end
32 changes: 32 additions & 0 deletions src/+otp/+kuramotosivashinsky/KuramotoSivashinskyProblem.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
classdef KuramotoSivashinskyProblem < otp.Problem

methods
function obj = KuramotoSivashinskyProblem(timeSpan, y0, parameters)
obj@otp.Problem('Kuramoto Sivashinsky Problem', [], timeSpan, y0, parameters);
end
end

methods (Access = protected)
function onSettingsChanged(obj)
n = obj.Parameters.n;
l = obj.Parameters.l;

domain = [-l, l];
D = otp.utils.pde.D(n, domain, 'C');
L = otp.utils.pde.laplacian(n, domain, 1, 'C');

obj.Rhs = otp.Rhs(@(t, u) otp.kuramotosivashinsky.f(t, u, D, L), ...
otp.Rhs.FieldNames.Jacobian, @(t, u) otp.kuramotosivashinsky.jac(t, u, D, L));

end

function validateNewState(obj, newTimeSpan, newY0, newParameters)
validateNewState@otp.Problem(obj, ...
newTimeSpan, newY0, newParameters)

otp.utils.StructParser(newParameters) ...
.checkField('n', 'scalar', 'integer', 'finite', 'positive') ...
.checkField('l', 'scalar', 'integer', 'finite', 'positive');
end
end
end
5 changes: 5 additions & 0 deletions src/+otp/+kuramotosivashinsky/f.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function du = f(~, u, D, L)

du = - L*(L*u + u) - u.*(D*u);
Comment thread
AndreyAPopov marked this conversation as resolved.
Outdated

end
5 changes: 5 additions & 0 deletions src/+otp/+kuramotosivashinsky/jac.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function j = jac(~, u, D, L)

j = -L*L - L - spdiags(u, 0, numel(u), numel(u))*D - spdiags(D*u, 0, numel(u), numel(u));
Comment thread
AndreyAPopov marked this conversation as resolved.
Outdated

end