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])
_cell_to_gdsii_binary(c, grid_steps_per_unit, max_points, max_line_points, timestamp)) 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:
self.add_dlw_data('taper', str(label), {'origin': taper_port.origin.tolist(), 'angle': port.angle, 'starting_width': port.width, 'taper_length': taper_length}) if with_markers: for i, (v, l) in enumerate(itertools.product((-20, 20), (taper_length, 0))): self.add_dlw_marker(str(label) + '-' + str(i), layer, port.parallel_offset(v).longitudinal_offset(l).origin) if __name__ == '__main__': from gdshelpers.parts.port import Port from gdshelpers.parts.waveguide import Waveguide from gdshelpers.geometry.chip import Cell # Create a cell-like object that offers a save output command '.save' which creates the .gds or .oas file by using # gdsCAD,gdspy or fatamorgana device_cell = Cell('my_cell') # Create a port to connect waveguide structures to port = Port(origin=(0, 0), width=1, angle=0) waveguide = Waveguide.make_at_port(port) for i in range(9): waveguide.add_bend(angle=np.pi, radius=60 + i * 40) # Add direct laser writing taper and alignment marker for postprocessing with a dlw printer to the cell-like object. # The cell dlw files will be saved with the cell. device_cell.add_dlw_taper_at_port('A0', 2, port.inverted_direction, 30) device_cell.add_dlw_taper_at_port('A1', 2, waveguide.current_port, 30) device_cell.add_to_layer(1, waveguide) device_cell.show() # Creates the output file by using gdspy,gdsCAD or fatamorgana. To use the implemented parallell processing, set # parallel=True. device_cell.save(name='my_design', parallel=True, library='gdspy')