PDE toolbox: how to stop Edges from changing their number ID during iterative process?
2 views (last 30 days)
Show older comments
Hello,
I'm working with the Electromagnetic PDE toolbox. I have created a model and a geometry based on the example provided by Mathworks (https://uk.mathworks.com/help/pde/ug/current-density-between-two-metallic-conductors.html). I have added two rectangles between the circular metallic conductors in the form of:
R1 = [3,4,x11(i),x12(i),x13(i),x14(i),y11(i),y12(i),y13(i),y14(i)]';
R2 = [3,4,x21(i),x22(i),x23(i),x24(i),y21(i),y22(i),y23(i),y24(i)]';
These two rectangles increase in dimension with each iteration of i.
The rectangles at the iteration 1 have Edges labelled as 1 to 4 for R1, and 5 to 8 for the R2.
During the iterative process, the Edges of the rectangles change "ID". So, if previously R1 was made of Edge1, Edge2, Edge3 and Edge4, and R2 was made of Edge5, Edge 6, Edge7 and Edge8, after n-iterations R1 shows up as made of Edge 3, Edge 4, Edge5 and Edge6, while Edge1, Edge2, Edge7 and Edge8 makes R2. Essentially, the Edge IDs get shuffled between R1 and R2 in a way that I can't seem to understand.
I have noticed that this problem also happens during the initial 2-5 iterations, and then the Edges ID stay the same for the remaining hundreds iterations.
This, of course, messes up my numerical simulation.
Any idea on how to "stick" the Edge number to the geometry so that it doesn't change during the iterative process?
Thank you in advance for the support.
Stefano
1 Comment
Answers (1)
Rangesh
on 7 Nov 2023
Hi Stefano,
I understand that you are trying to resolve the issue of changing edges for an iterative process. I have tried reproducing a small portion of the code by creating a PDE model and iterating over it.
R1 = [3;4;-1.2;-1.2;1.2;1.2;-0.6;0.6;0.6;-0.6];
R1 = [3;4;-1.2;-1.2;1.2;1.2;-0.6;0.6;0.6;-0.6]; % rectangle 1
for i=1:3
C1 = [1;-0.6;0;0.3];
C2 = [1;0.6;0;0.3];
coord=[-0.2,-0.2,-0.1,-0.1,-0.1,0.1,0.1,-0.1];
R2 = [[3 4] coord*(1+0.1*i)]'; % rectangle 2
coord=[-0.2,-0.2,-0.1,-0.1,-0.1,0.1,0.1,-0.1];
R3 = [[3 4] -coord*(1+0.1*i)]'; %rectangle 3
C1 = [C1;zeros(length(R2) - length(C1),1)]; % circle 1
C2 = [C2;zeros(length(R2) - length(C2),1)]; % circle 2
gd = [R1,R2,R3,C1,C2];
ns = char('R1','R2','R3','C1','C2');
ns = ns';
sf = 'R1-(R2+R3+C1+C2)';
figure()
g = decsg(gd,sf,ns);
model = createpde("electromagnetic","conduction");
geometryFromEdges(model,g);
pdegplot(model,"EdgeLabels","on")
end
The above code creates two additional rectangles, 'R2' and 'R3', based on the example mentioned in the MathWorks documentation (https://uk.mathworks.com/help/pde/ug/current-density-between-two-metallic-conductors.html).
In each iteration, the size of the rectangles increases by a fraction of 10%. However, it appears that the labels for the rectangles have not been changed by this approach.
If you could provide your specific code, I would be able to better understand the issue you are facing and assist you accordingly. Alternatively, you can try the approach mentioned above to see if it resolves your issue.
Please let me know if there's anything else I can help you with.
Thanks,
Rangesh.
0 Comments
See Also
Categories
Find more on Geometry and Mesh in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!