matthuszagh / pyems

High-level python interface to OpenEMS with automatic mesh generation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

thirds rule is incorrectly adhered to in certain cases

matthuszagh opened this issue · comments

One example of this is the differential microstrip example, where a mesh line is placed 2/3 inside the inside edges of each trace and 1/3 inside the gap between those traces. Instead, the line should be 1/3 inside the trace and 2/3 inside the gap. This occurs because the gap is considered of metal type. The reason for this is that the mesh module finds two structures that contain this y-position: the substrate and the backing copper plane. They are each of identical size and metal structures get priority in a tie.

I think probably the best way to deal with this is to "fragment" primitives based on priorities and box overlaps. Then, use the fragmented primitives rather than the originals. To understand this, imagine a simple copper-backed microstrip tx line. The microstrip extends in the x-direction and is flat in the z-direction. Take the boundaries of the microstrip line to be [[-1, 1], [-0.1, 0.1], [0, 0]], the boundaries the backing plane to be [[-1, 1], [-1, 1], [-1, -1]] and the boundaries of the substrate to be [[-1, 1], [-1, 1], [-1, 0]]. The microstrip line and copper plane have the same priority, which is higher than that of the substrate. Fragmenting the primitives will replace the substrate primitive with 5 primitives and leave the rest unchanged. These 5 new primitives would be of substrate type with boundaries [[-1, 1], [-1, -0.1], [0, 0]], [[-1, 1], [0.1, 1], [0, 0]], [[-1, 1], [-1, -0.1], [-1, 0]], [[-1, 1], [0.1, 1], [-1, 0]] and [[-1, 1], [-0.1, 0.1], [-1, 0]]. To understand this, it helps to look at an image from the yz plane for a non-zero height microstrip:

IMG_0258

The microstrip is the shaded region, the unfilled region is substrate and the backing plane is ignored. The new regions are the segmented areas to the left and right of the microstrip, below the microstrip and the segments to the left and right of the region below the microstrip. We could, of course, merge the lower left and right corner regions with the middle or top regions, but we can't merge them with both and it's not clear which merge is superior. There's no disadvantage to not merge them since the microstrip already requires a mesh for the left, right and middle bottom regions. The only difference from this image for a 0-height microstrips is that the left and right regions will have zero height and the bottom regions will extend all the way up to z=0.

This should allow us to keep BoundedType only hold information about 1 dimensions, which simplifies the meshing logic.

The first challenge to implementing this will be to compute the intersection of two boxes (this should go in coordinate.py after box_overlap). Then, we need to go from a box and an intersection to a collection of the fragmented boxes.