Пример #1
0
def align_TE_on_via():

    cell = dl.Device("Align TE on VIA")

    circle = pg.circle(radius=50, layer=pt.LayoutDefault.layerVias)

    cross = pg.cross(width=30, length=250, layer=pt.LayoutDefault.layerVias)

    g = Group([circle, cross])

    g.align(alignment='x')
    g.align(alignment='y')
    circle.add(cross)

    viapattern = pg.union(circle, 'A+B', layer=pt.LayoutDefault.layerVias)

    TEpattern = pg.union(circle, 'A+B',
                         layer=pt.LayoutDefault.layerTop).copy('tmp',
                                                               scale=0.8)

    cell.add(viapattern)
    cell.add(TEpattern)

    cell.align(alignment='x')
    cell.align(alignment='y')

    cell.flatten()

    return cell
Пример #2
0
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')
Пример #3
0
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')
Пример #4
0
def test_group():
    # Test all types
    D = Device()
    E1 = pg.ellipse(radii=(10, 5), angle_resolution=2.5, layer=0)
    E2 = pg.rectangle(size=(4, 2), layer=0).movex(15)
    e1 = D << E1
    e2 = D << E2
    e3 = D << E2
    e4 = D.add_label('hello', position=(1.5, -1.5))
    e5 = pg.snspd()
    e6 = D.add_polygon([(8, 6, 7, 9, 7, 0), (6, 8, 9, 5, 7, 0)])
    e7 = D.add_array(pg.cross())
    e2verify = D << E2

    # Test creation and addition
    G = Group()
    G.add(e1)
    G.add(e2)
    G.add([e3, e4, e5])
    G += (e6, e7)
    assert np.allclose(G.bbox.flatten(), np.array([-10., -8.5, 105., 105.]))

    # Test movement
    G.move((2, 7))
    e2verify.move((2, 7))
    assert np.allclose(G.bbox.flatten(), np.array([-8., -1.5, 107., 112.]))
    assert all(e2.center == e2verify.center)
    assert e2.rotation == e2verify.rotation

    # Test rotation
    G.rotate(90, center=(5, 5))
    e2verify.rotate(90, center=(5, 5))
    assert np.allclose(G.bbox.flatten(), np.array([-102., -8., 11.5, 107.]))
    assert all(e2.center == e2verify.center)
    assert e2.rotation == e2verify.rotation

    # Test mirroring
    G.mirror(p1=(1, 1), p2=(-1, 1))
    e2verify.mirror(p1=(1, 1), p2=(-1, 1))
    assert np.allclose(G.bbox.flatten(), np.array([-102., -105., 11.5, 10.]))
    assert all(e2.center == e2verify.center)
    assert e2.rotation == e2verify.rotation
    h = D.hash_geometry(precision=1e-4)
    assert (h == '3964acb3971771c6e70ceb587c2ae8b37f2ed112')
Пример #5
0
#==============================================================================
# Creating polygons
#==============================================================================
# Create and add a polygon from separate lists of x points and y points
# e.g. [(x1, x2, x3, ...), (y1, y2, y3, ...)]
poly1 = D.add_polygon([(8, 6, 7, 9), (6, 8, 9, 5)], layer=0)

# Alternatively, create and add a polygon from a list of points
# e.g. [(x1,y1), (x2,y2), (x3,y3), ...] using the same function
poly2 = D.add_polygon([(-5, 3), (-4, 4), (-4, 6), (-8, 6)], layer=1)

# As a third option, use functions from the built-in geometry library
# (more examples below in section "Using the built-in geometry library")
# and a listing is available at http://phidl.readthedocs.io/ )
D << pg.ellipse(radii=(3, 1.5), layer=1).move([10, -4])
D << pg.cross(length=3, width=0.2, layer=0).move([10, -8])
D << pg.rectangle(size=(4, 2), layer=3).move([-10, -5])
D << pg.litho_steps(
    line_widths=[.1, .2, .4, .8], line_spacing=1, height=6, layer=0).move(
        [0, -5])

qp(D)  # quickplot it!

#%%

#==============================================================================
# Manipulating geometry 1 - Basic movement and rotation
#==============================================================================
# There are several actions we can take to move and rotate the geometry.  These
# actions include movement, rotation, and reflection.
Пример #6
0
import phidl.geometry as pg
from phidl import quickplot as qp
from phidl import Device

D = Device()
arc = D << pg.arc(radius = 10, width = 0.5, theta = 85, layer = 1).rotate(25)
 # Draw a rectangle around the arc we created by using the arc's bounding box
rect = D << pg.bbox(bbox = arc.bbox, layer = 0)
qp(D) # quickplot the geometry
create_image(D, 'bbox')

# example-cross
import phidl.geometry as pg
from phidl import quickplot as qp

D = pg.cross(length = 10, width = 0.5, layer = 0)
qp(D) # quickplot the geometry
create_image(D, 'cross')

# example-ellipse
import phidl.geometry as pg
from phidl import quickplot as qp

D = pg.ellipse(radii = (10,5), angle_resolution = 2.5, layer = 0)
create_image(D, 'ellipse')

# example-circle
import phidl.geometry as pg
from phidl import quickplot as qp

D = pg.circle(radius = 10, angle_resolution = 2.5, layer = 0)
Пример #7
0
def test_invert():
    A = pg.cross(length=10, width=3, layer=0)
    B = pg.ellipse(radii=(10, 5), angle_resolution=2.5, layer=1)
    D = pg.invert([A, B], border=4, precision=1e-6, layer=2)
    h = D.hash_geometry(precision=1e-4)
    assert (h == 'eed5a4cb31da61a495c9ff4c5dc4d06fe28707aa')
Пример #8
0
def test_cross():
    D = pg.cross(length=10, width=3, layer=0)
    h = D.hash_geometry(precision=1e-4)
    assert (h == '18470cb24843265fe42a283f1cde91cbc8a2abe2')
Пример #9
0
def test_outline():
    A = pg.cross(length=10, width=3, layer=0)
    B = pg.ellipse(radii=(10, 5), angle_resolution=2.5, layer=1)
    D = pg.outline([A, B], distance=1, precision=1e-6, layer=2)
    h = D.hash_geometry(precision=1e-4)
    assert (h == '503522b071080be6c98017cdc616752c1a3d75ce')
Пример #10
0
def test_boolean():
    A = pg.cross(length=10, width=3, layer=0)
    B = pg.ellipse(radii=(10, 5), angle_resolution=2.5, layer=1)
    D = pg.boolean(A=A, B=B, operation='and', precision=1e-6, layer=2)
    h = D.hash_geometry(precision=1e-4)
    assert (h == 'fcf1d0809488be01480027a5914dfb399faf088c')