前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >5.2.2 二维导热算例-迭代计算

5.2.2 二维导热算例-迭代计算

作者头像
周星星9527
发布2018-08-08 15:55:58
4840
发布2018-08-08 15:55:58
举报

我们首先介绍温度场的求解吧,假设边界条件和初始条件已经设定。在贴代码之前,我们先谈谈这个类需要什么属性和行为:节点数组用于存储计算变量、网格大小、维度定义、计算函数,也就这么多了。如何计算某节点的温度?计算其东南西北方位相接节点对该节点的穿导热之和即可,读者这里可以考虑一下如何添加源相和对流换热进去。

代码语言:javascript
复制
1. packageSoong.Solver
2. {
3.  public class TSolver
4.    {
5.  public var Tlist:Vector.<Node>;
6.  
7.  private var xGridNum:uint = 1;//Number of GridAllocated in X Direction
8.  private var yGridNum:uint = 1;//Number of GridAllocated in X Direction
9.  
10.  public var dx:Number = 1;//Grid Size in XDirection
11.  public var dy:Number = 1;//Grid Size in YDirection
12.  
13.  public var Sx:Number = 0;//Area of HeatInterface in X Direction
14.  public var Sy:Number = 0;//Area of HeatInterface in X Direction
15.  
16.  public var cellVol:Number = 0;//Volume ofControl Volume
17.  
18.  public var Freezing:Boolean=false;//If Time toFreeze
19.  
20.  public functionTSolver(xGridNum:uint,yGridNum:uint,dx:Number,dy:Number)
21.       {
22.  this.xGridNum = xGridNum;
23.  this.yGridNum = yGridNum;
24.  
25.  this.dx = dx;
26.  this.dy = dy;
27.  
28.  this.Sx = dy * 1;
29.  this.Sy = dx * 1;
30.  
31.  this.cellVol = dx * dy * 1;
32.       }
33.  
34.  public functionStep(timeStep:Number):void
35.       {
36.  var col:uint = 0;
37.  var row:uint = 0;
38.  var node:Node = null;
39.  
40.  for (col = 2; col < xGridNum - 2; col++ )
41.          {
42.  for (row = 2; row < yGridNum-2; row++ )
43.             {
44.                node= Tlist[Index(col, row)] as Node;
45.  
46.                CalTnext(timeStep,node,col,row);
47.  
48.                node.T0=node.T;
49.             }
50.          }
51.       }
52.  
53.  public functionCalTnext(timeStep:Number,node:Node,col:uint,row:uint):void
54.       {
55.  var conner:Boolean=false;
56.  var node_Adj:Node = null;
57.  
58.  var conductionHeat:Number= 0;
59.  
60.  //For Node on/in Connor or Edge
61.  var SxFix:Number=1;//Area Fix Factor For Non-Interior Region in X Direction
62.  var SyFix:Number=1;//Area Fix Factor For Non-Interior Region in Y Direction
63.  
64.  var VolFix:Number=1;//Volume Fix Factor For Non-Interior Region in Y Direction
65.  
66.  if(((col==2)&&(row==2))||((col==2)&&(row==yGridNum-3))||((col==xGridNum-3)&&(row==2))||((col==xGridNum-3)&&(row==yGridNum-3)))
67.          {
68.             SxFix=1/2.0;
69.             SyFix=1/2.0;
70.  
71.             conner=true;
72.          }
73.  
74.  if((col==2)||(col==xGridNum-3))
75.          {
76.             VolFix/=2;
77.  
78.  if(!conner)
79.             {
80.                SyFix=1/2.0;
81.             }
82.          }
83.  
84.  if((row==2)||(row==yGridNum-3))
85.          {
86.             VolFix/=2;
87.  
88.  if(!conner)
89.             {
90.                SxFix=1/2.0;
91.             }
92.          }
93.  
94.          node_Adj= Tlist[Index(col+1, row)] as Node;
95.          conductionHeat+=node.eHeatExchangeFactor*(node_Adj.T0-node.T0)*Sx*SxFix;
96.  
97.          node_Adj= Tlist[Index(col-1, row)] as Node;
98.          conductionHeat+=node.wHeatExchangeFactor*(node_Adj.T0-node.T0)*Sx*SxFix;
99.  
100.         node_Adj= Tlist[Index(col, row+1)] as Node;
101.         conductionHeat+=node.nHeatExchangeFactor*(node_Adj.T0-node.T0)*Sy*SyFix;
102. 
103.         node_Adj= Tlist[Index(col, row - 1)] as Node;
104.         conductionHeat+=node.sHeatExchangeFactor*(node_Adj.T0-node.T0)*Sy*SyFix;
105. 
106. var dT:Number =conductionHeat * timeStep;
107.         dT/= cellVol * VolFix * node.Rho * node.Cp;
108. 
109.         node.T= node.T0 + dT;
110.      }
111. 
112. public functionLatentHeatRelease(node:Node):void
113.      {
114. 
115.      }
116. 
117. //Apply the Boundary Condition
118. public functionApplyBC():void
119.      {
120. 
121.      }
122. 
123. private functionIndex(col:uint=0,row:uint=0):uint
124.      {
125. return row * xGridNum + col;
126.      }
127.   }
128.}

简单吧,需要注意的是不同位置的节点其传热面积以及控制体体积不尽相同,需要Fix一下。可以预见,如果将SxFix、SyFix,VolFix设置为Node类的成员变量,计算会更快。这里给出初步的计算结果(迭代100s的结果)。目前笔者没有贴出所有代码,这时按照笔者提供的程序是无法运行的,读者想想,还缺点什么?

将其对称得到整个界面:

有点样子了,这还不是最终的计算结果,凝固潜热还没有考虑进去,可以使用物理意义明确的温度回升法处理。另外,我们没有离散偏微分方程,但是我们的方法和离散偏微分方程殊途同归的。

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2018-07-27,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 传输过程数值模拟学习笔记 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档