| 10 | |
| 11 | class TestBendFlux(ApproxComparisonTestCase): |
| 12 | def init(self, no_bend=False, gdsii=False): |
| 13 | sx = 16 |
| 14 | sy = 32 |
| 15 | cell = mp.Vector3(sx, sy, 0) |
| 16 | pad = 4 |
| 17 | w = 1 |
| 18 | wvg_ycen = -0.5 * (sy - w - (2 * pad)) |
| 19 | wvg_xcen = 0.5 * (sx - w - (2 * pad)) |
| 20 | height = mp.inf |
| 21 | data_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data")) |
| 22 | gdsii_file = os.path.join(data_dir, "bend-flux.gds") |
| 23 | |
| 24 | if no_bend: |
| 25 | if gdsii: |
| 26 | geometry = mp.get_GDSII_prisms( |
| 27 | mp.Medium(epsilon=12), gdsii_file, 1, 0, height |
| 28 | ) |
| 29 | else: |
| 30 | no_bend_vertices = [ |
| 31 | mp.Vector3(-0.5 * sx - 5, wvg_ycen - 0.5 * w), |
| 32 | mp.Vector3(+0.5 * sx + 5, wvg_ycen - 0.5 * w), |
| 33 | mp.Vector3(+0.5 * sx + 5, wvg_ycen + 0.5 * w), |
| 34 | mp.Vector3(-0.5 * sx - 5, wvg_ycen + 0.5 * w), |
| 35 | ] |
| 36 | |
| 37 | geometry = [ |
| 38 | mp.Prism(no_bend_vertices, height, material=mp.Medium(epsilon=12)) |
| 39 | ] |
| 40 | elif gdsii: |
| 41 | geometry = mp.get_GDSII_prisms( |
| 42 | mp.Medium(epsilon=12), gdsii_file, 2, 0, height |
| 43 | ) |
| 44 | else: |
| 45 | bend_vertices = [ |
| 46 | mp.Vector3(-0.5 * sx, wvg_ycen - 0.5 * w), |
| 47 | mp.Vector3(wvg_xcen + 0.5 * w, wvg_ycen - 0.5 * w), |
| 48 | mp.Vector3(wvg_xcen + 0.5 * w, 0.5 * sy), |
| 49 | mp.Vector3(wvg_xcen - 0.5 * w, 0.5 * sy), |
| 50 | mp.Vector3(wvg_xcen - 0.5 * w, wvg_ycen + 0.5 * w), |
| 51 | mp.Vector3(-0.5 * sx, wvg_ycen + 0.5 * w), |
| 52 | ] |
| 53 | |
| 54 | geometry = [mp.Prism(bend_vertices, height, material=mp.Medium(epsilon=12))] |
| 55 | |
| 56 | fcen = 0.15 |
| 57 | df = 0.1 |
| 58 | sources = [ |
| 59 | mp.Source( |
| 60 | mp.GaussianSource(fcen, fwidth=df), |
| 61 | component=mp.Ez, |
| 62 | center=mp.Vector3(1 + (-0.5 * sx), wvg_ycen), |
| 63 | size=mp.Vector3(0, w), |
| 64 | ) |
| 65 | ] |
| 66 | |
| 67 | pml_layers = [mp.PML(1.0)] |
| 68 | resolution = 10 |
| 69 | nfreq = 100 |