利用matlab程序解决热传导问题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
哈佛大学能源与环境学院
课程作业报告
作业名称:传热学大作业——利用matlab程序解决热传导问题
院系:能源与环境学院
专业:建筑环境与设备工程
学号:
姓名:盖茨比
2015年6月8日
一、题目及要求
1.原始题目及要求
2.各节点的离散化的代数方程
3.源程序
4.不同初值时的收敛快慢
5.上下边界的热流量(λ=1W/(m℃))
6.计算结果的等温线图
7.计算小结
题目:已知条件如下图所示:
二、各节点的离散化的代数方程
各温度节点的代数方程
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