Skip to content

Commit 1e01ad9

Browse files
committed
Implement 2N low-storage methods.
1 parent 08f33b8 commit 1e01ad9

File tree

6 files changed

+45
-3
lines changed

6 files changed

+45
-3
lines changed

RK-coeff-opt/nonlinear_constraints.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
% The input arguments are:
77
% * :math:`x`: vector of the decision variables. See unpack_rk.m for details about
88
% the order in which they are stored.
9-
% * *class*: class of method to search ('erk' = explicit RK; 'irk' = implicit RK; 'dirk' = diagonally implicit RK; 'sdirk' = singly diagonally implicit RK; '2S', '3S', '2S*', '3S*' = low-storage formulations).
9+
% * *class*: class of method to search ('erk' = explicit RK; 'irk' = implicit RK; 'dirk' = diagonally implicit RK; 'sdirk' = singly diagonally implicit RK; '2S', '3S', '2S*', '3S*', '2N' = low-storage formulations).
1010
% * :math:`s`:number of stages.
1111
% * :math:`p`: order of the RK scheme.
1212
% * *objective*: objective function ('ssp' = maximize SSP coefficient; 'acc' = minimize leading truncation error coefficient).

RK-coeff-opt/rk_obj.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
%
66
% Inputs:
77
% * :math:`x`: vector of the unknowns.
8-
% * class: class of method to search ('erk' = explicit RK; 'irk' = implicit RK; 'dirk' = diagonally implicit RK; 'sdirk' = singly diagonally implicit RK; '2S', '3S', '2S*', '3S*' = low-storage formulations).
8+
% * *class*: class of method to search ('erk' = explicit RK; 'irk' = implicit RK; 'dirk' = diagonally implicit RK; 'sdirk' = singly diagonally implicit RK; '2S', '3S', '2S*', '3S*', '2N' = low-storage formulations).
99
% * :math:`s`:number of stages.
1010
% * :math:`p`: order of the RK scheme.
1111
% * objective: objective function ('ssp' = maximize SSP coefficient; 'acc' = minimize leading truncation error coefficient).

RK-coeff-opt/rk_opt.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ pctRunOnAll warning('on', 'all')
150150

151151

152152
% Check order of the scheme
153-
if strcmp(class(1:2),'2S') || strcmp(class(1:2),'3S')
153+
if strcmp(class(1:2),'2S') || strcmp(class(1:2),'3S' || strcmp(class), '2N')
154154
[rk.A,rk.Ahat,rk.b,rk.bhat,rk.c,rk.chat,rk.alpha,rk.beta,rk.gamma1,rk.gamma2,rk.gamma3,rk.delta] = unpack_lsrk(X,class);
155155
order = check_RK_order(rk.A,rk.b,rk.c,'nonlinear');
156156
elseif k==1

RK-coeff-opt/set_n.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
n = 4*s - 3;
3535
case '3SstarembFSAL' %Low-storage 3S* embedded pairs of Ketcheson
3636
n = 4*s - 2;
37+
case '2N' % Williamson
38+
n = 2*s -1;
3739

3840
%=====================
3941
% Multistep RK classes

RK-coeff-opt/unpack_lsrk.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,26 @@
5050
% gamma_{53} ... gamma_{s+1,3} delta_s delta_{s+1} delta_{s+2} ]
5151
delta =[1 X(s:2*s-3) X(end-3:end-1)];
5252
betahat = X(end);
53+
case '2N'
54+
% n = 2s - 1 free parameters
55+
s = (length(X)+1)/2; % # of stages
56+
% for 2N methods:
57+
% X = [A_2, A_3, ..., A_s, B_1, ..., B_s]
58+
A_2N = [0 X(1:s-1)];
59+
B_2N = X(s:end);
60+
K = zeros(s+1,s);
61+
for i=1:s-1
62+
K(i,i+1) = B_2N(i);
63+
for j = 2:s-i+1
64+
for k=0:j-1
65+
K(i+j,i) = K(i+j,i) + B_2N(i+k)*prod(A_2N(i+1:i+k));
66+
end
67+
end
68+
end
69+
A = K(1:s,:);
70+
b = K(s+1,:); b=b';
71+
c=sum(A,2);
72+
5373
end
5474

5575
if strcmp(class(1:2),'2S')

RK-coeff-opt/unpack_rk.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,26 @@
8888
% gamma_{53} ... gamma_{s+1,3} delta_s delta_{s+1} delta_{s+2} ]
8989
delta =[1 X(s:2*s-3) X(end-3:end-1)];
9090
betahat = X(end);
91+
case '2N'
92+
% n = 2s - 1 free parameters
93+
s = (length(X)+1)/2; % # of stages
94+
% for 2N methods:
95+
% X = [A_2, A_3, ..., A_s, B_1, ..., B_s]
96+
A_2N = [0 X(1:s-1)];
97+
B_2N = X(s:end);
98+
K = zeros(s+1,s);
99+
for i=1:s-1
100+
K(i,i+1) = B_2N(i);
101+
for j = 2:s-i+1
102+
for k=0:j-1
103+
K(i+j,i) = K(i+j,i) + B_2N(i+k)*prod(A_2N(i+1:i+k));
104+
end
105+
end
106+
end
107+
A = K(1:s,:);
108+
b = K(s+1,:); b=b';
109+
c=sum(A,2);
110+
91111
end
92112

93113

0 commit comments

Comments
 (0)