Skip to content

Simulation results change with resolution #2196

@mawc2019

Description

@mawc2019

It seems that simulation results may not quickly converge as resolution increases. Here is an example, where the transmission spectrum is calculated as the normalized transmission power. The central wavelength is 0.5. The structure is as follows.
image

The transmission spectra for a series of resolution are as follows. The unit of resolution is the number of points per unit length.
image

The normalized transmission power at the central frequency (=2) under a series of resolution is as follows. If we assume that the result at the resolution 200 is correct, we need the resolution to be higher than 90 in order to attain a relative error below 10%, and we need the resolution to be higher than 110 in order to attain a relative error below 5%. Is this situation normal?
image

The code for calculating the transmission spectrum at a given resolution is as follows.

import meep as mp
import numpy as np
from matplotlib import pyplot as plt
mp.verbosity(0)
Si,SiO2 = mp.Medium(index=3.4),mp.Medium(index=1.44)

resolution = 40
Sx,Sy = 1,8
block_width,monitor_height = Sx,2
pml_layers = [mp.PML(1.0,direction=mp.Y)]
cell_size = mp.Vector3(Sx,Sy)

fcen,fwidth,nf = 2,0.4,200
source_center,source_size  = [0,-2,0],mp.Vector3(Sx,0)
src = mp.GaussianSource(frequency=fcen,fwidth=fwidth)
source = [mp.EigenModeSource(src,eig_band = 1,size = source_size,center=source_center)]

geometry = [mp.Block(center=mp.Vector3(), size=mp.Vector3(block_width,block_width), material=Si)]
sim = mp.Simulation(cell_size=cell_size,boundary_layers=pml_layers,geometry=geometry,sources=source,k_point=mp.Vector3(),
                    default_material=SiO2,resolution=resolution)

fluxregion = mp.FluxRegion(center=mp.Vector3(0,monitor_height),size=mp.Vector3(Sx,0))
trans = sim.add_flux(fcen,fwidth,nf,fluxregion)

fig = plt.figure()
sim.plot2D(ax=fig.gca())
plt.show()

sim.run(until_after_sources=mp.stop_when_fields_decayed(50, mp.Ex, mp.Vector3(0,monitor_height), 1e-8))
power = np.array(mp.get_fluxes(trans))
sim.reset_meep()

sim = mp.Simulation(cell_size=cell_size,boundary_layers=pml_layers,geometry=[],sources=source,k_point=mp.Vector3(),
                    default_material=SiO2,resolution=resolution)
fluxregion = mp.FluxRegion(center=mp.Vector3(0,monitor_height),size=mp.Vector3(Sx,0))
trans = sim.add_flux(fcen,fwidth,nf,fluxregion)
sim.run(until_after_sources=mp.stop_when_fields_decayed(50, mp.Ex, mp.Vector3(0,monitor_height), 1e-8))
power_ref = np.array(mp.get_fluxes(trans))
sim.reset_meep()

freqs = np.linspace(fcen-fwidth/2,fcen+fwidth/2,nf)
plt.plot(freqs,power/power_ref)
plt.title("Transmission spectra")
plt.xlabel("Frequency")
plt.ylabel("Normalized transmission power");

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