%Alexander Bazzi
%Center for Advanced Turbomachinery and Energy Research
%Propulsion and Energy Research Laboratory
%% 2D STEADY-STATE HEAT DIFFUSION WITH SOURCES %%
clear all;
%% variable declarations
nx = 30;
ny = 30;
dy = 0.1;
dx = dy;
tol = 10^-3;
maxIt = 5000;
guess = 300;
temp = 10^5;
k = 1000; %thermal conductivity of material
t = 0.01; %thickness of plate
areaX = t*dx;
areaY = t*dy;
q = 5*10^7; %heat flux (heat generation) [W/m^2]
count = 1;
%% boundary conditions
N_TEMP = 100;
E_TEMP = 100;
W_TEMP = 100;
S_TEMP = 100;
N_FLUX = 100;
E_FLUX = 0;
W_FLUX = 0;
S_FLUX = 0;
%% matrix initializations
T(nx,ny) = guess;
oldT(nx,ny) = guess - 100;
T(1,:) = N_TEMP;
T(nx,:) = S_TEMP;
T(:,1) = W_TEMP;
T(:,ny) = E_TEMP;
disp(T);
W_COEFF = k*areaX/dx;
E_COEFF = W_COEFF;
N_COEFF = W_COEFF;
S_COEFF = W_COEFF;
%% iterating subroutine
for i = 1:maxIt
%% west boundary
for i = 1:ny %west boundary
if W_FLUX == 0
break;
end
w = 0;
e = E_COEFF;
s = S_COEFF;
n = N_COEFF;
source = W_FLUX*areaX;
if i == 1 && source ~= 0 %north/west corner
n = 0;
T(i,1) = temperature2d(i, 1, T, 'nw', w, e, s, n, source);
elseif i == ny && source ~= 0 %south/west corner
s = 0;
T(i,1) = temperature2d(i, 1, T, 'sw', w, e, s, n, source);
elseif i ~= 1 && i ~= ny %along west boundary
T(i,1) = temperature2d(i, 1, T, 'w', w, e, s, n, source);
end
end
%% east boundary
for i = 1:ny
if E_FLUX == 0
break;
end
w = W_COEFF;
e = 0;
s = S_COEFF;
n = N_COEFF;
source = E_FLUX*areaX;
if i == 1 %north/east corner
n = 0;
T(i,nx) = temperature2d(i, nx, T, 'ne', w, e, s, n, source);
elseif i == ny %south/east corner
s = 0;
T(i,nx) = temperature2d(i, nx, T, 'se', w, e, s, n, source);
elseif i ~= 1 && i ~= ny %along east boundary
T(i,nx) = temperature2d(i, nx, T, 'e', w, e, s, n, source);
end
end
%% north boundary
for j = 1:nx
if N_FLUX == 0
break;
end
w = W_COEFF;
e = E_COEFF;
s = S_COEFF;
n = 0;
source = N_FLUX*areaY;
if j == 1 %north/west corner
w = 0;
T(1,j) = temperature2d(1, j, T, 'nw', w, e, s, n, source);
elseif j == nx %north/east corner
e = 0;
T(1,j) = temperature2d(1, j, T, 'ne', w, e, s, n, source);
elseif j ~= 1 && j ~= ny %along north boundary
T(1,j) = temperature2d(1, j, T, 'n', w, e, s, n, source);
end
end
%% south boundary
for j = 1:nx
if S_FLUX == 0
break;
end
w = W_COEFF;
e = E_COEFF;
s = 0;
n = N_COEFF;
source = S_FLUX*areaY;
if j == 1 %south/west corner with generation
w = 0;
T(ny,j) = temperature2d(ny, j, T, 'sw', w, e, s, n, source);
elseif j == nx %south/east corner with generation
e = 0;
T(ny,j) = temperature2d(ny, j, T, 'se', w, e, s, n, source);
elseif j ~= 1 && j ~= ny %along south boundary
T(ny,j) = temperature2d(ny, j, T, 's', w, e, s, n, source);
end
end
%% interior nodes
for i = 2:ny - 1
for j = 2:nx - 1
w = W_COEFF;
e = E_COEFF;
s = S_COEFF;
n = N_COEFF;
source = 0;
%{
residual(count, resCount) = abs(temperature2d(i, j, T, 'interior', w, e, s, n, source) - T(i,j));
resCount = resCount + 1;
T(i,j) = temperature2d(i, j, T, 'interior', w, e, s, n, source);
itConv(count + 1) = abs(T(i,j) - oldT(i,j));
if itConv(count + 1) < temp
itConv(count + 1) = temp;
end
temp = itConv(count + 1);
%}
residual(i-1,j-1) = abs(temperature2d(i, j, T, 'interior', w, e, s, n, source) - T(i,j));
T(i,j) = temperature2d(i, j, T, 'interior', w, e, s, n, source);
itConv(i-1,j-1) = abs(T(i,j) - oldT(i,j));
oldT(i,j) = T(i,j);
end
end
res(count) = norm(residual, 2);
conv(count) = norm(itConv, 2);
if mod(count,80) == 0
fprintf('residual:%5.2e\n', res(count));
fprintf('convergence:%5.2e\n', conv(count));
end
if res(count) < tol && conv(count) < tol
break;
end
count = count + 1;
end
%% visualizing the results
contourplot(T, 'jet', min(min(T)), max(max(T)));
meshplot(T, nx, ny);
没有合适的资源?快使用搜索试试~ 我知道了~
物理应用基于matlab求解矩形板上二维温度分布【含Matlab源码 2219期】.zip
共6个文件
m:4个
jpg:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 162 浏览量
2022-11-15
15:41:47
上传
评论
收藏 54KB ZIP 举报
温馨提示
CSDN海神之光上传的全部代码均可运行,亲测可用,尽我所能,为你服务; 1、代码压缩包内容 主函数:twodheatconduction.m; 调用函数:其他m文件;无需运行 运行结果效果图; 2、代码运行版本 Matlab 2019b;若运行有误,根据提示修改;若不会,可私信博主; 3、运行操作步骤 步骤一:将所有文件放到Matlab的当前文件夹中; 步骤二:双击打开twodheatconduction.m文件; 步骤三:点击运行,等程序运行完得到结果; 4、物理应用 仿真:导航、地震、电磁、电路、电能、机械、工业控制、水位控制、直流电机、平面电磁波、管道瞬变流 光学:光栅、杨氏双缝、单缝、多缝、圆孔、矩孔衍射、夫琅禾费、干涉、拉盖尔高斯、光束、光波、涡旋 定位问题:chan、taylor、RSSI、music、卡尔曼滤波UWB 气动学:弹道、气体扩散、龙格库弹道 运动学:倒立摆、泊车 天体学:卫星轨道、姿态
资源推荐
资源详情
资源评论
收起资源包目录
【物理应用】基于matlab求解矩形板上二维温度分布【含Matlab源码 2219期】.zip (6个子文件)
【物理应用】基于matlab求解矩形板上二维温度分布【含Matlab源码 2219期】
diffusion_2D-master
temperature2d.m 894B
twodheatconduction.m 5KB
meshplot.m 160B
contourplot.m 319B
运行结果1.jpg 20KB
运行结果2.jpg 40KB
共 6 条
- 1
资源评论
海神之光
- 粉丝: 3w+
- 资源: 2093
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功