% load image.new 
addpath('D:\Osney_IFTI\DPhil\TINA\SIMULATIONS\M7\lam\');
IMG = loadimaget('image.new');
Qdot = load('qdota.new');
%nx = size(IMG)
% allocate variable to vectors or matrices:
x = IMG(:,1,1);
y = IMG(1,:,2);
rho = IMG(:,:,3);
p = IMG(:,:,4);
T = IMG(:,:,5);
M = IMG(:,:,7);
u = IMG(:,:,8);
v = IMG(:,:,9);
mu = IMG(:,:,10);
h_0 = IMG(:,:,11); %kJ/kg
x_N2 = IMG(:,:,12);
x_O2 = IMG(:,:,13);
x_He = IMG(:,:,14);
qdot = Qdot(:,2);

%mass flux:
rhou = rho.*u; %elementwise

%Non-dimensional quantities:
u_nd = u./u(:,end);
T_nd = T./T(:,end);
rho_nd = rho./rho(:,end);
x_N2_nd = (x_N2(:,150)-x_N2)./(x_N2(:,150)-1);%x_N2./x_N2(:,end);
x_He_nd = (x_He(:,150)-x_He)./(x_He(:,150)-1);

% Convert to St number
R = 287.1; %specific gas constant, air
g = 1.4; %ratio of specific heats
Cpe = 1005; %specific heat capacity, constant pressure
PrRef = 0.71; %reference Prandtl number
Tw = 298; %K
He = 0.5*u.^2*PrRef^(1/3)+Cpe.*T; %edge enthalpy
Hw = Cpe*Tw; %wall enthalpy

%Eckert reference values
TRef = T.*(1+0.032*M.^2+0.58.*(Tw./T-1)); %reference temperature
muRef = sutherland(TRef, 'air'); %reference viscosity
rhoRef = p./TRef/R; %reference density

%free-stream RexRef:
RexRef_tina = rhoRef(:,150).*u(:,150).*x(:,1)./muRef(:,150); %reference Rex

%Stanton number at the wall:
St_tina = qdot(:,1)./(u(:,150).*rhoRef(:,150).*(He(:,150)-Hw));

%BL thickness:
delta = zeros(length(x),1);
for i = 1:length(x)
    for j = 1:150
        if u_nd(i,j) <= 0.99
        delta(i,1)= y(1,j);
        %disp(delta(i,1))
        end
        %disp(j)
    end
    %disp(i)
    %disp(j)
end

%stream-wise locations:
xloc = [100; 180; 210; 230; 250; 270; 290; 310; 330];

% define pseudoschlieren: 
drho_dy = diff(rho,1,2);
xmm = x*1e3;
ymm = y*1e3;
figure,
fig_ps = pcolor(xmm,ymm(1:end-1),transpose(diff(rho,1,2)));
set(fig_ps, 'EdgeColor', 'none');
axis xy
axis image
colormap('gray');
xlim([150 300]);
ylim([0 10]);

%Re_cell (eval at wall):
Re_cell = y(2)*sqrt(1.4*287.1*T(:,1)).*rho(:,1)./(mu(:,1));
figure, plot(x, Re_cell);

%save variables
clc
disp('saving vairables ...');
save('TINA_post.mat');
 disp('Variables written to file.');
%% plot normalised velocity profiles
Figure1=figure(1);clf;
set(Figure1,'defaulttextinterpreter','latex');
f1 = plot(u(100, :)/u(1, end),y*1e3, '.-', 'Color', 'black','MarkerFaceColor','black', 'MarkerSize',10);
hold on
f2 = plot(u(180, :)/u(1, end),y*1e3, 'Color', 'black', 'LineWidth',1.2);
hold on
f3 = plot(u(210, :)/u(1, end),y*1e3, '--', 'Color', 'black', 'LineWidth',1);
xlabel('$\frac{u}{u_e}\;[-]$', 'FontSize', 18);
ylabel('$y\;[\mathrm{mm}]$', 'FontSize', 14);
xlim([0 1.1]);
ylim([0 7]);
lgd=legend([f1 f2 f3], '$x =150\;\mathrm{mm}$, upstream of injector', '$x =180\;\mathrm{mm}$, at injector', '$x =210\;\mathrm{mm}$, downstream of injector', 'Location', 'northwest');
set(lgd,'Interpreter','latex')
legend('boxoff');
lgd.FontSize = 12;
print('-dpdf', 'u-vel');
print('-dpng', '-r300', 'u-vel');

% %% plot normalised max flux profiles
% Figure2=figure(2);clf;
% set(Figure2,'defaulttextinterpreter','latex');
% f1 = plot(rhou(100, :)/rhou(1, end),y*1e3, '.-', 'Color', 'black','MarkerFaceColor','black', 'MarkerSize',10);
% hold on
% f2 = plot(rhou(180, :)/rhou(1, end),y*1e3, 'Color', 'black', 'LineWidth',1.2);
% hold on
% f3 = plot(rhou(210, :)/rhou(1, end),y*1e3, '--', 'Color', 'black', 'LineWidth',1);
% xlabel('$\frac{\rho u}{\rho_e U_e}\;[-]$', 'FontSize', 14);
% ylabel('$y\;[mm]$', 'FontSize', 14);
% xlim([0 1.2]);
% ylim([0 5]);
% lgd=legend([f1 f2 f3], 'x =', 'x =', 'x=', 'Location', 'northwest');
% set(lgd,'Interpreter','latex')
% legend('boxoff');
% lgd.FontSize = 12;
% print('-dpdf', 'rhou');
% print('-dpng', '-r300', 'rhou');
%% plot normalised density profiles
Figure2=figure(2);clf;
set(Figure2,'defaulttextinterpreter','latex');
f1 = plot(rho(100, :)/rho(1, end),y*1e3, '.-', 'Color', 'black','MarkerFaceColor','black', 'MarkerSize',10);
hold on
f2 = plot(rho(180, :)/rho(1, end),y*1e3, 'Color', 'black', 'LineWidth',1.2);
hold on
f3 = plot(rho(210, :)/rho(1, end),y*1e3, '--', 'Color', 'black', 'LineWidth',1);
xlabel('$\frac{\rho}{\rho_e}\;[-]$', 'FontSize', 18);
ylabel('$y\;[\mathrm{mm}]$', 'FontSize', 14);
xlim([-0.5 1.5]);
ylim([0 10]);
lgd=legend([f1 f2 f3], '$x =100\;\mathrm{mm}$, upstream of injector', '$x =180\;\mathrm{mm}$, at injector', '$x =210\;\mathrm{mm}$, downstream of injector', 'Location', 'northwest');
set(lgd,'Interpreter','latex')
legend('boxoff');
lgd.FontSize = 12;
print('-dpdf', 'rho');
print('-dpng', '-r300', 'rho');
%% plot normalised temperature profiles
Figure2=figure(2);clf;
set(Figure2,'defaulttextinterpreter','latex');
f1 = plot(T(100, :)/T(1, end),y*1e3, '.-', 'Color', 'black','MarkerFaceColor','black', 'MarkerSize',10);
hold on
f2 = plot(T(180, :)/T(1, end),y*1e3, 'Color', 'black', 'LineWidth',1.2);
hold on
f3 = plot(T(210, :)/T(1, end),y*1e3, '--', 'Color', 'black', 'LineWidth',1);
xlabel('$\frac{T}{T_e}\;[-]$', 'FontSize', 14);
ylabel('$y\;[\mathrm{mm}]$', 'FontSize', 14);
xlim([0.9 7.5]);
ylim([0 7]);
lgd=legend([f1 f2 f3], '$x =100\;\mathrm{mm}$, upstream of injector', '$x =180\;\mathrm{mm}$, at injector', '$x =210\;\mathrm{mm}$, downstream of injector', 'Location', 'northeast');
set(lgd,'Interpreter','latex')
legend('boxoff');
lgd.FontSize = 12;
print('-dpdf', 'T');
print('-dpng', '-r300', 'T');
%% plot mole fraction of N2 along x at the wall
Figure3=figure(3);clf;
set(Figure3,'defaulttextinterpreter','latex');
hold on; box on
xlimit = ([0 500]);
ylimit = ([0.75 1]);
set(gca, 'ylim', ylimit, 'xlim', xlimit)    
v_err = [160:4:200 flip(160:4:200)];
dp_err = [(ylimit(2)-0.005)*ones(1,11) (ylimit(1)+0.005)*ones(1,11)];
fill(v_err, dp_err, [1 0.8 0.8], 'LineStyle','none');
clear alpha
alpha(0.8);
f1 = plot(x*1e3, x_N2(:,1), '-', 'Color', 'black', 'LineWidth',1.2);
xlabel('$x\;[\mathrm{mm}]$', 'FontSize', 14);
ylabel('$x_{\mathrm{N_2}}\;[-]$', 'FontSize', 14);
lgd=legend('Injector', 'mole fraction of $\mathrm{N_2}$', 'Location', 'northeast');
set(lgd,'Interpreter','latex')
legend('boxoff');
lgd.FontSize = 12;
print('-dpdf', 'x_N2_wall');
print('-dpng', '-r300', 'x_N2_wall');

%% plot normalised velocity profiles with normalised y
Figure4=figure(4);clf;
set(Figure4,'defaulttextinterpreter','latex');
f1 = plot(u_nd(xloc(1),:),y/delta(xloc(1)), 'Color', 'black', 'LineWidth',1);
hold on
f2 = plot(u_nd(xloc(2),:),y/delta(xloc(2)), '-d','Color', 'blue','MarkerFaceColor','blue', 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f3 = plot(u_nd(xloc(3),:),y/delta(xloc(3)), ':', 'Color', [0.8500, 0.3250, 0.0980], 'LineWidth',2);
hold on
f4 = plot(u_nd(xloc(4),:),y/delta(xloc(4)), 's-','Color', [0.8500, 0.3250, 0.0980], 'MarkerFaceColor','white', 'MarkerSize',6, 'LineWidth',1, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f5 = plot(u_nd(xloc(5),:),y/delta(xloc(5)), '-*', 'Color', [0.8500, 0.3250, 0.0980],'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f6 = plot(u_nd(xloc(6),:),y/delta(xloc(6)), '--', 'Color', [0.8500, 0.3250, 0.0980], 'LineWidth',1);
hold on
f7 = plot(u_nd(xloc(7),:),y/delta(xloc(7)), '.-', 'Color', [0.8500, 0.3250, 0.0980],'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',10, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f8 = plot(u_nd(xloc(8),:),y/delta(xloc(8)), '-o', 'Color', [0.8500, 0.3250, 0.0980],'MarkerFaceColor','white', 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f9 = plot(u_nd(xloc(9),:),y/delta(xloc(9)), 's-', 'Color', [0.8500, 0.3250, 0.0980], 'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',5, 'LineWidth',1, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
xlabel('$\frac{u}{u_e}\;[-]$', 'FontSize', 24);
ylabel('$\frac{y}{\delta}\;[-]$', 'FontSize', 24);
xlim([-0.1 1.05]);
ylim([0 1.2]);
lgd=legend([f1 f2 f3 f4 f5 f6 f7 f8 f9], '$x =100\;\mathrm{mm}$', '$x =180\;\mathrm{mm}$', '$x =210\;\mathrm{mm}$', '$x =230\;\mathrm{mm}$', '$x =250\;\mathrm{mm}$', '$x =270\;\mathrm{mm}$', '$x =290\;\mathrm{mm}$', '$x =310\;\mathrm{mm}$', '$x =330\;\mathrm{mm}$', 'Location', 'northwest');
set(lgd,'Interpreter','latex')
legend('boxoff');
lgd.FontSize = 12;
print('-dpdf', 'u-vel-norm');
print('-dpng', '-r300', 'u-vel-norm');

%% plot normalised velocity profiles with normalised y (closeup)
Figure5=figure(5);clf;
set(Figure5,'defaulttextinterpreter','latex');
f1 = plot(u_nd(xloc(1),:),y/delta(xloc(1)), 'Color', 'black', 'LineWidth',1);
hold on
f2 = plot(u_nd(xloc(2),:),y/delta(xloc(2)), '-d','Color', 'blue','MarkerFaceColor','blue', 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f3 = plot(u_nd(xloc(3),:),y/delta(xloc(3)), ':', 'Color', [0.8500, 0.3250, 0.0980], 'LineWidth',2);
hold on
f4 = plot(u_nd(xloc(4),:),y/delta(xloc(4)), 's-','Color', [0.8500, 0.3250, 0.0980], 'MarkerFaceColor','white', 'MarkerSize',6, 'LineWidth',1, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f5 = plot(u_nd(xloc(5),:),y/delta(xloc(5)), '-*', 'Color', [0.8500, 0.3250, 0.0980],'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f6 = plot(u_nd(xloc(6),:),y/delta(xloc(6)), '--', 'Color', [0.8500, 0.3250, 0.0980], 'LineWidth',1);
hold on
f7 = plot(u_nd(xloc(7),:),y/delta(xloc(7)), '.-', 'Color', [0.8500, 0.3250, 0.0980],'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',10, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f8 = plot(u_nd(xloc(8),:),y/delta(xloc(8)), '-o', 'Color', [0.8500, 0.3250, 0.0980],'MarkerFaceColor','white', 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f9 = plot(u_nd(xloc(9),:),y/delta(xloc(9)), 's-', 'Color', [0.8500, 0.3250, 0.0980], 'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',5, 'LineWidth',1, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
xlabel('$\frac{u}{u_e}\;[-]$', 'FontSize', 24);
ylabel('$\frac{y}{\delta}\;[-]$', 'FontSize', 24);
xlim([-0.04 0.1]);
ylim([0 0.3]);
lgd=legend([f1 f2 f3 f4 f5 f6 f7 f8 f9], '$x =100\;\mathrm{mm}$', '$x =180\;\mathrm{mm}$', '$x =210\;\mathrm{mm}$', '$x =230\;\mathrm{mm}$', '$x =250\;\mathrm{mm}$', '$x =270\;\mathrm{mm}$', '$x =290\;\mathrm{mm}$', '$x =310\;\mathrm{mm}$', '$x =330\;\mathrm{mm}$', 'Location', 'northwest');
set(lgd,'Interpreter','latex')
legend('boxoff');
lgd.FontSize = 12;
print('-dpdf', 'u-vel-norm_closeup');
print('-dpng', '-r300', 'u-vel-norm_closeup');

%% plot normalised temperature profiles with normalised y 
Figure6=figure(6);clf;
set(Figure6,'defaulttextinterpreter','latex');
f1 = plot(T_nd(xloc(1),:),y/delta(xloc(1)), 'Color', 'black', 'LineWidth',1);
hold on
f2 = plot(T_nd(xloc(2),:),y/delta(xloc(2)), '-d','Color', 'blue','MarkerFaceColor','blue', 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f3 = plot(T_nd(xloc(3),:),y/delta(xloc(3)), ':', 'Color', [0.8500, 0.3250, 0.0980], 'LineWidth',2);
hold on
f4 = plot(T_nd(xloc(4),:),y/delta(xloc(4)), 's-','Color', [0.8500, 0.3250, 0.0980], 'MarkerFaceColor','white', 'MarkerSize',6, 'LineWidth',1, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f5 = plot(T_nd(xloc(5),:),y/delta(xloc(5)), '-*', 'Color', [0.8500, 0.3250, 0.0980],'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f6 = plot(T_nd(xloc(6),:),y/delta(xloc(6)), '--', 'Color', [0.8500, 0.3250, 0.0980], 'LineWidth',1);
hold on
f7 = plot(T_nd(xloc(7),:),y/delta(xloc(7)), '.-', 'Color', [0.8500, 0.3250, 0.0980],'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',10, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f8 = plot(T_nd(xloc(8),:),y/delta(xloc(8)), '-o', 'Color', [0.8500, 0.3250, 0.0980],'MarkerFaceColor','white', 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f9 = plot(T_nd(xloc(9),:),y/delta(xloc(9)), 's-', 'Color', [0.8500, 0.3250, 0.0980], 'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',5, 'LineWidth',1, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
xlabel('$\frac{T}{T_e}\;[-]$', 'FontSize', 24);
ylabel('$\frac{y}{\delta}\;[-]$', 'FontSize', 24);
xlim([0.9 7.5]);
ylim([0 1.1]);
lgd=legend([f1 f2 f3 f4 f5 f6 f7 f8 f9], '$x =100\;\mathrm{mm}$', '$x =180\;\mathrm{mm}$', '$x =210\;\mathrm{mm}$', '$x =230\;\mathrm{mm}$', '$x =250\;\mathrm{mm}$', '$x =270\;\mathrm{mm}$', '$x =290\;\mathrm{mm}$', '$x =310\;\mathrm{mm}$', '$x =330\;\mathrm{mm}$', 'Location', 'southwest');
set(lgd,'Interpreter','latex')
legend('boxoff');
lgd.FontSize = 12;
print('-dpdf', 'T-norm');
print('-dpng', '-r300', 'T-norm');

%% plot normalised temperature profiles with normalised y (closeup)
Figure7=figure(7);clf;
set(Figure7,'defaulttextinterpreter','latex');
f1 = plot(T_nd(xloc(1),:),y/delta(xloc(1)), 'Color', 'black', 'LineWidth',1);
hold on
f2 = plot(T_nd(xloc(2),:),y/delta(xloc(2)), '-d','Color', 'blue','MarkerFaceColor','blue', 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f3 = plot(T_nd(xloc(3),:),y/delta(xloc(3)), ':', 'Color', [0.8500, 0.3250, 0.0980], 'LineWidth',2);
hold on
f4 = plot(T_nd(xloc(4),:),y/delta(xloc(4)), 's-','Color', [0.8500, 0.3250, 0.0980], 'MarkerFaceColor','white', 'MarkerSize',6, 'LineWidth',1, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f5 = plot(T_nd(xloc(5),:),y/delta(xloc(5)), '-*', 'Color', [0.8500, 0.3250, 0.0980],'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f6 = plot(T_nd(xloc(6),:),y/delta(xloc(6)), '--', 'Color', [0.8500, 0.3250, 0.0980], 'LineWidth',1);
hold on
f7 = plot(T_nd(xloc(7),:),y/delta(xloc(7)), '.-', 'Color', [0.8500, 0.3250, 0.0980],'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',10, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f8 = plot(T_nd(xloc(8),:),y/delta(xloc(8)), '-o', 'Color', [0.8500, 0.3250, 0.0980],'MarkerFaceColor','white', 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f9 = plot(T_nd(xloc(9),:),y/delta(xloc(9)), 's-', 'Color', [0.8500, 0.3250, 0.0980], 'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',5, 'LineWidth',1, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
xlabel('$\frac{T}{T_e}\;[-]$', 'FontSize', 24);
ylabel('$\frac{y}{\delta}\;[-]$', 'FontSize', 24);
xlim([6.4 6.9]);
ylim([0 0.3]);
lgd=legend([f1 f2 f3 f4 f5 f6 f7 f8 f9], '$x =100\;\mathrm{mm}$', '$x =180\;\mathrm{mm}$', '$x =210\;\mathrm{mm}$', '$x =230\;\mathrm{mm}$', '$x =250\;\mathrm{mm}$', '$x =270\;\mathrm{mm}$', '$x =290\;\mathrm{mm}$', '$x =310\;\mathrm{mm}$', '$x =330\;\mathrm{mm}$', 'Location', 'southwest');
set(lgd,'Interpreter','latex')
legend('boxoff');
lgd.FontSize = 12;
print('-dpdf', 'T-norm-closeup');
print('-dpng', '-r300', 'T-norm-closeup');

%% plot normalised concentration profiles with normalised y 
Figure8=figure(8);clf;
set(Figure8,'defaulttextinterpreter','latex');
f1 = plot(x_N2_nd(xloc(1),:),y/delta(xloc(1)), 'Color', 'black', 'LineWidth',1);
hold on
f2 = plot(x_N2_nd(xloc(2),:),y/delta(xloc(2)), '-d','Color', 'blue','MarkerFaceColor','blue', 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f3 = plot(x_N2_nd(xloc(3),:),y/delta(xloc(3)), ':', 'Color', [0.8500, 0.3250, 0.0980], 'LineWidth',2);
hold on
f4 = plot(x_N2_nd(xloc(4),:),y/delta(xloc(4)), 's-','Color', [0.8500, 0.3250, 0.0980], 'MarkerFaceColor','white', 'MarkerSize',6, 'LineWidth',1, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f5 = plot(x_N2_nd(xloc(5),:),y/delta(xloc(5)), '-*', 'Color', [0.8500, 0.3250, 0.0980],'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f6 = plot(x_N2_nd(xloc(6),:),y/delta(xloc(6)), '--', 'Color', [0.8500, 0.3250, 0.0980], 'LineWidth',1);
hold on
f7 = plot(x_N2_nd(xloc(7),:),y/delta(xloc(7)), '.-', 'Color', [0.8500, 0.3250, 0.0980],'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',10, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f8 = plot(x_N2_nd(xloc(8),:),y/delta(xloc(8)), '-o', 'Color', [0.8500, 0.3250, 0.0980],'MarkerFaceColor','white', 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f9 = plot(x_N2_nd(xloc(9),:),y/delta(xloc(9)), 's-', 'Color', [0.8500, 0.3250, 0.0980], 'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',5, 'LineWidth',1, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
xlabel('$C_{c,\;\mathrm{N_2}}\;[-]$', 'FontSize', 18);
ylabel('$\frac{y}{\delta}\;[-]$', 'FontSize', 24);
xlim([-0.05 1.1]);
ylim([0 1.1]);
lgd=legend([f1 f2 f3 f4 f5 f6 f7 f8 f9], '$x =100\;\mathrm{mm}$', '$x =180\;\mathrm{mm}$', '$x =210\;\mathrm{mm}$', '$x =230\;\mathrm{mm}$', '$x =250\;\mathrm{mm}$', '$x =270\;\mathrm{mm}$', '$x =290\;\mathrm{mm}$', '$x =310\;\mathrm{mm}$', '$x =330\;\mathrm{mm}$', 'Location', 'northeast');
set(lgd,'Interpreter','latex')
legend('boxoff');
lgd.FontSize = 12;
print('-dpdf', 'x_N2-norm');
print('-dpng', '-r300', 'x_N2-norm');

%% plot mole fraction of N2 along x at the wall (normalised)
Figure9=figure(9);clf;
set(Figure9,'defaulttextinterpreter','latex');
hold on; box on
xlimit = ([0 500]);
ylimit = ([0.0 1]);
set(gca, 'ylim', ylimit, 'xlim', xlimit)    
v_err = [160:4:200 flip(160:4:200)];
dp_err = [(ylimit(2)-0.005)*ones(1,11) (ylimit(1)+0.005)*ones(1,11)];
fill(v_err, dp_err, [1 0.8 0.8], 'LineStyle','none');
clear alpha
alpha(0.8);
f1 = plot(x*1e3, (x_N2(:,150)-x_N2(:,1))./(x_N2(:,150)-1), '-', 'Color', 'black', 'LineWidth',1.2);
xlabel('$x\;[\mathrm{mm}]$', 'FontSize', 14);
ylabel('$\eta_c\;[-]$', 'FontSize', 14);
lgd=legend('Injector', 'X based effectiveness', 'Location', 'northeast');
set(lgd,'Interpreter','latex')
legend('boxoff');
lgd.FontSize = 12;
print('-dpdf', 'eta_c_vs_x');
print('-dpng', '-r300', 'eta_c_vs_x');
saveas(Figure9, 'eta_c_vs_x');
%% plot mole fraction of He along x at the wall (normalised)
Figure10=figure(10);clf;
set(Figure10,'defaulttextinterpreter','latex');
hold on; box on
xlimit = ([0 500]);
ylimit = ([0.0 1]);
set(gca, 'ylim', ylimit, 'xlim', xlimit)    
v_err = [160:4:200 flip(160:4:200)];
dp_err = [(ylimit(2)-0.005)*ones(1,11) (ylimit(1)+0.005)*ones(1,11)];
fill(v_err, dp_err, [1 0.8 0.8], 'LineStyle','none');
clear alpha
alpha(0.8);
f1 = plot(x*1e3, x_He(:,1), '-', 'Color', 'black', 'LineWidth',1.2);
xlabel('$x\;[\mathrm{mm}]$', 'FontSize', 14);
ylabel('$\eta_c\;[-]$', 'FontSize', 14);
lgd=legend('Injector', 'X based effectiveness', 'Location', 'northeast');
set(lgd,'Interpreter','latex')
legend('boxoff');
lgd.FontSize = 12;
print('-dpdf', 'eta_c_vs_x_He');
print('-dpng', '-r300', 'eta_c_vs_x_He');
saveas(Figure10, 'eta_c_vs_x_He');
%% viscous effects (displacement):
C = rho(:,1).*mu(:,1)./(rho(:,150).*mu(:,150)); % approx. e condition similar to infty condition
Re_x = rho(:,150).*u(:,150).*x(:,1)./mu(:,150);
X_bar = M(:,150).^3.*sqrt(C)./sqrt(Re_x);
pw_p_weak = 1+0.31.*X_bar+0.05.*X_bar.^2;

figure, plot(x, p(:,1)./p(:,150));
hold on;
plot(x, pw_p_weak);
legend('TINA', 'Weak Ineraction Theory');
xlabel('x [m]');
ylabel('p_w/p_{\infty} [-]');
%% plot normalised velocity profiles with normalised y incl. inset
Figure11=figure(11);clf;
set(Figure11,'defaulttextinterpreter','latex');
f1 = plot(u_nd(xloc(1),:),y/delta(xloc(1)), 'Color', 'black', 'LineWidth',1);
hold on
f2 = plot(u_nd(xloc(2),:),y/delta(xloc(2)), '-d','Color', 'blue','MarkerFaceColor','blue', 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))), 'LineWidth', 1.0);
hold on
f3 = plot(u_nd(xloc(3),:),y/delta(xloc(3)), ':', 'Color', [0.8500, 0.3250, 0.0980], 'LineWidth',2);
hold on
f9 = plot(u_nd(xloc(9),:),y/delta(xloc(9)), 's-', 'Color', [0.8500, 0.3250, 0.0980], 'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',5, 'LineWidth',1, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
xlabel('$\frac{u}{u_e}\;[-]$', 'FontSize', 24);
ylabel('$\frac{y}{\delta}\;[-]$', 'FontSize', 24);
xlim([0 1.1]);
ylim([0 1.1]);
lgd=legend([f1 f2 f3 f9], '$x =100\;\mathrm{mm}$', '$x =180\;\mathrm{mm}$', '$x =210\;\mathrm{mm}$', '$x =330\;\mathrm{mm}$', 'Location', 'northwest');
set(lgd,'Interpreter','latex')
legend('boxoff');
lgd.FontSize = 12;
ax = axes('Position',[.64 .21 .25 .3]);
box on; hold on;
plot(ax,u_nd(xloc(1),:),y/delta(xloc(1)), 'Color', 'black', 'LineWidth',1);
plot(u_nd(xloc(2),:),y/delta(xloc(2)), '-d','Color', 'blue','MarkerFaceColor','blue', 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))), 'LineWidth', 1.0);
plot(u_nd(xloc(3),:),y/delta(xloc(3)), ':', 'Color', [0.8500, 0.3250, 0.0980], 'LineWidth',2);
plot(u_nd(xloc(9),:),y/delta(xloc(9)), 's-', 'Color', [0.8500, 0.3250, 0.0980], 'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',5, 'LineWidth',1, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
xlim([0 0.1]);
ylim([0 0.1]);
print('-dpdf', 'u-vel-norm_inset');
print('-dpng', '-r300', 'u-vel-norm_inset');
%% plot normalised temperature profiles with normalised y incl. inset
Figure12=figure(12);clf;
set(Figure12,'defaulttextinterpreter','latex');
f1 = plot(T_nd(xloc(1),:),y/delta(xloc(1)), 'Color', 'black', 'LineWidth',1);
hold on
f2 = plot(T_nd(xloc(2),:),y/delta(xloc(2)), '-d','Color', 'blue','MarkerFaceColor','blue', 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))), 'LineWidth', 1.0);
hold on
f3 = plot(T_nd(xloc(3),:),y/delta(xloc(3)), ':', 'Color', [0.8500, 0.3250, 0.0980], 'LineWidth',2);
hold on
f9 = plot(T_nd(xloc(9),:),y/delta(xloc(9)), 's-', 'Color', [0.8500, 0.3250, 0.0980], 'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',5, 'LineWidth',1, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
xlabel('$\frac{T}{T_e}\;[-]$', 'FontSize', 24);
ylabel('$\frac{y}{\delta}\;[-]$', 'FontSize', 24);
xlim([1 7.1]);
ylim([0 1.1]);
lgd=legend([f1 f2 f3 f9], '$x =100\;\mathrm{mm}$', '$x =180\;\mathrm{mm}$', '$x =210\;\mathrm{mm}$', '$x =330\;\mathrm{mm}$', 'Location', 'northeast');
set(lgd,'Interpreter','latex')
legend('boxoff');
lgd.FontSize = 12;
ax = axes('Position',[.19 .21 .3 .3]);
box on; hold on;
plot(ax,T_nd(xloc(1),:),y/delta(xloc(1)), 'Color', 'black', 'LineWidth',1);
plot(T_nd(xloc(2),:),y/delta(xloc(2)), '-d','Color', 'blue','MarkerFaceColor','blue', 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))), 'LineWidth', 1.0);
plot(T_nd(xloc(3),:),y/delta(xloc(3)), ':', 'Color', [0.8500, 0.3250, 0.0980], 'LineWidth',2);
plot(T_nd(xloc(9),:),y/delta(xloc(9)), 's-', 'Color', [0.8500, 0.3250, 0.0980], 'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',5, 'LineWidth',1, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
xlim([6.5 6.8]);
ylim([0 0.1]);
print('-dpdf', 'T-vel-norm_inset');
print('-dpng', '-r300', 'u-vel-norm_inset');
%% plot normalised concentration profiles with normalised y 
Figure12=figure(12);clf;
set(Figure12,'defaulttextinterpreter','latex');
f1 = plot(x_He_nd(xloc(1),:),y/delta(xloc(1)), 'Color', 'black', 'LineWidth',1);
hold on
f2 = plot(x_He_nd(xloc(2),:),y/delta(xloc(2)), '-d','Color', 'blue','MarkerFaceColor','blue', 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f3 = plot(x_He_nd(xloc(3),:),y/delta(xloc(3)), ':', 'Color', [0.8500, 0.3250, 0.0980], 'LineWidth',2);
hold on
f4 = plot(x_He_nd(xloc(4),:),y/delta(xloc(4)), 's-','Color', [0.8500, 0.3250, 0.0980], 'MarkerFaceColor','white', 'MarkerSize',6, 'LineWidth',1, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f5 = plot(x_He_nd(xloc(5),:),y/delta(xloc(5)), '-*', 'Color', [0.8500, 0.3250, 0.0980],'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f6 = plot(x_He_nd(xloc(6),:),y/delta(xloc(6)), '--', 'Color', [0.8500, 0.3250, 0.0980], 'LineWidth',1);
hold on
f7 = plot(x_He_nd(xloc(7),:),y/delta(xloc(7)), '.-', 'Color', [0.8500, 0.3250, 0.0980],'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',10, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f8 = plot(x_He_nd(xloc(8),:),y/delta(xloc(8)), '-o', 'Color', [0.8500, 0.3250, 0.0980],'MarkerFaceColor','white', 'MarkerSize',5, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
hold on
f9 = plot(x_He_nd(xloc(9),:),y/delta(xloc(9)), 's-', 'Color', [0.8500, 0.3250, 0.0980], 'MarkerFaceColor',[0.8500, 0.3250, 0.0980], 'MarkerSize',5, 'LineWidth',1, 'MarkerIndices', 1:5:length(y/delta(xloc(2))));
xlabel('$C_{c,\;\mathrm{He}}\;[-]$', 'FontSize', 18);
ylabel('$\frac{y}{\delta}\;[-]$', 'FontSize', 24);
xlim([-0.05 1.1]);
ylim([0 1.1]);
lgd=legend([f1 f2 f3 f4 f5 f6 f7 f8 f9], '$x =100\;\mathrm{mm}$', '$x =180\;\mathrm{mm}$', '$x =210\;\mathrm{mm}$', '$x =230\;\mathrm{mm}$', '$x =250\;\mathrm{mm}$', '$x =270\;\mathrm{mm}$', '$x =290\;\mathrm{mm}$', '$x =310\;\mathrm{mm}$', '$x =330\;\mathrm{mm}$', 'Location', 'northeast');
set(lgd,'Interpreter','latex')
legend('boxoff');
lgd.FontSize = 11.5;
print('-dpdf', 'x_He-norm');
print('-dpng', '-r300', 'x_He-norm');