victorliu / S4

Stanford Stratified Structure Solver - Electromagnetic simulator for layered periodic structures
http://www.stanford.edu/group/fan/S4/
GNU General Public License v2.0
131 stars 149 forks source link

A problem of "SetLayerPatternPolygon" #109

Open fr0ger opened 1 year ago

fr0ger commented 1 year ago

Hi. I want to set a slab which is made of a unit cell like this:

屏幕截图 2023-10-28 112557

The part framed by the red line is the cell I constructed. Inside this, I expect all the triangles are air(epsilon=1), and the rest to be a uniform medium(epsilon=2.02^2).

The problem is when I set these triangles with S:SetLayerPatternPolygon, even though I have set them to epsilon=1, I always end up with an error when I use S:GetEpsilon to check the dielectric constant distribution, as shown in the image above (yellow means high permittivity refer to color bar).

I think this problem is universal. Because no matter how I switch my SetLayerPatternPolygons, those triangles with abnormal permittivity will always be the second-to-last and third-to-last.

I wonder if there is a solution or a way around it. Many thanks! image

fr0ger commented 1 year ago

Thank God it didn't take me long to solve the problem.

The reason is I defined the center of the right triangle at the right-edge side, so the program can't tell what's inside or outside the boundary.

But also defining the center of a right triangle inside the triangle means you need to set one more parameter and consider more complex geometric relationships. So I don't recommend adding this parameter unless you have to.

My ultimate goal is to set up six equilateral triangles. So my solution is to define the equilateral triangle directly, even though it crosses the unit cell boundary you defined. Rest assured that this will not cause any errors. Hopefully this will be helpful for people who need to define complex graphics. image