3D温度分布 [英] 3D temperature distribution

查看:193
本文介绍了3D温度分布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我只是Matlab的入门者,因此该程序没有经过优化.现在,我只想让它运行.这是具有边界条件的3D热问题.北方的温度固定,与底部的温度绝缘,并且我们在4个相邻边上的对流具有相同的h.当我运行它时,它并不能使我正确收敛.我具有解析和SolidWorks近似值,因此我知道在Matlab中得到的结果是错误的.有人可以告诉我. 感谢您的帮助.

First of all I am just a starter in Matlab, so the program is not optimized. For now I just want to get it running. This is a 3D heat problem with boundary conditions. Fixed temperature from the north, insulated from the bottom, and we have convection on the 4 surrounding sides with the same h. when I run it it does not give me the right convergences. I have the analytical and the solidworks approximations, so I know the results I get in Matlab are wrong. Could someone advise me please. Your help is appreciated.

%===Solution of the problem of 2D in the bookmarks:Case2a=====
clc;
close all;
clear all;

DX=0.01; % step size
DY=0.01;
DZ=0.01;
Lx= 0.6; %length along x-axis in cmn
Ly=0.4;   %length along y-axis
Lz=0.3;   %length along z-axis
Nx=Lx/DX+1;    %Number of nodes along x-axis
Nx=floor(Nx)+1; % I shouldn't add 1. I should get it automatically 
Ny=(Ly/DY+1);    %Number of nodes along y-axis
Ny=floor(Ny);
Nz=(Lz/DZ+1);
Nz=floor(Nz)+1;

K=2;
h=500;
T_inf=20;

X=0:DX:Lx;
Y=0:DY:Ly;
Z=0:DZ:Lz;

T=zeros(Nx,Ny,Nz);                                                            
% I added imaginary nodes outside then it gave me numbers

tol=1;
s=0; %s=2000 could be set as the maximum number of allowed iteration for 
example
err=1; 
T_old=1;

while err >=tol %&& s<2001
    s=s+1;

%------------boundary conditions------------------------------------------

%====North temperature (Boundary)
T(:,Ny,:)=90;  
%===South Boundary "insulation" ==============
for k=1:Nz
    for i=2:Nx-1
   T(i,1,k)=0.25*[2*T(i,2,k)+T(i-1,1,k)+T(i+1,1,k)];
  %T(i-1,1,k)=4* T(i,1,k)-2*T(i,2,k)-T(i+1,1,k);
    end
end
%================Back Boundary "Convection" ================
for j=2:Ny-1 %changed
    for i=2:Nx-1
  T(i,j,1)=0.5*K/(h*DX+2*K)*[2*T(i,j,2)+T(i-1,j,1)+T(i+1,j,1)+2*h*DX*T_inf/K];
    end
end
%================Front Boundary "Convection" ================
for j=2:Ny-1
    for i=2:Nx-1
  T(i,j,Nz)=0.5*K/(h*DX+2*K)*[2*T(i,j,Nz-1)+T(i-1,j,Nz-1)+T(i+1,j,Nz-1)+2*h*DX*T_inf/K];
    end
end

%================West Boundary "Convection" ================
for j=2:Ny-1
for k=2:Nz-1
  T(1,j,k)=0.5*K/(h*DX+2*K)*[2*T(2,j,k)+T(1,j,k-1)+T(1,j,k+1)+2*h*DX*T_inf/K];
    end
end
%================East Boundary "Convection" ================
for j=2:Ny-1
    for k=2:Nz-1
  T(Nx,j,k)=0.5*K/(h*DX+2*K)*[2*T(Nx-1,j,k)+T(Nx,j,k-1)+T(Nx,j,k+1)+2*h*DX*T_inf/K];
    end
end



% The interior nodes
for k = 2:Nz-1 % I think it needs to go loop by loop(pairs of loops)
    for j = 2:Ny-1
        for i=2:Nx-1
    T(i,j,k)=(1/6)*(T(i-1,j,k)+T(i+1,j,k)+T(i,j-1,k)+T(i,j+1,k)+T(i,j,k-1)+T(i,j,k+1));
        end
    end
end
err=max(max(abs(T-T_old)));
T_old=T;
end

T=rot90(T)

推荐答案

我提供的代码是给我一个3d矩阵,其垂直边全为零.我所做的就是为垂直边缘创建了其他4个循环,但是最后我得到了底部4个角均为零的值.我所做的是平均每个角落的3个相邻温度.这样我就有了一个3D全矩阵.现在它正在工作,我只需要弄清楚如何绘制它.谢谢大家的建议.

The code I provided was giving me a 3d matrix with the vertical edges being all zeros. all I did was that I created 4 other loops for the vertical edges, but then I ended up with the bottom 4 corners having zero values. What i did was averaging the 3 neighboring temperatures of each corner. That way I have a 3d full matrix. Now it is working and I just have to figure out how to plot it. Thank you everyone for the suggestions.

这篇关于3D温度分布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆