【发布时间】:2015-02-06 11:52:43
【问题描述】:
我对 Matlab 环境很陌生,我正在 Matlab (2014b) 中进行传热模拟。我打算有一个不同材料的多层墙(目前,只有一种材料 - 铜)并在一个图中显示结果。在我尝试将墙的第三层附加到情节之前,一切正常。 以下是 PDE 求解器 (r3-r0) 的基本变量和几何定义:
k = 400;
rho = 8960;
specificHeat = 386;
thick = .01;
stefanBoltz = 5.670373e-8;
hCoeff = 1;
ta = 300;
emiss = .5;
c = thick*k;
a = sprintf('2*%g + 2*%g*%g*u.^3', hCoeff, emiss, stefanBoltz);
f = 2*hCoeff*ta + 2*emiss*stefanBoltz*ta^4;
d = thick*rho*specificHeat;
r0 = [3 4 0 1 1 0 1 1 1.3 1.3];
r1 = [3 4 0 1 1 0 0.6 0.6 1 1];
r2 = [3 4 0 1 1 0 0.3 0.3 0.6 0.6];
r3 = [3 4 0 1 1 0 0 0 0.3 0.3];
现在,以下代码计算通过墙底层 (r3) 的热传递,输入温度为 1000 K:
gdm = r3';
g = decsg(gdm, 'R3', ('R3')');
hmax = .1; % element size
[p, e, t] = initmesh(g, 'Hmax', hmax);
numberOfPDE = 1;
pb = pde(numberOfPDE);
pg = pdeGeometryFromEdges(g);
uBottom = pdeBoundaryConditions(pg.Edges(1),'u',1000);
pb.BoundaryConditions = uBottom;
u = pdenonlin(pb,p,e,t,c,a,f, 'jacobian', 'lumped');
fprintf('Temperature at the top edge of the plate = %5.1f degrees-K\n', ...
u(4));
figure
pdeplot(p, e, t, 'xydata', u, 'contour', 'on', 'colormap', 'jet')
hold on
在“hold on”之后,我基本上对“r2”矩形重复前面的代码,输入温度为“u(4)”(上一层的输出),然后是最后一段代码:
hold off
axis([0,1,0,2])
caxis manual
caxis([u(4) 1000]);
colorbar;
正如我所说,这一切正常,第一层和第二层的结果都在同一个图中。但是在我对第三层(r1)重复该过程并将结果绘制到原始图形中之后(当然,“延迟”位在代码的最后),该图仅显示结果第三层。我不确定这是否是 Matlab 的一些限制,或者我的解决方案是否错误,所以我想寻求一些帮助或一些指导。提前致谢
下面是完整的代码以便更好地理解:
k = 400;
rho = 8960;
specificHeat = 386;
thick = .01;
stefanBoltz = 5.670373e-8;
hCoeff = 1;
ta = 300;
emiss = .5;
c = thick*k;
a = sprintf('2*%g + 2*%g*%g*u.^3', hCoeff, emiss, stefanBoltz);
f = 2*hCoeff*ta + 2*emiss*stefanBoltz*ta^4;
d = thick*rho*specificHeat;
r0 = [3 4 0 1 1 0 1 1 1.3 1.3];
r1 = [3 4 0 1 1 0 0.6 0.6 1 1];
r2 = [3 4 0 1 1 0 0.3 0.3 0.6 0.6];
r3 = [3 4 0 1 1 0 0 0 0.3 0.3];
%---------------------------------------------------------
gdm = r3';
g = decsg(gdm, 'R3', ('R3')');
hmax = .1; % element size
[p, e, t] = initmesh(g, 'Hmax', hmax);
numberOfPDE = 1;
pb = pde(numberOfPDE);
pg = pdeGeometryFromEdges(g);
uBottom = pdeBoundaryConditions(pg.Edges(1),'u',1000);
pb.BoundaryConditions = uBottom;
u = pdenonlin(pb,p,e,t,c,a,f, 'jacobian', 'lumped');
fprintf('Temperature at the top edge of the plate = %5.1f degrees-K\n', ...
u(4));
figure
pdeplot(p, e, t, 'xydata', u, 'contour', 'on', 'colormap', 'jet')
hold on
%----------------------------------------------------------------------
gdm = r2';
g = decsg(gdm, 'R2', ('R2')');
hmax = .1; % element size
[p, e, t] = initmesh(g, 'Hmax', hmax);
numberOfPDE = 1;
pb = pde(numberOfPDE);
pg = pdeGeometryFromEdges(g);
uBottom = pdeBoundaryConditions(pg.Edges(1),'u',u(4));
pb.BoundaryConditions = uBottom;
u = pdenonlin(pb,p,e,t,c,a,f, 'jacobian', 'lumped');
fprintf('Temperature at the top edge of the plate = %5.1f degrees-K\n', ...
u(4));
pdeplot(p, e, t, 'xydata', u, 'contour', 'on', 'colormap', 'jet')
%----------------------------------------------------------------------------
gdm = r1';
g = decsg(gdm, 'R1', ('R1')');
hmax = .1; % element size
[p, e, t] = initmesh(g, 'Hmax', hmax);
numberOfPDE = 1;
pb = pde(numberOfPDE);
pg = pdeGeometryFromEdges(g);
uBottom = pdeBoundaryConditions(pg.Edges(1),'u',u(4));
pb.BoundaryConditions = uBottom;
u = pdenonlin(pb,p,e,t,c,a,f, 'jacobian', 'lumped');
fprintf('Temperature at the top edge of the plate = %5.1f degrees-K\n', ...
u(4));
pdeplot(p, e, t, 'xydata', u, 'contour', 'on', 'colormap', 'jet')
%----------------------------------------------------------------------------
gdm = r0';
g = decsg(gdm, 'R0', ('R0')');
hmax = .1; % element size
[p, e, t] = initmesh(g, 'Hmax', hmax);
numberOfPDE = 1;
pb = pde(numberOfPDE);
pg = pdeGeometryFromEdges(g);
uBottom = pdeBoundaryConditions(pg.Edges(1),'u',u(4));
pb.BoundaryConditions = uBottom;
u = pdenonlin(pb,p,e,t,c,a,f, 'jacobian', 'lumped');
fprintf('Temperature at the top edge of the plate = %5.1f degrees-K\n', ...
u(4));
pdeplot(p, e, t, 'xydata', u, 'contour', 'on', 'colormap', 'jet')
%hold off
axis([0,1,0,2])
%caxis manual
caxis([u(4) 1000]);
【问题讨论】:
-
最后一个
hold off和末尾的caxis manual都不需要。您可以删除它们。 -
谢谢,但这仍然不能解决我的问题,即绘图只显示一层墙
-
你能发布你的整个程序吗?
-
我将它添加到主帖中,基本上你可以删除任何两层 - 例如以“gdm = r0”开头的部分和以“gdm = r2”开头的部分 - 它会起作用(例外是必须在边界条件中定义其输入温度的第一层)。但是对于三层或多层材料,只有最后一层被绘制