How can I simulate 2 materials in pde toolbox script?

24 次查看(过去 30 天)
In order to simulate 2 materials in a heat diffusion equation I define 2 different geometries, but then how I define the different coefficients for each material? One has heat source and the other hasn't. I am doing it as shown bellow, but the results are not what I would expect, so I am wondering if I am doing it right. There is another way to do that? Do I need to define 2 diff. equations instead?
Thank you very much in advance,
Here is my script:
numberOfPDE = 1;
model = createpde(numberOfPDE);
r1 = [3,4,0,0,0.5*10^-6,0.5*10^-6,-160*10^-9,-1.16*10^-6,-1.16*10^-6,-160*10^-9];
r2 = [3,4,0,0,0.5*10^-6,0.5*10^-6,0,-160*10^-9,-160*10^-9,0];
gdm = [r1; r2]';
g = decsg(gdm,'R1+R2',['R1'; 'R2']');
geometryFromEdges(model,g);
specifyCoefficients(model,'m',0,'d',5,'c',16,'a',0,'f',0,'face',1);
specifyCoefficients(model,'m',0,'d',5,'c',50,'a',0,'f',2*10^18,'face',2);
applyBoundaryCondition(model,'edge',1,'r',298);
applyBoundaryCondition(model,'edge',2,'q',2000,'g',596000);
applyBoundaryCondition(model,'edge',3,'g',0);
applyBoundaryCondition(model,'edge',4,'g',0);
applyBoundaryCondition(model,'edge',6,'g',0);
applyBoundaryCondition(model,'edge',7,'g',0);
hmax = 2*10^-8; % element size
msh=generateMesh(model,'Hmax',hmax);
tinitial = 0;
tfinal = 2*10^-8;
interval = 100;
tlist = linspace(tinitial,tfinal,interval);
u0 = 298; % initial temperature in the geometry
setInitialConditions(model,u0);
results = solvepde(model,tlist);
u = result.NodalSolution;
%Plot the solution at time t = tfinal.
figure;
pdeplot(model,'xydata',results.NodalSolution,'contour','on')
  2 个评论
michio
michio 2016-9-8
It seems to me that you are doing alright in specifying different coefficients for different sub-domains. I assume two different materials are represented by the two sub-domains.
specifyCoefficients(model,'m',0,'d',5,'c',16,'a',0,'f',0,'face',1);
specifyCoefficients(model,'m',0,'d',5,'c',50,'a',0,'f',2*10^18,'face',2);
It may help us help you if you describe more about your issues, your problem settings, what part of the result is not what you expect.
Laura Monreal
Laura Monreal 2016-9-14
Hi Michio,
I changed my name because I had problems with the other sesion. Thank you for you answer. So, in fact my f coefficient for the subdomain 2 is a cosinus that I do not see in the simulation, but i see it when I simulatet the "material" 2 byitself. I think I am not getting the result I spect because of the mesh, there is a way to introduce different meshing for different subdomains? I saw that you can not implement refinemesh usind a PDEmodel, so how should I do it?
Thank you in advance

请先登录,再进行评论。

采纳的回答

michio
michio 2016-9-14
编辑:michio 2016-9-15
Thanks for your clarification. As you have already made use of it, but sub-domain support is available for 2D problems, so yes you can simulate 2 materials using PDE Toolbox.
If your issue is really caused by meshing, you can try legacy workflow that supports refinement. This entry might be of your help. How can I refine a subdomain in the PDE Toolbox mesh generation tool?
I didn't understand the details since you mentioned "my f coefficient for the subdomain 2 is a cosinus". If your f coefficient needs to be expressed as some function of space, you can try defining f coefficient in a functional form. The related doc page is f Coefficient for specifyCoefficients
  6 个评论
Laura Pare
Laura Pare 2016-9-16
It works perfectly,
Thank you very much for your help Michio!

请先登录,再进行评论。

更多回答(2 个)

Alan Weiss
Alan Weiss 2016-9-8
You might like the plot better if you plot the end time rather than the initial time:
pdeplot(model,'xydata',results.NodalSolution(:,end))
I am not sure that you have scaled things correctly, because I see very little difference between this plot and the plot at the second time step:
figure;pdeplot(model,'xydata',results.NodalSolution(:,2))
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
  1 个评论
Laura Pare
Laura Pare 2016-9-8
Hi Alan,
Thank you for your answer. You are right about the time, I copied that part of the script wrong.
But then, is that the way to simulate two different materials with different coefficients?
I also saw something separating the coefficients by ! , but I didn't get how to do it: http://es.mathworks.com/help/pde/ug/scalar-coefficients-in-string-form.html?searchHighlight=subdomains
Shoudn't I simulate 2 differential equations then?
Thanks,

请先登录,再进行评论。


Moncef
Moncef 2019-7-1
Hello,
please how to introduce the c coeffecient which is has matrix form:
c = [x-y, 0; 1, x.^2]
using "specifyCoefficients" matlab command?
With best regards

类别

Help CenterFile Exchange 中查找有关 Geometry and Mesh 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by