def _example(): from gdshelpers.geometry.chip import Cell cell = Cell('test') wg1 = Waveguide.make_at_port(Port((0, 0), 0, 1.)) wg1.add_straight_segment(100) ring1 = RingResonator.make_at_port(wg1.current_port, 1., 50., race_length=30, straight_feeding=True, draw_opposite_side_wg=True) wg2 = Waveguide.make_at_port(ring1.port) wg2.add_straight_segment(100) ring2 = RingResonator.make_at_port(wg2.current_port, 1., 50., vertical_race_length=30, straight_feeding=True, draw_opposite_side_wg=True) wg3 = Waveguide.make_at_port(ring2.port) wg3.add_straight_segment(100) ring3 = RingResonator.make_at_port(wg3.current_port, -1., 50., vertical_race_length=30, straight_feeding=True, draw_opposite_side_wg=True) cell.add_to_layer(1, wg1, ring1, wg2, ring2, wg3, ring3) cell.show()
def test_region_layers(self): cell = Cell("test_device") wg1 = Waveguide([0, 0], 0, 1) wg1.add_straight_segment(10) wg1_shapely = wg1.get_shapely_object() cell.add_to_layer(1, wg1) wg2 = Waveguide([40, 0], 0, 1) wg2.add_straight_segment(10) wg2_shapely = wg2.get_shapely_object() cell.add_to_layer(2, wg2) cell.add_region_layer(100) cell.add_region_layer(101, [1]) cell.add_region_layer(102, [1, 2]) self.assertTrue(100 in cell.layer_dict) self.assertTrue(cell.layer_dict[100][0].contains(wg1_shapely)) self.assertTrue(cell.layer_dict[100][0].contains(wg2_shapely)) self.assertTrue(101 in cell.layer_dict) self.assertTrue(cell.layer_dict[101][0].contains(wg1_shapely)) self.assertFalse(cell.layer_dict[101][0].contains(wg2_shapely)) self.assertTrue(102 in cell.layer_dict) self.assertTrue(cell.layer_dict[102][0].contains(wg1_shapely)) self.assertTrue(cell.layer_dict[102][0].contains(wg2_shapely))
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.port import Port from gdshelpers.parts.waveguide import Waveguide from gdshelpers.parts.mode_converter import StripToSlotModeConverter wg_1 = Waveguide.make_at_port( Port(origin=(0, 0), angle=0, width=1.2)) # scalar as width -> strip waveguide wg_1.add_straight_segment(5) mc_1 = StripToSlotModeConverter.make_at_port( wg_1.current_port, 5, [0.4, 0.2, 0.4], 2, 0.2) # array as width -> slot waveguide wg_2 = Waveguide.make_at_port(mc_1.out_port) wg_2.add_bend(angle=np.pi, radius=5) mc_2 = StripToSlotModeConverter.make_at_port( wg_2.current_port, 5, 1, 2, 0.2) # scalar as width -> strip waveguide wg_3 = Waveguide.make_at_port(mc_2.out_port) wg_3.add_straight_segment(5) cell = Cell('CELL') cell.add_to_layer(1, wg_1, mc_1, wg_2, mc_2, wg_3) cell.show()
def generate_bunch_of_guides(number_of_lines, line_widths, length): guides = Cell('guides') line_widths = iop.fill_list(number_of_lines, line_widths, sorting='ascending') for y in range(0, number_of_lines): guide = Waveguide.make_at_port(Port((0, y*5), 0, line_widths[y])) guide.add_straight_segment(length) guides.add_to_layer(1, guide) return guides
def _example(): from gdshelpers.geometry.chip import Cell img = GdsImage([0, 0], "wolfram_monochrome_100.png", 10) cell = Cell('TEST_IMAGE') cell.add_to_layer(1, img) cell.show() return cell
def _example(): from gdshelpers.geometry.chip import Cell kit_logo = KITLogo([0, 0], 1) wwu_logo = WWULogo([0, 0], 1, 1) cell = Cell('LOGOS') cell.add_to_layer(1, kit_logo) cell.add_to_layer(1, translate(wwu_logo.get_shapely_object(), 2.5)) cell.show()
def test_empty_cell(self): # An empty cell should have 'None' as bounding box cell = Cell('test_cell') # self.assertEqual(cell.bounds, None) cell.add_to_layer(4, box(60, 0, 70, 10)) self.assertEqual(cell.bounds, (60, 0, 70, 10)) subcell = Cell('subcell') cell.add_cell(subcell, origin=(0, 0)) # bounding box of cell should still be the the original bbox self.assertEqual(cell.bounds, (60, 0, 70, 10))
def _example(): text = Text([100, 100], 10, 'The quick brown fox jumps over the lazy dog\n123\n4567', alignment='left-bottom', angle=0.1) print(text.bounding_box) from gdshelpers.geometry.chip import Cell cell = Cell('FONTS') cell.add_to_layer(2, shapely.geometry.box(*text.bounding_box.reshape(4))) cell.add_to_layer(1, text) cell.show()
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 test_bounds_subcell(self): cell = Cell('test_cell') subcell = Cell('subcell') subcell.add_to_layer(3, box(0, 0, 100, 100)) cell.add_cell(subcell, origin=(100, 100)) self.assertEqual(cell.bounds, (100, 100, 200, 200)) cell.add_cell(subcell, origin=(500, 100), angle=np.pi) # cell.save('test_bounds_subcell') self.assertEqual(cell.bounds, (100, 0, 500, 200))
def _example(): qr_code = QRCode([0, 0], 'A0.0', 1.0, version=1, error_correction=QRCode.ERROR_CORRECT_M) from gdshelpers.geometry.chip import Cell device = Cell('test') device.add_to_layer(1, qr_code) device.show() chip = Cell('optical_codes') chip.add_cell(device) chip.start_viewer() chip.save()
def _example(): from gdshelpers.geometry.chip import Cell wg = Waveguide((0, 0), 1, 1) wg.add_straight_segment(30) spiral = Spiral.make_at_port(wg.current_port, 2, 5, 50) wg2 = Waveguide.make_at_port(spiral.out_port) wg2.add_straight_segment(100) print(spiral.length) cell = Cell('Spiral') cell.add_to_layer(1, wg, spiral, wg2) cell.show()
def test_frame(self): # Add frame cell = Cell('test_frame') cell.add_to_layer(4, box(0, 0, 10, 10)) cell.add_frame(padding=10, line_width=1., frame_layer=5) self.assertEqual(cell.bounds, (-11, -11, 21, 21)) self.assertEqual(cell.get_bounds(layers=[4]), (0, 0, 10, 10)) self.assertEqual(cell.get_bounds(layers=[5]), (-11, -11, 21, 21)) cell.add_frame(padding=10, line_width=1., frame_layer=99, bounds=(0, 0, 2, 3)) self.assertEqual(cell.get_bounds(layers=[99]), (-11, -11, 13, 14))
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 _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 test_parallel_export(self): waveguide = Waveguide([0, 0], 0, 1) for i_bend in range(9): waveguide.add_bend(angle=np.pi, radius=60 + i_bend * 40) cells = [Cell('main')] for i in range(10): cell = Cell('sub_cell_' + str(i)) cell.add_to_layer(waveguide) cells[-1].add_cell(cell, (10, 10)) cells[0].save('serial.gds', library='gdshelpers', parallel=False) cells[0].save('parallel.gds', library='gdshelpers', parallel=True) self.assertTrue(filecmp.cmp('serial.gds', 'parallel.gds'))
def generate_layout_cell(size=50, line_width=10): cell = Cell('templateMembraneAlign, size = {}, line_width = {}'.format( size, line_width)) # ring, ring_location = iop.port_ring(15, 10, offset=(100, 200)) corners = [-30, -10, -30, 10, 30, 10, 30, -10] shape, shape_port = iop.port_shape_cartesian(corners, rotate=np.pi * 0, port=Port((-100, 250), 0, 1), offset=(100, 200)) # ============================================ cell.add_to_layer(1, shape) 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 _example(): layout = GridLayout('Test layout\nwith very cool features' + 'long! ' * 50, tight=False, region_layer_type=None) layout.add_column_label_row(['c0', 'c1'], 'col_labels') layout.begin_new_row('row1') test_cell_1 = Cell('TC1') test_cell_1.add_to_layer(1, shapely.geometry.box(0, 00, 335, 125)) test_cell_2 = Cell('TC2') # test_cell_2.add_to_layer(1, shapely.geometry.box(101, 101, 335, 125)) test_cell_2.add_to_layer(1, shapely.geometry.box(0, 0, 600, 400)) layout.add_to_row(test_cell_1, realign=False) # , alignment='left-bottom') layout.add_to_row(test_cell_1, realign=True) # , alignment='center-center') layout.begin_new_row('row2') layout.add_to_row(test_cell_2, realign=True) # , alignment='left-bottom') layout.add_to_row(test_cell_2, realign=True) # , alignment='left-bottom') layout.add_to_row(test_cell_2, realign=True) # , alignment='left-bottom') layout.add_to_row(test_cell_2, realign=True) # , alignment='left-bottom') layout.add_to_row(test_cell_2, realign=True) # , alignment='left-bottom') layout.add_to_row(test_cell_2, realign=True) # , alignment='left-bottom') layout.add_to_row(test_cell_2, realign=True) # , alignment='left-bottom') layout.begin_new_row('row3') layout.add_to_row(test_cell_2, realign=True) # , alignment='left-bottom') layout.add_to_row(test_cell_2, realign=True) # , alignment='left-bottom') layout.add_to_row(test_cell_2, realign=True) # , alignment='left-bottom') layout.add_to_row(test_cell_2, realign=True) # , alignment='left-bottom') layout.add_to_row(test_cell_2, realign=True) # , alignment='left-bottom') layout.add_to_row(test_cell_2, realign=True) # , alignment='left-bottom') layout.add_to_row(test_cell_2, realign=True) # , alignment='left-bottom') # layout.add_to_row(test_cell_1, realign=True)#, alignment='left-bottom') layout_cell, mapping = layout.generate_layout() layout_cell.show() layout_cell.save()
def test_cell_bounds(self): cell = Cell('test_cell') wg1 = Waveguide([0, 0], 0, 1) wg1.add_straight_segment(10) cell.add_to_layer(1, wg1) wg2 = Waveguide([40, 0], 0, 1) wg2.add_straight_segment(10) cell.add_to_layer(2, wg2) cell.add_region_layer(100, [1]) cell.add_region_layer(101, [1, 2]) self.assertTrue(100 in cell.layer_dict) self.assertEqual(cell.bounds, (0.0, -0.5, 50.0, 0.5)) subcell = Cell('subcell') subcell.add_to_layer(3, box(0, 0, 60, 70)) self.assertEqual(subcell.bounds, (0.0, 0, 60.0, 70)) # add subcell cell.add_cell(subcell, origin=(0, 0)) self.assertEqual(cell.bounds, (0.0, -0.5, 60.0, 70.)) subcell2 = Cell('subcell2') subcell2.add_to_layer(3, box(0, 0, 60, 70)) # add subcell at different origin cell.add_cell(subcell2, origin=(20, 0)) self.assertEqual(cell.bounds, (0.0, -0.5, 80.0, 70.)) # add object to subcell after adding the subcell to cell subcell2.add_to_layer(4, box(60, 0, 70, 10)) self.assertEqual(subcell2.bounds, (0.0, 0, 70.0, 70)) self.assertEqual(cell.bounds, (0.0, -0.5, 90.0, 70.)) # check total region layer cell.add_region_layer(102) self.assertTrue(102 in cell.layer_dict) self.assertEqual(cell.get_bounds(layers=[102]), cell.bounds)
def test_bounds_rotation(self): import numpy.testing as np_testing cell1 = Cell('test_cell') cell1.add_to_layer(1, box(10, 10, 30, 20)) np_testing.assert_almost_equal(cell1.bounds, (10, 10, 30, 20)) cell2 = Cell('root_cell') cell2.add_cell(cell1, angle=0.5 * np.pi) np_testing.assert_almost_equal(cell2.bounds, (-20, 10, -10, 30)) cell3 = Cell('root_cell') cell3.add_cell(cell1, angle=1.5 * np.pi) np_testing.assert_almost_equal(cell3.bounds, (10, -30, 20, -10)) cell4 = Cell('root_cell') cell4.add_cell(cell1, angle=1 * np.pi) np_testing.assert_almost_equal(cell4.bounds, (-30, -20, -10, -10)) # For manually testing the bounds rotation, uncomment the following code and look at the resulting GDS """
def _example(): from gdshelpers.geometry.chip import Cell devicename = 'MZI' mzi = MachZehnderInterferometer(origin=(0, 0), angle=0, width=1.2, splitter_length=10, splitter_separation=5, bend_radius=50, upper_vertical_length=50, lower_vertical_length=0, horizontal_length=0) mzi_mmi = MachZehnderInterferometerMMI(origin=(300, 0), angle=0, width=1.2, splitter_length=33, splitter_width=7.7, bend_radius=50, upper_vertical_length=50, lower_vertical_length=0, horizontal_length=0) print(mzi_mmi.device_width) wg = Waveguide.make_at_port(mzi_mmi.port) wg.add_straight_segment(length=50) cell = Cell(devicename) cell.add_to_layer(1, mzi) cell.add_to_layer(1, mzi_mmi) cell.add_to_layer(1, wg) cell.save('%s.gds' % devicename)
def test_export_import(self): waveguide = Waveguide([0, 0], 0, 1) for i_bend in range(9): waveguide.add_bend(angle=np.pi, radius=60 + i_bend * 40) offset = (10, 10) angle = np.pi cell = Cell('test') cell.add_to_layer(1, waveguide) sub_cell = Cell('sub_cell') sub_cell.add_to_layer(2, waveguide) cell.add_cell(sub_cell, origin=(0, 0), angle=0) sub_cell2 = Cell('sub_cell2') sub_cell2.add_to_layer(3, waveguide) cell.add_cell(sub_cell2, origin=offset, angle=angle) cell.save(grid_steps_per_micron=10000) def assert_almost_equal_shapely(a, b, tolerance=2e-4): self.assertTrue(a.buffer(tolerance).contains(b)) self.assertTrue(b.buffer(tolerance).contains(a)) assert_almost_equal_shapely( waveguide.get_shapely_object(), GDSIIImport('test.gds', 'test', 1).get_shapely_object()) assert_almost_equal_shapely( waveguide.get_shapely_object(), GDSIIImport('test.gds', 'test', 2).get_shapely_object()) assert_almost_equal_shapely( translate(rotate(waveguide.get_shapely_object(), angle, use_radians=True, origin=(0, 0)), *offset), GDSIIImport('test.gds', 'test', 3).get_shapely_object()) self.assertTrue(GDSIIImport('test.gds', 'test', 1, 2).get_shapely_object().is_empty)
def _example(): from gdshelpers.geometry.chip import Cell cell = Cell('test') wg1 = Waveguide((0, 0), 0.5 * np.pi, 1.) wg1.add_straight_segment(10.) cell.add_to_layer(3, wg1) detector = SNSPD.make_at_port(wg1.current_port, nw_width=0.1, nw_gap=0.1, nw_length=70, passivation_buffer=0.2, waveguide_tapering=True) cell.add_to_layer(1, detector) cell.add_to_layer(2, detector.get_waveguide()) cell.add_to_layer(5, detector.get_passivation_layer()) # cell.add_to_layer(6, detector.right_electrode_port.debug_shape) # cell.add_to_layer(6, detector.left_electrode_port.debug_shape) wg2 = Waveguide.make_at_port(detector.current_port) wg2.add_straight_segment(20.) cell.add_to_layer(3, wg2) cell.save('SNSPD_test.gds') cell.show()
def test_dlw(self): # Make sure that cells with DLW data only exist once top = Cell('parent_cell') child = Cell('child1') wg1 = Waveguide([0, 0], 0, 1) wg1.add_straight_segment(10) child.add_to_layer(1, wg1) # This should be ok, as child contains no DLW data top.add_cell(child, [0, 0]) top.add_cell(child, [100, 0]) child2 = Cell('child2') child2.add_to_layer(1, wg1) child2.add_dlw_taper_at_port("foo", 1, wg1.current_port, taper_length=40.) top.add_cell(child2, [0, 0]) with self.assertRaises(ValueError): top.add_cell(child2, [100, 0])
def test_export_import(self): waveguide = Waveguide([0, 0], 0, 1) for i_bend in range(9): waveguide.add_bend(angle=np.pi, radius=60 + i_bend * 40) offset = (10, 10) angle = np.pi cell = Cell('test') cell.add_to_layer(1, waveguide) sub_cell = Cell('sub_cell') sub_cell.add_to_layer(2, waveguide) cell.add_cell(sub_cell, origin=(0, 0), angle=0) sub_cell2 = Cell('sub_cell2') sub_cell2.add_to_layer(3, waveguide) cell.add_cell(sub_cell2, origin=offset, angle=angle) cell.save(library='gdshelpers', grid_steps_per_micron=10000) self.assertTrue(waveguide.get_shapely_object().almost_equals( GDSIIImport('test.gds', 'test', 1).get_shapely_object(), decimal=3)) self.assertTrue(waveguide.get_shapely_object().almost_equals( GDSIIImport('test.gds', 'test', 2).get_shapely_object(), decimal=3)) self.assertTrue( translate( rotate(waveguide.get_shapely_object(), angle, use_radians=True, origin=(0, 0)), *offset).almost_equals(GDSIIImport('test.gds', 'test', 3).get_shapely_object(), decimal=3)) self.assertTrue( GDSIIImport('test.gds', 'test', 1, 2).get_shapely_object().is_empty)
x_off = self.origin[0] + np.cos(self._angle) * x - np.sin( self._angle) * y y_off = self.origin[1] + np.sin(self._angle) * x + np.cos( self._angle) * y return Port((x_off, y_off), self._angle - np.pi / 2, self._outer_channel_width) if __name__ == '__main__': from gdshelpers.geometry.chip import Cell part1 = Ntron(origin=(5, -5), angle=0, gate_width_1=0.3, gate_width_2=0.06, choke_width_1=0.06, choke_width_2=0.015, choke_length_2=0.06, choke_length_3=0.03) wgdrain = Waveguide.make_at_port(part1.port_drain) wgdrain.add_straight_segment(0.5) wggate = Waveguide.make_at_port(part1.port_gate) wggate.add_straight_segment(0.5) wgsource = Waveguide.make_at_port(part1.port_source) wgsource.add_straight_segment(0.5) cell = Cell('_channel') cell.add_to_layer(1, part1) cell.show()
outfile.write(pack('>2H', 4, 0x0400)) # ENDLIB N0_DATA if __name__ == '__main__': from gdshelpers.parts.port import Port from gdshelpers.parts.waveguide import Waveguide from gdshelpers.geometry.chip import Cell device_cell = Cell('cell') start_port = Port(origin=(10, 0), width=1, angle=0) waveguide = Waveguide.make_at_port(start_port) for i_bend in range(9): waveguide.add_bend(angle=np.pi, radius=60 + i_bend * 40) device_cell.add_dlw_taper_at_port('A', 2, waveguide.in_port, 30) device_cell.add_dlw_taper_at_port('B', 2, waveguide.current_port, 30) device_cell.add_to_layer(1, waveguide) sub_cell = Cell('sub_cell') sub_cell.add_to_layer(1, waveguide) sub_cell.add_to_layer(3, LineString(((0, 0), (100, 100)))) line = LineString(((0, 0), (-100, 100))) line.width = 3 sub_cell.add_to_layer(3, line) device_cell.add_cell(sub_cell, origin=(10, 10), angle=np.pi / 2) with open('gdsii_export.gds', 'wb') as file: write_cell_to_gdsii_file(file, device_cell, parallel=True)
wg_sep=wg_sep, electrode_wg_sep=electrode_wg_sep, gc_params={ 'width': 0.5, 'full_opening_angle': np.deg2rad(180), 'grating_period': 0.49, 'grating_ff': 0.2, 'n_gratings': 10, 'ap_max_ff': 0.8, 'n_ap_gratings': 65, 'taper_length': 9.64 }) left4x4_cell.add_to_layer( comment_layer, Text((560, 540), 10, 'wg_width={:.2f}um\nexp_wg_width={:.2f}um\ngrat_period={:.2f}um'. format(wg_width, wg_Expwidth, 0.49), alignment='center-top')) # Adding Right 4x4 interferometer right4x4_cell = Cell('4x4 interferometer_Right') _, right_init_wf_point, right_in_bounds = interferometer_and_fiber_array( cell=right4x4_cell, inports=device_inports_2, gc_positions=grating_coupler_positions_2, electrode_length=1250, coupler_sep=0.5, coupler_length=30, sm_wg_width=wg_width, wg_layer=9,