Last active
July 19, 2021 04:44
-
-
Save oskooi/2279c48206a3594d35c6351f20e08726 to your computer and use it in GitHub Desktop.
DFT field monitors with yee_grid=True
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import meep as mp | |
from meep.materials import Al as ALU | |
import numpy as np | |
lambda_min = 0.4 # minimum source wavelength | |
lambda_max = 0.8 # maximum source wavelength | |
fmin = 1/lambda_max # minimum source frequency | |
fmax = 1/lambda_min # maximum source frequency | |
fcen = 0.5*(fmin+fmax) # source frequency center | |
df = fmax-fmin # source frequency width | |
resolution = 55 | |
nfreq = 25 | |
tABS = 0.5 | |
tPML = 0.5 | |
tGLS = 0.5 | |
tITO = 0.5 | |
tORG = 0.5 | |
tALU = 0.2 | |
L = 1.0 # length of OLED | |
# length of computational cell along Z | |
sz = tPML+tGLS+tITO+tORG+tALU | |
# length of non-absorbing region of computational cell in X and Y | |
sxy = L+2*tABS | |
cell_size = mp.Vector3(sxy,sxy,sz) | |
boundary_layers = [mp.Absorber(tABS,direction=mp.X), | |
mp.Absorber(tABS,direction=mp.Y), | |
mp.PML(tPML,direction=mp.Z,side=mp.High)] | |
ORG = mp.Medium(index=1.75) | |
geometry = [mp.Block(material=mp.Medium(index=1.5), | |
size=mp.Vector3(mp.inf,mp.inf,tPML+tGLS), | |
center=mp.Vector3(z=0.5*sz-0.5*(tPML+tGLS))), | |
mp.Block(material=mp.Medium(index=1.2), | |
size=mp.Vector3(mp.inf,mp.inf,tITO), | |
center=mp.Vector3(z=0.5*sz-tPML-tGLS-0.5*tITO)), | |
mp.Block(material=ORG, | |
size=mp.Vector3(mp.inf,mp.inf,tORG), | |
center=mp.Vector3(z=0.5*sz-tPML-tGLS-tITO-0.5*tORG)), | |
mp.Block(material=ALU, | |
size=mp.Vector3(mp.inf,mp.inf,tALU), | |
center=mp.Vector3(z=0.5*sz-tPML-tGLS-tITO-tORG-0.5*tALU))] | |
sources = [mp.Source(mp.ContinuousSource(fcen), | |
component=mp.Ez, | |
center=mp.Vector3(z=0.5*sz-tPML-tGLS-tITO-0.5*tORG))] | |
sim = mp.Simulation(resolution=resolution, | |
cell_size=cell_size, | |
boundary_layers=boundary_layers, | |
geometry=geometry, | |
sources=sources, | |
eps_averaging=False) | |
cmpts = [mp.Ex, mp.Ey, mp.Ez] | |
srcbox_width = 0.05 | |
srcbox_top = sim.add_dft_fields(cmpts, fcen, df, nfreq, | |
where=mp.Volume(center=mp.Vector3(z=0.5*sz-tPML-tGLS), size=mp.Vector3(srcbox_width,srcbox_width,0)), | |
yee_grid=True) | |
srcbox_bot = sim.add_dft_fields(cmpts, fcen, df, nfreq, | |
where=mp.Volume(center=mp.Vector3(z=0.5*sz-tPML-tGLS-tITO-0.8*tORG), size=mp.Vector3(srcbox_width,srcbox_width,0)), | |
yee_grid=True) | |
srcbox_xp = sim.add_dft_fields(cmpts, fcen, df, nfreq, | |
where=mp.Volume(center=mp.Vector3(0.5*srcbox_width,0,0.5*sz-tPML-tGLS-0.5*(tITO+0.8*tORG)), size=mp.Vector3(0,srcbox_width,tITO+0.8*tORG)), | |
yee_grid=True) | |
srcbox_xm = sim.add_dft_fields(cmpts, fcen, df, nfreq, | |
where=mp.Volume(center=mp.Vector3(-0.5*srcbox_width,0,0.5*sz-tPML-tGLS-0.5*(tITO+0.8*tORG)), size=mp.Vector3(0,srcbox_width,tITO+0.8*tORG)), | |
yee_grid=True) | |
srcbox_yp = sim.add_dft_fields(cmpts, fcen, df, nfreq, | |
where=mp.Volume(center=mp.Vector3(0,0.5*srcbox_width,0.5*sz-tPML-tGLS-0.5*(tITO+0.8*tORG)), size=mp.Vector3(srcbox_width,0,tITO+0.8*tORG)), | |
yee_grid=True) | |
srcbox_ym = sim.add_dft_fields(cmpts, fcen, df, nfreq, | |
where=mp.Volume(center=mp.Vector3(0,-0.5*srcbox_width,0.5*sz-tPML-tGLS-0.5*(tITO+0.8*tORG)), size=mp.Vector3(srcbox_width,0,tITO+0.8*tORG)), | |
yee_grid=True) | |
# padding for flux box to fully capture waveguide mode | |
fluxbox_dpad = 0.05 | |
glass_flux = sim.add_dft_fields(cmpts, fcen, df, nfreq, | |
where=mp.Volume(center=mp.Vector3(z=0.5*sz-tPML-(tGLS-fluxbox_dpad)), size = mp.Vector3(L,L,0)), | |
yee_grid=True) | |
wvgbox_xp = sim.add_dft_fields(cmpts, fcen, df, nfreq, | |
where=mp.Volume(size=mp.Vector3(0,L,fluxbox_dpad+tITO+tORG+fluxbox_dpad), center=mp.Vector3(0.5*L,0,0.5*sz-tPML-tGLS-0.5*(tITO+tORG))), | |
yee_grid=True) | |
wvgbox_xm = sim.add_dft_fields(cmpts, fcen, df, nfreq, | |
where=mp.Volume(size=mp.Vector3(0,L,fluxbox_dpad+tITO+tORG+fluxbox_dpad), center=mp.Vector3(-0.5*L,0,0.5*sz-tPML-tGLS-0.5*(tITO+tORG))), | |
yee_grid=True) | |
wvgbox_yp = sim.add_dft_fields(cmpts, fcen, df, nfreq, | |
where=mp.Volume(size=mp.Vector3(L,0,fluxbox_dpad+tITO+tORG+fluxbox_dpad), center=mp.Vector3(0,0.5*L,0.5*sz-tPML-tGLS-0.5*(tITO+tORG))), | |
direction=True) | |
wvgbox_ym = sim.add_dft_fields(cmpts, fcen, df, nfreq, | |
where=mp.Volume(size=mp.Vector3(L,0,fluxbox_dpad+tITO+tORG+fluxbox_dpad), center=mp.Vector3(0,-0.5*L,0.5*sz-tPML-tGLS-0.5*(tITO+tORG))), | |
yee_grid=True) | |
mp.verbosity(2) | |
sim.run(until=2.0) | |
sim.fields.reset_timers() | |
for _ in range(5): | |
sim.fields.step() | |
print("DFT-updates:, {}".format(sim.time_spent_on(6)[0])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Results comparing the unmodified vs. modified DFT field updates for clang (v11.0.1-2) for the above test run 10 different times using single-thread Intel Xeon 2.0 GHz. The results show no performance improvement.
unmodified mean time: 0.028382 ± 0.003934 s
modified mean time: 0.027437 ± 0.003901 s