0% found this document useful (0 votes)
5 views2 pages

Lab 13

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Lab 13

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

4/18/25 10:22 PM C:\...\Lab13.

m 1 of 2

clc;
clear;

%% Parameters
L = 1; % Length of plate (m)
Nx = 20; % Number of grid points in x-direction
Ny = 20; % Number of grid points in y-direction
alpha = 122.0e-3; % Thermal diffusivity (m^2/s)
dx = L / (Nx - 1);
dy = L / (Ny - 1);
dt = 0.25 * (dx^2 * dy^2) / (alpha * (dx^2 + dy^2)); %
Stability condition
time_steps = 4000;

%% Initialize temperature field


T = ones(Nx, Ny) * 25; % Initial condition inside the
plate

%% Apply Boundary Conditions


T(:, 1) = 25; % Left boundary (x=0)
T(:, end) = 25; % Right boundary (x=L)
T(1, :) = 25; % Bottom boundary (y=0)
T(end, :) = 50; % Top boundary (y=L)

%% Time-stepping loop
for t = 1:time_steps
T_old = T;

for i = 2:Nx-1
for j = 2:Ny-1
4/18/25 10:22 PM C:\...\Lab13.m 2 of 2

T(i, j) = T_old(i, j) + alpha * dt *


((T_old(i+1, j) - 2*T_old(i, j) + T_old(i-1, j)) /
dx^2 + ...
(T_old
(i, j+1) - 2*T_old(i, j) + T_old(i, j-1)) / dy^2);
end
end
end

%% Visualization
[X, Y] = meshgrid(linspace(0, L, Nx), linspace(0, L,
Ny));
figure;
contourf(X, Y, T, 20, 'LineColor', 'none');
colormap(jet);
colorbar;
caxis([25 50]);
axis equal;
title('2D Heat Diffusion in Mild Steel Plate');
xlabel('X (m)');
ylabel('Y (m)');

You might also like