clear all
clc
clf
n = 21;
L = 1;
A = sparse(n,n);
B = sparse(n,n);
Bx = zeros(n,1);
Ta = zeros(n,1);
Tb = zeros(n,1);
dx = L/(n-1);
dt = 20;
tmax = 4000;
t = 0:dt:tmax;
Tl = 100;
Tr = 100;
x = linspace(0,L,n);
alpha = 1e-4;
r = alpha * dt /(2 *dx^2);
for i = 2 : n-1
A(i,i-1) = -r;
A(i,i ) = (1+2*r);
A(i,i+1) = -r;
end
A(1 ,1 ) = 1;
A(n ,n ) = 1;
for j = 2 : n-1
B(j,j-1) = r;
B(j,j ) = (1-2*r);
B(j,j+1) = r;
end
B(1 ,1 ) = 1;
B(n ,n ) = 1;
Bx(1,1) = Tl;
Bx(n,1) = Tr;
for k = 2 : length(t)
Bx(2 : n-1) = Tb(2 : n-1);
Tb = B * Bx;
fprintf('Time t=%d\n',k-1);
end
Ta = A\Tb;
pos1 = [0.1 0.17 0.4 0.7];
subplot('Position',pos1)
plot(x,Ta);
title('Nodes Vs Temperature');
xlabel('Nodes (i)');
ylabel('Temperature °C');
grid on
grid minor
a=0:L;
d=0:0;
pos2 = [0.51 0.45 0.45 0.1];
subplot('Position',pos2)
ax = gca;
imagesc(a,d,Ta', 'Parent', ax);
ax.YAxis.Visible = 'off';
title('Temperature Gradient');
xlabel('Nodes (i)');
h = colorbar;
ylabel(h, 'Temperature °C')
colormap jet
댓글 수: 4
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/558454-1-d-transient-heat-conduction-with-no-heat-generation-fdm-crank-nicholson#comment_923141
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/558454-1-d-transient-heat-conduction-with-no-heat-generation-fdm-crank-nicholson#comment_923141
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/558454-1-d-transient-heat-conduction-with-no-heat-generation-fdm-crank-nicholson#comment_923195
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/558454-1-d-transient-heat-conduction-with-no-heat-generation-fdm-crank-nicholson#comment_923195
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/558454-1-d-transient-heat-conduction-with-no-heat-generation-fdm-crank-nicholson#comment_923225
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/558454-1-d-transient-heat-conduction-with-no-heat-generation-fdm-crank-nicholson#comment_923225
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/558454-1-d-transient-heat-conduction-with-no-heat-generation-fdm-crank-nicholson#comment_923342
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/558454-1-d-transient-heat-conduction-with-no-heat-generation-fdm-crank-nicholson#comment_923342
댓글을 달려면 로그인하십시오.