Skip to content

Commit c487b3d

Browse files
authored
Merge pull request #21 from ComputationalScienceLaboratory/lorenz96-fix-sandu-preset
Fixes to L96 preset PopovSandu
2 parents 305da7f + ee4c5ac commit c487b3d

File tree

1 file changed

+13
-34
lines changed

1 file changed

+13
-34
lines changed

src/+otp/+lorenz96/+presets/PopovSandu.m

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,35 @@
11
classdef PopovSandu < otp.lorenz96.Lorenz96Problem
2-
% [Name]
3-
% Time-dependent Forcing
4-
%
5-
% [Description]
6-
% Used in (Popov and Sandu, 2019)
7-
%
8-
% [NoVars]
9-
% 40
10-
%
11-
% [Properties]
12-
% Chaotic
13-
%
2+
3+
% Used in https://doi.org/10.5194/npg-26-109-2019
4+
145
methods
156
function obj = PopovSandu(varargin)
167

178
p = inputParser;
18-
p.KeepUnmatched = true;
19-
addParameter(p, 'Size', 40, @isscalar);
9+
10+
p.addParameter('Size', 40, @isscalar);
11+
p.addParameter('Partitions', 4, @isscalar);
12+
p.addParameter('ForcingPeriod', 1, @isscalar); % default corresponds to 5 days
2013

21-
parse(p, varargin{:});
14+
p.parse(varargin{:});
2215

2316
s = p.Results;
2417

2518
N = s.Size;
26-
27-
pu = p.Unmatched;
28-
29-
p = inputParser;
30-
p.KeepUnmatched = true;
31-
p.addParameter('Partitions', (mod(N, 4) == 0)*4 + (mod(N, 4) ~= 0)*1, @(x) mod(N, x) == 0);
32-
p.parse(pu);
33-
34-
s = p.Results;
35-
3619
q = s.Partitions;
37-
38-
sixHours = 0.05;
39-
day = sixHours * 4;
40-
numDays = 5;
41-
omega = 2 * pi/(day * numDays);
42-
43-
F = @(t) 8 + 4*cos(omega*(t + mod((1:40) - 1, q)/q)).';
20+
omega = s.ForcingPeriod;
21+
22+
F = @(t) 8 + 4*cospi(2*omega*(t + mod((1:N) - 1, q)/q)).';
4423

4524
params.forcingFunction = F;
4625

4726
% We initialise the Lorenz96 model as in (Lorenz & Emanuel 1998)
4827

4928
y0 = 8*ones(N, 1);
5029

51-
y0(20) = 8.008;
30+
y0(floor(N/2)) = 8.008;
5231

53-
tspan = [0, sixHours]; % 6 hours
32+
tspan = [0, 720]; % 3600 days
5433

5534
obj = obj@otp.lorenz96.Lorenz96Problem(tspan, y0, params);
5635

0 commit comments

Comments
 (0)