包含对流环热,热流边界,等温边界的稳态热传导方程的FEM求解。

以下面的问题为例:对于如图所示的平面传热问题,

若上端有给定的热流-2W/m2,即从下往上传输热量,结构下端有确定的温度100°,周围介质温度为20°,在两侧有换热,换热系数为α=100W/㎡/K,热导率200W/m/K,试分析其稳定温度场。

 

使用下面的程序包进行求解:

首先:

将区域划分为4个单元,各单元包含的节点在element3.dat中显示:

1 2 4
2 5 4
2 6 5
2 3 6

每个节点的横纵坐标在coordinates.dat文件中显示:

-10 0
0 0
10 0
-5 10
0 10
5 10

边界包含三个:

恒温边界的节点编号,在dirichelet.dat文件中显示:

1 2
2 3

热流边界的节点编号在neumann.dat文件中显示:

4 5
5 6

对流环热边界的节点编号在convective.dat文件中显示:

3 6
1 4

 

下面介绍使用到的程序:

主程序Heat_conduction_steady.m

View Code
%*****************************************************************************
%
%    The unknown state variable U(x,y) is assumed to satisfy
%    Poisson's equation (steady heat conduction equation):
%      -K(Uxx(x,y) + Uyy(x,y)) = qv(x,y) in Omega
%    here qv means volumetric heat generation rate,K is thermocal
%    conductivity
%    
%    clearclose all
%  Read the nodal coordinate data file.load coordinates.dat;
%  Read the triangular element data file.load elements3.dat;
%  Read the Neumann boundary condition data file.
%  I THINK the purpose of the EVAL command is to create an empty NEUMANN array
%  if no Neumann file is found.eval ( 'load neumann.dat;', 'neumann=[];' );
%  Read the Dirichlet boundary condition data file.load dirichlet.dat;
%  Read the Convective heat transfer boundary condition data file.eval ( 'load Convective.dat;', 'Convective=[];' );
alpha=100;% Convective heat transfer coefficient
tf=20;% ambient temperature
q=-2;% Surface heat flux at Neumann boundary condition
K=200;% Thermal conductivityA = sparse ( size(coordinates,1), size(coordinates,1) );b = sparse ( size(coordinates,1), 1 );
%
%  Assembly.if ( ~isempty(Convective) )for j = 1 : size(elements3,1)A(elements3(j,:),elements3(j,:)) = A(elements3(j,:),elements3(j,:)) ...+ stima3(coordinates(elements3(j,:),:),K) ...+ stima3_1(coordinates(elements3(j,:),:),elements3(j,:),Convective,alpha);endelsefor j = 1 : size(elements3,1)A(elements3(j,:),elements3(j,:)) = A(elements3(j,:),elements3(j,:)) ...+ stima3(coordinates(elements3(j,:),:),K);endend%  Volume Forces.
%
% from the center of each element to Nodes
% Notice that the result of f here means qv/K instead of qvfor j = 1 : size(elements3,1)b(elements3(j,:)) = b(elements3(j,:)) ...+ det( [1,1,1; coordinates(elements3(j,:),:)'] ) * ...f(sum(coordinates(elements3(j,:),:))/3)/6;end
%  Neumann conditions.if ( ~isempty(neumann) )for j = 1 : size(neumann,1)b(neumann(j,:)) = b(neumann(j,:)) + ...norm(coordinates(neumann(j,1),:) - coordinates(neumann(j,2),:)) * ...g(sum(coordinates(neumann(j,:),:))/2,q)/2;endend%  Convective heat transfer boundary condition.if ( ~isempty(Convective) )for j = 1 : size(Convective,1)b(Convective(j,:)) = b(Convective(j,:)) + ...norm(coordinates(Convective(j,1),:) - coordinates(Convective(j,2),:)) * ...h(sum(coordinates(Convective(j,:),:))/2,tf,alpha)/2;endend
%
%  Determine which nodes are associated with Dirichlet conditions.
%  Assign the corresponding entries of U, and adjust the right hand side.
%u = sparse ( size(coordinates,1), 1 );BoundNodes = unique ( dirichlet );u(BoundNodes) = u_d ( coordinates(BoundNodes,:) );b = b - A * u;
%
%  Compute the solution by solving A * U = B for the remaining unknown values of U.
%FreeNodes = setdiff ( 1:size(coordinates,1), BoundNodes );u(FreeNodes) = A(FreeNodes,FreeNodes) \ b(FreeNodes);
%
%  Graphic representation.figuretrisurf ( elements3, coordinates(:,1), coordinates(:,2), (full ( u )));
view(2)
colorbar
shading interp
xlabel('x')

热传导确定的单元刚度矩阵的子程序stima3.m

View Code
function M = stima3 ( vertices ,K)%*****************************************************************************80
%
%% STIMA3 determines the local stiffness matrix for a triangular element.
%
%  Parameters:
%
%    Input, 
%   real VERTICES(3,2), contains the 2D coordinates of the vertices.
%   K: thermal conductivity
%    Output, 
%   real M(3,3), the local stiffness matrix for the element.
%d = size ( vertices, 2 );D_eta = [ ones(1,d+1); vertices' ] \ [ zeros(1,d); eye(d) ];
M = det ( [ ones(1,d+1); vertices' ] ) * D_eta * D_eta' / prod ( 1:d );
M=M*K;

由对流换热确定的单元刚度矩阵的子程序stima3_1.m

View Code
function M = stima3 ( vertices,elements ,Convective,alpha)
%*****************************************************************************80
%% STIMA3 determines the local stiffness matrix for a triangular element.
%  Parameters:
%    Input, 
%   real VERTICES(3,2), contains the 2D coordinates of the vertices.
%   elements(3,1), the node index of local element
%   Convective(N,2), node index of each boundaryline of convective heat
%   transfer boundary
%   alpha, convective heat transfer coefficient
%    Output, 
%   real M(3,3), the local stiffness matrix  for the element.
%
M=zeros(3,3);
for i1=1:length(Convective)temp1=ismember(elements,Convective(i1,:));if sum(temp1) == 2temp2=find(temp1 == 0);if temp2 == 1ijm=23;elseif temp2 == 2ijm=31;elseif temp2 == 3ijm=12;endswitch ijmcase 12S=norm(vertices(2,:)-vertices(1,:));M=M+alpha*S/6*[2 1 0;1 2 0;0 0 0];case 23S=norm(vertices(3,:)-vertices(2,:));M=M+alpha*S/6*[0 0 0;0 2 1;0 1 2;];case 31S=norm(vertices(3,:)-vertices(1,:));M=M+alpha*S/6*[2 0 1;0 0 0;1 0 2;];end     end
end

由内生热导致的载荷项f.m:

View Code
function value = f ( u )%*****************************************************************************80%%% F evaluates the right hand side of Laplace's equation. NOtice that F is qv/K instead of qv.%%%    This routine must be changed by the user to reflect a particular problem.%%%  Parameters:%%    Input, real U(N,M), contains the M-dimensional coordinates of N points.%%    Output, VALUE(N), contains the value of the right hand side of Laplace's%    equation at each of the points.%n = size ( u, 1 );value(1:n) = zeros(n,1);

由热流边界计算的载荷项g.m:

View Code
function value = g ( u,q )%*****************************************************************************80%% G evaluates the outward normal values assigned at Neumann boundary conditions.%  Parameters:%    Input, %    real U(N,2), contains the 2D coordinates of N points.%    q: surface heat flux at Neumann boundary%    Output, %   VALUE(N), contains the value of outward normal at each point%    where a Neumann boundary condition is applied.%value = q*ones ( size ( u, 1 ), 1 );

由对流换热导致的载荷项h.m:

View Code
function value = h ( u,tf,alpha)%****************************************************************************%%  evaluates the Convective heat transfer force.%  Parameters:%    Input, %    real U(N,2), contains the 2D coordinates of N points.%    tf: ambient temperature at Convective boundary%    alpha: convective heat transfer coefficient%    Output, %   VALUE(N), contains the value of outward normal at each point%    where a Neumann boundary condition is applied.%value = alpha*tf*ones ( size ( u, 1 ), 1 );

恒温边界条件的引入u_d.m:

View Code
function value = u_d ( u )%*****************************************************************************80%%% U_D evaluates the Dirichlet boundary conditions.%%%    The user must supply the appropriate routine for a given problem%%%  Parameters:%%    Input, real U(N,M), contains the M-dimensional coordinates of N points.%%    Output, VALUE(N), contains the value of the Dirichlet boundary%    condition at each point.%value = ones ( size ( u, 1 ), 1 )*100;

 

上述程序,所得结果为:

 

 下面使用coord3.m程序自动将计算区域划分单元,且节点编号,边界条件的分配等。

View Code
% the coordinate index is from 1~Nx(from left to right) for the bottom line
% and then from Nx+1~2*Nx  (from left to right) for the next line above 
% and then next
xminl=-10;xmaxl=10;
xminu=-5;xmaxu=5;
ymin=0;ymax=10;
Nx=13;Ny=13;
y=linspace(ymin,ymax,Ny);
xmin=linspace(xminl,xminu,Ny);
xmax=linspace(xmaxl,xmaxu,Ny);
k=0;
for i1=1:Nyx=linspace(xmin(i1),xmax(i1),Nx);for i2=1:Nxk=k+1;Coord(k,:)=[x(i2),y(i1)];    end
endsave coordinates.dat Coord -ascii% the element index
k=0;
vertices=zeros((Nx-1)*(Ny-1)*2,3);
for i1=1:Ny-1for i2=1:Nx-1k=k+1;ijm1=i2+(i1-1)*Nx;ijm2=i2+1+(i1-1)*Nx;ijm3=i2+1+i1*Nx;vertices(k,:)=[ijm1,ijm2,ijm3];k=k+1;ijm1=i2+1+i1*Nx;ijm2=i2+i1*Nx;ijm3=i2+(i1-1)*Nx;vertices(k,:)=[ijm1,ijm2,ijm3];end
end
save elements3.dat vertices -ascii% The direchlet boundary condition (index of the two end nodes for each boundary line)
boundary=zeros(Nx-1,2);
temp1=1:Nx-1;
temp2=2:Nx;
temp3=1:Nx-1;
boundary(temp3',:)=[temp1',temp2'];
save dirichlet.dat boundary -ascii% The Neumann boundary condition (index of the two end nodes for each boundary line)
boundary=zeros(Nx-1,2);
temp1=(1:Nx-1)+(Ny-1)*Nx;
temp2=(2:Nx)+(Ny-1)*Nx;
temp3=1:Nx-1;
boundary(temp3',:)=[temp1',temp2'];
save neumann.dat boundary -ascii% The Convective heat transfer boundary condition (index of the two end nodes for each boundary line)
boundary=zeros((Ny-1)*2,2);
temp1=Nx*(1:Ny-1);
temp2=temp1+Nx;
temp3=1:Ny-1;
boundary(temp3',:)=[temp1',temp2'];
temp1=Nx*(Ny-1)+1:-Nx:Nx+1;
temp2=temp1-Nx;
temp3=temp3+Ny-1;
boundary(temp3',:)=[temp1',temp2'];
save Convective.dat boundary -ascii

划分的单元如下:

计算的温度场分布如下:

 

转载于:https://www.cnblogs.com/heaventian/archive/2012/12/04/2801606.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/434068.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

php安装扩展步骤,PHP扩展安装方法步骤解析

php扩展安装方法极简单. 也遵循3大步.但多出一个phpize的步骤.1.pecl.php.net 在右上解的输入框 中输入需要的扩展 比如 redis2.搜索完成后会看到两个蓝色的框 . 下方有个表格. 表格内容如 search results (1 of 1) 再下面有一行不起眼的结果. 其中就有一个redis(搜索什么显示什…

python生成动态二维码实例_python生成动态个性二维码(示例代码)

1 安装工具 2 生成普通二维码 3 带图片的二维码 4 动态 GIF 二维码 5 在Python程序中使用 一、安装 首先在python环境下运行, 打开cmd进入python27 进入scripts 然后在scripts输入命令:pip install myqr二、 生成普通二维码 安装了 myqr 之后&#xff0c…

MFC取消菜单栏

在CMainFrame的OnCreate()中添加如下代码://去掉标题栏及其他样式SetWindowLong(this->m_hWnd,GWL_STYLE,0);//去掉边框及其他样式SetWindowLong(this->m_hWnd,GWL_EXSTYLE,0);//取消菜单栏this->SetMenu(NULL); 在CView中的OnCreate()中也去掉边框 //去掉…

php的cookie变量作用,PHP语言中cookie的作用

PHP语言中cookie的作用时间:2015-11-9Cookie的概念最早是由Netscape在1994年提出来的,它是保存在浏览器中的小信息包,更确切地说,Cookie是保存在客户端硬盘里的,由字符串组成的小文本文件.文本文件的命令格式如下;用户名网站地址[数字].txt举个例子,如果用户在系统盘…

如何查看Linux版本号(内核版本号和发行版本号)

首先,要分清内核版本号和发行版本号的区别。 因为所有linux都是使用kernel.org上来的内核来作为发行版的基础的,所以内核版本号的高低大致能体现该linux版本的新旧。 而发行版本的版本号完全是各发行商自己定义的,不能用来和其它发行版本的版…

matlab武汉理工大学数值分析线性函数拟合实验_「首席架构师推荐」数值计算库精选...

这是一个著名的数值库列表,这些库用于软件开发中执行数值计算。它不是一个完整的列表,而是一个包含Wikipedia上文章的数字库列表,很少有例外。典型库的选择取决于一系列不同的需求,例如:期望的特性(例如:大维线性代数、并行计算、…

DCE和DTE的区别

DCE(数据通信设备或者数据电路终端设备):该设备和其与通信网络的连接构成了网络终端的用户网络接口。它提供了到网络的一条物理连接、转发业务量,并且提供了一个用于同步DCE设备和DTE设备之间数据传输的时钟信号。调制解调器和接口…

php 弹出保存对话框,如何在不将页面留在PHP中的情况下强制保存为对话框?

当使用StijnvanBael的代码时,请小心,它会使您面临一些严重的安全漏洞攻击。尝试以下方法:--- download.php ---$allowed_files array(file.pdf, otherfile.pdf);if (isset($_REQUEST[file]) && in_array($_REQUEST[file], $allowed_files)){$filename $_REQUEST[file…

JSONP跨域原理和jQuery.getJSON用法

JSONP是一个非官方的协议,它允许在服务器端集成Script tags返回至客户端,通过javascript callback的形式实现跨域访问(这仅仅是JSONP简单的实现形式)。本文主要介绍JSONP跨域原理,一起来看。 JSONP是一个非官方的协议&…

window10安装python2.7_window10下python2.7安装pip报错

get-pip.py 文件内容来源于(将网页内容保存) https://bootstrap.pypa.io/get-pip.py 报错信息 D:\softs\python\Python27>python get-pip.py DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 wont…

DAHDI与Zaptel

1、DAHDI是什么? DAHDI表示DigiumAsterisk Hardware Device Interface,Zaptel是"ZapataTelephony"的缩写。 2、DAHDI的由来 Kevin Fleming是这样介绍DAHDI的来由的:“大约2006年,ZapTel商标的持有人找上我们&#x…

php判断桌面宽度,js获取页面宽度高度及屏幕分辨率

网页可见区域宽: document.body.clientWidth;网页可见区域高: document.body.clientHeight;网页可见区域宽: document.body.offsetWidth (包括边线的宽);网页可见区域高: document.body.offsetHeight (包括边线的宽);网页正文全…

串口输出5v电压_为什么RS485比串口速度快距离远?--谈单端信号与差分信号之差异...

嵌入式系统中,串口、RS485、CAN、网络和USB等都是非常常用的通信方式。但是串口通信速度慢,距离近,为什么转换成RS485后,通信距离和速度都大幅提高了呢?USB也是近距离,为什么速度可以这么快?原因…

IIS7.0站点/虚拟目录中访问共享

目的:实现一个2008serve的IIS的虚拟目录(通过网络路径(UNC)的形式,共享在另外一个2008服务器上) 准备工作1.运行组策略编辑器(gpedit.msc);找到本地安全策略-本地策略-安…

易语言操作php文本文件,易语言对文本操作的步骤教学

在易语言编程中,我们往往需要对一些文字进行截取或分割出来,如何准确、快速的实现这一目标呢?下面笔者来为大家演示1、首先,我们打开易语言编程软件,点击左上角,新建一个文件,如图所示2、我们点…

Asterisk入门系列

什么是asterisk?开源电话平台 Asterisk 通过了电话的开源平台。基本上就是一个软件的PBX。 最初是Digium 公司的Mark Spencer编写的,这个公司就是他创立的,专门生产并销售Asterisk使用的硬件。Asterisk简直就是一场电话的革命。 为什么使用Asterisk&…

xxl-job 执行结果是空_xxljob dotnet core executor执行器开源

DotXxlJob[(github)https://github.com/xuanye/DotXxlJob][https://github.com/xuanye/DotXxlJob] xxl-job的dotnet core 执行器实现,支持XXL-JOB 2.01 XXL-JOB概述[XXL-JOB][1]是一个轻量级分布式任务调度平台,其核心设计目标是开发迅速、学习简单、轻量…

两千内给力的大屏手机(二)

一看标题就知道哈,这是接着上次来说的呢,上次介绍了四款手机,这次介绍剩下的四款,大家看好了啊 1、HTC T329t双核 你还没有忘记新渴望 VT这款产品吧,作为HTC和移动推出的性价比大众智能产品,新渴望 VT在上市…

php5.4 windows2003,PHP实战:Windows2003下php5.4安装配置教程(IIS)

《PHP实战:Windows2003下php5.4安装配置教程(IIS)》要点:本文介绍了PHP实战:Windows2003下php5.4安装配置教程(IIS),希望对您有用。如果有疑问,可以联系我们。PHP教程一、在Windows2003安装IISPHP教程1、首先打开Windo…

foxmail 怎么把邮件格式默认为html_Python SMTP发送邮件-smtplib模块

在进入正题之前,我们需要对一些基本内容有所了解:常用的电子邮件协议有SMTP、POP3、IMAP4,它们都隶属于TCP/IP协议簇,默认状态下,分别通过TCP端口25、110和143建立连接。Python内置对SMTP的支持,该协议支持…