Skip to content

Prism geometry rendering artifacts #1523

@ianwilliamson

Description

@ianwilliamson

I am encountering some strange artifacts in Meep's rendering of Prism geometries onto the simulation grid. Consider the case shown below. The prism vertices are traced on the left and the Meep simulation domain is shown on the right, with the same vertices overlaid as x's.

image

You can see that there is an artifact around the lower left part of the cutout. This seems to be coming from the extra vertex that sits on that diagonal interface. While this vertex is not strictly necessary to describe the outline of this prism, I would not have expected Meep to render this geometry as shown in the image.

The code for reproducing the result shown above is provided below:

import meep as mp
import matplotlib.pyplot as plt
geometry = [
    mp.Prism(
        vertices=[
            mp.Vector3(3450.0008325358162, 300.0, 0.0),
            mp.Vector3(3450.0008209110665, 235.0, 0.0),
            mp.Vector3(3450.000676495217, 195.0, 0.0),
            mp.Vector3(3240.0000608065666, 115.0, 0.0),
            mp.Vector3(3230.0000572294366, 54.999999999999545, 0.0),
            mp.Vector3(3245.0, 39.99988881841773, 0.0),
            mp.Vector3(3255.0, 30.000042326215862, 0.0),
            mp.Vector3(3450.00077515856, 125.0, 0.0),
            mp.Vector3(3450.0004644694577, -100.0, 0.0),
            mp.Vector3(3200.0, -100.0, 0.0),
            mp.Vector3(3200.0, 300.0, 0.0),
        ],
        height=100,
        sidewall_angle=0,
        material=mp.Medium(index=4),
    ),
]

simulation = mp.Simulation(
    cell_size=mp.Vector3(300.00099904297946, 480.0, 0.0),
    boundary_layers=[],
    geometry=geometry,
    geometry_center=mp.Vector3(3322.401246760824, 95.34725790541609, 0.0),
    resolution=0.1,
    eps_averaging=False,
)
simulation.init_sim()
epsr = simulation.get_array(
    center=simulation.geometry_center,
    size=simulation.cell_size,
    component=mp.Dielectric,
    cmplx=False,
)

(x, y, z, _) = simulation.get_array_metadata(
    center=simulation.geometry_center,
    size=simulation.cell_size,
)

fig, ax = plt.subplots(1,2, figsize=(6,6), constrained_layout=True)
ax[1].pcolormesh(x, y, epsr.T)

for g in simulation.geometry:
  if isinstance(g, mp.Prism):
    ax[1].plot([vtx.x for vtx in g.vertices], [vtx.y for vtx in g.vertices], 'rx')
    ax[0].plot([vtx.x for vtx in g.vertices], [vtx.y for vtx in g.vertices], 'r-')

ax[0].axis('image')
ax[0].set_title('Polygon')
ax[1].axis('image')
ax[1].set_title('Meep simulation domain')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions