|
| 1 | +% Heat equation in radial coordinates (circular pipe) to understand Nusselt number in turbulent flow |
| 2 | +% Can set up for heated walls or with internal dissipation profile |
| 3 | + |
| 4 | +clear all |
| 5 | +close all |
| 6 | + |
| 7 | +Re_list=[1000000]; |
| 8 | +Nu_list=zeros(size(Re_list)); |
| 9 | +for Rei=1:length(Re_list) |
| 10 | + |
| 11 | + r0=0.2; % Pipe radius (m) |
| 12 | + |
| 13 | + % Typical 0 deg conditions used in ice sheet subglacial modeling |
| 14 | + k=0.558; % Thermal conductivity of water (W/m/K) |
| 15 | + cw=4.22e3; %specific heat capacity of water (J/kg/K) |
| 16 | + mu=1.787e-3; % Dynamic viscosity of water at 0 degC (Pa s) |
| 17 | + |
| 18 | + rhow=1000; % Density of water (kg/m3) |
| 19 | + kappa=k/(rhow*cw); % Thermal diffusivity |
| 20 | + nu=mu/rhow; % Kinematic viscosity (m2/s) |
| 21 | + |
| 22 | + Q=1; % Set to 0 to turn off internal heat generation, 1 for internal dissipation |
| 23 | + |
| 24 | + dr=0.00001*r0; |
| 25 | + J=ceil(r0/dr+1); |
| 26 | + z=0:dr:r0; |
| 27 | + |
| 28 | + % Get velocity profile |
| 29 | + y=0:dr:r0; |
| 30 | + Re=Re_list(Rei); % Prescribe bulk Reynolds number |
| 31 | + vonK=0.4; % Von Karman constant |
| 32 | + B=5; % Constant to use in log-law |
| 33 | + Cf=fzero(@(Cf) -sqrt(2/Cf)+1/vonK*log(Re*sqrt(Cf)/2/sqrt(2))-1/vonK+B,0.009); % Friction factor (from log-law, A/A eqn 1.5) |
| 34 | + u_b=Re*nu/(2*r0); % Bulk mean velocity -- A/A uses 2h, where h is half-width, but Re should depend on hydraulic radius? |
| 35 | + tau_w=Cf*rhow*u_b^2/2; % Wall shear stress |
| 36 | + u_tau=(tau_w/rhow)^0.5; % Friction velocity (inner velocity scale) |
| 37 | + yplus=y.*u_tau./nu; % Non-dimensional y coordinate near wall |
| 38 | + |
| 39 | + uplus(yplus<=20)=yplus(yplus<=20)-1.2533e-4*yplus(yplus<=20).^4+3.9196e-6.*yplus(yplus<=20).^5; % Velocity smooth profile (transition at yplus=20) |
| 40 | + uplus(yplus>20)=1/vonK*log(yplus(yplus>20))+B; % Log-layer |
| 41 | + u=flip(uplus)'.*(u_tau); |
| 42 | + |
| 43 | + ub=2/r0^2*trapz(u.*z')*dr; % Mean bulk velocity for circular pipe |
| 44 | + |
| 45 | + % Dissipation profile (based on Abe and Antonia, missing interior portion) |
| 46 | + % depth-integrated E=<epsilon_bar>+<nu*(du/dz)^2>=(2.54.*log(yplus)+2.41).*u_tau^3; |
| 47 | + % eps here epsilon_bar, NOT depth-integrated! |
| 48 | + outer=find((r0-abs(z))/r0>0.2); |
| 49 | + eps(outer)=(2.45./((r0-abs(z(outer)))./r0)-1.7).*u_tau^3/r0; |
| 50 | + inner=find((r0-abs(z))/r0<=0.2); |
| 51 | + eps(inner)=(2.54./((r0-abs(z(inner)))./r0)-2.6).*u_tau^3/r0; |
| 52 | + % Inner portion of dissipation function (very near wall) |
| 53 | + hplus=u_tau*r0/nu; |
| 54 | + [ii,jj]=find(abs(y/r0-30/hplus)==(min(abs(y/r0-30/hplus)))); |
| 55 | + wall=find((r0-abs(z))/r0<30/hplus); |
| 56 | + eps(wall)=eps(min(wall)-1); |
| 57 | + |
| 58 | + % % Get eddy diffusivity |
| 59 | + tau=tau_w.*z./r0; % Laminar shear stress distribution - linear |
| 60 | + nu_T=-(tau(1:end-1)+tau(2:end))./2./(rhow.*diff(u')./dr)-nu; % Eddy viscosity (at half-nodes) |
| 61 | + nu_T(nu_T<0)=0; |
| 62 | + kappa_T=nu_T; % Eddy diffusivity from Reynolds' analogy (at half-nodes) |
| 63 | + |
| 64 | + dx=r0; |
| 65 | + nx=5000/dx; % Number of x steps (iterations) |
| 66 | + |
| 67 | + z_half=(z(1:end-1)+z(2:end))./2; % Half-node radial coordinates |
| 68 | + alpha=(kappa+kappa_T').*dx./dr'.^2.*z_half'; |
| 69 | + |
| 70 | + % Define vectors (coefficients for interior nodes) |
| 71 | + aconst=-alpha./2./z(2:end)'; |
| 72 | + bconst=(u(2:end-1)+alpha(2:end)./2./z(2:end-1)'+alpha(1:end-1)./2./z(2:end-1)'); |
| 73 | + cconst=-alpha./2./z(1:end-1)'; |
| 74 | + |
| 75 | + % Build a,b,c,r vectors |
| 76 | + a=[0;aconst]; |
| 77 | + b=[0;bconst;0]; |
| 78 | + c=[cconst;0]; |
| 79 | + r=zeros(J,1); |
| 80 | + |
| 81 | + % Boundary condition at pipe center (symmetry condition) |
| 82 | + % Type II at z=0 (no-flux) |
| 83 | + a(1)=0; |
| 84 | + b(1)=-1; |
| 85 | + c(1)=1; |
| 86 | + r(1)=0; |
| 87 | + |
| 88 | + |
| 89 | + if Q==0 % Type I at wall (heated) |
| 90 | + a(J)=0; |
| 91 | + b(J)=1; |
| 92 | + c(J)=0; |
| 93 | + r(J)=1; |
| 94 | + end |
| 95 | + |
| 96 | + if Q==1 % Type I at wall (T=0) |
| 97 | + a(J)=0; |
| 98 | + b(J)=1; |
| 99 | + c(J)=0; |
| 100 | + r(J)=0; |
| 101 | + end |
| 102 | + |
| 103 | + % % Type II at top (no-flux) |
| 104 | + % a(J)=-1; |
| 105 | + % b(J)=1; |
| 106 | + % c(J)=0; |
| 107 | + % r(J)=0; |
| 108 | + |
| 109 | + % Initial condition u(x,0)=0 |
| 110 | + T=2*ones(J,1); |
| 111 | + |
| 112 | + T_CN=[]; % Pre-allocate matrix to store plot values for each t |
| 113 | + |
| 114 | + % Loop through distance along x |
| 115 | + for it=1:nx |
| 116 | + |
| 117 | + % Interior nodes |
| 118 | + r(2:J-1)=alpha(1:end-1)./2./z(2:end-1)'.*T(1:J-2)+(u(2:J-1)-alpha(1:end-1)./2./z(2:end-1)'-alpha(2:end)./2./z(2:end-1)').*T(2:J-1)+alpha(2:end)./2./z(2:end-1)'.*T(3:J)+... |
| 119 | + Q/rhow/cw*dx.*(eps(2:J-1)'.*rhow+mu.*((u(3:J)-u(1:J-2))./dr).^2); |
| 120 | + |
| 121 | + |
| 122 | + Tnext=thomas(a,b,c,r); |
| 123 | + T=Tnext'; |
| 124 | + % Tbar(it)=trapz(T)*dr/r0; |
| 125 | + Tbar(it)=2/(ub*r0^2)*trapz(u.*T.*z')*dr; |
| 126 | + |
| 127 | + % Save to plot for selected downstream distances |
| 128 | + if it*dx==1 | it*dx==5 | it*dx==10 | it*dx==20 | it*dx==50 | it*dx==100 |
| 129 | + T_CN=[T_CN T]; |
| 130 | + end |
| 131 | + |
| 132 | +% % Brinkman number |
| 133 | + Br_lam(it)=mu.*ub.^2./(k.*(T(end)-Tbar(it))); |
| 134 | + Phi=2*pi.*((mu*trapz(((u(2:J)-u(1:J-1))'./dr).^2.*(z(2:J)+z(1:J-1))/2))+trapz(eps.*z)*rhow)*dr; |
| 135 | + h_coeff=Phi/(2*pi*r0*(Tbar(end)-T(J))); |
| 136 | + Br(it)=Phi./(2*h_coeff*(2-T(J))); |
| 137 | + |
| 138 | + |
| 139 | + end |
| 140 | + |
| 141 | + % Plotting - turn off for timing in problem 3 |
| 142 | + figure(1) |
| 143 | + hold on |
| 144 | + plot(T_CN,z./r0,'--','linewidth',1.2) |
| 145 | + % axis([0 1 0 1]) |
| 146 | + legend('x=0.01','x=0.1','x=0.2','x=0.5','x=1','x=2','x=5','x=10','x=20','x=50','x=100','x=200','x=500','x=1000') |
| 147 | + xlabel('T') |
| 148 | + ylabel('r/r_{0}') |
| 149 | + |
| 150 | + figure(2);hold on; |
| 151 | + x=(0:(nx-1)).*dx; |
| 152 | + plot(x./r0,log(Tbar-T(end)),'linewidth',2); |
| 153 | + xlabel('x/r_0','fontsize',14);ylabel('ln(T_b-T_w)','fontsize',14) |
| 154 | + |
| 155 | + if Q==0 % For wall-heating case |
| 156 | + p=polyfit(x,log(T(end)-Tbar),1); |
| 157 | + Nu=-p(1)*rhow*cw*u_b*r0^2/k; |
| 158 | + elseif Q==1 % For internal dissipation case -- with constant T=0 walls |
| 159 | + Phi=2*pi.*((mu*trapz(((u(2:J)-u(1:J-1))'./dr).^2.*(z(2:J)+z(1:J-1))/2))+trapz(eps.*z)*rhow)*dr; |
| 160 | + h_coeff=Phi/(2*pi*r0*(Tbar(end)-T(J))); |
| 161 | + Nu=h_coeff*2*r0/k; |
| 162 | + end |
| 163 | + |
| 164 | + % Comparison with Siegel and Sparrow for internal heat generation (fig. 2) |
| 165 | + % -- make sure to set wall b.c. as no-flux for comparison |
| 166 | + SS=(T(J)-Tbar(end))./(Q*r0^2/k); % Siegel and Sparrow, fig. 2 |
| 167 | + |
| 168 | + % Plot Brinkman number |
| 169 | + figure(3);hold on;plot(x./r0,Br) |
| 170 | + xlabel('x/r_0','fontsize',14);ylabel('Brinkman number') |
| 171 | + |
| 172 | + % Plot non-dimensional Brinkman |
| 173 | + figure(4);hold on;plot(x./r0,log((Tbar-T(J))./(2-T(J))),'linewidth',2) |
| 174 | + xlabel('x/r_0','fontsize',14);ylabel('ln((T_b-T_w)/(T_0-T_w))','fontsize',14) |
| 175 | + |
| 176 | +end |
| 177 | + |
| 178 | + |
| 179 | + |
| 180 | + |
| 181 | + |
| 182 | + |
| 183 | + |
0 commit comments