Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3D simulation 2D visualization PML bug #2022

Closed
hammy4815 opened this issue Mar 28, 2022 · 3 comments · Fixed by #2079
Closed

3D simulation 2D visualization PML bug #2022

hammy4815 opened this issue Mar 28, 2022 · 3 comments · Fixed by #2079
Labels

Comments

@hammy4815
Copy link
Contributor

hammy4815 commented Mar 28, 2022

There appears to be in issue when running 3D simulations and calling plot2D to visualize. It shows PML everywhere, when there shouldn't be.

import meep.adjoint as mpa
from matplotlib import pyplot as plt
import numpy as np

diamond = mp.Medium(index=2.4)  # Lossless diamond
air = mp.Medium(index=1.0)  # Lossless air

# Geometry
radius = 0.88
geometry = [
    mp.Cylinder(radius=radius, height=0.22, material=diamond),  
]

# Source
fcen = 1.67969  # Center frequency
df = 0.05  # pulse frequency width
sources = [
    mp.Source(src=mp.GaussianSource(fcen, fwidth=df), component=mp.Ex, center=mp.Vector3(0.88 - 0.15, 0, 0.00))
]  # Dipole source

# Simulation
sim = mp.Simulation(
    cell_size=mp.Vector3(7*radius, 7*radius, 10),  # Size of the simulation cell
    geometry=geometry,  # Geometry
    boundary_layers=[mp.PML(1.0,direction=mp.X),mp.PML(1.0,direction=mp.Y),mp.PML(1.0,direction=mp.Z)],  # Boundary conditions
    resolution=10,  # Resolution
    sources=sources,  # Sources
)

# Plot the geometry
sim.init_sim()
if mp.am_really_master():
    plt.figure()
    sim.plot2D(output_plane=mp.Volume(center=mp.Vector3(0, 0, 0), size=mp.Vector3(7*radius, 7*radius, 0)))
    plt.savefig("geom")`

geom

cc @smartalecH

@smartalecH smartalecH added the bug label Mar 28, 2022
@smartalecH
Copy link
Collaborator

Similar issues with 2D simulations that simply change the geometry_center.

@stevengj
Copy link
Collaborator

I guess it is getting confused by the PML in the z direction, and doesn't notice that those PML layers don't intersect the slice being plotted?

@oskooi
Copy link
Collaborator

oskooi commented Apr 3, 2022

This bug is indeed related to the use of PML since replacing mp.PML(...) with mp.Absorber(...) produces the correct output (i.e., no hatched lines).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants