def _example(): import gdsCAD.core from math import pi from gdshelpers.geometry import convert_to_gdscad from gdshelpers.parts.waveguide import Waveguide from gdshelpers.parts.coupler import GratingCoupler left_coupler = GratingCoupler.make_traditional_coupler_from_database( [0, 0], 1, 'sn330', 1550) wg = Waveguide.make_at_port(left_coupler.port) wg.add_straight_segment(length=10) wg.add_bend(-pi / 2, radius=50) wg.add_straight_segment(length=150) wg.add_bend(-pi / 2, radius=50) wg.add_straight_segment(length=10) right_coupler = GratingCoupler.make_traditional_coupler_from_database_at_port( wg.current_port, 'sn330', 1550) cell = gdsCAD.core.Cell('SIMPLE_DEVICE') cell.add(convert_to_gdscad([left_coupler, wg, right_coupler], layer=1)) cell.add( convert_to_gdscad([ left_coupler.get_description_text(side='right'), right_coupler.get_description_text(side='left') ], layer=2)) save_as_image(cell, '/tmp/test.png', resolution=1) save_as_image(cell, '/tmp/test.pdf') save_as_image(cell, '/tmp/test.svg')
def _example_iii(): from gdshelpers.parts.waveguide import Waveguide from gdshelpers.parts.coupler import GratingCoupler from gdshelpers.geometry import geometric_union import numpy as np coupler1 = GratingCoupler.make_traditional_coupler((250 / 2, 0), 1.3, np.deg2rad(40), 1.13, 0.85, 20, taper_length=16, ap_max_ff=0.985, n_ap_gratings=10) wave_guide = Waveguide.make_at_port(coupler1.port) wave_guide.add_straight_segment(20) wave_guide.add_bend(0.5 * np.pi, 40) wave_guide.add_straight_segment(250 - 2 * 40) wave_guide.add_bend(0.5 * np.pi, 40) wave_guide.add_straight_segment(20) coupler2 = GratingCoupler.make_traditional_coupler( (wave_guide.current_port.origin[0], wave_guide.current_port.origin[1]), 1.3, np.deg2rad(40), 1.13, 0.85, 20, taper_length=16, ap_max_ff=0.985, n_ap_gratings=10) shapely_objects = [ Shapely3d( geometric_union([ coupler1.get_shapely_object(), wave_guide.get_shapely_object(), coupler2.get_shapely_object() ]), 0.0, 0.7, (255, 255, 255)) ] render_image_and_save_as_blend(shapely_objects, "test_device_under_right", camera_position_y='under', camera_position_x='right') render_image_and_save_as_blend(shapely_objects, "test_device_above_left", camera_position_y='above', camera_position_x='left') render_image_and_save_as_blend(shapely_objects, "test_device_under_left", camera_position_y='under', camera_position_x='left') render_image_and_save_as_blend(shapely_objects, "test_device_above_right", camera_position_y='above', camera_position_x='right')
def test_coupler_apodized_period(self): coupler1 = GratingCoupler.make_traditional_coupler( origin=[0, 0], width=1, full_opening_angle=np.deg2rad(40), grating_period=3, grating_ff=0.5, n_gratings=22, ap_max_ff=0.25, n_ap_gratings=10, taper_length=22, angle=-0.5 * np.pi, ap_start_period=1., ) coupler2 = GratingCoupler.make_traditional_coupler( origin=[100, 0], width=1, full_opening_angle=np.deg2rad(40), grating_period=3, grating_ff=0.5, n_gratings=22, ap_max_ff=0.25, n_ap_gratings=10, taper_length=22, angle=-0.5 * np.pi, ap_start_period=3., ) coupler3 = GratingCoupler.make_traditional_coupler( origin=[200, 0], width=1, full_opening_angle=np.deg2rad(40), grating_period=3, grating_ff=0.5, n_gratings=22, ap_max_ff=0.25, n_ap_gratings=10, taper_length=22, angle=-0.5 * np.pi, ap_start_period=None, ) self.assertAlmostEqual(coupler2.maximal_radius, coupler3.maximal_radius) layout = Cell('LIBRARY') cell = Cell('TOP') cell.add_to_layer(1, coupler1) cell.add_to_layer(1, coupler2) cell.add_to_layer(1, coupler3) layout.add_cell(cell)
def _example(): from gdshelpers.geometry.chip import Cell from gdshelpers.parts.waveguide import Waveguide from gdshelpers.parts.resonator import RingResonator # ==== create some sample structures (straight line with ring resonator) wg = Waveguide(origin=(0, 0), angle=np.deg2rad(-90), width=1) wg.add_straight_segment(length=5) wg.add_bend(np.pi / 2, 5) wg2 = Waveguide.make_at_port(wg.current_port) wg2.add_straight_segment(15) reso = RingResonator.make_at_port(port=wg2.current_port, gap=0.2, radius=5) wg2.add_straight_segment(length=15) coupler2 = GratingCoupler.make_traditional_coupler_from_database_at_port( wg2.current_port, db_id='si220', wavelength=1550) underetching_parts = geometric_union([wg2, reso, coupler2]) structure = geometric_union([underetching_parts, wg]) # create the holes with a radius of 0.5 microns, a distance of 2 microns to the structure borders and # a distance of 2 microns between the holes holes = create_holes_for_under_etching(underetch_parts=underetching_parts, complete_structure=structure, hole_radius=0.5, hole_distance=2, hole_spacing=3, hole_length=3) # create a cell with the structures in layer 1 and the holes in layer 2 cell = Cell('CELL') cell.add_to_layer(1, structure) cell.add_to_layer(2, holes) # Show the cell cell.show()
def _example(): from gdshelpers.geometry.chip import Cell from gdshelpers.parts.splitter import Splitter from gdshelpers.parts.coupler import GratingCoupler port = Port([0, 0], 0, 1) path = Waveguide.make_at_port(port) path.add_straight_segment(10) path.add_bend(np.pi / 2, 10, final_width=0.5) path.add_bend(-np.pi / 2, 10, final_width=1) path.add_arc(np.pi * 3 / 4, 10, ) splitter = Splitter.make_at_root_port(path.current_port, 30, 10) path2 = Waveguide.make_at_port(splitter.right_branch_port) path2.add_bend(-np.pi / 4, 10) n = 10 path2.add_parameterized_path(lambda t: (n * 10 * t, np.cos(n * 2 * np.pi * t) - 1), path_derivative=lambda t: (n * 10, -n * 2 * np.pi * np.sin(n * 2 * np.pi * t)), width=lambda t: np.cos(n * 2 * np.pi * t) * 0.2 + np.exp(-t) * 0.3 + 0.5, width_function_supports_numpy=True) path2.add_straight_segment(10, width=[.5, .5, .5]) print(path2.length) print(path2.length_last_segment) path2.add_cubic_bezier_path((0, 0), (5, 0), (10, 10), (5, 10)) path2.add_bend(-np.pi, 40) coupler1 = GratingCoupler([100, 50], 0, 1, np.deg2rad(30), [10, 0.1, 2, 0.1, 2], start_radius_absolute=True) path3 = Waveguide((0, -50), np.deg2rad(0), 1) path3.add_bezier_to(coupler1.port.origin, coupler1.port.inverted_direction.angle, bend_strength=50) splitter2 = Splitter.make_at_left_branch_port(splitter.left_branch_port, 30, 10, wavelength_root=2) path4 = Waveguide.make_at_port(splitter2.root_port) path4.add_straight_segment(20) path4.width = 1 path4.add_straight_segment(20) empty_path = Waveguide.make_at_port(path4.current_port) whole_layout = (path, splitter, path2, splitter2, coupler1, path3, path4, empty_path) layout = Cell('LIBRARY') cell = Cell('TOP') cell.add_to_layer(1, *whole_layout) cell.add_to_layer(2, empty_path) cell.add_to_layer(4, splitter.root_port.debug_shape) layout.add_cell(cell) cell_df = Cell('TOP_DF') cell_df.add_to_layer(1, convert_to_positive_resist(whole_layout, buffer_radius=1.5)) layout.add_cell(cell_df) layout.save('output.gds') cell.show()
def Ring_Test(label, gap, ring_r, ring_wg_width=wg_width): cell = Cell('Ring_Test' + label) r_bend = 60 #bend_r r_eff = r_bend / euler_to_bend_coeff outports = [Port((opt_space * i, 0), np.pi / 2, std_coupler_params['width']) for i in (0, 1)] gratingcouplers = [GratingCoupler.make_traditional_coupler_at_port(outport, **std_coupler_params) for outport in outports] port = outports[0].inverted_direction wg = Waveguide.make_at_port(port) wg.add_straight_segment(grating_added_taper_len, wg_width) # wgAdd_EulerBend(wg, np.pi / 2., r_eff, False) wg.add_bend(np.pi / 2., r_bend) dist_straight = opt_space - 2 * r_bend wg.add_straight_segment(dist_straight / 2.) ring_res = RingResonator.make_at_port(wg.current_port.inverted_direction, gap=gap, radius=ring_r, res_wg_width=ring_wg_width) wg.add_straight_segment(dist_straight / 2.) # wgAdd_EulerBend(wg, np.pi / 2., r_eff, False) wg.add_bend(np.pi / 2., r_bend) wg.add_straight_segment_until_y(outports[1].origin[1]-grating_added_taper_len) wg.add_straight_segment(grating_added_taper_len, std_coupler_params['width']) label_txt = Text((opt_space / 2., -6), 25, label, alignment='center-top') shapely_object = geometric_union(gratingcouplers + [label_txt] + [wg] + [ring_res]) cell.add_to_layer(wg_layer, shapely_object) comments = Text((60, 40), 10, 'gap={:.2f}\nrad={:.2f}\nwg_width={:.2f}'.format(gap, ring_r, ring_wg_width), alignment='center-top') cell.add_to_layer(comment_layer, comments) x_cords = [] y_cords = [] box_disty = 2 for this_poly in shapely_object.geoms: temp_x_cords, temp_y_cords = this_poly.exterior.coords.xy x_cords = x_cords + list(temp_x_cords) y_cords = y_cords + list(temp_y_cords) x_max = max(x_cords) + box_dist x_min = min(x_cords) - box_dist y_max = max(y_cords) + box_disty y_min = min(y_cords) - box_disty box_size = (x_max - x_min, y_max - y_min) box = Waveguide(((x_min + x_max) / 2., y_min), np.pi / 2, box_size[0]) box.add_straight_segment(box_size[1]) total_box = geometric_union([box]) cell.add_to_layer(wg_wf_layer, total_box) cell.add_to_layer(wg_reg_layer, total_box) return cell
def Efficiency_Grating(label, period, ff, grating_angle = None): cell = Cell('GC_Test' + label) r_bend = 60 #bend_r r_eff = r_bend / euler_to_bend_coeff coupler_params = std_coupler_params.copy() coupler_params['grating_period'] = period coupler_params['grating_ff'] = ff if grating_angle is not None: coupler_params['full_opening_angle'] = grating_angle outports = [Port((opt_space * i, 0), np.pi / 2, std_coupler_params['width']) for i in (0, 1)] gratingcouplers = [GratingCoupler.make_traditional_coupler_at_port(outport, **coupler_params) for outport in outports] port = outports[0].inverted_direction wg = Waveguide.make_at_port(port) wg.add_straight_segment(grating_added_taper_len, wg_width) wg.add_bend(np.pi / 2., r_bend) wg.add_straight_segment(opt_space - 2 * r_bend) wg.add_bend(np.pi / 2., r_bend) wg.add_straight_segment_until_y(outports[1].origin[1]-grating_added_taper_len) wg.add_straight_segment(grating_added_taper_len, std_coupler_params['width']) label_txt = Text((opt_space / 2., -6), 25, label, alignment='center-top') # self.shapely_object = geometric_union([wg] + [label] + gratingcouplers) shapely_object = geometric_union(gratingcouplers + [label_txt] + [wg]) cell.add_to_layer(wg_layer, shapely_object) comments = Text((60, 40), 10, 'period={:.2f}\nff={:.2f}'.format(coupler_params['grating_period'], coupler_params['grating_ff']), alignment='center-top') cell.add_to_layer(comment_layer, comments) x_cords = [] y_cords = [] box_disty = 2 # 2.5 * marker_dims for this_poly in shapely_object.geoms: temp_x_cords, temp_y_cords = this_poly.exterior.coords.xy x_cords = x_cords + list(temp_x_cords) y_cords = y_cords + list(temp_y_cords) x_max = max(x_cords) + box_dist x_min = min(x_cords) - box_dist y_max = max(y_cords) + box_disty y_min = min(y_cords) - box_disty box_size = (x_max - x_min, y_max - y_min) box = Waveguide(((x_min + x_max) / 2., y_min), np.pi / 2, box_size[0]) box.add_straight_segment(box_size[1]) total_box = geometric_union([box]) cell.add_to_layer(wg_wf_layer, total_box) cell.add_to_layer(wg_reg_layer, total_box) return cell
def Demux_active(coupler_sep, coupler_length, Mod_length, electrodes_sep, label, exp_wg_width=wg_Expwidth, grating_coupler_period=std_coupler_params['grating_period']): cell = Cell('Demux_active' + label) x_in = 0 y_in = 0 MZ_length = Mod_length + 50 wg_sep = mod_params['wg_sep'] wg_sep_out = 60 wg_sep_small = 10 wg_width_in_mod = wg_Expwidth taper_length = l_Exptaper ##Generating input and output grating couplers coupler_params = std_coupler_params.copy() coupler_params['grating_period'] = grating_coupler_period for j in range(4): incoupler = GratingCoupler.make_traditional_coupler( (x_in + j * opt_space, y_in), **coupler_params) cell.add_to_layer(wg_layer, incoupler) outcouplers = [] empty_gratcouplers = 0 for j in range(4): outcoupler = GratingCoupler.make_traditional_coupler( (x_in + (j + 4 + empty_gratcouplers) * opt_space, y_in), **coupler_params) outcouplers.append(outcoupler) cell.add_to_layer(wg_layer, outcoupler) ###Generating waveguides inports = [ Port((x_in + j * opt_space, y_in), np.deg2rad(90), std_coupler_params['width']) for j in (0, 1, 2, 3) ] wg = [Waveguide.make_at_port(inport) for inport in inports] x_ref0 = x_in + 1.5 * opt_space # y_ref0 = y_in - 3*bend_r x_refout = x_ref0 + (4 + empty_gratcouplers) * opt_space x_lastout = x_in + (7 + empty_gratcouplers) * opt_space x_centre = (x_in + x_lastout) / 2. y_start_epads = y_in - MZ_length - 930 ########## Input Connections for j in range(4): # adding final tapers as suggested by Munster, SP 21/10/21 wg[j].add_straight_segment(grating_added_taper_len, final_width=wg_width) wg[j].add_bend(np.pi / 2.0, bend_r + j * wg_sep_small) wg[j].add_straight_segment_until_x(x_in - bend_r - 1) wg[j].add_bend(np.pi / 2.0, bend_r + j * wg_sep_small) wg[j].add_straight_segment(grating_added_taper_len + 20) wg[j].add_bend(np.pi / 2.0, bend_r + j * wg_sep_small) wg[j].add_straight_segment_until_x(x_ref0 - (j - 1.5) * wg_sep_out - bend_r) wg[j].add_bend(-np.pi / 2.0, bend_r) y_ref0 = wg[-1].current_port.origin[1] - 1 for j in range(4): wg[j].add_straight_segment_until_y(y_ref0) ########## Zero-th MZI mzi0_xstart = x_ref0 mzi0_ystart = y_ref0 for j in (1, 2): wgAdd_EulerSBend(wg[j], offset=(j - 1.5) * (wg_sep_out - wg_sep), radius=bend_r) ##directional coupler with sinusoidal s-bend x_length = 60 y_length = wg_sep / 2.0 - (coupler_sep + wg_width) / 2.0 - (j - 1) * ( wg_sep - wg_width - coupler_sep) wg[j].add_parameterized_path( path=lambda t: (t * x_length, .5 * (np.cos(np.pi * t) - 1) * y_length), path_derivative=lambda t: (x_length, -np.pi * .5 * np.sin(np.pi * t) * y_length)) wg[j].add_straight_segment(coupler_length) y_length = -(wg_sep / 2.0 - (coupler_sep + wg_width) / 2.0 - (j - 1) * (wg_sep - wg_width - coupler_sep)) wg[j].add_parameterized_path( path=lambda t: (t * x_length, .5 * (np.cos(np.pi * t) - 1) * y_length), path_derivative=lambda t: (x_length, -np.pi * .5 * np.sin(np.pi * t) * y_length)) #add taper to multimode wg wg[j].add_straight_segment(taper_length, final_width=wg_width_in_mod) ###reference port for electrodes in MZI ref_port0 = wg[j].current_port ###straight section wg[j].add_straight_segment(MZ_length) #add taper to single-mode wg wg[j].add_straight_segment(taper_length, final_width=wg_width) ##directional coupler with sinusoidal s-bend x_length = 60 y_length = wg_sep / 2.0 - (coupler_sep + wg_width) / 2.0 - (j - 1) * ( wg_sep - wg_width - coupler_sep) wg[j].add_parameterized_path( path=lambda t: (t * x_length, .5 * (np.cos(np.pi * t) - 1) * y_length), path_derivative=lambda t: (x_length, -np.pi * .5 * np.sin(np.pi * t) * y_length)) wg[j].add_straight_segment(coupler_length) y_length = -(wg_sep / 2.0 - (coupler_sep + wg_width) / 2.0 - (j - 1) * (wg_sep - wg_width - coupler_sep)) wg[j].add_parameterized_path( path=lambda t: (t * x_length, .5 * (np.cos(np.pi * t) - 1) * y_length), path_derivative=lambda t: (x_length, -np.pi * .5 * np.sin(np.pi * t) * y_length)) wgAdd_EulerSBend(wg[j], offset=-(j - 1.5) * (wg_sep_out - wg_sep), radius=bend_r) mzi0_xend = x_ref0 mzi0_yend = wg[j].current_port.origin[1] for j in (0, 3): wg[j].add_straight_segment(l_Exptaper, final_width=exp_wg_width) wg[j].add_straight_segment_until_y(mzi0_yend + l_Exptaper) wg[j].add_straight_segment(l_Exptaper, final_width=wg_width) ########## Turn for j in range(4): wg[j].add_bend(np.pi / 2.0, bend_r + j * wg_sep_small) wg[j].add_straight_segment(l_Exptaper, final_width=exp_wg_width) wg[j].add_straight_segment_until_x(x_refout - 1.5 * wg_sep_out - bend_r + j * (wg_sep_out - wg_sep_small) - l_Exptaper) wg[j].add_straight_segment(l_Exptaper, final_width=wg_width) wg[j].add_bend(np.pi / 2.0, bend_r + j * wg_sep_small) ########## First MZI (left) mzi1_xstart = wg[0].current_port.origin[0] mzi1_ystart = wg[0].current_port.origin[1] for j in (0, 1): wgAdd_EulerSBend(wg[j], offset=(j - 0.5) * (wg_sep_out - wg_sep), radius=bend_r) #directional coupler with sinusoidal s-bend x_length = 60 y_length = wg_sep / 2.0 - (coupler_sep + wg_width) / 2.0 - j * ( wg_sep - wg_width - coupler_sep) wg[j].add_parameterized_path( path=lambda t: (t * x_length, .5 * (np.cos(np.pi * t) - 1) * y_length), path_derivative=lambda t: (x_length, -np.pi * .5 * np.sin(np.pi * t) * y_length)) wg[j].add_straight_segment(coupler_length) y_length = -(wg_sep / 2.0 - (coupler_sep + wg_width) / 2.0 - j * (wg_sep - wg_width - coupler_sep)) wg[j].add_parameterized_path( path=lambda t: (t * x_length, .5 * (np.cos(np.pi * t) - 1) * y_length), path_derivative=lambda t: (x_length, -np.pi * .5 * np.sin(np.pi * t) * y_length)) # add taper to multimode wg wg[j].add_straight_segment(taper_length, final_width=wg_width_in_mod) ###reference port for electrodes in MZI ref_port1 = wg[j].current_port ###straight section wg[j].add_straight_segment(MZ_length) # add taper to single-mode wg wg[j].add_straight_segment(taper_length, final_width=wg_width) ##directional coupler with sinusoidal s-bend x_length = 60 y_length = wg_sep / 2.0 - (coupler_sep + wg_width) / 2.0 - j * ( wg_sep - wg_width - coupler_sep) wg[j].add_parameterized_path( path=lambda t: (t * x_length, .5 * (np.cos(np.pi * t) - 1) * y_length), path_derivative=lambda t: (x_length, -np.pi * .5 * np.sin(np.pi * t) * y_length)) wg[j].add_straight_segment(coupler_length) y_length = -(wg_sep / 2.0 - (coupler_sep + wg_width) / 2.0 - j * (wg_sep - wg_width - coupler_sep)) wg[j].add_parameterized_path( path=lambda t: (t * x_length, .5 * (np.cos(np.pi * t) - 1) * y_length), path_derivative=lambda t: (x_length, -np.pi * .5 * np.sin(np.pi * t) * y_length)) wgAdd_EulerSBend(wg[j], offset=-(j - 0.5) * (wg_sep_out - wg_sep), radius=bend_r) ########## Second MZI (left) mzi1_xstart = wg[2].current_port.origin[0] mzi1_ystart = wg[2].current_port.origin[1] for j in (2, 3): wgAdd_EulerSBend(wg[j], offset=(j - 2.5) * (wg_sep_out - wg_sep), radius=bend_r) ##directional coupler with sinusoidal s-bend x_length = 60 y_length = wg_sep / 2.0 - (coupler_sep + wg_width) / 2.0 - (j - 2) * ( wg_sep - wg_width - coupler_sep) wg[j].add_parameterized_path( path=lambda t: (t * x_length, .5 * (np.cos(np.pi * t) - 1) * y_length), path_derivative=lambda t: (x_length, -np.pi * .5 * np.sin(np.pi * t) * y_length)) wg[j].add_straight_segment(coupler_length) y_length = -(wg_sep / 2.0 - (coupler_sep + wg_width) / 2.0 - (j - 2) * (wg_sep - wg_width - coupler_sep)) wg[j].add_parameterized_path( path=lambda t: (t * x_length, .5 * (np.cos(np.pi * t) - 1) * y_length), path_derivative=lambda t: (x_length, -np.pi * .5 * np.sin(np.pi * t) * y_length)) # add taper to multimode wg wg[j].add_straight_segment(taper_length, final_width=wg_width_in_mod) ###reference port for electrodes in MZI ref_port2 = wg[j].current_port ###straight section wg[j].add_straight_segment(MZ_length) # add taper to single-mode wg wg[j].add_straight_segment(taper_length, final_width=wg_width) ##directional coupler with sinusoidal s-bend x_length = 60 y_length = wg_sep / 2.0 - (coupler_sep + wg_width) / 2.0 - (j - 2) * ( wg_sep - wg_width - coupler_sep) wg[j].add_parameterized_path( path=lambda t: (t * x_length, .5 * (np.cos(np.pi * t) - 1) * y_length), path_derivative=lambda t: (x_length, -np.pi * .5 * np.sin(np.pi * t) * y_length)) wg[j].add_straight_segment(coupler_length) y_length = -(wg_sep / 2.0 - (coupler_sep + wg_width) / 2.0 - (j - 2) * (wg_sep - wg_width - coupler_sep)) wg[j].add_parameterized_path( path=lambda t: (t * x_length, .5 * (np.cos(np.pi * t) - 1) * y_length), path_derivative=lambda t: (x_length, -np.pi * .5 * np.sin(np.pi * t) * y_length)) wgAdd_EulerSBend(wg[j], offset=-(j - 2.5) * (wg_sep_out - wg_sep), radius=bend_r) ########## Output Connections for j in range(4): wg[j].add_straight_segment((3 - j) * wg_sep_small + 1) wg[j].add_bend(-np.pi / 2.0, bend_r) wg[j].add_straight_segment_until_x(x_lastout + bend_r + 1) wg[j].add_bend(np.pi / 2.0, bend_r + j * wg_sep_small) wg[j].add_straight_segment(grating_added_taper_len + 20) wg[j].add_bend(np.pi / 2.0, bend_r + j * wg_sep_small) wg[j].add_straight_segment_until_x(x_lastout - j * (opt_space) + bend_r + j * wg_sep_small) wg[j].add_bend(np.pi / 2.0, bend_r + j * wg_sep_small) wg[j].add_straight_segment(grating_added_taper_len, final_width=std_coupler_params['width']) # for j in range(4): cell.add_to_layer(wg_layer, wg[j]) ##MODULATORs ELECTRODES electr_width = mod_params['electrode_width'] sep_econns = mod_params['electrode_sep_y'] cross_width = mod_params['crossing_width'] pads_pitch = mod_params['connector_probe_pitch'] pads_width = mod_params['connector_probe_dims'][0] pads_width_gnd = mod_params['connector_probe_dims_gnd'][0] pads_len = mod_params['connector_probe_dims'][1] - 200 min_safedist_from_wg = 22 x_start_epads = x_centre - 3 * pads_pitch #### ELECTRODES IN ZEROTH MZI x_safe_dist = ref_port0.origin[ 0] - min_safedist_from_wg - pads_width - wg_sep / 2.0 - wg_sep_out ##left ground electrode Inport = Port((ref_port0.origin[0] - electrodes_sep / 2.0 - wg_sep / 2.0, ref_port0.origin[1]), np.deg2rad(-90), electr_width) g_left0 = Waveguide.make_at_port(Inport) g_left0.add_straight_segment(Mod_length - cross_width / 2. - 2 * sep_econns) g_left0._current_port.angle = g_left0.current_port.angle - np.pi / 2.0 g_left0._current_port.origin[ 0] = g_left0.current_port.origin[0] + g_left0.current_port.width / 2.0 g_left0._current_port.width = cross_width g_left0.add_straight_segment_until_x(x_safe_dist + wg_sep_out) g_left0.add_straight_segment(wg_sep, electr_width) g_left0.add_straight_segment_until_x(x_safe_dist) g_left0.add_straight_segment(2 * sep_econns) g_left0._current_port.angle = g_left0.current_port.angle + np.pi / 2.0 g_left0._current_port.origin[ 1] = g_left0.current_port.origin[1] + g_left0.current_port.width / 2.0 g_left0.add_straight_segment_until_y(y_start_epads - 2 * sep_econns) g_left0._current_port.angle = g_left0.current_port.angle + np.pi / 2.0 g_left0._current_port.origin[ 0] = g_left0.current_port.origin[0] - g_left0.current_port.width / 2.0 g_left0._current_port.origin[ 1] = g_left0.current_port.origin[1] + g_left0.current_port.width / 2.0 g_left0.add_straight_segment_until_x(x_start_epads) g_left0._current_port.angle = g_left0.current_port.angle - np.pi / 2.0 g_left0._current_port.origin[0] = g_left0.current_port.origin[ 0] #+ pads_width_gnd / 2.0 # g_left0._current_port.origin[1] = g_left0.current_port.origin[1] + g_left0.current_port.width / 2.0 g_left0._current_port.width = pads_width_gnd g_left0.add_straight_segment(pads_len) cell.add_to_layer(electrode_layer, g_left0) ## signal electrode Inport = Port((ref_port0.origin[0] + wg_sep / 2.0, ref_port0.origin[1]), np.deg2rad(-90), electr_width - electrodes_sep) s0 = Waveguide.make_at_port(Inport) s0.add_straight_segment(Mod_length - cross_width / 2. - sep_econns) s0._current_port.angle = s0.current_port.angle - np.pi / 2.0 s0._current_port.origin[ 0] = s0.current_port.origin[0] + s0.current_port.width / 2.0 s0._current_port.width = cross_width s0.add_straight_segment_until_x(x_safe_dist + wg_sep_out) s0.add_straight_segment(wg_sep, electr_width) s0.add_straight_segment_until_x(x_safe_dist) s0.add_straight_segment(sep_econns) s0._current_port.angle = s0.current_port.angle + np.pi / 2.0 s0._current_port.origin[ 1] = s0.current_port.origin[1] + s0.current_port.width / 2.0 s0.add_straight_segment_until_y(y_start_epads - sep_econns) s0._current_port.angle = s0.current_port.angle + np.pi / 2.0 s0._current_port.origin[ 0] = s0.current_port.origin[0] - s0.current_port.width / 2.0 s0.add_straight_segment_until_x(x_start_epads + pads_pitch) # s0._current_port.angle = s0.current_port.angle - np.pi / 2.0 s0._current_port.origin[0] = s0.current_port.origin[0] #+ pads_width / 2.0 s0._current_port.origin[ 1] = s0.current_port.origin[1] + s0.current_port.width / 2.0 s0._current_port.width = pads_width s0.add_straight_segment_until_y(g_left0.current_port.origin[1] + 50) cell.add_to_layer(electrode_layer, s0) # ##right ground electrode Inport = Port( (ref_port0.origin[0] + wg_sep + wg_sep / 2.0 + electrodes_sep / 2.0, ref_port0.origin[1]), np.deg2rad(-90), electr_width) g_right0 = Waveguide.make_at_port(Inport) g_right0.add_straight_segment(Mod_length - cross_width / 2.) g_right0._current_port.angle = g_right0.current_port.angle - np.pi / 2.0 g_right0._current_port.origin[0] = g_right0.current_port.origin[ 0] + g_right0.current_port.width / 2.0 g_right0._current_port.width = cross_width g_right0.add_straight_segment_until_x(x_safe_dist + wg_sep_out) g_right0.add_straight_segment(wg_sep, electr_width) g_right0.add_straight_segment_until_x(x_safe_dist) g_right0._current_port.angle = g_right0.current_port.angle + np.pi / 2.0 g_right0._current_port.origin[1] = g_right0.current_port.origin[ 1] + g_right0.current_port.width / 2.0 g_right0.add_straight_segment_until_y(y_start_epads) g_right0._current_port.angle = g_right0.current_port.angle + np.pi / 2.0 g_right0._current_port.origin[0] = g_right0.current_port.origin[ 0] - g_right0.current_port.width / 2.0 g_right0.add_straight_segment_until_x(x_start_epads + 2 * pads_pitch) g_right0._current_port.angle = g_right0.current_port.angle - np.pi / 2.0 g_right0._current_port.origin[0] = g_right0.current_port.origin[ 0] #+ 5. #+ pads_width_gnd / 2.0 g_right0._current_port.origin[1] = g_right0.current_port.origin[ 1] + g_right0.current_port.width / 2.0 g_right0._current_port.width = pads_width_gnd g_right0.add_straight_segment_until_y(g_left0.current_port.origin[1]) g_right0._current_port.angle = g_right0.current_port.angle - np.pi / 2.0 g_right0._current_port.origin[0] = g_right0.current_port.origin[ 0] + g_right0.current_port.width / 2.0 g_right0._current_port.width = pads_width / 2. g_right0._current_port.origin[1] = g_right0.current_port.origin[ 1] - g_right0._current_port.width / 2. # g_right0.add_straight_segment(2 * pads_pitch + pads_width) g_right0.add_straight_segment(2 * pads_pitch + pads_width_gnd) cell.add_to_layer(electrode_layer, g_right0) # #### ELECTRODES FOR FIRST MZI elec_offset = 90 x_safe_dist = ref_port1.origin[ 0] + min_safedist_from_wg + pads_width + wg_sep / 2.0 + 2 * wg_sep_out ##right ground electrode Inport = Port( (ref_port1.origin[0] + wg_sep - wg_sep / 2.0 + electrodes_sep / 2.0, ref_port1.origin[1] + MZ_length - elec_offset), np.deg2rad(-90), electr_width) g_right1 = Waveguide.make_at_port(Inport) g_right1.add_straight_segment(Mod_length - cross_width / 2. - 2 * sep_econns) g_right1._current_port.angle = g_right1.current_port.angle + np.pi / 2.0 g_right1._current_port.origin[0] = g_right1.current_port.origin[ 0] - g_right1.current_port.width / 2.0 g_right1._current_port.width = cross_width g_right1.add_straight_segment_until_x(x_safe_dist - wg_sep_out) g_right1.add_straight_segment(wg_sep, electr_width) g_right1.add_straight_segment_until_x(x_safe_dist) g_right1.add_straight_segment(2 * sep_econns) g_right1._current_port.angle = g_right1.current_port.angle - np.pi / 2.0 g_right1._current_port.origin[1] = g_right1.current_port.origin[ 1] + g_right1.current_port.width / 2.0 g_right1.add_straight_segment_until_y(y_start_epads - 2 * sep_econns) g_right1._current_port.angle = g_right1.current_port.angle - np.pi / 2.0 g_right1._current_port.origin[0] = g_right1.current_port.origin[ 0] + g_right1.current_port.width / 2.0 g_right1.add_straight_segment_until_x(x_start_epads + 4 * pads_pitch) g_right1._current_port.angle = g_right1.current_port.angle + np.pi / 2.0 g_right1._current_port.origin[0] = g_right1.current_port.origin[ 0] #+ 5. #+ pads_width_gnd / 2.0 g_right1._current_port.origin[1] = g_right1.current_port.origin[ 1] + g_right1.current_port.width / 2.0 g_right1._current_port.width = pads_width_gnd g_right1.add_straight_segment_until_y(g_left0.current_port.origin[1]) g_right1._current_port.angle = g_right1.current_port.angle - np.pi / 2.0 g_right1._current_port.origin[0] = g_right1.current_port.origin[ 0] + g_right1.current_port.width / 2.0 g_right1._current_port.width = pads_width / 2. g_right1._current_port.origin[1] = g_right1.current_port.origin[ 1] - g_right1._current_port.width / 2. g_right1.add_straight_segment(2 * pads_pitch + pads_width) cell.add_to_layer(electrode_layer, g_right1) ## signal electrode Inport = Port((ref_port1.origin[0] - wg_sep / 2.0, ref_port1.origin[1] + MZ_length - elec_offset), np.deg2rad(-90), electr_width - electrodes_sep) s1 = Waveguide.make_at_port(Inport) s1.add_straight_segment(Mod_length - cross_width / 2. - sep_econns) s1._current_port.angle = s1.current_port.angle + np.pi / 2.0 s1._current_port.origin[ 0] = s1.current_port.origin[0] - s1.current_port.width / 2.0 s1._current_port.width = cross_width s1.add_straight_segment_until_x(x_safe_dist - wg_sep_out) s1.add_straight_segment(wg_sep, electr_width) s1.add_straight_segment_until_x(x_safe_dist) s1.add_straight_segment(sep_econns) s1._current_port.angle = s1.current_port.angle - np.pi / 2.0 s1._current_port.origin[ 1] = s1.current_port.origin[1] + s1.current_port.width / 2.0 s1.add_straight_segment_until_y(y_start_epads - sep_econns) s1._current_port.angle = s1.current_port.angle - np.pi / 2.0 s1._current_port.origin[ 0] = s1.current_port.origin[0] + s1.current_port.width / 2.0 s1.add_straight_segment_until_x(x_start_epads + 3 * pads_pitch) s1._current_port.angle = s1.current_port.angle + np.pi / 2.0 s1._current_port.origin[0] = s1.current_port.origin[0] #+ pads_width / 2.0 s1._current_port.origin[ 1] = s1.current_port.origin[1] + s1.current_port.width / 2.0 s1._current_port.width = pads_width s1.add_straight_segment_until_y(g_left0.current_port.origin[1] + 50) cell.add_to_layer(electrode_layer, s1) # ##left ground electrode Inport = Port( (ref_port1.origin[0] - wg_sep - wg_sep / 2.0 - electrodes_sep / 2.0, ref_port1.origin[1] + MZ_length - elec_offset), np.deg2rad(-90), electr_width) g_left1 = Waveguide.make_at_port(Inport) g_left1.add_straight_segment(Mod_length - cross_width / 2.) g_left1._current_port.angle = g_left1.current_port.angle + np.pi / 2.0 g_left1._current_port.origin[ 0] = g_left1.current_port.origin[0] - g_left1.current_port.width / 2.0 g_left1._current_port.width = cross_width g_left1.add_straight_segment_until_x(x_safe_dist - wg_sep_out) g_left1.add_straight_segment(wg_sep, electr_width) g_left1.add_straight_segment_until_x(x_safe_dist) g_left1._current_port.angle = g_left1.current_port.angle - np.pi / 2.0 g_left1._current_port.origin[ 1] = g_left1.current_port.origin[1] + g_left1.current_port.width / 2.0 g_left1.add_straight_segment_until_y(y_start_epads) g_left1._current_port.angle = g_left1.current_port.angle - np.pi / 2.0 g_left1._current_port.origin[ 0] = g_left1.current_port.origin[0] + g_left1.current_port.width / 2.0 g_left1.add_straight_segment_until_x(x_start_epads + 2 * pads_pitch) # g_left1._current_port.angle = g_left1.current_port.angle + np.pi / 2.0 # g_left1._current_port.origin[0] = g_left1.current_port.origin[0] + pads_width_gnd / 2.0 # g_left1._current_port.origin[1] = g_left1.current_port.origin[1] + g_left1.current_port.width / 2.0 # g_left1._current_port.width = pads_width_gnd # g_left1.add_straight_segment_until_y(g_left0.current_port.origin[1]) cell.add_to_layer(electrode_layer, g_left1) # #### ELECTRODES FOR SECOND MZI # x_safe_dist = x_safe_dist + 3*sep_econns ##right ground electrode Inport = Port( (ref_port2.origin[0] + wg_sep - wg_sep / 2.0 + electrodes_sep / 2.0, ref_port2.origin[1] + elec_offset), np.deg2rad(90), electr_width) g_right2 = Waveguide.make_at_port(Inport) g_right2.add_straight_segment(Mod_length - cross_width / 2. - 2 * sep_econns) g_right2._current_port.angle = g_right2.current_port.angle - np.pi / 2.0 g_right2._current_port.origin[0] = g_right2.current_port.origin[ 0] - g_right2.current_port.width / 2.0 g_right2._current_port.width = cross_width g_right2.add_straight_segment_until_x(x_safe_dist - wg_sep_out) g_right2.add_straight_segment(wg_sep, electr_width) g_right2.add_straight_segment_until_x(x_safe_dist) g_right2.add_straight_segment(3 * sep_econns) g_right2._current_port.angle = g_right2.current_port.angle - np.pi / 2.0 g_right2._current_port.origin[1] = g_right2.current_port.origin[ 1] + g_right2.current_port.width / 2.0 g_right2.add_straight_segment_until_y(y_start_epads - 2 * sep_econns) g_right2._current_port.angle = g_right2.current_port.angle - np.pi / 2.0 g_right2._current_port.origin[0] = g_right2.current_port.origin[ 0] + g_right2.current_port.width / 2.0 g_right2.add_straight_segment_until_x(x_start_epads + 4 * pads_pitch) # g_right2._current_port.angle = g_right2.current_port.angle + np.pi / 2.0 # g_right2._current_port.origin[0] = g_right2.current_port.origin[0] #+ pads_width_gnd / 2.0 # g_right2._current_port.origin[1] = g_right2.current_port.origin[1] + g_right2.current_port.width / 2.0 # g_right2._current_port.width = pads_width_gnd # g_right2.add_straight_segment_until_y(g_left0.current_port.origin[1]) cell.add_to_layer(electrode_layer, g_right2) ## signal electrode Inport = Port((ref_port2.origin[0] - wg_sep / 2.0, ref_port2.origin[1] + elec_offset), np.deg2rad(90), electr_width - electrodes_sep) s2 = Waveguide.make_at_port(Inport) s2.add_straight_segment(Mod_length - cross_width / 2. - sep_econns) s2._current_port.angle = s2.current_port.angle - np.pi / 2.0 s2._current_port.origin[ 0] = s2.current_port.origin[0] - s2.current_port.width / 2.0 s2._current_port.width = cross_width s2.add_straight_segment_until_x(x_safe_dist - wg_sep_out) s2.add_straight_segment(wg_sep, electr_width) s2.add_straight_segment_until_x(x_safe_dist) s2.add_straight_segment(4 * sep_econns) s2._current_port.angle = s2.current_port.angle - np.pi / 2.0 s2._current_port.origin[ 1] = s2.current_port.origin[1] + s2.current_port.width / 2.0 s2.add_straight_segment_until_y(y_start_epads - 3 * sep_econns) s2._current_port.angle = s2.current_port.angle - np.pi / 2.0 s2._current_port.origin[ 0] = s2.current_port.origin[0] + s2.current_port.width / 2.0 s2.add_straight_segment_until_x(x_start_epads + 5 * pads_pitch) # s2._current_port.angle = s2.current_port.angle + np.pi / 2.0 s2._current_port.origin[0] = s2.current_port.origin[0] #+ pads_width / 2.0 s2._current_port.origin[ 1] = s2.current_port.origin[1] + s2.current_port.width / 2.0 s2._current_port.width = pads_width s2.add_straight_segment_until_y(g_left0.current_port.origin[1] + 50) cell.add_to_layer(electrode_layer, s2) # ##left ground electrode Inport = Port( (ref_port2.origin[0] - wg_sep - wg_sep / 2.0 - electrodes_sep / 2.0, ref_port2.origin[1] + elec_offset), np.deg2rad(90), electr_width) g_left2 = Waveguide.make_at_port(Inport) g_left2.add_straight_segment(Mod_length - cross_width / 2.) g_left2._current_port.angle = g_left2.current_port.angle - np.pi / 2.0 g_left2._current_port.origin[ 0] = g_left2.current_port.origin[0] - g_left2.current_port.width / 2.0 g_left2._current_port.width = cross_width g_left2.add_straight_segment_until_x(x_safe_dist - wg_sep_out) g_left2.add_straight_segment(wg_sep, electr_width) g_left2.add_straight_segment_until_x(x_safe_dist) g_left2.add_straight_segment(5 * sep_econns) g_left2._current_port.angle = g_left2.current_port.angle - np.pi / 2.0 g_left2._current_port.origin[ 1] = g_left2.current_port.origin[1] + g_left2.current_port.width / 2.0 g_left2.add_straight_segment_until_y(y_start_epads - 4 * sep_econns) g_left2._current_port.angle = g_left2.current_port.angle - np.pi / 2.0 g_left2._current_port.origin[ 0] = g_left2.current_port.origin[0] + g_left2.current_port.width / 2.0 # g_left2._current_port.origin[1] = g_left2.current_port.origin[1] + g_left2.current_port.width / 2.0 g_left2.add_straight_segment_until_x(x_start_epads + 6 * pads_pitch) g_left2._current_port.origin[ 1] = g_left2.current_port.origin[1] - g_left2.current_port.width / 2.0 g_left2._current_port.angle = g_left2.current_port.angle + np.pi / 2.0 g_left2._current_port.origin[0] = g_left2.current_port.origin[ 0] #+ 5. #+ pads_width_gnd / 2.0 g_left2._current_port.origin[ 1] = g_left2.current_port.origin[1] + g_left2.current_port.width g_left2._current_port.width = pads_width_gnd g_left2.add_straight_segment_until_y(g_left0.current_port.origin[1]) g_left2._current_port.angle = g_left2.current_port.angle - np.pi / 2.0 g_left2._current_port.origin[ 0] = g_left2.current_port.origin[0] + g_left2.current_port.width / 2.0 g_left2._current_port.width = pads_width / 2. g_left2._current_port.origin[ 1] = g_left2.current_port.origin[1] - g_left2._current_port.width / 2. g_left2.add_straight_segment(2 * pads_pitch + pads_width) cell.add_to_layer(electrode_layer, g_left2) # # # # ###WRITE FIELDs waveguide # # outer_corners = [(x_in - 80, y_in + 160), (x_in + 5 * 127 + 60, y_in + 160), # (x_in + 5 * 127 + 60, y_in + 160 - 1040), (x_in - 80, y_in + 160 - 1040)] # polygon1 = Polygon(outer_corners) # cell.add_to_layer(wg_wf_layer, polygon1) # outer_corners = [(x_in - 80, y_in + 160 - 1040), (x_in + 5 * 127 + 60, y_in + 160 - 1040), # (x_in + 5 * 127 + 60, y_in + 160 - 1040 - (MZ_length + 2*taper_length + 660 - 1040)), # (x_in - 80, y_in + 160 - 1040 - ((MZ_length + 2*taper_length + 660 - 1040)))] # polygon2 = Polygon(outer_corners) # cell.add_to_layer(wg_wf_layer, polygon2) # polygon = geometric_union([polygon1, polygon2]) # cell.add_to_layer(wg_reg_layer, polygon) # # ###WRITE FIELDs electrodes # # outer_corners = [(x_in - 210, y_in - 100), (x_in + 5 * 127 + 140, y_in - 100), # (x_in + 5 * 127 + 140, y_in - 100 - 1040), (x_in - 210, y_in - 100 - 1040)] # polygon1 = Polygon(outer_corners) # cell.add_to_layer(electrode_wf_layer, polygon1) # outer_corners = [(x_in - 210, y_in - 100 - 1040), (x_in + 5 * 127 + 140, y_in - 100 - 1040), # (x_in + 5 * 127 + 140, y_in - 100 - 1040 - (MZ_length + 2*taper_length + 762 - 1040)), # (x_in - 210, y_in - 100 - 1040 - (MZ_length + 2*taper_length + 762 - 1040))] # polygon2 = Polygon(outer_corners) # cell.add_to_layer(electrode_wf_layer, polygon2) # polygon = geometric_union([polygon1, polygon2]) # cell.add_to_layer(electrode_reg_layer, polygon) # # ####Local markers # # ### first set on layer 3 # positions = [(x_in, y_in - 320), (x_in + 5 * 127 - 60, y_in - 320), (x_in + 5 * 127 - 60, y_in - 320 - 450)] # marker = [SquareMarker.make_marker(position, 20) for position in positions] # cell.add_to_layer(3, geometric_union(marker)) # marker = [SquareMarker.make_marker(position, 30) for position in positions] # cell.add_to_layer(9, geometric_union(marker)) # marker = [SquareMarker.make_marker(position, 40) for position in positions] # cell.add_to_layer(15, geometric_union(marker)) # # ### second set on layer 4 # positions = [(x_in, y_in - 320 - 150), (x_in + 5 * 127 - 60, y_in - 320 - 150), (x_in + 5 * 127-60, y_in - 320 - 300)] # marker = [SquareMarker.make_marker(position, 20) for position in positions] # cell.add_to_layer(marker_layer_1, geometric_union(marker)) # marker = [SquareMarker.make_marker(position, 30) for position in positions] # cell.add_to_layer(wg_layer, geometric_union(marker)) # marker = [SquareMarker.make_marker(position, 40) for position in positions] # cell.add_to_layer(marker_protection_layer, geometric_union(marker)) ###Label device_label = Text(origin=(x_in, y_in - 700), height=30, text=label, alignment='center-bottom', angle=np.pi) cell.add_to_layer(wg_layer, device_label) ###Device Info info_text = ('Mod_length = %.1f um\nElectrodes_sep = %.1f nm\nCoupler_length= %.1f um\n') \ % (Mod_length, electrodes_sep, coupler_length) device_info = Text(origin=(x_in, y_in - 850), height=20, text=info_text, alignment='center-bottom', angle=np.pi) cell.add_to_layer(comment_layer, device_info) return cell
def MZI_active_with_phase(coupler_sep, coupler_length, MZ_length, electrodes_sep, label): cell = Cell('MZI_active_withphase'+label) x_in = 0 y_in = 0 wg_sep = mod_params['wg_sep'] wg_width_in_mod = wg_Expwidth taper_length = l_Exptaper ##Generating input and output grating couplers coupler_params = std_coupler_params.copy() for j in (0, 1): incoupler = GratingCoupler.make_traditional_coupler((x_in + j * opt_space, y_in), **coupler_params) cell.add_to_layer(wg_layer, incoupler) outcouplers = [] for j in (3, 4): outcoupler = GratingCoupler.make_traditional_coupler((x_in + j * opt_space, y_in), **coupler_params) outcouplers.append(outcoupler) cell.add_to_layer(wg_layer, outcoupler) ###Generating waveguides inports = [Port((x_in + j * opt_space, y_in), np.deg2rad(90), std_coupler_params['width']) for j in (0, 1)] wg = [Waveguide.make_at_port(inport) for inport in inports] for j in (0, 1): # adding final tapers as suggested by Munster, SP 21/10/21 wg[j].add_straight_segment(grating_added_taper_len, final_width=wg_width) # wg[j].add_straight_segment(bend_r-grating_added_taper_len) wg[j].add_bend(-np.pi / 2.0, bend_r + (1 - j) * wg_sep) wg[j].add_straight_segment((1 - j) * (opt_space - wg_sep)) wg[j].add_bend(-np.pi / 2.0, bend_r + (1 - j) * wg_sep) wg[j].add_straight_segment(bend_r) ##directional coupler with sinusoidal s-bend x_length = 60 y_length = wg_sep / 2.0 - (coupler_sep + wg_width) / 2.0 - j * (wg_sep - wg_width - coupler_sep) wg[j].add_parameterized_path(path=lambda t: (t * x_length, .5 * (np.cos(np.pi * t) - 1) * y_length), path_derivative=lambda t: (x_length, -np.pi * .5 * np.sin(np.pi * t) * y_length)) wg[j].add_straight_segment(coupler_length) y_length = -(wg_sep / 2.0 - (coupler_sep + wg_width) / 2.0 - j * (wg_sep - wg_width - coupler_sep)) wg[j].add_parameterized_path(path=lambda t: (t * x_length, .5 * (np.cos(np.pi * t) - 1) * y_length), path_derivative=lambda t: (x_length, -np.pi * .5 * np.sin(np.pi * t) * y_length)) #add taper to multimode wg wg[j].add_straight_segment(taper_length, final_width=wg_width_in_mod) ###reference port for electrodes in MZI ref_port = wg[j].current_port ###reference port for electrodes in PHASE ref_port_ph = wg[j].current_port ###straight section wg[j].add_straight_segment(MZ_length) #add taper to single-mode wg wg[j].add_straight_segment(taper_length, final_width=wg_width) ##directional coupler with sinusoidal s-bend x_length = 60 y_length = wg_sep / 2.0 - (coupler_sep + wg_width) / 2.0 - j * (wg_sep - wg_width - coupler_sep) wg[j].add_parameterized_path(path=lambda t: (t * x_length, .5 * (np.cos(np.pi * t) - 1) * y_length), path_derivative=lambda t: (x_length, -np.pi * .5 * np.sin(np.pi * t) * y_length)) wg[j].add_straight_segment(coupler_length) y_length = -(wg_sep / 2.0 - (coupler_sep + wg_width) / 2.0 - j * (wg_sep - wg_width - coupler_sep)) wg[j].add_parameterized_path(path=lambda t: (t * x_length, .5 * (np.cos(np.pi * t) - 1) * y_length), path_derivative=lambda t: (x_length, -np.pi * .5 * np.sin(np.pi * t) * y_length)) x_dist_inout=2*mod_params['electrode_width'] + 15 wg[j].add_straight_segment(10) wg[j].add_bend(np.pi/2., bend_r + j * wg_sep) wg[j].add_straight_segment(x_dist_inout+wg_sep) wg[j].add_bend(np.pi, bend_r + j * wg_sep) wg[j].add_bend(-np.pi / 2., bend_r + (1-j) * wg_sep) wg[j].add_straight_segment_until_y(inports[0].y - 3*bend_r) wg[j].add_bend(-np.pi / 2., bend_r + (1 - j) * wg_sep) wg[j].add_straight_segment_until_x(outcouplers[-1].origin[0]+bend_r) wg[j].add_bend(np.pi / 2., bend_r + j * wg_sep) wg[j].add_straight_segment_until_y(inports[0].y) wg[j].add_straight_segment(grating_added_taper_len) wg[j].add_bend(np.pi / 2., bend_r + j* wg_sep) wg[j].add_straight_segment_until_x(outcouplers[1-j].origin[0]+(bend_r + j * wg_sep)) wg[j].add_bend(np.pi / 2., bend_r + j*wg_sep) # # adding final tapers as suggested by Munster, SP 21/10/21 wg[j].add_straight_segment(grating_added_taper_len, final_width=std_coupler_params['width']) for j in (0, 1): cell.add_to_layer(wg_layer, wg[j]) ##MODULATOR ELECTRODES #### ELECTRODES IN MZI electr_width = mod_params['electrode_width'] sep_econns = mod_params['electrode_sep_y'] cross_width = mod_params['crossing_width'] pads_pitch = mod_params['connector_probe_pitch'] pads_width = mod_params['connector_probe_dims'][0] pads_width_gnd = mod_params['connector_probe_dims_gnd'][0] pads_len = mod_params['connector_probe_dims'][1] min_safedist_from_wg = 22 x_safe_dist = ref_port.origin[0] - min_safedist_from_wg - pads_width ##left ground electrode Inport = Port((ref_port.origin[0] - electrodes_sep / 2.0 - wg_sep / 2.0, ref_port.origin[1]), np.deg2rad(-90), electr_width) g_left = Waveguide.make_at_port(Inport) g_left.add_straight_segment(MZ_length - cross_width/2. - 2 * sep_econns) g_left._current_port.angle = g_left.current_port.angle - np.pi / 2.0 g_left._current_port.origin[0] = g_left.current_port.origin[0] + g_left.current_port.width / 2.0 g_left.add_straight_segment_until_x(x_safe_dist) g_left.add_straight_segment(2 * pads_pitch + (pads_width-pads_width_gnd/2.)) g_left._current_port.angle = g_left.current_port.angle + np.pi / 2.0 g_left._current_port.origin[0] = g_left.current_port.origin[0] + pads_width_gnd / 2.0 g_left._current_port.width = pads_width_gnd g_left.add_straight_segment(pads_len) cell.add_to_layer(electrode_layer, g_left) ## signal electrode Inport = Port((ref_port.origin[0] + wg_sep / 2.0, ref_port.origin[1]), np.deg2rad(-90), electr_width - electrodes_sep) s = Waveguide.make_at_port(Inport) s.add_straight_segment(MZ_length - cross_width/2. - sep_econns) s._current_port.angle = s.current_port.angle - np.pi / 2.0 s._current_port.origin[0] = s.current_port.origin[0] + s.current_port.width / 2.0 s._current_port.width = cross_width s.add_straight_segment(wg_sep+5) s.add_straight_segment(wg_sep, electr_width) s.add_straight_segment_until_x(x_safe_dist) s.add_straight_segment(pads_pitch+ (pads_width-pads_width_gnd/2.)) s._current_port.angle = s.current_port.angle + np.pi / 2.0 s._current_port.origin[0] = s.current_port.origin[0] + pads_width / 2.0 s._current_port.width = pads_width s.add_straight_segment_until_y(g_left.current_port.origin[1] + 50) cell.add_to_layer(electrode_layer, s) ##right ground electrode Inport = Port((ref_port.origin[0] + wg_sep + wg_sep / 2.0 + electrodes_sep / 2.0, ref_port.origin[1]), np.deg2rad(-90), electr_width) g_right = Waveguide.make_at_port(Inport) g_right.add_straight_segment(MZ_length - cross_width/2.) g_right._current_port.angle = g_right.current_port.angle - np.pi / 2.0 g_right._current_port.origin[0] = g_right.current_port.origin[0] + g_right.current_port.width / 2.0 g_right._current_port.width = cross_width g_right.add_straight_segment(2*wg_sep+5) g_right.add_straight_segment(wg_sep, electr_width) g_right.add_straight_segment_until_x(x_safe_dist) g_right.add_straight_segment(pads_width_gnd/2.) g_right._current_port.angle = g_right.current_port.angle + np.pi / 2.0 g_right._current_port.origin[0] = g_right.current_port.origin[0] + pads_width_gnd / 2.0 g_right._current_port.width = pads_width_gnd g_right.add_straight_segment_until_y(g_left.current_port.origin[1]) g_right._current_port.angle = g_right.current_port.angle - np.pi / 2.0 g_right._current_port.origin[0] = g_right.current_port.origin[0] + g_right.current_port.width / 2.0 g_right._current_port.width = pads_width / 2. g_right._current_port.origin[1] = g_right.current_port.origin[1] - g_right._current_port.width / 2. g_right.add_straight_segment(2 * pads_pitch + pads_width) cell.add_to_layer(electrode_layer, g_right) #### ELECTRODES FOR PHASE ref_port_ph = deepcopy(ref_port) ref_port_ph.origin[0] = ref_port.origin[0] + 2*wg_sep + x_dist_inout x_safe_dist_ph = ref_port_ph.origin[0] + min_safedist_from_wg + pads_width x_startpos_pads_ph = s._current_port.origin[0] + 4*pads_pitch + (pads_width_gnd - pads_width)/2. + (pads_width-pads_width_gnd/2.) y_startpos_pads_ph = s._current_port.origin[1] +280 ##right ground electrode Inport = Port((ref_port_ph.origin[0] + electrodes_sep / 2.0 + wg_sep / 2.0, ref_port.origin[1]), np.deg2rad(-90), electr_width) g_right_ph = Waveguide.make_at_port(Inport) g_right_ph.add_straight_segment(MZ_length - cross_width/2. - 2 * sep_econns) g_right_ph._current_port.angle = g_right_ph.current_port.angle + np.pi / 2.0 g_right_ph._current_port.origin[0] = g_right_ph.current_port.origin[0] - g_right_ph.current_port.width / 2.0 g_right_ph.add_straight_segment_until_x(x_startpos_pads_ph) g_right_ph._current_port.angle = g_right_ph.current_port.angle - np.pi / 2.0 g_right_ph._current_port.origin[0] = g_right_ph.current_port.origin[0] - g_right_ph.current_port.width / 2.0 g_right_ph.add_straight_segment_until_y(y_startpos_pads_ph-2*sep_econns+ g_right_ph.current_port.width) g_right_ph._current_port.origin[0] = g_right_ph._current_port.origin[0] - (pads_width_gnd- g_right_ph.current_port.width) / 2.0 g_right_ph._current_port.width = pads_width_gnd g_right_ph.add_straight_segment_until_y(g_left._current_port.origin[1]) cell.add_to_layer(electrode_layer, g_right_ph) ## signal electrode Inport = Port((ref_port_ph.origin[0] - wg_sep / 2.0, ref_port_ph.origin[1]), np.deg2rad(-90), electr_width - electrodes_sep) s_ph = Waveguide.make_at_port(Inport) s_ph.add_straight_segment(MZ_length - cross_width/2. - sep_econns) s_ph._current_port.angle = s.current_port.angle + np.pi / 2.0 s_ph._current_port.origin[0] = s_ph.current_port.origin[0] - s_ph.current_port.width / 2.0 s_ph._current_port.width = cross_width s_ph.add_straight_segment(wg_sep+5) s_ph.add_straight_segment(wg_sep, electr_width) s_ph.add_straight_segment_until_x(x_startpos_pads_ph - sep_econns) s_ph._current_port.angle = s_ph.current_port.angle - np.pi / 2.0 s_ph._current_port.origin[0] = s_ph.current_port.origin[0] - s_ph.current_port.width / 2.0 s_ph.add_straight_segment_until_y(y_startpos_pads_ph-sep_econns) s_ph._current_port.angle = s_ph.current_port.angle - np.pi / 2.0 s_ph._current_port.origin[1] = s_ph.current_port.origin[1] + s_ph.current_port.width / 2.0 s_ph.add_straight_segment_until_x(s.current_port.origin[0] + 3*pads_pitch-pads_width / 2.0) s_ph._current_port.angle = s_ph.current_port.angle + np.pi / 2.0 s_ph._current_port.origin[0] = s_ph.current_port.origin[0] + pads_width / 2.0 s_ph._current_port.width = pads_width s_ph.add_straight_segment_until_y(s.current_port.origin[1]) cell.add_to_layer(electrode_layer, s_ph) ##left ground electrode Inport = Port((ref_port_ph.origin[0] - wg_sep - wg_sep / 2.0 - electrodes_sep / 2.0, ref_port_ph.origin[1]), np.deg2rad(-90), electr_width) g_left_ph = Waveguide.make_at_port(Inport) g_left_ph.add_straight_segment(MZ_length - cross_width/2.) g_left_ph._current_port.angle = g_left_ph.current_port.angle + np.pi / 2.0 g_left_ph._current_port.origin[0] = g_left_ph.current_port.origin[0] - g_left_ph.current_port.width / 2.0 g_left_ph._current_port.width = cross_width g_left_ph.add_straight_segment(2*wg_sep+5) g_left_ph.add_straight_segment(wg_sep, electr_width) g_left_ph.add_straight_segment_until_x(x_startpos_pads_ph - 2*sep_econns) g_left_ph._current_port.angle = g_left_ph.current_port.angle - np.pi / 2.0 g_left_ph._current_port.origin[0] = g_left_ph.current_port.origin[0] - g_left_ph.current_port.width / 2.0 g_left_ph.add_straight_segment_until_y(y_startpos_pads_ph) g_left_ph._current_port.angle = g_left_ph.current_port.angle - np.pi / 2.0 g_left_ph._current_port.origin[1] = g_left_ph.current_port.origin[1] + g_left_ph.current_port.width / 2.0 g_left_ph.add_straight_segment_until_x(s.current_port.origin[0] + 2*pads_pitch - pads_width / 2.0) g_left_ph._current_port.angle = g_left_ph.current_port.angle + np.pi / 2.0 g_left_ph._current_port.origin[0] = g_left_ph.current_port.origin[0] + pads_width_gnd / 2.0 g_left_ph._current_port.width = pads_width_gnd g_left_ph.add_straight_segment_until_y(g_right_ph.current_port.origin[1]) g_left_ph._current_port.angle = g_left_ph.current_port.angle + np.pi / 2.0 g_left_ph._current_port.origin[0] = g_left_ph.current_port.origin[0] - g_left_ph.current_port.width / 2.0 g_left_ph._current_port.width = pads_width / 2. g_left_ph._current_port.origin[1] = g_left_ph.current_port.origin[1] - g_left_ph._current_port.width / 2. g_left_ph.add_straight_segment(2 * pads_pitch + pads_width) cell.add_to_layer(electrode_layer, g_left_ph) ###WRITE FIELDs waveguide outer_corners = [(x_in - 80, y_in + 160), (x_in + 5 * 127 + 60, y_in + 160), (x_in + 5 * 127 + 60, y_in + 160 - 1040), (x_in - 80, y_in + 160 - 1040)] polygon1 = Polygon(outer_corners) cell.add_to_layer(wg_wf_layer, polygon1) outer_corners = [(x_in - 80, y_in + 160 - 1040), (x_in + 5 * 127 + 60, y_in + 160 - 1040), (x_in + 5 * 127 + 60, y_in + 160 - 1040 - (MZ_length + 2*taper_length + 660 - 1040)), (x_in - 80, y_in + 160 - 1040 - ((MZ_length + 2*taper_length + 660 - 1040)))] polygon2 = Polygon(outer_corners) cell.add_to_layer(wg_wf_layer, polygon2) polygon = geometric_union([polygon1, polygon2]) cell.add_to_layer(wg_reg_layer, polygon) ###WRITE FIELDs electrodes outer_corners = [(x_in - 210, y_in - 100), (x_in + 5 * 127 + 140, y_in - 100), (x_in + 5 * 127 + 140, y_in - 100 - 1040), (x_in - 210, y_in - 100 - 1040)] polygon1 = Polygon(outer_corners) cell.add_to_layer(electrode_wf_layer, polygon1) outer_corners = [(x_in - 210, y_in - 100 - 1040), (x_in + 5 * 127 + 140, y_in - 100 - 1040), (x_in + 5 * 127 + 140, y_in - 100 - 1040 - (MZ_length + 2*taper_length + 762 - 1040)), (x_in - 210, y_in - 100 - 1040 - (MZ_length + 2*taper_length + 762 - 1040))] polygon2 = Polygon(outer_corners) cell.add_to_layer(electrode_wf_layer, polygon2) polygon = geometric_union([polygon1, polygon2]) cell.add_to_layer(electrode_reg_layer, polygon) ####Local markers ### first set on layer 3 positions = [(x_in, y_in - 320), (x_in + 5 * 127 - 60, y_in - 320), (x_in + 5 * 127 - 60, y_in - 320 - 450)] marker = [SquareMarker.make_marker(position, 20) for position in positions] cell.add_to_layer(3, geometric_union(marker)) marker = [SquareMarker.make_marker(position, 30) for position in positions] cell.add_to_layer(9, geometric_union(marker)) marker = [SquareMarker.make_marker(position, 40) for position in positions] cell.add_to_layer(15, geometric_union(marker)) ### second set on layer 4 positions = [(x_in, y_in - 320 - 150), (x_in + 5 * 127 - 60, y_in - 320 - 150), (x_in + 5 * 127-60, y_in - 320 - 300)] marker = [SquareMarker.make_marker(position, 20) for position in positions] cell.add_to_layer(marker_layer_1, geometric_union(marker)) marker = [SquareMarker.make_marker(position, 30) for position in positions] cell.add_to_layer(wg_layer, geometric_union(marker)) marker = [SquareMarker.make_marker(position, 40) for position in positions] cell.add_to_layer(marker_protection_layer, geometric_union(marker)) ###Label device_label = Text(origin=(x_in, y_in - 700), height=30, text=label, alignment='center-bottom', angle=np.pi) cell.add_to_layer(wg_layer, device_label) ###Device Info info_text = ('MZ_length = %.1f um\nElectrodes_sep = %.1f nm\nCoupler_length= %.1f um\n') \ % (MZ_length, electrodes_sep, coupler_length) device_info = Text(origin=(x_in, y_in - 850), height=20, text=info_text, alignment='center-bottom' , angle=np.pi) cell.add_to_layer(comment_layer, device_info) return cell
def wgs_to_fiber_array(cell, ports, coupler_positions, region_marker, is_incoupling, param, all_wf_layers=[], all_region_markers=[], alignment_test=False): total_bounds = (np.inf, np.inf, -np.inf, -np.inf) first_line_bounds = list(total_bounds).copy() wgs = [Waveguide.make_at_port(prt) for prt in ports] first_bend = -np.pi / 2 if is_incoupling: first_bend = np.pi / 2 coupler_positions = coupler_positions[::-1] for idx, wg in enumerate(wgs): if is_incoupling: wg._current_port.angle = -np.pi / 2 wg.add_straight_segment(param['wg_sep'] * (3 - idx)) else: wg.add_straight_segment(param['wg_sep'] * (idx)) # first bend then heading away from structure wg.add_bend(first_bend, param['min_radius']) if is_incoupling: wg.add_straight_segment_until_x(coupler_positions[-1][0] - param['min_radius']) if idx == 0: first_line_bounds = list( update_bounds(first_line_bounds, wg.get_shapely_outline().bounds)) # if alignment_test: first_line_bounds[2] -= 2 * 127 first_line_bounds[0] -= 10 first_line_bounds[1] -= 10 if region_marker is None: region_marker = bounds_to_polygon(first_line_bounds) _, region_marker = wf_line_from_bounds( cell=cell, bounds=first_line_bounds, region_marker=region_marker, wf_maxlength=1040, wf_layer=param['wf_layer'], axis=0, direction=1) wg.add_straight_segment_until_x(coupler_positions[idx][0] - param['min_radius']) wg.add_bend(first_bend, param['min_radius']) # adiabatic taper wg.add_straight_segment(40, final_width=0.75) wg.add_straight_segment_until_y(coupler_positions[idx][1]) gc = GratingCoupler.make_traditional_coupler_at_port( wg.current_port, **param['gc_params']) if idx == 0: second_line_bounds = [ first_line_bounds[2], first_line_bounds[1], (wg.current_port.origin[0] + 127 / 2 - 10), first_line_bounds[1] + 1040 ] cell.add_to_layer(param['wg_layer'], gc, wg) add_markers_to_top( cell=cell, wf_bounds=second_line_bounds, device_top_bound=(wgs[0].current_port.origin[1] + 70), marker_dims=20, wg_layer=param['wg_layer'], marker_layer_1=3, marker_layer_2=4, marker_protection_layer=15) else: wg.add_straight_segment_until_x(coupler_positions[0][0] + param['min_radius']) if idx == 3: first_line_bounds = list( update_bounds(first_line_bounds, wg.get_shapely_outline().bounds)) first_line_bounds[1] -= 10 first_line_bounds[2] += 10 # if alignment_test: first_line_bounds[0] += 1.5 * 127 if region_marker is None: region_marker = bounds_to_polygon(first_line_bounds) _, region_marker = wf_line_from_bounds( cell=cell, bounds=first_line_bounds, region_marker=region_marker, wf_maxlength=1040, wf_layer=param['wf_layer'], axis=0, direction=-1) wg.add_straight_segment_until_x(coupler_positions[idx][0] + param['min_radius']) wg.add_bend(first_bend, param['min_radius']) # adiabatic taper wg.add_straight_segment(40, final_width=0.75) wg.add_straight_segment_until_y(coupler_positions[idx][1]) gc = GratingCoupler.make_traditional_coupler_at_port( wg.current_port, **param['gc_params']) cell.add_to_layer(param['wg_layer'], gc, wg) if idx == 3: second_line_bounds = [ (wg.current_port.origin[0] - 127 / 2 + 10), first_line_bounds[1], first_line_bounds[0], first_line_bounds[1] + 1040 ] if alignment_test: test_coupler_positions = [ [coupler_positions[-1][0] - 127, coupler_positions[-1][1]], [ coupler_positions[-1][0] - 2 * 127, # +8*127 coupler_positions[-1][1] ] ] test_port = Port(test_coupler_positions[0], np.pi / 2.0, wgs[0].width) test_gc_0 = GratingCoupler.make_traditional_coupler_at_port( test_port, **param['gc_params']) test_wg = Waveguide.make_at_port(test_gc_0.port) test_wg._current_port.angle = -np.pi / 2 test_wg.add_bend(-np.pi / 2, param['min_radius']) test_wg.add_straight_segment_until_x(test_coupler_positions[1][0] + param['min_radius']) test_wg.add_bend(-np.pi / 2, param['min_radius']) test_gc_1 = GratingCoupler.make_traditional_coupler_at_port( test_wg.current_port, **param['gc_params']) cell.add_to_layer(param['wg_layer'], test_wg, test_gc_0, test_gc_1) _, region_marker = wf_line_from_bounds(cell=cell, bounds=second_line_bounds, region_marker=region_marker, wf_maxlength=1040, wf_layer=param['wf_layer'], axis=1, direction=1) if is_incoupling: for idx in range(len(all_wf_layers)): all_region_markers[idx] = bounds_to_polygon(second_line_bounds) _, all_region_markers[idx] = wf_line_from_bounds( cell=cell, bounds=second_line_bounds, region_marker=all_region_markers[idx], wf_maxlength=1040, wf_layer=all_wf_layers[idx], axis=1, direction=1) total_bounds = update_bounds(first_line_bounds, second_line_bounds) return total_bounds, region_marker
def RectangularSpiral(label, num, add_xlength=0., add_ylength=100., sep=4., r_curve=50., return_xmax=False, grating_angle = None, exp_wg_width=wg_Expwidth, grating_coupler_period = std_coupler_params['grating_period']): cell = Cell('DC_Test' + label) r_eff = r_curve / euler_to_bend_coeff delta = 2 * sep orizontal_length = add_xlength + 2 * sep coupler_params = std_coupler_params.copy() coupler_params['grating_period'] = grating_coupler_period if grating_angle is not None: coupler_params['full_opening_angle'] = grating_angle grating_coupl_pos = np.array((0, 0)) couplers = [ GratingCoupler.make_traditional_coupler(grating_coupl_pos + (opt_space * x, 0), **coupler_params) for x in (0, 1)] # ports = [Port(grating_coupl_pos - (opt_space * x, 0), np.pi / 2, wg_width) for x in (0, 1)] ### Adding final tapers as suggested by Munster, SP 21/10/21 ports = [Port(grating_coupl_pos - (opt_space * x, 0), np.pi / 2, std_coupler_params['width']) for x in (0, 1)] couplers = [GratingCoupler.make_traditional_coupler_at_port(port, **coupler_params) for port in ports] waveguides = [Waveguide.make_at_port(port.inverted_direction) for port in ports] ### Adding final tapers as suggested by Munster, SP 21/10/21 waveguides[0].add_straight_segment(grating_added_taper_len, final_width=wg_width) waveguides[0].add_straight_segment(sep, final_width=wg_width) wgAdd_EulerBend(waveguides[0], -np.pi / 2, r_eff, True) waveguides[0].add_straight_segment(sep + opt_space) wgAdd_EulerBend(waveguides[0], -np.pi / 2., r_eff, True) ### Adding final tapers as suggested by Munster, SP 21/10/21 waveguides[1].add_straight_segment(grating_added_taper_len, final_width=wg_width) wgAdd_EulerBend(waveguides[1], -np.pi / 2., r_eff, True) wgAdd_EulerBend(waveguides[1], -np.pi / 2., r_eff, True) waveguides[1].add_straight_segment(grating_added_taper_len, final_width=wg_width) origin_spiral = Port((-opt_space / 2., 320 + add_ylength / 2. + num * sep), 0, wg_width) wg1 = Waveguide.make_at_port(origin_spiral) wgAdd_EulerBend(wg1, -np.pi / 2., r_eff, True) if add_ylength > (4 * l_Exptaper): wg1.add_straight_segment(l_Exptaper, final_width=exp_wg_width) wg1.add_straight_segment(add_ylength / 2. - 2 * l_Exptaper) wg1.add_straight_segment(l_Exptaper, final_width=wg_width) else: wg1.add_straight_segment(add_ylength / 2.) wgAdd_EulerBend(wg1, -np.pi / 2., r_eff, True) if (add_xlength / 2. + sep) > (2 * l_Exptaper): wg1.add_straight_segment(l_Exptaper, final_width=exp_wg_width) wg1.add_straight_segment(add_xlength / 2. + sep - 2 * l_Exptaper) wg1.add_straight_segment(l_Exptaper, final_width=wg_width) else: wg1.add_straight_segment(add_xlength / 2. + sep) wgAdd_EulerBend(wg1, -np.pi / 2., r_eff, True) if (sep + add_ylength + 2 * r_curve) > (2 * l_Exptaper): wg1.add_straight_segment(l_Exptaper, final_width=exp_wg_width) wg1.add_straight_segment(sep + add_ylength + 2 * r_curve - 2 * l_Exptaper) wg1.add_straight_segment(l_Exptaper, final_width=wg_width) else: wg1.add_straight_segment(sep + add_ylength + 2 * r_curve) wgAdd_EulerBend(wg1, -np.pi / 2., r_eff, True) wg2 = Waveguide.make_at_port(origin_spiral.inverted_direction) wgAdd_EulerBend(wg2, -np.pi / 2., r_eff, True) if add_ylength > (4 * l_Exptaper): wg2.add_straight_segment(l_Exptaper, final_width=exp_wg_width) wg2.add_straight_segment(add_ylength / 2. - 2 * l_Exptaper) wg2.add_straight_segment(l_Exptaper, final_width=wg_width) else: wg2.add_straight_segment(add_ylength / 2.) wgAdd_EulerBend(wg2, -np.pi / 2., r_eff, True) if (add_xlength / 2. + sep) > (2 * l_Exptaper): wg2.add_straight_segment(l_Exptaper, final_width=exp_wg_width) wg2.add_straight_segment(add_xlength / 2. + sep - 2 * l_Exptaper) wg2.add_straight_segment(l_Exptaper, final_width=wg_width) else: wg2.add_straight_segment(add_xlength / 2. + sep) wgAdd_EulerBend(wg2, -np.pi / 2., r_eff, True) if (sep + add_ylength + 2 * r_curve) > (2 * l_Exptaper): wg2.add_straight_segment(l_Exptaper, final_width=exp_wg_width) wg2.add_straight_segment(sep + add_ylength + 2 * r_curve - 2 * l_Exptaper) wg2.add_straight_segment(l_Exptaper, final_width=wg_width) else: wg2.add_straight_segment(sep + add_ylength + 2 * r_curve) wgAdd_EulerBend(wg2, -np.pi / 2., r_eff, True) if (orizontal_length + sep) > (2 * l_Exptaper): wg2.add_straight_segment(l_Exptaper, final_width=exp_wg_width) wg2.add_straight_segment(orizontal_length + sep - 2 * l_Exptaper) wg2.add_straight_segment(l_Exptaper, final_width=wg_width) else: wg2.add_straight_segment(orizontal_length + sep) wgAdd_EulerBend(wg2, -np.pi / 2., r_eff, True) if (sep + delta + add_ylength + 2 * r_curve) > (2 * l_Exptaper): wg2.add_straight_segment(l_Exptaper, final_width=exp_wg_width) wg2.add_straight_segment(sep + delta + add_ylength + 2 * r_curve - 2 * l_Exptaper) wg2.add_straight_segment(l_Exptaper, final_width=wg_width) else: wg2.add_straight_segment(sep + delta + add_ylength + 2 * r_curve) wgAdd_EulerBend(wg2, -np.pi / 2., r_eff, True) for i in np.arange(1, num): if (orizontal_length + delta * i - sep) > (2 * l_Exptaper): wg1.add_straight_segment(l_Exptaper, final_width=exp_wg_width) wg1.add_straight_segment(orizontal_length + delta * i - sep - 2 * l_Exptaper) wg1.add_straight_segment(l_Exptaper, final_width=wg_width) else: wg1.add_straight_segment(orizontal_length + delta * i - sep) wgAdd_EulerBend(wg1, -np.pi / 2., r_eff, True) if (delta * i + sep + add_ylength + 2 * r_curve) > (2 * l_Exptaper): wg1.add_straight_segment(l_Exptaper, final_width=exp_wg_width) wg1.add_straight_segment(delta * i + sep + add_ylength + 2 * r_curve - 2 * l_Exptaper) wg1.add_straight_segment(l_Exptaper, final_width=wg_width) else: wg1.add_straight_segment(delta * i + sep + add_ylength + 2 * r_curve) wgAdd_EulerBend(wg1, -np.pi / 2., r_eff, True) for j in np.arange(2, num): if (orizontal_length + j * delta - sep) > (2 * l_Exptaper): wg2.add_straight_segment(l_Exptaper, final_width=exp_wg_width) wg2.add_straight_segment(orizontal_length + j * delta - sep - 2 * l_Exptaper) wg2.add_straight_segment(l_Exptaper, final_width=wg_width) else: wg2.add_straight_segment(orizontal_length + j * delta - sep) wgAdd_EulerBend(wg2, -np.pi / 2., r_eff, True) if (delta * (j + 1) - sep + add_ylength + 2 * r_curve) > (2 * l_Exptaper): wg2.add_straight_segment(l_Exptaper, final_width=exp_wg_width) wg2.add_straight_segment(delta * (j + 1) - sep + add_ylength + 2 * r_curve - 2 * l_Exptaper) wg2.add_straight_segment(l_Exptaper, final_width=wg_width) else: wg2.add_straight_segment(delta * (j + 1) - sep + add_ylength + 2 * r_curve) wgAdd_EulerBend(wg2, -np.pi / 2., r_eff, True) waveguides[0].add_straight_segment(l_Exptaper, final_width=exp_wg_width) waveguides[0].add_straight_segment_until_y(wg1.y - r_curve - l_Exptaper) waveguides[0].add_straight_segment(l_Exptaper, final_width=wg_width) wgAdd_EulerBend(waveguides[0], -np.pi / 2., r_eff, True) waveguides[0].add_straight_segment(l_Exptaper, final_width=exp_wg_width) waveguides[0].add_straight_segment_until_x(wg1.x - l_Exptaper) waveguides[0].add_straight_segment(l_Exptaper, final_width=wg_width) waveguides[1].add_straight_segment(r_curve / 2., final_width=wg_width) wgAdd_EulerBend(waveguides[1], -np.pi / 2., r_eff, True) # if (num * delta - sep + orizontal_length) > 2 * l_Exptaper: wg2.add_straight_segment(l_Exptaper, final_width=exp_wg_width) wg2.add_straight_segment(num * delta - sep + orizontal_length - 2 * l_Exptaper) wg2.add_straight_segment(l_Exptaper, final_width=wg_width) else: wg2.add_straight_segment(num * delta - sep + orizontal_length) wgAdd_EulerBend(wg2, -np.pi / 2., r_eff, True) waveguides[1].add_straight_segment(l_Exptaper, final_width=exp_wg_width) waveguides[1].add_straight_segment_until_x(wg2.x - r_curve - l_Exptaper) waveguides[1].add_straight_segment(l_Exptaper, final_width=wg_width) wgAdd_EulerBend(waveguides[1], np.pi / 2., r_eff, False) waveguides[1].add_straight_segment(l_Exptaper, final_width=exp_wg_width) waveguides[1].add_straight_segment_until_y(wg2.y - l_Exptaper) waveguides[1].add_straight_segment(l_Exptaper, final_width=wg_width) label_txt = Text(origin_spiral.origin + (0, -r_curve), 25, label, alignment='center-top') shapely_object = geometric_union(waveguides + [wg1, wg2, label_txt] + couplers) cell.add_to_layer(wg_layer, shapely_object) comments = Text((-100, -10), 30, 'length={:.2f}'.format( (wg1.length + wg2.length + waveguides[1].length + waveguides[0].length) * 1e-4), alignment='center-top') cell.add_to_layer(comment_layer, comments) x_cords = [] y_cords = [] for this_poly in shapely_object.geoms: temp_x_cords, temp_y_cords = this_poly.exterior.coords.xy x_cords = x_cords + list(temp_x_cords) y_cords = y_cords + list(temp_y_cords) x_max = max(x_cords) + box_dist x_min = min(x_cords) - box_dist y_max = max(y_cords) + box_dist y_min = min(y_cords) - box_dist box_size = (x_max - x_min, y_max - y_min) num_boxes = int(box_size[1] / max_box_size[1]) + 1 box_x_dim = box_size[0] box_y_dim = box_size[1] / num_boxes box_list = [] for i in range(num_boxes): box = Waveguide(((x_min + x_max) / 2., y_min + i * box_y_dim), np.pi / 2, box_x_dim) box.add_straight_segment(box_y_dim) box_list.append(box) # self.box = geometric_union(box_list) for this_box in box_list: cell.add_to_layer(wg_wf_layer, this_box) all_boxes = geometric_union(box_list) cell.add_to_layer(wg_reg_layer, all_boxes) if return_xmax: return cell, x_max else: return cell
def DirectionalCouplersTest_standard(label, coupler_sep, coupler_length, grating_angle = None): cell = Cell('DC_standard_test'+label) coupler_params = std_coupler_params.copy() if grating_angle is not None: coupler_params['full_opening_angle'] = grating_angle x_in = 0 y_in = 0 ##Generating input and output grating couplers for j in (0, 1): incoupler = GratingCoupler.make_traditional_coupler((x_in + j * 127, y_in), **coupler_params) cell.add_to_layer(9, incoupler) for j in (0, 3): outcoupler = GratingCoupler.make_traditional_coupler((x_in - 127 + j * 127, y_in), **coupler_params) cell.add_to_layer(9, outcoupler) ###Generating waveguides inports = [Port((x_in + j * 127, y_in), np.deg2rad(90), std_coupler_params['width']) for j in (0, 1)] wg = [Waveguide.make_at_port(inport) for inport in inports] for j in (0, 1): wg[j].add_straight_segment(grating_added_taper_len, wg_width) ##directional coupler with sinusoidal s-bend x_length = 130 y_length = 127 / 2.0 - (coupler_sep + wg_width) / 2.0 - j * (127 - wg_width - coupler_sep) wg[j].add_parameterized_path(path=lambda t: (t * x_length, .5 * (np.cos(np.pi * t) - 1) * y_length), path_derivative=lambda t: (x_length, -np.pi * .5 * np.sin(np.pi * t) * y_length)) wg[j].add_straight_segment(coupler_length) y_length = -(127 / 2.0 - (coupler_sep + wg_width) / 2.0 - j * (127 - wg_width - coupler_sep)) wg[j].add_parameterized_path(path=lambda t: (t * x_length, .5 * (np.cos(np.pi * t) - 1) * y_length), path_derivative=lambda t: (x_length, -np.pi * .5 * np.sin(np.pi * t) * y_length)) wg[j].add_straight_segment(30) wg[j].add_bend(np.pi - j * 2 * np.pi, 127 / 2.0) wg[j].add_straight_segment_until_y(y_in+grating_added_taper_len) wg[j].add_straight_segment(grating_added_taper_len, std_coupler_params['width']) for j in (0, 1): cell.add_to_layer(wg_layer, wg[j]) ##write field outer_corners = [(x_in - 127 - 127 / 2.0, y_in - 50), (x_in + 2 * 127 + 127 / 2.0, y_in - 50), (x_in + 2 * 127 + 127 / 2.0, y_in + 400 + coupler_length), (x_in - 127 - 127 / 2.0, y_in + 400 + coupler_length)] polygon = Polygon(outer_corners) cell.add_to_layer(wg_wf_layer, polygon) cell.add_to_layer(wg_reg_layer, polygon) ###Label device_label = Text(origin=(x_in + 127 + 127 / 2.0, y_in + 200), height=30, text=label, alignment='center-bottom', angle=np.pi) cell.add_to_layer(wg_layer, device_label) ###Device Info info_text = ('Coupler length = %.2f um\nCoupler sep= %.2f') \ % (coupler_length, coupler_sep) device_info = Text(origin=(x_in + 127 + 127 / 2.0, y_in + 100), height=20, text=info_text, alignment='center-bottom', angle=np.pi) cell.add_to_layer(comment_layer, device_info) return cell
def DirectionalCouplersTest(label, gap, length, AMZI_DeltaL, r_curve=50, grating_angle = None): cell = Cell('DC_Test' + label) couplerList = [] outports = [] wgs = [] coupler_params = std_coupler_params.copy() if grating_angle is not None: coupler_params['full_opening_angle'] = grating_angle r_eff = r_curve / euler_to_bend_coeff port = Port((0, 0), 0, wg_width) couplerList.append(DirectionalCoupler.make_at_port(port, length=length, gap=gap, bend_radius=r_curve)) wg = Waveguide.make_at_port(couplerList[0].right_ports[1]) wg.add_straight_segment(2 * r_curve) wgs.append(wg) wg = Waveguide.make_at_port(couplerList[0].right_ports[0]) wg.add_straight_segment(2 * r_curve) couplerList.append(DirectionalCoupler.make_at_port(wg.current_port, length=length, gap=gap, bend_radius=r_curve)) sep = 5 len_eulers = EulerLength(r_eff, np.pi / 2.) Delta_L = max(0, (AMZI_DeltaL - 12 * len_eulers - 5 * sep) / 4.) wg = Waveguide.make_at_port(couplerList[0].right_ports[0]) wgAdd_EulerBend(wg, -np.pi / 2., r_eff, True) wg.add_straight_segment(Delta_L + sep) wgAdd_EulerBend(wg, -np.pi / 2., r_eff, True) wgAdd_EulerBend(wg, -np.pi / 2., r_eff, True) wg.add_straight_segment(Delta_L) wgAdd_EulerBend(wg, np.pi / 2., r_eff, False) wgAdd_EulerBend(wg, np.pi / 2., r_eff, False) wg.add_straight_segment(Delta_L + sep) wgAdd_EulerBend(wg, np.pi / 2., r_eff, False) wg.add_straight_segment(6 * r_curve + sep) wgAdd_EulerBend(wg, np.pi / 2., r_eff, False) wg.add_straight_segment(Delta_L + sep) wgAdd_EulerBend(wg, np.pi / 2., r_eff, False) wgAdd_EulerBend(wg, np.pi / 2., r_eff, False) wg.add_straight_segment(Delta_L) wgAdd_EulerBend(wg, -np.pi / 2., r_eff, True) wgAdd_EulerBend(wg, -np.pi / 2., r_eff, True) wg.add_straight_segment(Delta_L + sep) wgAdd_EulerBend(wg, -np.pi / 2., r_eff, True) wgs.append(wg) # wg = Waveguide.make_at_port(couplerList[0].left_ports[0]) wgAdd_EulerBend(wg, -np.pi / 2., r_eff, True) wgs.append(wg) outports.append(wg.port) outports.append(outports[0].parallel_offset(-3 * opt_space)) wg = Waveguide.make_at_port(couplerList[1].right_ports[0]) wg.add_bezier_to(np.array(outports[1].origin), bend_strength=r_curve / 1.2, final_angle=np.pi / 2.) wgs.append(wg) wg = Waveguide.make_at_port(couplerList[0].left_ports[1]) wg.add_bend(angle=-np.pi, radius=r_curve / 4) wg.add_straight_segment(50, final_width=0.1) wgs.append(wg) wg = Waveguide.make_at_port(couplerList[1].right_ports[1]) wg.add_bend(angle=np.pi, radius=r_curve / 4) wg.add_straight_segment(50, final_width=0.1) wgs.append(wg) gratingcouplers = [GratingCoupler.make_traditional_coupler_at_port(outport, **coupler_params) for outport in outports] label_txt = Text((180, 70), 25, label, alignment='center-top') box = Waveguide((+520, -40), np.pi / 2., 1025) box.add_straight_segment(730) shapely_object = geometric_union(wgs + [label_txt] + couplerList + gratingcouplers) cell.add_to_layer(wg_layer, shapely_object) comments = Text((105, 70), 10, 'gap={:.2f}\nlength={:.2f}'.format(gap, length), alignment='center-top') cell.add_to_layer(comment_layer, comments) x_cords = [] y_cords = [] for this_poly in shapely_object.geoms: temp_x_cords, temp_y_cords = this_poly.exterior.coords.xy x_cords = x_cords + list(temp_x_cords) y_cords = y_cords + list(temp_y_cords) x_max = max(x_cords) + box_dist x_min = min(x_cords) - box_dist y_max = max(y_cords) + box_dist y_min = min(y_cords) - box_dist box_size = (x_max - x_min, y_max - y_min) box = Waveguide(((x_min + x_max) / 2., y_min), np.pi / 2, box_size[0]) box.add_straight_segment(box_size[1]) total_box = geometric_union([box]) cell.add_to_layer(wg_wf_layer, total_box) cell.add_to_layer(wg_reg_layer, total_box) return cell
if __name__ == '__main__': import gdsCAD.core from gdshelpers.parts.waveguide import Waveguide from gdshelpers.parts.resonator import RingResonator from gdshelpers.geometry import convert_to_gdscad # ==== create some sample structures (straight line with ring resonator) wg = Waveguide(origin=(0, 0), angle=np.deg2rad(-90), width=1) wg.add_straight_segment(length=5) wg.add_bend(np.pi / 2, 5) wg2 = Waveguide.make_at_port(wg.current_port) wg2.add_straight_segment(15) reso = RingResonator.make_at_port(port=wg2.current_port, gap=0.2, radius=5) wg2.add_straight_segment(length=15) coupler2 = GratingCoupler.make_traditional_coupler_from_database_at_port( wg2.current_port, db_id='si220', wavelength=1550) underetching_parts = geometric_union([wg2, reso, coupler2]) structure = geometric_union([underetching_parts, wg]) # create the holes with a radius of 0.5 microns, a distance of 2 microns to the structure borders and # a distance of 2 microns between the holes holes = create_holes_for_under_etching(underetch_parts=underetching_parts, complete_structure=structure, hole_radius=0.5, hole_distance=2, hole_spacing=3) # create a cell with the structures in layer 1 and the holes in layer 2 cell = gdsCAD.core.Cell('CELL') cell.add(convert_to_gdscad(structure, layer=1)) cell.add(convert_to_gdscad(holes, layer=2))