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(): 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)) # Show the cell cell.show()
def _example(): import gdsCAD.core from gdshelpers.geometry import convert_to_gdscad kit_logo = KITLogo([0, 0], 1) wwu_logo = WWULogo([0, 0], 1, 1) cell = gdsCAD.core.Cell('LOGOS') cell.add(convert_to_gdscad(kit_logo)) cell.add(convert_to_gdscad(translate(wwu_logo.get_shapely_object(), 2.5))) cell.show()
def main(): import gdsCAD from gdshelpers.geometry import convert_to_gdscad devicename = 'Cavity' cavitiyparameter_const = {'origin': [0, 0], 'angle': 0, 'width': 0.726, 'lengthofcavity': 0.26, 'numberofholes': 17, 'holediameters': 0.416, 'holedistances': 0.53} cavitiyparameter_lin = {'origin': [100, 500], 'angle': 0, 'width': 0.726, 'lengthofcavity': 0.26, 'numberofholes': 17, 'holediameters': np.linspace(0.233, 0.416, 17), 'holedistances': np.linspace(0.53, 0.605, 16)} taperlength = 15 * 0.414 cavitiyparameter_tap_width = {'origin': [-50, -30], 'angle': np.pi, 'width': 1.1, 'numberofholes': 25, 'taperlength': taperlength, 'lengthofcavity': -0.414, 'finalwidth': 1.55, 'tapermode': 'quadratic', 'holediameters': 0.414, 'holedistances': 0.620} holeparams_bg = {'mindia': 0.267, 'maxdia': 0.267, 'mindist': 0.512, 'maxdist': 0.512, 'numholestap': 1, 'numholesmir': 10} bandgapparameter = {'origin': [0, 0], 'angle': 0, 'width': 1.015, 'lengthofcavity': -0.512 / 2, 'holeparams': holeparams_bg} # pccav1 = PhotonicCrystalCavity(**cavitiyparameter_const) bandgap = PhotonicCrystalCavity(**bandgapparameter) port1 = Port(origin=[10, 10], angle=np.pi / 2, width=1) # cav2 = PhotonicCrystalCavity.make_at_port(port=port1, **cavitiyparameter_tap_width) pccav3 = PhotonicCrystalCavity(**cavitiyparameter_tap_width) wg = Waveguide.make_at_port(port1.inverted_direction) wg.add_straight_segment(length=5) cell = gdsCAD.core.Cell(devicename) # cell.add(convert_to_gdscad(pccav1.layer_photonic_cavity, layer=1)) # cell.add(convert_to_gdscad(pccav2.layer_marker, layer=StandardLayers.lmarklayer)) # cell.add(convert_to_gdscad(pccav2.layer_underetch, layer=StandardLayers.masklayer1)) # cell.add(convert_to_gdscad(pccav2.layer_photonic_cavity, layer=StandardLayers.nanolayer)) # cell.add(convert_to_gdscad(pccav3.layer_marker, layer=StandardLayers.lmarklayer)) # cell.add(convert_to_gdscad(pccav3.layer_underetch, layer=StandardLayers.masklayer1)) cell.add(convert_to_gdscad(bandgap.layer_underetch, layer=StandardLayers.masklayer1)) cell.add(convert_to_gdscad(bandgap.layer_photonic_cavity, layer=StandardLayers.nanolayer)) # cell.add(convert_to_gdscad(pccav2.layer_photonic_cavity, layer=1)) # cell.add(convert_to_gdscad(pccav3.get_holes_list())) holes = pccav3.get_holes_list() layout = gdsCAD.core.Layout() layout.add(cell=cell) layout.show()
def _example(): import gdsCAD.core from gdshelpers.geometry import convert_to_gdscad from gdshelpers.parts.waveguide import Waveguide mpsv2 = MultiPortSwitch(origin=[0, 0], angle=np.deg2rad(0.), in_ports=4, out_ports=7, port_spacing=10, taper_length=40, taper_function=lambda t: t * (1.0 - 0.05) + 0.05, radius=50., displacement=0., wg_bend_radius=40., minimal_final_spacing=20) wg = Waveguide([100, 100], np.pi / 4, 1) wg.add_straight_segment(100) # mpsv2_2 = MultiPortSwitch.make_at_out_port(wg.current_port, 3, # in_ports=2, out_ports=7, # port_spacing=10, # taper_length=10, taper_function=lambda t: t * (1.0 - 0.05) + 0.05, # radius=50., displacement=00., # wg_bend_radius=40., ) cell = gdsCAD.core.Cell('TEST') cell.add(convert_to_gdscad([ mpsv2, wg, ])) cell.show()
def _example(): from gdshelpers.geometry import convert_to_gdscad import gdsCAD cell = gdsCAD.core.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(convert_to_gdscad([wg1, ring1, wg2, ring2, wg3, ring3], layer=1)) cell.show()
def _example_mmi(): import gdsCAD.core from gdshelpers.geometry import convert_to_gdscad mmi = MMI((80, 0), 0, 1, 20, 10, 2, 2) cell = gdsCAD.core.Cell('Splitter') cell.add(convert_to_gdscad(geometric_union([mmi]))) cell.show()
def _example(): import gdsCAD.core from gdshelpers.geometry import convert_to_gdscad img = GdsImage([0, 0], "wolfram_monochrome_100.png", 10) cell = gdsCAD.core.Cell('TEST_IMAGE') cell.add(convert_to_gdscad(img)) cell.show() return cell
def _cnt_example(): import gdsCAD.core from gdshelpers.geometry import convert_to_gdscad from gdshelpers.parts.waveguide import Waveguide # photonics start_port = Port((0, 0), 0, 1.1) wg = Waveguide.make_at_port(start_port) wg.add_straight_segment(20) cnt_port = wg.current_port cnt = CNT.make_at_port(cnt_port, gap=0.4, l_taper=100, w_taper=0.1) wg2 = Waveguide.make_at_port(cnt.out_port) wg2.add_bend(np.pi / 4, 100) cnt2 = CNT.make_at_port(wg2.current_port, gap=0.15) union = geometric_union([wg, cnt, wg2, cnt2]) # electrodes el1_l = Waveguide.make_at_port(cnt.left_electrode_port) el1_l.add_straight_segment(100, 100) el1_r = Waveguide.make_at_port(cnt.right_electrode_port) # el1_r.add_straight_segment(100) port = cnt2.left_electrode_port port.width = 20 el2_l = Waveguide.make_at_port(port) el2_l.add_straight_segment(30) el = geometric_union( [cnt.electrodes, cnt2.electrodes, el1_l, el1_r, el2_l]) cell = gdsCAD.core.Cell('test') cell.add(convert_to_gdscad(union)) cell.add(convert_to_gdscad(el, layer=2)) layout = gdsCAD.core.Layout() layout.add(cell) layout.show() layout.save('CNT_Device_Test.gds')
def _example(): text = Text([100, 100], 10, 'The quick brown fox jumps over the lazy dog\n123\n4567', alignment='left-bottom') print(text.bounding_box) import gdsCAD.core from gdshelpers.geometry import convert_to_gdscad cell = gdsCAD.core.Cell('FONTS') cell.add(convert_to_gdscad(text)) cell.show()
def _example(): import gdsCAD 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 = gdsCAD.core.Cell(devicename) cell.add(convert_to_gdscad(mzi, layer=1)) cell.add(convert_to_gdscad(mzi_mmi, layer=1)) cell.add(convert_to_gdscad(wg, layer=1)) layout = gdsCAD.core.Layout() layout.add(cell=cell) layout.save('%s.gds' % devicename) layout.show()
def _example(): import gdsCAD.core from gdshelpers.geometry import convert_to_gdscad dc = DirectionalCoupler((0, 0), np.pi / 4, 1, 10, 1, 10) dc2 = DirectionalCoupler.make_at_port(dc.right_ports[1], 5, 2, 10, which=0) wg = Waveguide.make_at_port(dc.left_ports[1]) wg.add_straight_segment(12) wg2 = Waveguide.make_at_port(dc2.right_ports[0]) wg2.add_straight_segment(12) mmi = MMI((80, 0), 0, 1, 20, 10, 2, 1) mmi2 = MMI.make_at_port(dc2.right_ports[1], 10, 10, 2, 2, 'i1') cell = gdsCAD.core.Cell('Splitter') cell.add(convert_to_gdscad(geometric_union((dc, dc2, wg, wg2, mmi, mmi2)))) cell.show()
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__': import gdsCAD.core 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 = gdsCAD.core.Cell('_channel') cell.add(convert_to_gdscad([part1], layer=1)) cell.show()
def _example(): import gdsCAD import gdsCAD.templates from gdshelpers.geometry import convert_to_gdscad, geometric_union 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) print(path2.length) print(path2.length_last_segment) path2.add_cubic_bezier_path((0, 0), (5, 0), (10, 10), (5, 10)) 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 = gdsCAD.core.Layout('LIBRARY') cell = gdsCAD.core.Cell('TOP') cell.add(convert_to_gdscad(whole_layout)) cell.add(convert_to_gdscad(empty_path, layer=2)) cell.add(convert_to_gdscad(splitter.root_port.debug_shape, layer=4)) layout.add(cell) cell_df = gdsCAD.core.Cell('TOP_DF') cell_df.add( convert_to_gdscad( convert_to_positive_resist(whole_layout, buffer_radius=1.5))) layout.add(cell_df) layout.save('output.gds') cell.show()
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)) # Show the cell cell.show()