-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfigure3_coordinate_plot.m
179 lines (143 loc) · 6.83 KB
/
figure3_coordinate_plot.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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
clear
close all
addpath(genpath('./functions/'))
% Load model parameters
[rl0, rm0, re0, cell_thickness, l, k, phi_m, phi_c, qlin, qein, plout, peout, eta, Wbar, dl, dm, dc, Rm0, Re0, Qlin, Plout, Qein, Peout, epsilon, beta, delta, Cin, Vmax, Km, Peclet_l, Dm] = parameters();
[Plin, Pein] = QtoP(Qlin, Qein, Plout, Peout, Rm0, Re0, beta);
%% COORDINATE SYSTEM
n = 300; % Number of points per line
m = 14; % Number of streamlines
lil = 0.00001; % Numerical correction factor
% Define colour scheme
colors = ametrine(6);
% Define axisymmetric coordinates
z_array = linspace(0,1,n);
rl_array = linspace(0,1,n);
rm_array = linspace(1,Rm0,n);
re_array = linspace(Rm0,Re0,n);
% Define meshgrid
[~, R_l] = meshgrid(z_array, rl_array);
[~, R_m] = meshgrid(z_array, rm_array);
[Z, R_e] = meshgrid(z_array, re_array);
% Concatinate meshgrids
R_array = cat(2,rl_array, rm_array, re_array);
R_array(length(rl_array) + length(rm_array) + 1) = [];
R_array(length(rl_array)+1) = [];
[ZZ, R] = meshgrid(z_array, R_array);
% Solve streamfunction across whole domain
[psi, psi_l, psi_m, psi_e, ~, ~] = streamfunction(1, Rm0, Re0, n, Plin, Plout, Pein, Peout, beta);
% Identify maximum streamline value
psi_max = max(psi,[],'all')-lil;
% Choose your coordinate points
psi_value = linspace(0,psi_max,n);
s_value = linspace(0,3,13);
tic
for j = 1:length(psi_value)
[r(:,j), z(:,j)] = transform(s_value, psi_value(j), 1, Rm0, Re0, n, Plin, Plout, Pein, Peout, beta);
end
toc
% Identify critical streamlines
psi_lcrit = psi_l(end);
psi_ecrit = psi_e(1);
% Define streamfunction-arclength coordinates
psi_array = linspace(0,psi_max,m);
s_array = linspace(0,3,3*m);
psil_array = [linspace(0,psi_lcrit,m) NaN(1,2*m)];
psim_array = [NaN(1,m) linspace(psi_lcrit, psi_ecrit, m) NaN(1,m)];
psie_array = [NaN(1, 2*m) linspace(psi_ecrit, psi_max, m)];
% Define meshgrid
[~, SPYl] = meshgrid(s_array, psil_array);
[~, SPYm] = meshgrid(s_array, psim_array);
[S, SPYe] = meshgrid(s_array, psie_array);
[Ml,~] = contour(Z, R_l, psi_l, [psi_lcrit,psi_lcrit]);
Ml = Ml(:,2:end)';
[Me,~] = contour(Z, R_e, psi_e, [psi_ecrit,psi_ecrit]);
Me = Me(:,2:end)';
%% PLOT
font_size = 22;
set(groot,'defaultAxesTickLabelInterpreter','latex');
set(groot, 'DefaultAxesFontSize', font_size);
set(groot, 'DefaultAxesLineWidth', 2);
figure('Name','Coordinate Transform')
subplot(1,2,1)
hold on
contour(ZZ, R, psi, m, 'Color', colors(2,:), 'LineWidth', 3)
plot(Ml(:,1),Ml(:,2),'--','LineWidth',5, 'Color', 'k')
plot(Me(:,1),Me(:,2),'--','LineWidth',5, 'Color', 'k')
plot(zeros(1,m),linspace(1,Rm0,m), '--','LineWidth',5,'Color','k')
plot(ones(1,m),linspace(1,Rm0,m), '--','LineWidth',5,'Color','k')
for i = 1:length(s_value)
hold on
if s_value(i) == 0
plot(zeros(1,n),rl_array,'Color', colors(4,:),'LineWidth',3)
elseif s_value(i) == 1
plot(ones(1,n),rl_array, 'Color', colors(4,:),'LineWidth',3)
elseif s_value(i) == 1.25
plot(z_array, repmat(1 + (Rm0-1)./4,1,n), 'Color', colors(4,:),'LineWidth',3)
elseif s_value(i) == 1.5
plot(z_array, repmat((1+Rm0)./2,1,n), 'Color', colors(4,:),'LineWidth',3)
elseif s_value(i) == 1.75
plot(z_array, repmat(1 + 3.*(Rm0-1)./4,1,n), 'Color', colors(4,:),'LineWidth',3)
elseif s_value(i) == 2
plot(zeros(1,n),re_array, 'Color', colors(4,:),'LineWidth',3)
elseif s_value(i) > 2 && s_value(i) < 3
plot(z(i,:), r(i,:), 'Color', colors(4,:), 'LineWidth',3)
z(i,1) = 0;
[right,ok] = max(z(i,:));
plot(linspace(right,1,20),linspace(r(i,ok),Rm0,20), 'Color', colors(4,:),'LineWidth',3)
elseif s_value(i) == 3
plot(ones(1,n),re_array, 'Color', colors(4,:),'LineWidth',3)
else
hold on
plot(z(i,:), r(i,:), 'Color', colors(4,:), 'LineWidth',3)
end
end
plot(z_array, zeros(1,n), 'Color', colors(2,:), 'LineWidth',3)
plot(z_array, ones(1,n),'k', 'LineWidth',3)
plot(z_array, repmat(Rm0,1,n),'k', 'LineWidth',3)
plot(z_array, repmat(Re0,1,n),'k', 'LineWidth',3)
xlim([0 1])
ylim([0 Re0])
xlabel('$z$','FontSize', font_size, 'Interpreter','latex')
ylabel('$r$', 'FontSize',font_size, 'Interpreter','latex')
subplot(1,2,2)
hold on
for i = 1:length(psi_array)-1
if psi_array(i) <= psi_lcrit
plot(linspace(0,1,m),repmat(psi_array(i),1,m), 'Color', colors(2,:),'LineWidth',3)
elseif psi_array(i) >= psi_ecrit
plot(linspace(2,3,m),repmat(psi_array(i),1,m), 'Color', colors(2,:),'LineWidth',3)
else
plot(linspace(0,3,m),repmat(psi_array(i),1,m), 'Color', colors(2,:),'LineWidth',3)
end
end
plot(linspace(2,3,m),repmat(psi_array(end),1,m),'k','LineWidth',3)
plot(linspace(0,1,m), zeros(1,m), 'Color', colors(2,:),'LineWidth',3)
plot(s_array,repmat(psi_lcrit,1,length(s_array)),'--','LineWidth',5, 'Color', 'k')
plot(s_array,repmat(psi_ecrit,1,length(s_array)),'--','LineWidth',5, 'Color', 'k')
plot(zeros(1,m),linspace(0,psi_ecrit,m), 'Color', colors(4,:), 'LineWidth',3)
plot(repmat(0.25,1,m),linspace(0,psi_ecrit,m), 'Color', colors(4,:), 'LineWidth',3)
plot(repmat(0.5,1,m),linspace(0,psi_ecrit,m), 'Color', colors(4,:), 'LineWidth',3)
plot(repmat(0.75,1,m),linspace(0,psi_ecrit,m), 'Color', colors(4,:), 'LineWidth',3)
plot(ones(1,m),linspace(0,psi_lcrit,m), 'Color', colors(4,:), 'LineWidth',3)
plot(repmat(1.25,1,m),linspace(psi_lcrit,psi_ecrit,m), 'Color', colors(4,:), 'LineWidth',3)
plot(repmat(1.5,1,m),linspace(psi_lcrit,psi_ecrit,m), 'Color', colors(4,:), 'LineWidth',3)
plot(repmat(1.75,1,m),linspace(psi_lcrit,psi_ecrit,m), 'Color', colors(4,:), 'LineWidth',3)
plot(repmat(2,1,m),linspace(psi_ecrit,psi_max+lil,m), 'Color', colors(4,:), 'LineWidth',3)
plot(repmat(2.25,1,m),linspace(psi_lcrit,psi_max+lil,m), 'Color', colors(4,:), 'LineWidth',3)
plot(repmat(2.5,1,m),linspace(psi_lcrit,psi_max+lil,m), 'Color', colors(4,:), 'LineWidth',3)
plot(repmat(2.75,1,m),linspace(psi_lcrit,psi_max+lil,m), 'Color', colors(4,:), 'LineWidth',3)
plot(repmat(3,1,m),linspace(psi_lcrit,psi_max+lil,m), 'Color', colors(4,:), 'LineWidth',3)
plot(ones(1,m),linspace(psi_lcrit,psi_ecrit,m),'k','LineWidth',3)
plot(repmat(2,1,m),linspace(psi_lcrit,psi_ecrit,m),'k','LineWidth',3)
xlabel('$s$', 'FontSize', font_size, 'Interpreter', 'latex')
ylabel('$\psi$', 'FontSize', font_size, 'Interpreter', 'latex')
xlim([0 3])
ylim([0 psi_max+lil])
h1 = plot(nan, nan, 'LineWidth', 3, 'Color', colors(2,:), 'DisplayName', 'Streamlines (constant $\psi$)');
h2 = plot(nan, nan, 'LineWidth', 3, 'Color', colors(4,:), 'DisplayName', 'Streamline contours (constant $s$)');
h3 = plot(nan, nan, 'LineWidth', 3, 'Color', 'k', 'DisplayName', 'Domain boundaries');
h4 = plot(nan, nan, '--', 'LineWidth', 5, 'Color', 'k', 'DisplayName', 'Critical streamlines ($\psi_{i,crit}$)');
leg = legend([h1,h2,h3,h4], 'FontSize', font_size-10, 'Interpreter', 'latex', 'Orientation', 'horizontal');
set(leg,'Location','south')
hold off