示例#1
0
    def _repr_html_(self):
        from phidl import quickplot as qp
        from pp.write_component import show

        qp(self)
        show(self)
        return self.__str__()
示例#2
0
def check(device: Device, joined=False, blocking=True):
    ''' Shows the device layout.

        If run by terminal, blocks script until window is closed.

        Parameters
        ----------
            device : phidl.Device

            joined : boolean (optional, default False)

                if true, returns a flattened/joined version of device

    '''
    set_quickplot_options(blocking=blocking)

    if joined:

        cell = Device()
        cell.absorb(cell << device)
        cell.flatten()
        qp(join(cell))

    else:

        qp(device)
示例#3
0
    def view(self, blocking=False):
        ''' Visualize cell layout with current parameters.

        Parameters
        ----------
        blocking : boolean

            if true,block scripts until window is closed.
        '''

        set_quickplot_options(blocking=blocking)
        qp(self.draw())
        return
示例#4
0
def create_image(D, filename, filepath = '_static/'):
    # if any(D.size == 0):
    #     D = pg.text('?')
    qp(D)
    fig = plt.gcf()
    # ax = plt.gca()
    scale = 0.75
    fig.set_size_inches(10*scale, 4*scale, forward=True)
    # ax.autoscale()
    # plt.draw()
    # plt.show(block = False)
    filename +=  '.png'
    filepathfull = os.path.join(os.path.curdir, filepath, filename)
    print(filepathfull)
    fig.savefig(filepathfull, dpi=int(96/scale))
示例#5
0
    def plot(self, **kwargs) -> None:
        """Plot component in matplotlib

        Args:
            show_ports: True
            show_subports:
            label_ports:
            label_aliases:
            new_window

        """
        from phidl import quickplot as qp

        from pp.cell import clear_cache

        qp(self, **kwargs)
        clear_cache()
示例#6
0
def check(device: Device, joined=False, blocking=True, gds=False):
    ''' Shows the device layout.

        If run by terminal, blocks script until window is closed.

        Parameters
        ----------
            device : phidl.Device

            joined : boolean (optional, default False)
                if true, returns a flattened/joined version of device

            gds : boolean
                if true, view in gdspy viewer

    '''
    set_quickplot_options(blocking=blocking)

    if joined:

        cell = join(device)

    else:

        cell = device

    if gds:

        lib = gdspy.GdsLibrary()

        gcell = lib.new_cell("Output")

        gcell.add(cell)

        gdspy.LayoutViewer(lib)

    else:

        qp(cell)
示例#7
0
from phidl import set_quickplot_options

set_quickplot_options(blocking=True)

distance = 50
width = 10
spacing = 50
n = 4

d = Device()

for i in range(n):

    d.add_port(
        Port(
            midpoint=(spacing * i, 0),
            # midpoint=(0,spacing*i),
            width=width,
            orientation=90,
            name='top_' + str(i)))

connector = connect_ports(d, tag='top', distance=distance)

d << connector

for p in connector.get_ports(depth=0):

    d.add_port(connector.ports[p.name])

qp(d)
WG1 = waveguide(width=10, height=1)
WG2 = waveguide(width=12, height=2)

# Now we've made two waveguides Device WG1 and WG2, and we have a blank
# device D. We can add references from the devices WG1 and WG2 to our blank
# device byz using the add_ref() function.
# After adding WG1, we see that the add_ref() function returns a handle to our
# reference, which we will label with lowercase letters wg1 and wg2.  This
# handle will be useful later when we want to move wg1 and wg2 around in D.
wg1 = D.add_ref(WG1)  # Using the function add_ref()
wg2 = D << WG2  # Using the << operator which is identical to add_ref()

# Alternatively, we can do this all on one line
wg3 = D.add_ref(waveguide(width=14, height=3))

qp(D)  # quickplot it!

#==============================================================================
# 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)])

# 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([(0, 0), (1, 1), (1, 3), (-3, 3)])

qp(D)  # quickplot it!

#==============================================================================
示例#9
0
    fig.set_size_inches(10*scale, 4*scale, forward=True)
    # ax.autoscale()
    # plt.draw()
    # plt.show(block = False)
    filename +=  '.png'
    filepathfull = os.path.join(os.path.curdir, filepath, filename)
    print(filepathfull)
    fig.savefig(filepathfull, dpi=int(96/scale))


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

D = pg.rectangle(size = (4.5, 2), layer = 0)
qp(D) # quickplot the geometry
create_image(D, 'rectangle')


# example-bbox
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')
示例#10
0
import phidl.geometry as pg
import phidl.device_layout as dl
import phidl.path as pp
from phidl import quickplot as qp
from phidl import set_quickplot_options
set_quickplot_options(blocking=True)
p1 = (0, 0)
p2 = (0, 30)
p3 = (0, 30)
p4 = (0, 60)
p5 = (0, 60)
# p4=(20,2000)

p = dl.Path((p1, p2, p3, p4, p5))
c = p.extrude(width=10, layer=1)

qp(c)
示例#11
0
import phidl.utilities as pu
import phidl.path as pp
import layoutISING as li
import numpy as np
import matplotlib.pyplot as plt
from scipy.constants import pi, c

# # Initialization

# In[2]:

#Load process layers and save layer properties file for Klayout visualization.

ls = li.setup_layers()
P = pg.preview_layerset(ls)
qp(P)
# P.write_svg('Layers.svg')
pu.write_lyp('mac_0.lyp', layerset=ls)

#Set up the units

mm = 10**3
um = 1
nm = 10**(-3)

# Global Chip Parameters
chip_width = 23 * mm
chip_height = 13 * mm
ko = 1.5 * mm
T = li.chip(size=(chip_width, chip_height),
            name='MAC CHIP REV #0',
示例#12
0
WG1 = waveguide(width=10, height=1)
WG2 = waveguide(width=12, height=2)

# Now we've made two waveguides Device WG1 and WG2, and we have a blank
# device D. We can add references from the devices WG1 and WG2 to our blank
# device byz using the add_ref() function.
# After adding WG1, we see that the add_ref() function returns a handle to our
# reference, which we will label with lowercase letters wg1 and wg2.  This
# handle will be useful later when we want to move wg1 and wg2 around in D.
wg1 = D.add_ref(WG1)  # Using the function add_ref()
wg2 = D << WG2  # Using the << operator which is identical to add_ref()

# Alternatively, we can do this all on one line
wg3 = D.add_ref(waveguide(width=14, height=3))

qp(D)  # quickplot it!

#==============================================================================
# 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)])

# 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([(0, 0), (1, 1), (1, 3), (-3, 3)])

qp(D)  # quickplot it!

#==============================================================================
示例#13
0
import phidl.geometry as pg
import phidl.device_layout as dl
import phidl.path as pp
from phidl import quickplot as qp
from phidl import set_quickplot_options
set_quickplot_options(blocking=True)
p1 = (0, 0)
p2 = (0, 40)
p3 = (20, 1600)
p4 = (20, 2000)

path = pp.smooth(points=(p1, p2, p3, p4), radius=0.1, num_pts=1000)

qp(path)