-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample_3_Topographic_Destabilisation.m
More file actions
144 lines (94 loc) · 3.54 KB
/
Copy pathExample_3_Topographic_Destabilisation.m
File metadata and controls
144 lines (94 loc) · 3.54 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
% Topographic waves along a ridge with a linear background flow gradient
close all
clear
addpath("functions")
% set parameters:
S = -0.2;
f = 1;
type_y = [4 2 2 4]; % Laguerre at ends, Chebyshev in middle
k = 1;
n = 1;
omega_0 = 0.1*1i; % look for stationary growing modes
plot_sigma = true;
plot_modes = true;
% define background flow and buoyancy gradients:
U = @(y,z) S*y;
Uy = @(y,z) S + 0*y;
Uz = @(y,z) 0*y;
M2 = @(y,z) 0*y;
N2 = @(y,z) 1 + 0*y;
% build parameter structure:
params = Create_Params(U,M2,N2,f,1,0,0,0,Uy,Uz);
% plot sigma(H0) curve:
H0 = 0.01:0.01:0.9;
if plot_sigma
% set parameters:
omega = H0*0;
Nz = 31;
Ly = [-5 4 1 1 4]; % 4 regions of widths 4, 1, 1 & 4, starting at y = -5
Ny = [21 11 11 21];
% loop through H0 values:
for iH = 1:length(H0)
% define H and build grid:
H = @(y) 1-H0(iH)*sin(pi*(y+1)/2).*(abs(y)<1);
Hy = @(y) -H0(iH)*pi/2*cos(pi*(y+1)/2).*(abs(y)<1);
grid = Create_Grid(H,Nz,2,Ly,Ny,type_y,Hy);
omega_H = Find_Modes(grid,params,k,n,omega_0,[0 0],'lm');
if isempty(omega_H)
omega(iH) = 0;
else
[~, I] = sort(abs(real(omega_H)),1,"ascend");
omega_H = omega_H(I);
if abs(real(omega_H(1))) > 1e-8
omega(iH) = 0; % no stationary modes
else
omega(iH) = omega_H(1);
end
end
disp(['H_0 = ' num2str(H0(iH)) ', omega = ' num2str(omega(iH))])
end
% plot growth rate as a function of H0:
figure; plot(H0, imag(omega), 'k', 'LineWidth', 0.7)
xlabel('H_0'); ylabel('\sigma');
set(gca,'FontSize',12,'linewidth',0.7,'XGrid','on','YGrid','on');
end
% calculate and plot the mode structure at each growth rate peak:
if plot_modes
% set parameters:
Nz = 31;
Ly = [-6 5 1 1 5]; % 4 regions of widths 5, 1, 1 & 5, starting at y = -6
Ny = [21 21 21 21];
% Mode 1:
iH = 17;
H = @(y) 1-H0(iH)*sin(pi*(y+1)/2).*(abs(y)<1);
Hy = @(y) -H0(iH)*pi/2*cos(pi*(y+1)/2).*(abs(y)<1);
grid = Create_Grid(H,Nz,2,Ly,Ny,type_y,Hy);
[omega1,p1] = Find_Modes(grid,params,k,1,omega_0,[0 0],'lm');
n1 = (sum(Ny)-length(Ny))/2 + 1;
phi = atan(real(p1(n1,1)) / imag(p1(n1,1)));
p1 = exp(1i*phi) .* p1;
disp(num2str(omega1))
Plot_Mode(real(p1), grid.y, grid.z, H(grid.lambda), 'y', 'z', [-3 3])
% Mode 2:
iH = 47;
H = @(y) 1-H0(iH)*sin(pi*(y+1)/2).*(abs(y)<1);
Hy = @(y) -H0(iH)*pi/2*cos(pi*(y+1)/2).*(abs(y)<1);
grid = Create_Grid(H,Nz,2,Ly,Ny,type_y,Hy);
[omega2,p2] = Find_Modes(grid,params,k,1,omega_0,[0 0],'lm');
n1 = (sum(Ny)-length(Ny))/2 + 1;
phi = atan(real(p2(n1,1)) / imag(p2(n1,1)));
p2 = exp(1i*phi) .* p2;
disp(num2str(omega2))
Plot_Mode(real(p2), grid.y, grid.z, H(grid.lambda), 'y', 'z', [-3 3])
% Mode 3:
iH = 76;
H = @(y) 1-H0(iH)*sin(pi*(y+1)/2).*(abs(y)<1);
Hy = @(y) -H0(iH)*pi/2*cos(pi*(y+1)/2).*(abs(y)<1);
grid = Create_Grid(H,Nz,2,Ly,Ny,type_y,Hy);
[omega3,p3] = Find_Modes(grid,params,k,1,omega_0,[0 0],'lm');
n1 = (sum(Ny)-length(Ny))/2 + 1;
phi = atan(real(p3(n1,1)) / imag(p3(n1,1)));
p3 = exp(1i*phi) .* p3;
disp(num2str(omega3))
Plot_Mode(real(p3), grid.y, grid.z, H(grid.lambda), 'y', 'z', [-3 3])
end