|
| 1 | +close all; clear all; |
| 2 | + |
| 3 | + |
| 4 | +% Setup |
| 5 | +disp("Start average_tke_over_self_similar ..."); tic; |
| 6 | +set_user_inputs(); load variables/user_inputs.mat; |
| 7 | + |
| 8 | +ybeg = -5; yend = 5; ny = 101; |
| 9 | +y = linspace(ybeg,yend,ny); |
| 10 | + |
| 11 | +% Array |
| 12 | +T0_averaged = zeros(ny,1); |
| 13 | +P_averaged = zeros(ny,1); |
| 14 | +D_averaged = zeros(ny,1); |
| 15 | + |
| 16 | +% Compute averaged TKE budget |
| 17 | +for q = 1:Nfiles |
| 18 | + load("results/tke_budget_data/tstep_"+string(timesteps(q))+".mat"); |
| 19 | + |
| 20 | + % Normalization |
| 21 | + T0 = T0 / (8/mth); % T / (Delta U^3 / mth) |
| 22 | + P = P / (8/mth); % P / (Delta U^3 / mth) |
| 23 | + D = D / (8/mth); % D / (Delta U^3 / mth) |
| 24 | + |
| 25 | + % Interpolation |
| 26 | + i_start = 1; |
| 27 | + for j = 1:ny |
| 28 | + for i = i_start:length(y_norm_mth) - 1 |
| 29 | + if (y_norm_mth(i) <= y(j) && y_norm_mth(i+1) > y(j)) |
| 30 | + T0_averaged(j) = T0_averaged(j) + ((T0(i+1) - T0(i))/(y_norm_mth(i+1) - y_norm_mth(i))*(y(j) - y_norm_mth(i)) + T0(i))/Nfiles; |
| 31 | + P_averaged(j) = P_averaged(j) + ((P(i+1) - P(i))/(y_norm_mth(i+1) - y_norm_mth(i))*(y(j) - y_norm_mth(i)) + P(i))/Nfiles; |
| 32 | + D_averaged(j) = D_averaged(j) + ((D(i+1) - D(i))/(y_norm_mth(i+1) - y_norm_mth(i))*(y(j) - y_norm_mth(i)) + D(i))/Nfiles; |
| 33 | + i_start = i; |
| 34 | + break; |
| 35 | + end |
| 36 | + end |
| 37 | + end |
| 38 | +end |
| 39 | + |
| 40 | +T_averaged = f_compute_derivative_1d(T0_averaged,y*mth); |
| 41 | + |
| 42 | +% Plot |
| 43 | +plot_tke_budget(T_averaged, P_averaged, D_averaged, y, mth); |
| 44 | + |
| 45 | +disp("End of program"); toc; |
| 46 | + |
| 47 | +%% FUNCTIONS |
| 48 | +% Compute the wall-normal derivative of a discretized function, fun(y) |
| 49 | +function dfunds = f_compute_derivative_1d(fun,s) |
| 50 | + |
| 51 | + dfunds = zeros(size(fun)); % initialize discrete derivative vector |
| 52 | + |
| 53 | + % Compute one-sided derivative at the bottom boundary |
| 54 | + dfunds(1) = (fun(2) - fun(1)) / (s(2) - s(1)); |
| 55 | + |
| 56 | + % Compute one-sided derivative at the top boundary |
| 57 | + dfunds(end) = (fun(end) - fun(end-1)) / (s(end) - s(end-1)); |
| 58 | + |
| 59 | + % Compute two-sided derivatives for interior points |
| 60 | + for i = 2:length(s)-1 |
| 61 | + dfunds(i) = (fun(i+1) - fun(i-1)) / (s(i+1) - s(i-1)); |
| 62 | + end |
| 63 | +end |
| 64 | + |
| 65 | +% Plot TKE budget |
| 66 | +function plot_tke_budget(T, P, D, y_norm_mth, mth) |
| 67 | + |
| 68 | + load variables/user_inputs.mat; |
| 69 | + load reference_data/reference.mat; |
| 70 | + |
| 71 | + % Plot |
| 72 | + f1 = figure("DefaultAxesFontSize",18); |
| 73 | + set(f1,"Position",[200 200 1000 700]); |
| 74 | + |
| 75 | + % Present |
| 76 | + h1 = plot([-100 -100],[-100 -100],'-k','LineWidth',2); hold on; grid on; |
| 77 | + plot(y_norm_mth,T,'-b','LineWidth',2); |
| 78 | + plot(y_norm_mth,P,'-g','LineWidth',2); |
| 79 | + plot(y_norm_mth,D,'-r','LineWidth',2); |
| 80 | + xlim([-5 5]); xticks([-5:1:5]); |
| 81 | + ylim([-0.002 0.003]); |
| 82 | + xlabel('$y/\delta_\theta$','interpreter','latex'); |
| 83 | + set(gca,'TickLabelInterpreter','latex'); |
| 84 | + |
| 85 | + % Pantano & Sarkar (2002) |
| 86 | + h2 = plot([-100 -100],[-100 -100],'ko','LineWidth',2,'MarkerSize',8); |
| 87 | + plot(p2002_tke_transport(:,1),p2002_tke_transport(:,2),'bo','LineWidth',2,'MarkerSize',8); |
| 88 | + plot(p2002_tke_production(:,1),p2002_tke_production(:,2),'go','LineWidth',2,'MarkerSize',8); |
| 89 | + plot(p2002_tke_dissipation(:,1),p2002_tke_dissipation(:,2),'ro','LineWidth',2,'MarkerSize',8); |
| 90 | + |
| 91 | + % Rogers & Moser (1994) |
| 92 | + h3 = plot([-100 -100],[-100 -100],'k^','LineWidth',2,'MarkerSize',8); |
| 93 | + plot(r1994_tke_transport(:,1),r1994_tke_transport(:,2),'b^','LineWidth',2,'MarkerSize',8); |
| 94 | + plot(r1994_tke_production(:,1),r1994_tke_production(:,2),'g^','LineWidth',2,'MarkerSize',8); |
| 95 | + plot(r1994_tke_dissipation(:,1),r1994_tke_dissipation(:,2),'r^','LineWidth',2,'MarkerSize',8); |
| 96 | + |
| 97 | + % Vaghefi (2014) |
| 98 | + h4 = plot([-100 -100],[-100 -100],'k+','LineWidth',2,'MarkerSize',8); |
| 99 | + plot(v2014_tke_transport(:,1),v2014_tke_transport(:,2),'b+','LineWidth',2,'MarkerSize',8); |
| 100 | + plot(v2014_tke_production(:,1),v2014_tke_production(:,2),'g+','LineWidth',2,'MarkerSize',8); |
| 101 | + plot(v2014_tke_dissipation(:,1),v2014_tke_dissipation(:,2),'r+','LineWidth',2,'MarkerSize',8); |
| 102 | + |
| 103 | + % Wang et al. (2022) |
| 104 | + h5 = plot([-100 -100],[-100 -100],'k*','LineWidth',2,'MarkerSize',8); |
| 105 | + plot(w2022_tke_transport(:,1),w2022_tke_transport(:,2),'b*','LineWidth',2,'MarkerSize',8); |
| 106 | + plot(w2022_tke_production(:,1),w2022_tke_production(:,2),'g*','LineWidth',2,'MarkerSize',8); |
| 107 | + plot(w2022_tke_dissipation(:,1),w2022_tke_dissipation(:,2),'r*','LineWidth',2,'MarkerSize',8); |
| 108 | + |
| 109 | + legend([h1,h2,h3,h4,h5], {"$\mbox{Present}$", ... |
| 110 | + "$\mbox{Pantano \& Sarkar (2002)}$", ... |
| 111 | + "$\mbox{Rogers \& Moser (1994)}$", ... |
| 112 | + "$\mbox{Vaghefi (2014)}$", ... |
| 113 | + "$\mbox{Wang et al. (2022)}$"}, ... |
| 114 | + 'interpreter','latex','location','northeast'); |
| 115 | + |
| 116 | + saveas(f1, "results/tke_budget/avg_self_similar","png"); |
| 117 | + close(f1); |
| 118 | +end |
0 commit comments