MATLAB Answers

How to integrate PDE solution in 2D space?

17 views (last 30 days)
I am solving a time dependent PDE using solvepde. I want to numerically integrate the solution (at the end time, tf) over a 2D space on a semicircle (Face 2) in the geometry. The geometry I'm using is:
R1 = [3;4;-0.01;0.01;0.01;-0.01;-0.01;-0.01;0;0];
R2 = [3;4;-0.01;0.01;0.01;-0.01;0;0;0.01;0.01];
C1 = [1;0;0;Rg];
C1 = [C1;zeros(length(R1) - length(C1),1)];
gm = [R1,R2,C1];
sf = '(R1+C1)-R2';
ns = char('R1','R2','C1')';
g = decsg(gm,sf,ns);
geometryFromEdges(model,g);
figure
pdegplot(model,'EdgeLabels','on','FaceLabels','on');
I've tried using the following to get me in the right direction, but haven't been able to make any progress.
xq = -0.01:0.001:0.01;
yq = -(0.007317./2).*ones(size(xq));
uintrp = interpolateSolution(result,xq,yq);
No matter how I try to set up xq and yq, I always get the following error:
Error using pde.PDEResults/validatePointsMatrix (line 3)
Query point matrix does not contain coordinates of 2-D space in required format.
Can anyone help me?

  0 Comments

Sign in to comment.

Accepted Answer

Ravi Kumar
Ravi Kumar on 16 Jan 2020
If you are solving a single PDE, i.e., you used createpde(1) then you need to specify time-steps as the last argument. If you have a system of PDEs, then you need to also specify the component of solution:
uintrp = interpolateSolution(result,xq,yq,1:size(tlist));
where tlist is what you used in solvepde.
Regards,
Ravi

  3 Comments

Andrew Ferguson
Andrew Ferguson on 16 Jan 2020
Thanks for the help Ravi! I am able to get it to work now. However, when I compare the results of my 2D colormap using solvepde in pdeplot, it doesn't match the results of interpolateSolution. In solving the PDE initially I have an assymetric tspan to get a shorter interval initally and a longer one later.
tf = 12*60*60;
Ffast = 10;
Tf = 1/Ffast;
Nslow = 0.2;
tspan = [0:Tf:3600-Tf linspace(3600,tf,Nslow)];
Would this affect my results from interpolateSolution? Or do you have a thought on what may be affecting that?
Ravi Kumar
Ravi Kumar on 16 Jan 2020
I don't think asymmetry in tspan shouldn't matter. The interpolated solution grid could be coarser than the actual solution grid. Can you elaborate on what is the difference with images that compare them?
Regards,
Ravi
Andrew Ferguson
Andrew Ferguson on 16 Jan 2020
So I am solving the diffusion equation and have a component diffusing outward from the center of the semicircle and into the rest of the rectanglular shape. The colormap using solvepde displays a result that is expected - the concentration of the component decreases radially outward and decreases at the center from its initial value of 0.22. However, when I plot the results from interpolate solution, it shows that a large portion in the center of the semicircle is at 0.22 (which is untrue) and that a portion inside the semicircle is actually above 0.22, which isn't possible either.

Sign in to comment.

More Answers (0)

Sign in to answer this question.