-
Notifications
You must be signed in to change notification settings - Fork 0
/
Barkley_jacobian_weighted_operator.m
53 lines (33 loc) · 1.44 KB
/
Barkley_jacobian_weighted_operator.m
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function J = Barkley_jacobian_weighted_operator(U,V,L1,L2,L1r,par,numPar)
% Linearization about spiral wave in a weighted radial frame.
% Jacobian for spectral computations
% Assumes differentiation operators and spiral wave in short grid format.
% No-flux boundary conditions
% Boundary conditions implicitly built into the finite difference operators
% i.e., still apply the PDE at the boundary
%% Set up
% Numerical parameters
nx = numPar.nx;
ny = numPar.ny;
% System parameters
a = par.a;
b = par.b;
ep = 1./par.ep;
delta = par.delta; % Diffusion coefficient of v-equation
w = par.w; % Weight
omega = par.omega; % Angular frequency
% Define radial mesh for weight
hxn = par.r2/(ny-1);
R = (1:ny-1)*hxn; % radial mesh (not including origin)
R = repmat(R,nx,1);
R = R(:); R = [1;R]; % Add one more point for the origin
R = w./R; % Already includes weight
%% Jacobian
nonlin_jacob1 = ep*(2*(1+b/a)*U-b/a-(1/a)*V-3*U.^2+(2/a)*U.*V); % d(nonlin)/dU
nonlin_jacob2 = ep*(-(1/a)*U + (1/a)*U.^2); % d(nonlin)/dV
dU = [ L2 + 2.*w.*L1r + omega*L1 + spdiags(nonlin_jacob1 + R + w.^2, 0,nx*(ny-1)+1,nx*(ny-1)+1);
speye(nx*(ny-1)+1,nx*(ny-1)+1)];
dV = [ spdiags(nonlin_jacob2,0,nx*(ny-1)+1,nx*(ny-1)+1);
delta.*L2 + 2.*delta.*w.*L1r + omega*L1 + spdiags( delta.*R -1 + delta.*w.^2, 0,nx*(ny-1)+1,nx*(ny-1)+1)];
J = [dU, dV];
J = sparse(J);