1、哈工大传热学虚拟仿真实验报告Harbin Institute of Technology传热学虚拟仿真实验报告 院 系:能源科学与工程学院 班 级: 设 计 者: 学 号: * * 设计时间: 2016.11.7 传热学虚拟仿真实验报告1 应用背景 数值热分析在核工业、铁道、石油化工、航空航天、机械制造、能源、汽车交通、国防军工、电子、土木工程、造船、生物医学、轻工、地矿、水利、以及日用家电等各个领域都有广泛的应用。2 二维导热温度场的数值模拟2.1 二维稳态导热实例 假设一用砖砌成的长方形截面的冷空气通道,其截面如图2.1所示,假设在垂直于纸面方向上冷空气及砖墙的温度变化很小,可以近似地予以
2、忽略。图2.1 一用砖砌成的长方形截面的冷空气通道截面2.2 二维数值模拟 基于模型的对称性,简化为如图所示的四分之一模型。图2.2 二维数值模拟2.3 建立离散方程 此时对于内部节点,如图2.3: 对于平直边界上的节点,如图2.4: 对于外部和内部角点,如图2.5: 图2.3 内部节点 图2.4 平直边界上的节点 图2.5 内部角点和外部角点 对于对称边界(绝热边界),如图2.6: 图2.6 对称边界(绝热边界) 图2.7 建立离散方程此时显示格式、隐式格式依次为,如图2.7:2.4 C+程序2.4.1 程序流程图如下图2.8所示图2.8 程序流程图2.4.2 程序各变量含义如下图2.9所示
3、 n_L1, n_L2, n_L3, n_L4, n_thick1, n_thick2分别为对应边的网格数。2.4.3 程序#include#includeint main() float L1,L2,L3,L4,thick1,thick2; /* L1 外矩形宽,L2外矩形长,L3内矩形宽,L4内矩形长,thick1宽度方向厚度,thick1长度方向厚度*/ int n_L1,n_L2,n_L3,n_L4,n_thick1,n_thick2; /*各边网格数*/ int i,j,n,number; /*n迭代次数*/ double eps=5.0e-6; float delt_y1,delt
4、_y2,delt_x1,delt_x2; float cond,conv_out,conv_in,tout,tin; /* cond 导热系数 conv_out 外部对流换热系数 conv_in 内部对流换热系数 tout 外部环境温度 tin 内部环境温度*/ /*输入几何信息*/ printf(请输入 L1:); scanf(%f, &L1); printf(请输入 L2:); scanf(%f, &L2); printf(请输入 L3:); scanf(%f, &L3); printf(请输入 L4:); scanf(%f, &L4); /*输入网格信息*/ printf(请输入边L1网
5、格数(100):); scanf(%d, &n_L1); printf(请输入边L2网格数(100):); scanf(%d, &n_L2); printf(请输入边L3网格数(100):); scanf(%d, &n_L3); printf(请输入边L4网格数(100):); scanf(%d, &n_L4);/*输入边界条件*/ printf(请输入材料导热系数(W/(mK):); scanf(%f, &cond); printf(请输入外部环境温度(K):); scanf(%f, &tout); printf(请输入内部环境温度(K):); scanf(%f, &tin); printf
6、(请输入外部对流换热系数(W/(m2K):); scanf(%f, &conv_out); printf(请输入内部对流换热系数(W/(m2K):); scanf(%f, &conv_in); thick1=(L2-L4); thick2=(L1-L3); n_thick1=(n_L2-n_L4); n_thick2=(n_L1-n_L3);/*网格大小*/ delt_x1=thick1/n_thick1; delt_x2=L4/n_L4; delt_y1=thick2/n_thick2; delt_y2=L3/n_L3;/*/ /*节点赋初值*/ double tem0100100; /*节
7、点温度 tem0()上次迭代结果,tem()本次迭代结果*/ double tem100100; double x100100; double y100100; n=0; do /*区域1内部节点温度*/ /*/ for(i=1;in_thick1;i+) for(j=n_L3+1;jn_L1;j+) tem0ij=(temi+1j+temi-1j)*delt_y1*delt_y1+(temij+1+temij-1)*delt_x1*delt_x1)/2.0/(delt_y1*delt_y1+delt_x1*delt_x1); /*/ /*区域2内部节点温度*/ /*/ for(i=1;in_
8、thick1;i+) for(j=1;jn_L3;j+) tem0ij=(temi+1j+temi-1j)*delt_y2*delt_y2+(temij+1+temij-1)*delt_x1*delt_x1)/2.0/(delt_x1*delt_x1+delt_y2*delt_y2); /*/ /*区域3内部节点温度*/ /*/ for(i=n_thick1+1;in_L2;i+) for(j=n_L3+1;jn_L1;j+) tem0ij=(temi+1j+temi-1j)*delt_y1*delt_y1+(temij+1+temij-1)*delt_x2*delt_x2)/2.0/(del
9、t_x2*delt_x2+delt_y1*delt_y1); /*/ /*区域1与区域2边界线*/ /*/ for(i=1;in_thick1;i+) j=n_L3; tem0ij=(temi+1j+temi-1j)/2.0*(delt_y1+delt_y2)*delt_y1*delt_y2+temij+1*delt_y2*delt_x1*delt_x1+temij-1*delt_y1*delt_x1*delt_x1)/(delt_y1+delt_y2)*delt_y1*delt_y2+delt_y2*delt_x1*delt_x1+delt_x1*delt_x1*delt_y1); /*/
10、/*区域1与区域3边界线*/ /*/ for(j=n_L3+1;jn_L1;j+) i=n_thick1; tem0ij=(temij+1+temij-1)/2.0*(delt_x1+delt_x2)*delt_x1*delt_x2+temi-1j*delt_x2*delt_y1*delt_y1+temi+1j*delt_x1*delt_y1*delt_y1)/(delt_x1+delt_x2)*delt_x1*delt_x2+delt_x2*delt_y1*delt_y1+delt_y1*delt_y1*delt_x1); /*/ /*边界条件*/ /*绝热边界条件(对称面)*/ /*右边界
11、*/ for(j=n_L3+1;jn_L1;j+) i=n_L2; tem0ij=(2.0*temi-1j*delt_y1*delt_y1+(temij+1+temij-1)*delt_x2*delt_x2)/2.0/(delt_x2*delt_x2+delt_y1*delt_y1); /*下边界*/ for(i=1;in_thick1;i+) j=0; tem0ij=(delt_y2*temi-1j/2/delt_x1)+(delt_x1*temij+1/delt_y2)+(delt_y2*temi+1j/2/delt_x1)/(delt_y2/2/delt_x1)+(delt_x1/del
12、t_y2)+(delt_y2/2/delt_x1); for(i=n_thick1+1;in_L2;i+) j=n_L3; tem0ij=(delt_y1*temi-1j/2/delt_x2)+(delt_x2*temij+1/delt_y2)+(delt_y2*temi+1j/2/delt_x2)+(delt_x2*conv_in*tin)/(delt_y2/2/delt_x2)+(delt_x2/delt_y2)+(delt_y2/2/delt_x2)+(delt_x2*conv_in); /*外部对流边界条件*/ /*上边界*/ for(i=1;in_thick1;i+) j=n_L1;
13、 tem0ij=(cond*delt_y1*delt_y1*(temi-1j+temi+1j)+2.0*cond*delt_x1*delt_x1*temij-1+2.0*delt_y1*delt_x1*delt_x1*conv_out*tout)/(2.0*cond*delt_y1*delt_y1+2.0*cond*delt_x1*delt_x1+2.0*delt_y1*conv_out*delt_x1*delt_x1); for(i=n_thick1+1;in_L2;i+) j=n_L1; tem0ij=(cond*delt_y1*delt_y1*(temi-1j+temi+1j)+2.0*
14、cond*delt_x2*delt_x2*temij-1+2.0*delt_y1*delt_x2*delt_x2*conv_out*tout)/(2.0*cond*delt_y1*delt_y1+2.0*cond*delt_x2*delt_x2+2.0*delt_y1*conv_out*delt_x2*delt_x2); i=n_thick1; j=n_L1; tem0ij=(cond*delt_y1*delt_y1*delt_x2*temi-1j+cond*delt_y1*delt_y1*delt_x1*temi+1j+cond*delt_x1*delt_x2*(delt_x1+delt_x
15、2)*temij-1+delt_y1*delt_x1*delt_x2*(delt_x1+delt_x2)*conv_out*tout)/(cond*delt_y1*delt_y1*delt_x2+cond*delt_y1*delt_y1*delt_x1+cond*delt_x1*delt_x2*(delt_x1+delt_x2)+delt_y1*conv_out*delt_x1*delt_x2*(delt_x1+delt_x2); /*左边界*/ for(j=n_L3+1;jn_L1;j+) i=0; tem0ij=(cond*delt_x1*temij+1/2/delt_y1)+(cond*
16、delt_y1*temi+1j/delt_x1)+(cond*delt_x1*temij-1/2/delt_y1)+(delt_y1*conv_out*tout)/(cond*delt_x1/2/delt_y1)+(cond*delt_y1/delt_x1)+(cond*delt_x1/2/delt_y1)+(delt_y1*conv_out); for(j=1;jn_L3;j+) i=0; tem0ij=(cond*delt_x1*temij+1/2/delt_y2)+(cond*delt_y2*temi+1j/delt_x1)+(cond*delt_x1*temij-1/2/delt_y2
17、)+(delt_y2*conv_out*tout)/(cond*delt_x1/2/delt_y2)+(cond*delt_y2/delt_x1)+(cond*delt_x1/2/delt_y2)+(delt_y2*conv_out); i=0; j=n_L3; tem0ij=(cond*delt_x1*temij+1/2/delt_y1)+(cond*(delt_y1+delt_y2)/2)*temi+1j/delt_x1)+(cond*delt_x1*temij-1/2/delt_y2)+(delt_y1+delt_y2)/2)*conv_out*tout)/(cond*delt_x1/2
18、/delt_y1)+(cond*(delt_y1+delt_y2)/2)/delt_x1)+(cond*delt_x1/2/delt_y2)+(delt_y1+delt_y2)/2)*conv_out); /*内部对流边界条件*/ /*上边界*/ for(i=n_thick1+1;in_L2;i+) j=n_L3; tem0ij=(cond*delt_y1*delt_y1*(temi-1j+temi+1j)+2.0*cond*delt_x2*delt_x2*temij+1+2.0*delt_y1*delt_x2*delt_x2*conv_in*tin)/(2.0*cond*delt_y1*de
19、lt_y1+2.0*cond*delt_x2*delt_x2+2.0*delt_y1*conv_in*delt_x2*delt_x2); /*左边界*/ for(j=1;jn_L3;j+) i=n_thick1; tem0ij=(cond*delt_x1*temij+1/2/delt_y2)+(cond*delt_y2*temi-1j/delt_x1)+(cond*delt_x1*temij-1/2/delt_y2)+(delt_y2*conv_in*tin)/(cond*delt_x1/2/delt_y2)+(cond*delt_y2/delt_x1)+(cond*delt_x1/2/del
20、t_y2)+(delt_y2*conv_in); /*特殊点*/ /*左下角*/ tem000=(cond*delt_x1*delt_x1*tem01+cond*delt_y2*delt_y2*tem10+delt_y2*delt_y2*delt_x1*conv_out*tout)/(cond*delt_x1*delt_x1+cond*delt_y2*delt_y2+delt_y2*delt_y2*delt_x1*conv_out); /*右下角*/ tem0n_thick10=(cond*delt_x1*delt_x1*temn_thick11+cond*delt_y2*delt_y2*te
21、mn_thick1-10+delt_y2*delt_y2*delt_x1*conv_in*tin)/(cond*delt_x1*delt_x1+cond*delt_y2*delt_y2+delt_y2*delt_y2*delt_x1*conv_in); /*左上角*/ tem00n_L1=(cond*delt_y1*delt_y1*tem1n_L1+cond*delt_x1*delt_x1*tem0n_L1-1+delt_x1*delt_y1*(delt_y1+delt_x1)*conv_out*tout)/(cond*delt_y1*delt_y1+cond*delt_x1*delt_x1+
22、delt_x1*delt_y1*(delt_y1+delt_x1)*conv_out); /*右上角1*/ tem0n_L2n_L1=(cond*delt_y1*delt_y1*temn_L2-1n_L1+cond*delt_x2*delt_x2*temn_L2n_L1-1+delt_x2*delt_y1*delt_x2*conv_out*tout)/(cond*delt_y1*delt_y1+cond*delt_x2*delt_x2+delt_y1*delt_x2*delt_x2*conv_out); /*右上角2*/ tem0n_L2n_L3=(cond*delt_y1*delt_y1*t
23、emn_L2-1n_L3+cond*delt_x2*delt_x2*temn_L2n_L3+1+delt_x2*delt_y1*delt_x2*conv_in*tin)/(cond*delt_y1*delt_y1+cond*delt_x2*delt_x2+delt_y1*delt_x2*delt_x2*conv_in); /*内角点*/ tem0n_thick1n_L3=(cond*(delt_y1+delt_y2)/delt_x1*temn_thick1-1n_L3+cond*(delt_x1+delt_x2)/delt_y1*temn_thick1n_L3+1+cond*delt_y1/d
24、elt_x2*temn_thick1+1n_L3+cond*delt_x1/delt_y2*temn_thick1n_L3-1+(delt_x2+delt_y2)*conv_in*tin)/(cond*(delt_y1+delt_y2)/delt_x1+cond*(delt_x1+delt_x2)/delt_y1+cond*delt_y1/delt_x2+cond*delt_x1/delt_y2+(delt_x2+delt_y2)*conv_in);/*判断是否收敛*/ number=0; for(i=0;i=n_L2;i+) for(j=0;jeps) number+; for(i=0;i=
25、n_L2;i+) for(j=0;j0 & n1000000); /*计算各节点坐标*/ for (i=0;i=n_L2;i+) for(j=0;j=n_L1;j+) if(i=n_thick1 & j=n_L3) xij=delt_x1*i; yij=delt_y2*j; if(in_L3) xij=delt_x1*i; yij=delt_y2*n_L3+delt_y1*(j-n_L3); if(in_thick1 & jn_thick1 & jn_L3) xij=n_thick1*delt_x1+delt_x2*(i-n_thick1); yij=delt_y2*n_L3+delt_y1*(j-n_L3); /*计算各节点坐标结束*/ ofstream SaveFile(temperature.dat); /*输出计算结果*/ SaveFile title=Tempera
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1