
Lesson 19 1D steady state heat conduction (FVM).
Hi,
I tried to write the Matlab program for the Lesson 19 1D steady state heat conduction (FVM).
As per the lecture, the solution should be T1=140; T2=220; T3=300; T4=380; T5=460.
But my results are wrong. I spent 2 days and tried in different ways to write the same program, but I got error.
It would be helpful if you can support me to get the correct result.Thank you.
L = 0.5; %Length of rod
N = 5; %Number of cells
dx = L/N;
Tl = 100; %Left side temperature
Tr = 500; %Right side temperature
k = 1000; %Thermal conductivity
A = 10e2; %Area
T = zeros(N, 1);
Am = zeros(N, N); %Coefficient matrix)
b = zeros(N, 1);%vector
for i = 1:N
if i == 1 %at cell 1
Am(i, i) = 3*k*A/dx;
Am(i, i+1) = k*A/dx;
b(i) = Tl*k*A/dx;
elseif i >= 2 && i <= N1
Am(i, i1) = k*A/dx;
Am(i, i) = 2*k*A/dx;
Am(i, i+1) = k*A/dx;
b(i) = 0;
elseif i == N %at cell N
Am(i, i1) = k*A/dx;
Am(i, i) = 3*k*A/dx;
b(i) = Tr*k*A/dx;
end
end
T = Am\b;
fprintf(‘Node\tTemperature\n’);
fprintf(‘—————\n’);
for i = 1:N
fprintf(‘%d\t%.2f\n’, i, T(i));
end
plot(linspace(0, L, N), T);
xlabel(‘Position (m)’);
ylabel(‘Temperature’);
title(‘Temperature Distribution’);
grid on;
Log in to reply.