传热学MATLAB温度分布大作业完整版
时间:2026-01-18
时间:2026-01-18
东南大学能源与环境学院
作业名称:
课程作业报告 传热学大作业——利用matlab程序解决热传导问题 院系:能源与环境学院 专业:建筑环境与设备工程 学号: 姓名: 2014年11月9日
一、题目及要求
1.
2.
3.
4.
5.
6.
7. 原始题目及要求 各节点的离散化的代数方程 源程序 不同初值时的收敛快慢 上下边界的热流量(λ=1W/(m℃)) 计算结果的等温线图 计算小结
题目:已知条件如下图所示:
二、各节点的离散化的代数方程
各温度节点的代数方程
ta=(300+b+e)/4 ; tb=(200+a+c+f)/4; tc=(200+b+d+g)/4; td=(2*c+200+h)/4
te=(100+a+f+i)/4; tf=(b+e+g+j)/4; tg=(c+f+h+k)/4 ; th=(2*g+d+l)/4
ti=(100+e+m+j)/4; tj=(f+i+k+n)/4; tk=(g+j+l+o)/4; tl=(2*k+h+q)/4
tm=(2*i+300+n)/24; tn=(2*j+m+p+200)/24; to=(2*k+p+n+200)/24; tp=(l+o+100)/12
三、源程序
【G-S迭代程序】
【方法一】
函数文件为:
function [y,n]=gauseidel(A,b,x0,eps)
D=diag(diag(A));
L=-tril(A,-1);
U=-triu(A,1);
G=(D-L)\U;
f=(D-L)\b;
y=G*x0+f;
n=1;
while norm(y-x0)>=eps
x0=y;
y=G*x0+f;
n=n+1;
end
命令文件为:
A=[4,-1,0,0,-1,0,0,0,0,0,0,0,0,0,0,0;
-1,4,-1,0,0,-1,0,0,0,0,0,0,0,0,0,0;
0,-1,4,-1,0,0,-1,0,0,0,0,0,0,0,0,0;
0,0,-2,4,0,0,0,-1,0,0,0,0,0,0,0,0;
-1,0,0,0,4,-1,0,0,-1,0,0,0,0,0,0,0;
0,-1,0,0,-1,4,-1,0,0,-1,0,0,0,0,0,0;
0,0,-1,0,0,-1,4,-1,0,0,-1,0,0,0,0,0;
0,0,0,-1,0,0,-2,4,0,0,0,-1,0,0,0,0;
0,0,0,0,-1,0,-1,0,4,0,0,0,-1,0,0,0;
0,0,0,0,0,-1,0,0,-1,4,-1,0,0,-1,0,0;
0,0,0,0,0,0,-1,0,0,-1,4,-1,0,0,-1,0;
0,0,0,0,0,0,0,-1,0,0,-2,4,0,0,0,-1;
0,0,0,0,0,0,0,0,-2,0,0,0,24,-1,0,0;
0,0,0,0,0,0,0,0,0,-2,0,0,-1,24,-1,0;
0,0,0,0,0,0,0,0,0,0,-2,0,0,-1,24,-1;
0,0,0,0,0,0,0,0,0,0,0,-1,0,0,-1,12];
b=[300,200,200,200,100,0,0,0,100,0,0,0,300,200,200,100]';
[x,n]=gauseidel(A,b,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]',1.0e-6)
xx=1:1:4;
yy=xx;
[X,Y]=meshgrid(xx,yy);
Z=reshape(x,4,4);
Z=Z'
contour(X,Y,Z,30)
Z =
139.6088 150.3312 153.0517 153.5639
108.1040 108.6641 108.3119 108.1523
84.1429 67.9096 63.3793 62.4214
20.1557 15.4521 14.8744 14.7746
【方法2】>> t=zeros(5,5);
t(1,1)=100;
t(1,2)=100;
t(1,3)=100;
t(1,4)=100;
t(1,5)=100;
t(2,1)=200;
t(3,1)=200;
t(4,1)=200;
t(5,1)=200;
for i=1:10
t(2,2)=(300+t(3,2)+t(2,3))/4 ;
t(3,2)=(200+t(2,2)+t(4,2)+t(3,3))/4;
t(4,2)=(200+t(3,2)+t(5,2)+t(4,3))/4;
t(5,2)=(2*t(4,2)+200+t(5,3))/4;
t(2,3)=(100+t(2,2)+t(3,3)+t(2,4))/4;
t(3,3)=(t(3,2)+t(2,3)+t(4,3)+t(3,4))/4;
t(4,3)=(t(4,2)+t(3,3)+t(5,3)+t(4,4))/4;
t(5,3)=(2*t(4,3)+t(5,2)+t(5,4))/4;
t(2,4)=(100+t(2,3)+t(2,5)+t(3,4))/4;
t(3,4)=(t(3,3)+t(2,4)+t(4,4)+t(3,5))/4;
t(4,4)=(t(4,3)+t(4,5)+t(3,4)+t(5,4))/4;
t(5,4)=(2*t(4,4)+t(5,3)+t(5,5))/4;
t(2,5)=(2*t(2,4)+300+t(3,5))/24;
t(3,5)=(2*t(3,4)+t(2,5)+t(4,5)+200)/24;
t(4,5)=(2*t(4,4)+t(3,5)+t(5,5)+200)/24;
t(5,5)=(t(5,4)+t(4,5)+100)/12;
t'
end
contour(t',50);
ans =
100.0000 200.0000 200.0000 200.0000 200.0000
100.0000 136.8905 146.9674 149.8587 150.7444
100.0000 102.3012 103.2880 103.8632 104.3496
100.0000 70.6264 61.9465 59.8018 59.6008
100.0000 19.0033 14.8903 14.5393 14.5117
【Jacobi迭代程序】
函数文件为:
function [y,n]=jacobi(A,b,x0,eps)
D=diag(diag(A));
L=-tril(A,-1);
U=-triu(A,1);
B=D\(L+U);
f=D\b;
y=B*x0+f;
n=1;
while norm(y-x0)>=eps
x0=y;
y=B*x0+f;
n=n+1;
end
命令文件为:
A=[4,-1,0,0,-1,0,0,0,0,0,0,0,0,0,0,0;
-1,4,-1,0,0,-1,0,0,0,0,0,0,0,0,0,0;
0,-1,4,-1,0,0,-1,0,0,0,0,0,0,0,0,0;
0,0,-2,4,0,0,0,-1,0,0,0,0,0,0,0,0;
-1,0,0,0,4,-1,0,0,-1,0,0,0,0,0,0,0;
0,-1,0,0,-1,4,-1,0,0,-1,0,0,0,0,0,0;
0,0,-1,0,0,-1,4,-1,0,0,-1,0,0,0,0,0;
0,0,0,-1,0,0,-2,4,0,0,0,-1,0,0,0,0;
0,0,0,0,-1,0,-1,0,4,0,0,0,-1,0,0,0;
0,0,0,0,0,-1,0,0,-1,4,-1,0,0,-1,0,0;
0,0,0,0,0,0,-1,0,0,-1,4,-1,0,0,-1,0;
0,0,0,0,0,0,0,-1,0,0,-2,4,0,0,0,-1;
0,0,0,0,0,0,0,0,-2,0,0,0,24,-1,0,0;
0,0,0,0,0,0,0,0,0,-2,0,0,-1,24,-1,0;
0,0,0,0,0,0,0,0,0,0,-2,0,0,-1,24,-1;
0,0,0,0,0,0,0,0,0,0,0,-1,0,0,-1,12];
b=[300,200,200,200,100,0,0,0,100,0,0,0,300,200,200,100]';
[x,n]=jacobi(A,b,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]',1.0e-6);
xx=1:1:4;
yy=xx;
[X,Y]=meshgrid(xx,yy);
Z=reshape(x,4,4);
Z=Z'
contour(X,Y,Z,30)
n =97
Z =
139.6088 150.3312 153.0517 153.5639
108.1040 108.6641 108.3119 108.1523
84.1429 67.9096 63.3793 62.4214
20.1557 15.4521 14.8744 14.7746
四、不同初值时的收敛快慢
1、[方法1]在Gauss迭代和Jacobi迭代中,本程序应用的收敛条件均为norm(y-x0)>=eps,即使前后所求误差达到e的-6次方时,跳出循环得出结果。
将误差改为0.01时,只需迭代25次,如下
[x,n]=gauseidel(A,b,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]',0.01)运行结果为 将误差改为0.1时,需迭代20次,可见随着迭代次数增加,误差减小,变化速度也在减小。
[方法2]通过 i=1:10判断收敛,为迭代10次,若改为1:20,则迭代20次。
2、在同样的误差要求下,误差控制在e的-6次方内,Gauss迭代用了49次达到要求,而Jacobi迭代用了97次,可见,在迭代中尽量采用最新值,可以大幅度的减少 …… 此处隐藏:3109字,全部文档内容请下载后查看。喜欢就下载吧 ……
上一篇:宴会西餐服务程序