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

Subpixel averaging and material discretization at edges of domain #2640

Open
mawc2019 opened this issue Sep 15, 2023 · 3 comments
Open

Subpixel averaging and material discretization at edges of domain #2640

mawc2019 opened this issue Sep 15, 2023 · 3 comments

Comments

@mawc2019
Copy link
Contributor

mawc2019 commented Sep 15, 2023

Sometimes the permittivity in simulation is different from what the user should expect. An example is as follows, where the permittivity should be 4 everywhere, but the value given by sim.get_epsilon() is different at the lateral boundaries.
image
The script is as follows.

import meep as mp
import numpy as np
from matplotlib import pyplot as plt
SiN = mp.Medium(epsilon=4)

Lx, Ly, dpml = 0.3149, 4, 1
resolution = 200
pml_layers = [mp.PML(dpml,direction=mp.Y)]
cell_size = mp.Vector3(Lx,Ly+2*dpml)
geometry = [mp.Block(center=mp.Vector3(), size=cell_size, material=SiN)]

sim = mp.Simulation(cell_size=cell_size,boundary_layers=pml_layers,eps_averaging=False,
                    geometry=geometry,k_point=mp.Vector3(),resolution=resolution)
sim.run(until_after_sources=1)
epsilon = sim.get_epsilon()
sim.reset_meep()

plt.figure(figsize=(10,5))
plt.subplot(1,2,1)
plt.imshow(np.transpose(epsilon))
plt.title('Permittivity')
plt.xlabel('X')
plt.ylabel('Y')
plt.colorbar()

plt.subplot(1,2,2)
plt.plot(epsilon);
plt.title('Permittivity projected to the x axis')
plt.xlabel('X')
plt.ylabel('Permittivity');

The flaw remains no matter eps_averaging=True or False. If k_point is changed to False, the flaw in permittivity will become different.

@mawc2019 mawc2019 changed the title Flaw Flaw in permittivity Sep 15, 2023
@oskooi
Copy link
Collaborator

oskooi commented Sep 15, 2023

Take a look at this FAQ, particularly the third paragraph and the accompanying image. Try removing the k_point from the Simulation object constructor.

@mawc2019
Copy link
Contributor Author

That FAQ does not seem to answer the issue.

the permittivity should be 4 everywhere

In the above example, there is only one material with epsilon=4.

If k_point is changed to False, the flaw in permittivity will become different.

Setting k_point to False is equivalent to removing it from Simulation. The flaw in permittivity becomes different but still exists.
image

@stevengj
Copy link
Collaborator

stevengj commented Sep 21, 2023

Basically, it's an issue of what we should do right at the edge of the computational cell. Probably we should do subpixel averaging differently in that case. There is also some averaging with Yee grid points beyond the cell.

The simplest solution is to make the object a little bigger than the cell.

@stevengj stevengj changed the title Flaw in permittivity Subpixel averaging and material discretization at edges of domain Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants