snapshot 2020-12-20 19:25:22.178552
This commit is contained in:
commit
1024a32d2d
0
examples/tutorial/README.md
Normal file
0
examples/tutorial/README.md
Normal file
84
examples/tutorial/basic.py
Normal file
84
examples/tutorial/basic.py
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
from typing import Tuple, Sequence
|
||||||
|
|
||||||
|
import numpy # type: ignore
|
||||||
|
from numpy import pi
|
||||||
|
|
||||||
|
from masque import layer_t, Pattern, SubPattern, Label
|
||||||
|
from masque.shapes import Circle, Arc
|
||||||
|
from masque.builder import Device, Port
|
||||||
|
from masque.library import Library, DeviceLibrary
|
||||||
|
import masque.file.klamath
|
||||||
|
|
||||||
|
import pcgen
|
||||||
|
|
||||||
|
|
||||||
|
HOLE_SCALE: float = 1000
|
||||||
|
""" Radius for the 'hole' cell. Should be significantly bigger than
|
||||||
|
1 (minimum database unit) in order to have enough precision to
|
||||||
|
reasonably represent a polygonized circle (for GDS)
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def hole(radius: float = HOLE_SCALE,
|
||||||
|
layer: layer_t = (1, 0),
|
||||||
|
) -> Pattern:
|
||||||
|
"""
|
||||||
|
Generate a pattern containing a single circular hole.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
layer: Layer to draw the circle on.
|
||||||
|
radius: Circle radius.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Pattern, named `'hole'`
|
||||||
|
"""
|
||||||
|
pat = Pattern('hole', shapes=[
|
||||||
|
Circle(radius=radius, offset=(0, 0), layer=layer)
|
||||||
|
])
|
||||||
|
return pat
|
||||||
|
|
||||||
|
|
||||||
|
def smile(radius: float = HOLE_SCALE,
|
||||||
|
layer: layer_t = (1, 0),
|
||||||
|
secondary_layer: layer_t = (1, 2)
|
||||||
|
) -> Pattern:
|
||||||
|
"""
|
||||||
|
Generate a pattern containing a single smiley face.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
radius: Boundary circle radius.
|
||||||
|
layer: Layer to draw the outer circle on.
|
||||||
|
secondary_layer: Layer to draw eyes and smile on.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Pattern, named `'smile'`
|
||||||
|
"""
|
||||||
|
# Make an empty pattern
|
||||||
|
pat = Pattern('smile')
|
||||||
|
|
||||||
|
# Add all the shapes we want
|
||||||
|
pat.shapes += [
|
||||||
|
Circle(radius=radius, offset=(0, 0), layer=layer), # Outer circle
|
||||||
|
Circle(radius=radius / 10, offset=(radius / 3, radius / 3), layer=secondary_layer),
|
||||||
|
Circle(radius=radius / 10, offset=(-radius / 3, radius / 3), layer=secondary_layer),
|
||||||
|
Arc(radii=(radius * 2 / 3, radius * 2 / 3), # Underlying ellipse radii
|
||||||
|
angles=(7 / 6 * pi, 11 / 6 * pi), # Angles limiting the arc
|
||||||
|
width=radius / 10,
|
||||||
|
offset=(0, 0),
|
||||||
|
layer=secondary_layer),
|
||||||
|
]
|
||||||
|
|
||||||
|
return pat
|
||||||
|
|
||||||
|
|
||||||
|
def _main() -> None:
|
||||||
|
hole_pat = hole()
|
||||||
|
smile_pat = smile()
|
||||||
|
|
||||||
|
masque.file.klamath.writefile([hole_pat, smile_pat], 'basic.gds', 1e-9, 1e-3)
|
||||||
|
|
||||||
|
smile_pat.visualize()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
_main()
|
@ -10,31 +10,7 @@ from masque.library import Library, DeviceLibrary
|
|||||||
from masque.file.klamath import writefile
|
from masque.file.klamath import writefile
|
||||||
|
|
||||||
import pcgen
|
import pcgen
|
||||||
|
import basic
|
||||||
|
|
||||||
HOLE_SCALE: float = 1000
|
|
||||||
''' Radius for the 'hole' cell. Should be significantly bigger than
|
|
||||||
1 (minimum database unit) in order to have enough precision to
|
|
||||||
reasonably represent a polygonized circle (for GDS)
|
|
||||||
'''
|
|
||||||
|
|
||||||
def hole(layer: layer_t,
|
|
||||||
radius: float = HOLE_SCALE * 0.35,
|
|
||||||
) -> Pattern:
|
|
||||||
"""
|
|
||||||
Generate a pattern containing a single circular hole.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
layer: Layer to draw the circle on.
|
|
||||||
radius: Circle radius.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Pattern, named `'hole'`
|
|
||||||
"""
|
|
||||||
pat = Pattern('hole', shapes=[
|
|
||||||
Circle(radius=radius, offset=(0, 0), layer=layer, dose=1.0)
|
|
||||||
])
|
|
||||||
return pat
|
|
||||||
|
|
||||||
|
|
||||||
def perturbed_l3(lattice_constant: float,
|
def perturbed_l3(lattice_constant: float,
|
||||||
@ -152,13 +128,12 @@ def label_ports(device: Device, layer: layer_t = (3, 0)) -> Device:
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
hole_layer = (1, 2)
|
|
||||||
a = 512
|
a = 512
|
||||||
hole_pat = hole(layer=hole_layer)
|
hole= basic.smile()
|
||||||
wg0 = label_ports(waveguide(lattice_constant=a, hole=hole_pat, length=10, mirror_periods=5))
|
wg0 = label_ports(waveguide(lattice_constant=a, hole=hole, length=10, mirror_periods=5))
|
||||||
wg1 = label_ports(waveguide(lattice_constant=a, hole=hole_pat, length=5, mirror_periods=5))
|
wg1 = label_ports(waveguide(lattice_constant=a, hole=hole, length=5, mirror_periods=5))
|
||||||
bend0 = label_ports(bend(lattice_constant=a, hole=hole_pat, mirror_periods=5))
|
bend0 = label_ports(bend(lattice_constant=a, hole=hole, mirror_periods=5))
|
||||||
l3cav = label_ports(perturbed_l3(lattice_constant=a, hole=hole_pat, xy_size=(4, 10)))
|
l3cav = label_ports(perturbed_l3(lattice_constant=a, hole=hole, xy_size=(4, 10)))
|
||||||
|
|
||||||
dev = Device(name='my_bend', ports={})
|
dev = Device(name='my_bend', ports={})
|
||||||
dev.place(wg0, offset=(0, 0), port_map={'left': 'in', 'right': 'signal'})
|
dev.place(wg0, offset=(0, 0), port_map={'left': 'in', 'right': 'signal'})
|
@ -958,6 +958,8 @@ class Pattern(LockableImpl, AnnotatableImpl, Mirrorable, metaclass=AutoSlots):
|
|||||||
line_color=line_color, fill_color=fill_color)
|
line_color=line_color, fill_color=fill_color)
|
||||||
|
|
||||||
if not overdraw:
|
if not overdraw:
|
||||||
|
pyplot.xlabel('x')
|
||||||
|
pyplot.ylabel('y')
|
||||||
pyplot.show()
|
pyplot.show()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user