我对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
在“保持”之后,我基本上重复了前面的“r2”矩形代码,输入温度为“u(4)”(前一层的输出),然后是最后一段代码:< / p>
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]);
答案 0 :(得分:1)
出于某种原因(我并不完全清楚)pdeplot
函数在内部调用hold off
。
因此,要获得所需的结果,您需要在每次调用hold on
后添加pdeplot
。