def test_offset(): A = pg.cross(length=10, width=3, layer=0) B = pg.ellipse(radii=(10, 5), angle_resolution=2.5, layer=1) D = pg.offset([A, B], distance=0.1, join_first=True, precision=0.001, layer=2) h = D.hash_geometry(precision=1e-4) assert (h == 'dea81b4adf9f163577cb4c750342f5f50d4fbb6d')
def test_offset(): A = pg.cross(length=10, width=3, layer=0) B = pg.ellipse(radii=(10, 5), angle_resolution=2.5, layer=1) D = pg.offset([A, B], distance=0.1, join_first=True, precision=0.001, max_points=4000, layer=2) h = D.hash_geometry(precision=1e-4) assert (h == 'bd4b9182042522fa00b5ddb49d182523b4bf9eb5')
def global_markers(layer_marker=10, layer_mask=20): D = Device('Global Markers') R = pg.rectangle(size=(20, 20), layer=1) a = D.add_array(R, columns=6, rows=6, spacing=(100, 100)) a.move([-260, -260]) #Center of the array R = pg.rectangle(size=(20, 20), layer=1) a = D.add_array(R, columns=6, rows=6, spacing=(100, 100)) a.move([-260, -260]) #Center of the array #Add marker cover cover = pg.bbox(bbox=a.bbox, layer=layer_mask) D << pg.offset(cover, distance=100, layer=layer_mask) return D
def test_resistance( pad_size=[50, 50], num_squares=1000, width=1, res_layer=0, pad_layer=None, gnd_layer=None, ): """ meander to test resistance from phidl.geometry Args: pad_size: Size of the two matched impedance pads (microns) num_squares: Number of squares comprising the resonator wire width: The width of the squares (microns) res_layer: pad_layer: gnd_layer: .. plot:: :include-source: import pp c = pp.c.test_resistance() pp.plotgds(c) """ x = pad_size[0] z = pad_size[1] # Checking validity of input if x <= 0 or z <= 0: raise ValueError("Pad must have positive, real dimensions") elif width > z: raise ValueError("Width of cell cannot be greater than height of pad") elif num_squares <= 0: raise ValueError("Number of squares must be a positive real number") elif width <= 0: raise ValueError("Width of cell must be a positive real number") # Performing preliminary calculations num_rows = int(np.floor(z / (2 * width))) if num_rows % 2 == 0: num_rows -= 1 num_columns = num_rows - 1 squares_in_row = (num_squares - num_columns - 2) / num_rows # Compensating for weird edge cases if squares_in_row < 1: num_rows = round(num_rows / 2) - 2 squares_in_row = 1 if width * 2 > z: num_rows = 1 squares_in_row = num_squares - 2 length_row = squares_in_row * width # Creating row/column corner combination structure T = pp.Component() Row = pc.rectangle(size=(length_row, width), layer=res_layer) Col = pc.rectangle(size=(width, width), layer=res_layer) T.add_ref(Row) col = T.add_ref(Col) col.move([length_row - width, -width]) # Creating entire waveguide net N = pp.Component("net") n = 1 for i in range(num_rows): if i != num_rows - 1: d = N.add_ref(T) else: d = N.add_ref(Row) if n % 2 == 0: d.reflect(p1=(d.x, d.ymax), p2=(d.x, d.ymin)) d.movey(-(n - 1) * T.ysize) n += 1 d = N.add_ref(Col).movex(-width) d = N.add_ref(Col).move([length_row, -(n - 2) * T.ysize]) # Creating pads P = pp.Component() Pad1 = pc.rectangle(size=(x, z), layer=pad_layer) Pad2 = pc.rectangle(size=(x + 5, z), layer=pad_layer) Gnd1 = offset(Pad1, distance=-5, layer=gnd_layer) Gnd2 = offset(Pad2, distance=-5, layer=gnd_layer) pad1 = P.add_ref(Pad1).movex(-x - width) pad2 = P.add_ref(Pad1).movex(length_row + width) P.add_ref(Gnd1).center = pad1.center gnd2 = P.add_ref(Gnd2) P.add_ref(N).y = pad1.y gnd2.center = pad2.center gnd2.movex(2.5) return P
D = pg.C(width = 7, size = (10,20) , layer = 0) qp(D) # quickplot the geometry create_image(D, 'C') # example-offset import phidl.geometry as pg from phidl import quickplot as qp from phidl import Device # Create `T`, an ellipse and rectangle which will be offset (expanded / contracted) T = Device() e = T << pg.ellipse(radii = (10,5), layer = 1) r = T << pg.rectangle(size = [15,5], layer = 2) r.move([3,-2.5]) Texpanded = pg.offset(T, distance = 2, join_first = True, precision = 1e-6, num_divisions = [1,1], layer = 0) Tshrink = pg.offset(T, distance = -1.5, join_first = True, precision = 1e-6, num_divisions = [1,1], layer = 0) # Plot the original geometry, the expanded, and the shrunk versions D = Device() t1 = D.add_ref(T) t2 = D.add_ref(Texpanded) t3 = D.add_ref(Tshrink) D.distribute([t1,t2,t3], direction = 'x', spacing = 5) qp(D) # quickplot the geometry create_image(D, 'offset') # example-invert import phidl.geometry as pg from phidl import quickplot as qp
def resistance_meander( pad_size: Tuple[float] = (50.0, 50.0), num_squares: int = 1000, width: float = 1.0, res_layer: Tuple[int, int] = LAYER.M3, pad_layer: Tuple[int, int] = LAYER.M3, gnd_layer: Tuple[int, int] = LAYER.M3, ) -> Component: """meander to test resistance from phidl.geometry Args: pad_size: Size of the two matched impedance pads (microns) num_squares: Number of squares comprising the resonator wire width: The width of the squares (microns) res_layer: pad_layer: gnd_layer: """ x = pad_size[0] z = pad_size[1] # Checking validity of input if x <= 0 or z <= 0: raise ValueError("Pad must have positive, real dimensions") elif width > z: raise ValueError("Width of cell cannot be greater than height of pad") elif num_squares <= 0: raise ValueError("Number of squares must be a positive real number") elif width <= 0: raise ValueError("Width of cell must be a positive real number") # Performing preliminary calculations num_rows = int(np.floor(z / (2 * width))) if num_rows % 2 == 0: num_rows -= 1 num_columns = num_rows - 1 squares_in_row = (num_squares - num_columns - 2) / num_rows # Compensating for weird edge cases if squares_in_row < 1: num_rows = round(num_rows / 2) - 2 squares_in_row = 1 if width * 2 > z: num_rows = 1 squares_in_row = num_squares - 2 length_row = squares_in_row * width # Creating row/column corner combination structure T = Component() Row = pc.rectangle(size=(length_row, width), layer=res_layer) Col = pc.rectangle(size=(width, width), layer=res_layer) T.add_ref(Row) col = T.add_ref(Col) col.move([length_row - width, -width]) # Creating entire straight net N = Component("net") n = 1 for i in range(num_rows): if i != num_rows - 1: d = N.add_ref(T) else: d = N.add_ref(Row) if n % 2 == 0: d.reflect(p1=(d.x, d.ymax), p2=(d.x, d.ymin)) d.movey(-(n - 1) * T.ysize) n += 1 d = N.add_ref(Col).movex(-width) d = N.add_ref(Col).move([length_row, -(n - 2) * T.ysize]) # Creating pads P = Component() pad1 = pc.rectangle(size=(x, z), layer=pad_layer) pad2 = pc.rectangle(size=(x + 5, z), layer=pad_layer) gnd1 = offset(pad1, distance=-5, layer=gnd_layer) gnd2 = offset(pad2, distance=-5, layer=gnd_layer) pad1_ref = P.add_ref(pad1) pad1_ref.movex(-x - width) pad2_ref = P.add_ref(pad1) pad2_ref.movex(length_row + width) gnd1_ref = P.add_ref(gnd1) gnd1_ref.center = pad1_ref.center gnd2_ref = P.add_ref(gnd2) net = P.add_ref(N) net.y = pad1_ref.y gnd2_ref.center = pad2_ref.center gnd2_ref.movex(2.5) P.absorb(net) P.absorb(gnd1_ref) P.absorb(gnd2_ref) P.absorb(pad1_ref) P.absorb(pad2_ref) return P