首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MatLab PDE标绘问题

MatLab PDE标绘问题
EN

Stack Overflow用户
提问于 2015-02-06 11:52:43
回答 1查看 685关注 0票数 0

我对Matlab环境非常陌生,我正在Matlab (2014 B)中进行传热模拟。我打算有一个多层墙的不同材料(目前,只有一个单一的材料-铜),并显示在一个单一的结果在一个地方。一切都很顺利,直到我试图把第三层墙贴在情节上。以下是PDE求解器(R3-R0)基本变量和几何的定义:

代码语言:javascript
复制
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];

下面的代码计算了输入温度为1000 K的壁面底部层(r3)的传热情况:

代码语言:javascript
复制
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)”(前一层的输出),然后是最后一段代码:

代码语言:javascript
复制
hold off
axis([0,1,0,2])
caxis manual
caxis([u(4) 1000]);
colorbar; 

就像我说的,这一切都是可行的,第一层和第二层的结果都在同一个地块中。但是,在我重复第三层(r1)的过程,并将结果绘制为原始图(当然,“等待”位位于代码的末尾)之后,该图只显示第三层的结果。我不确定这是Matlab的一些限制,或者我的解决方案是错误的,所以我想寻求一些帮助或一些方向。提前感谢

以下是更好理解的完整代码:

代码语言:javascript
复制
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]);
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-02-06 15:17:36

由于某些原因(我并不完全清楚),pdeplot函数内部调用hold off

因此,要获得所需的结果,需要在每次调用hold on之后添加一个pdeplot

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28365199

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档