Advertisement
Guest User

Heat Transfer

a guest
Feb 5th, 2021
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.33 KB | None | 0 0
  1. clc; clear all; close all;
  2.  
  3. %%%%%% Heat transfer across a thin plate with a hole %%%%%%
  4.  
  5. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  6. %%%%% Material Properties %%%%%
  7. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  8. % Aluminum
  9. a = 9.7e-5; % m^2/s Thermal Diffusivity
  10. cp = 0.91; % kJ/kg*K Heat Capacity
  11. p = 2700; % kg/m^3 Density
  12.  
  13.  
  14.  
  15.  
  16. %%%%%% Input for plate geometry %%%%%%
  17.  
  18. Lx = 0.13; % length in the x-direction in meters
  19. Ly = 0.167; % length in the y-direction in meters
  20. thickness = 0.15; % thickness of the plate
  21. delta = 0.0025; % distance between grid points in meters
  22. R = 0.05; % radius of the hole in the plate in meters
  23. C = [Lx/2;Ly/2]; % center of the hole
  24. Mass = Lx*Ly*thickness*p; % Mass of Plate
  25.  
  26. %%%%%%%%%%%%%%%%%%%%%%%%
  27. %%%%% Temperatures %%%%%
  28. %%%%%%%%%%%%%%%%%%%%%%%%
  29.  
  30. % Gasoline
  31. Tc = 530.372; % degrees Kelvin (Temp of Combustion)
  32. % Ambient Temperature
  33. Ta = 288.706; % degrees Kelvin (Temp Outside)
  34. % Effective Temperature of Coolant
  35. Te = 274.817; % degrees Kelvin (Temp of the coolant)
  36.  
  37.  
  38.  
  39. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  40. %%%%%% Create plate geometry %%%%%%
  41. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  42.  
  43. x = [0:delta:Lx]; % vector of all x values
  44. y = [0:delta:Ly]; % vector of all y values
  45.  
  46.  
  47. M = length(x); % Number of points in x direction
  48. N = length(y); % Number of points in y direction
  49.  
  50. for i=1:M % Loop over all x values
  51. for j=1:N % Loop over all y values
  52.  
  53. X(i,j)= x(i); % Gridded data for all x values
  54. Y(i,j)= y(j); % Gridded data for all y values
  55. Conditional(i,j) = 1; % all points exist by default
  56.  
  57. %%% Initial conditions %%%
  58.  
  59. Q0(i,j) = Ta*Mass*cp; %Set heat equal to zero
  60.  
  61. if j == N
  62. Q0(i,j) = Te*Mass*cp % Temperature of cooled side
  63. end
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. %%% Create hole %%%
  71. D = sqrt( (C(1) - X(i,j))^2 + (C(2) - Y(i,j))^2 ); % distance from current point to center of the hole
  72. if D < R
  73. Conditional(i,j) = 0; % if point is in the hole, point does not exist
  74. end
  75. end
  76. end
  77. for i=2:M-1 %Loop through all x-points not on the edge of plate
  78. for j=2:N-1 %Loop through all y-points not on the edge of plate
  79. LeftN = Conditional(i-1,j);
  80. RightN = Conditional(i+1,j);
  81. TopN = Conditional(i,j+1);
  82. BottomN = Conditional(i,j-1);
  83.  
  84. %If any neighboring values DNE and the point exists, they are on the edge of the hole
  85. if LeftN ==0 || RightN == 0 || TopN == 0 || BottomN == 0
  86. if Conditional(i,j) == 1
  87. Q0(i,j) = Tc*Mass*cp; %Edge of hole is hot, like a piston would be
  88. end
  89. end
  90. end
  91. end
  92.  
  93. %%%%% Extend Plate %%%%%
  94.  
  95. % Add length of plate in x direction plus delta to current x-values
  96. %X1 = X + Lx + delta;
  97.  
  98. % Paste X and X1 together vertically where X1 is pasted just below X
  99. %X = vertcat(X,X1);
  100. % Paste two copies of Y vertically
  101. %Y = vertcat(Y,Y);
  102. % Paste two copies of Conditional vertically
  103. %Conditional = vertcat(Conditional,Conditional);
  104. % Paste two copies of Q0 vertically and set the initial heat of the joining
  105. % point to zero
  106. %Q0 = vertcat(Q0,Q0);
  107. %Q0(M,:) = 0;
  108. %Q0(M+1,:) = 0;
  109.  
  110. % Redefine M and N
  111. %M = length(X(:,1)); % M equals the number of rows in X
  112. %N = length(Y(1,:)); % N equals the number of columns in Y
  113.  
  114. %%%%%% Solve Heat Transfer Equation %%%%%%
  115.  
  116. Q = Q0; % Let current Q equal initial Q to start with
  117. t = 0; % Time starts at zero seconds
  118. dt = 8e-5; % Change in time in seconds
  119.  
  120. Tavg0 = 0;
  121. dTavg = 10;
  122. eps = 1e-12;
  123. while dTavg > eps
  124.  
  125. while t < 10
  126. for i=2:M-1 % Loop over all x values not on boundary
  127. for j=2:N-1 % Loop over all y values not on boundary
  128.  
  129. if Conditional(i,j) == 1 % If point exists, solve heat equation
  130.  
  131. LeftN = Conditional(i-1,j);
  132. RightN = Conditional(i+1,j);
  133. TopN = Conditional(i,j+1);
  134. BottomN = Conditional(i,j-1);
  135.  
  136. if LeftN == 1 && RightN == 1 && TopN == 1 && BottomN == 1
  137. Q(i,j) = ( (Q0(i+1,j) - ...
  138. 2*Q0(i,j) + Q0(i-1,j))/(0.02^2) + ...
  139. (Q0(i,j+1) - 2*Q0(i,j) + Q0(i,j-1))/(0.02^2))*dt + Q0(i,j);
  140. end
  141. end
  142. end
  143. end
  144. t = t + dt; % Update time
  145. Q0 = Q; % Make previous heat values equal current heat values for next loop
  146.  
  147.  
  148. figure(1)
  149. cla
  150. hold on
  151. surf(X,Y,Q,'EdgeColor','none')
  152. contour3(X,Y,Q,20,'k')
  153. xlabel('X')
  154. ylabel('Y')
  155. shading interp
  156. colormap(jet)
  157. view(0,90)
  158. pause(1e-16)
  159.  
  160. end
  161.  
  162. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  163.  
  164. %%%%%%%% Calculate Average Temperature Of Engine Head %%%%%%%%
  165.  
  166. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  167.  
  168. T = Q./(Mass*cp);
  169.  
  170. Tsum = 0;
  171.  
  172. Npoints = 0;
  173.  
  174.  
  175. for i=1:M
  176.  
  177. for j=1:N
  178.  
  179. if Conditional(i,j) == 1
  180.  
  181.  
  182.  
  183. Tsum = T(i,j) + Tsum;
  184.  
  185. Npoints = Npoints + 1;
  186.  
  187.  
  188.  
  189. end
  190.  
  191. end
  192.  
  193. end
  194.  
  195. Tavg = Tsum/Npoints;
  196. dTavg = Tavg - Tavg0;
  197. Tavg0 = Tavg;
  198.  
  199. %tcooling = [200; 250; 274.81; 300; 350];
  200.  
  201. %taverage = [374.64; 384.81; 389.86; 394.98; 405.15];
  202.  
  203.  
  204. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement