How can I simulate 2 materials in pde toolbox script?

조회 수: 9 (최근 30일)
Laura Pare
Laura Pare 2016년 9월 8일
답변: Moncef 2019년 7월 1일
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!
michio
michio 2016년 9월 16일
You are welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (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에서 General PDEs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by