Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

ME634 : ADVANCED COMPUTATIONAL FLUID DYNAMICS

Assignment_1
Name: Jitesh Hemji Roll No: 190408

Given the metallic square block as -

L = side length of block = 0.08 m


alpha = thermal diffusivity = 1.6e-5 m^2/s
k = thermal conductivity = 61 W/mK
T_inf = ambient temperature = 25 C
h = heat transfer coefficient =400 W/m^2K
T0 = initial temperature =100 C
t = 60 s

Next, we can write the Matlab code:

% Assignment_1
% Given Parameters
L = 0.08; % side length of the block [m]
alpha = 1.6e-5; % thermal diffusivity [m^2/s]
k = 61; % thermal conductivity [W/mK]
T_inf = 25; % ambient temperature [C]
h = 400; % heat transfer coefficient [W/m^2K]
T0 = 100; % initial temperature [C]
t = 60; % time [s]

% Discretization
N = 50; % number of grid points
dx = L / (N - 1); % spatial step size [m]
dt = dx^2 / (4 * alpha); % time step size [s]
n_steps = ceil(t / dt); % number of time steps

% Initialize temperature
T = ones(N, N) * T0;

% Time-stepping loop
for i = 1:n_steps
% Calculate T_star
T_star = T;
for j = 2:N-1
for k = 2:N-1
T_star(j, k) = T(j, k) + alpha * dt / dx^2 * (T(j+1, k) + T(j-1, k) + T(j, k+1) + T(j, k-1) - 4 * T(j, k));
end
end

% Apply boundary conditions


T_star(1, :) = T_inf + (T_star(2, :) - T_inf) * h * dx / k;
T_star(N, :) = T_inf + (T_star(N-1, :) - T_inf) * h * dx / k;
T_star(:, 1) = T_inf + (T_star(:, 2) - T_inf) * h * dx / k;
T_star(:, N) = T_inf + (T_star(:, N-1) - T_inf) * h * dx / k;

% Update temperature
T = T_star;
end

% Plot temperature profile on the horizontal mid-plane


T_mid_horizontal = T(N/2, :)
x = 0:dx:L;
plot(x, T_mid_horizontal);
xlabel('x [m]');
ylabel('Temperature [C]');
title('Temperature Profile on the Horizontal Mid-Plane');

% Plot temperature profile on the vertical mid-plane


T_mid_vertical = T(:, N/2)
y = 0:dx:L;
plot(y, T_mid_vertical);
xlabel('y [m]');
ylabel('Temperature [C]');
title('Temperature Profile on the Vertical Mid-Plane');

% Plot iso-lines for temperatures


contourf(T);
xlabel('x [m]');
ylabel('y [m]');
title('Temperature Distribution');
colorbar;

Results:
Temperature distribution on the domain after 60 seconds
T_mid_horizontal = T_mid_vertical =
25.00545138 25.00545138
25.40902372 25.40902372
25.81091705 25.81091705
26.20948163 26.20948163
26.6030814 26.6030814
26.99010067 26.99010067
27.36895079 27.36895079
27.73807666 27.73807666
28.09596309 28.09596309
28.44114106 28.44114106
28.77219373 28.77219373
29.08776225 29.08776225
29.38655136 29.38655136
29.66733466 29.66733466
29.9289597 29.9289597
30.17035267 30.17035267
30.39052281 30.39052281
30.58856648 30.58856648
30.76367088 30.76367088
30.91511734 30.91511734
31.0422843 31.0422843
31.14464986 31.14464986
31.2217939 31.2217939
31.27339983 31.27339983
31.29925585 31.29925585
31.29925585 31.29925585
31.27339983 31.27339983
31.2217939 31.2217939
31.14464986 31.14464986
31.0422843 31.0422843
30.91511734 30.91511734
30.76367088 30.76367088
30.58856648 30.58856648
30.39052281 30.39052281
30.17035267 30.17035267
29.9289597 29.9289597
29.66733466 29.66733466
29.38655136 29.38655136
29.08776225 29.08776225
28.77219373 28.77219373
28.44114106 28.44114106
28.09596309 28.09596309
27.73807666 27.73807666
27.36895079 27.36895079
26.99010067 26.99010067
26.6030814 26.6030814
26.20948163 26.20948163
25.81091705 25.81091705
25.40902372 25.40902372
25.00545138 25.00545138

Iso-lines for temperatures for a duration of 60 seconds:

You might also like