-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwoD_steady_adiabaticwall.m
More file actions
71 lines (50 loc) · 1.5 KB
/
twoD_steady_adiabaticwall.m
File metadata and controls
71 lines (50 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
clc;
clear all;
%% geometric information of domain
W = 1; % width of domain in m
H = 1; % height of domain in m
Nx = 101; % no of grids in x direction
Ny = 101; % no of grid pts in y dirn
dx = W/(Nx-1);
dy = H/(Ny-1);
%% boundary and initial conditions
T = 25*ones(Nx,Ny); % initial temp of entire plate 25deg C
TL = 120; % left wall temp
% right wall
TT = 40; % top wall
TB = 120; % bottom wall
T(1,1:Ny-1) = TL; % all the elements on left wall are kept at a temp of 120deg C
T(2:Nx,Ny) = TT; % all the grid elements on the top wall
T(2:Nx,1) = TB; % all the grid elements on bottom wall
% all the grid points on right wall
% for the corner points temp definition
T(1,Ny) = (TT+TL)/2;
%% computation
Epsilon = 1e-3;
error = 5; % calculation keeps going until error is < epsilon
iter = 0;
while(error>Epsilon)
iter = iter+1;
disp(iter);
Told = T;
for j = 2:Ny-1
for i = 2:Nx
if i == Nx
T(i,j) = T(i-1,j);
else
T(i,j) = (T(i+1,j)+T(i-1,j)+T(i,j+1)+T(i,j-1))/4;
end
end
end
error = sqrt(sumsqr(T-Told));
disp(error);
end
%% plotting
x = 0:dx:W;
y = 0:dy:H;
colormap("jet");
contourf(x, y, T');
colorbar;
title("temp Dist");
xlabel("Width in m");
ylabel("length in m");