Last active
October 22, 2021 15:04
-
-
Save oskooi/922c7dc21e872a54c7949276d9d76c97 to your computer and use it in GitHub Desktop.
S11 and S12 of a straight waveguide
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 | |
import numpy as np | |
cell_size = mp.Vector3(14,14) | |
pml_layers = [mp.PML(thickness=2)] | |
w = 1.0 | |
geometry = [mp.Block(center=mp.Vector3(), | |
size=mp.Vector3(mp.inf,w,mp.inf), | |
material=mp.Medium(epsilon=12))] | |
fsrc = 0.15 | |
sources = [mp.EigenModeSource(src=mp.GaussianSource(fsrc,fwidth=0.2*fsrc), | |
center=mp.Vector3(), | |
size=mp.Vector3(y=3*w), | |
direction=mp.NO_DIRECTION, | |
eig_kpoint=mp.Vector3(1,0,0), | |
eig_parity=mp.EVEN_Y+mp.ODD_Z)] | |
for res in [25, 50, 100, 200, 400]: | |
sim = mp.Simulation(cell_size=cell_size, | |
resolution=res, | |
boundary_layers=pml_layers, | |
sources=sources, | |
geometry=geometry, | |
symmetries=[mp.Mirror(mp.Y)]) | |
tran = sim.add_mode_monitor(fsrc, 0, 1, | |
mp.ModeRegion(center=mp.Vector3(x=5), | |
size=mp.Vector3(y=14)), | |
yee_grid=True) | |
sim.run(until_after_sources=50) | |
res_fwd = sim.get_eigenmode_coefficients(tran, | |
[1], | |
eig_parity=mp.EVEN_Y+mp.ODD_Z, | |
direction=mp.NO_DIRECTION, | |
kpoint_func=lambda f,n: mp.Vector3(+1,0,0)) | |
res_bwd = sim.get_eigenmode_coefficients(tran, | |
[1], | |
eig_parity=mp.EVEN_Y+mp.ODD_Z, | |
direction=mp.NO_DIRECTION, | |
kpoint_func=lambda f,n: mp.Vector3(-1,0,0)) | |
## res_fwd: alpha[0,0,0] --> S21, alpha[0,0,1] --> S11 | |
print("flux-fwd:, {}, {:.10f}, {:.10f}".format(res,abs(res_fwd.alpha[0,0,0])**2,abs(res_fwd.alpha[0,0,1])**2)) | |
## res_bwd: alpha[0,0,0] --> S11, alpha[0,0,1] --> S21 | |
print("flux-bwd:, {}, {:.10f}, {:.10f}".format(res,abs(res_bwd.alpha[0,0,0])**2,abs(res_bwd.alpha[0,0,1])**2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment