Skip to content

Commit

Permalink
Merge pull request #18 from gdsfactory/140
Browse files Browse the repository at this point in the history
simpler component_factory thanks to `import_module_factories` functio…
  • Loading branch information
joamatab authored Apr 6, 2022
2 parents 38104b9 + c57f140 commit d75869a
Show file tree
Hide file tree
Showing 13 changed files with 245 additions and 30 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [1.4.0]

- simpler component_factory thanks to `import_module_factories` function from gf.cell

## [1.3.9](https://github.com/gdsfactory/ubc/pull/17)

- add circuit samples
Expand Down
68 changes: 64 additions & 4 deletions docs/components.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,22 @@ add_fiber_array

import ubcpdk

c = ubcpdk.components.add_fiber_array(gc_port_name='o1', with_loopback=False, optical_routing_type=0, fanout_length=0.0)
c = ubcpdk.components.add_fiber_array(gc_port_name='opt1', with_loopback=False, optical_routing_type=0, fanout_length=0.0)
c.plot()



bend_euler
----------------------------------------------------

.. autofunction:: ubcpdk.components.bend_euler

.. plot::
:include-source:

import ubcpdk

c = ubcpdk.components.bend_euler(angle=90.0, p=0.5, with_arc_floorplan=True, npoints=720, direction='ccw', with_cladding_box=True)
c.plot()


Expand Down Expand Up @@ -112,6 +127,21 @@ dc_broadband_tm



ebeam_dc_te1550
----------------------------------------------------

.. autofunction:: ubcpdk.components.ebeam_dc_te1550

.. plot::
:include-source:

import ubcpdk

c = ubcpdk.components.ebeam_dc_te1550(gap=0.236, length=20.0, dy=5.0, dx=10.0)
c.plot()



gc_te1310
----------------------------------------------------

Expand Down Expand Up @@ -172,6 +202,36 @@ gc_tm1550



mzi
----------------------------------------------------

.. autofunction:: ubcpdk.components.mzi

.. plot::
:include-source:

import ubcpdk

c = ubcpdk.components.mzi(delta_length=10.0, length_y=2.0, length_x=0.1, with_splitter=True, port_e1_splitter='opt2', port_e0_splitter='opt3', port_e1_combiner='opt2', port_e0_combiner='opt3', nbends=2)
c.plot()



ring_single
----------------------------------------------------

.. autofunction:: ubcpdk.components.ring_single

.. plot::
:include-source:

import ubcpdk

c = ubcpdk.components.ring_single(gap=0.2, radius=10.0, length_x=4.0, length_y=0.6)
c.plot()



ring_with_crossing
----------------------------------------------------

Expand All @@ -182,7 +242,7 @@ ring_with_crossing

import ubcpdk

c = ubcpdk.components.ring_with_crossing()
c = ubcpdk.components.ring_with_crossing(gap=0.2, length_x=4, length_y=0, radius=5.0, with_component=True, port_name='opt4')
c.plot()


Expand Down Expand Up @@ -227,7 +287,7 @@ y_adiabatic

import ubcpdk

c = ubcpdk.components.y_adiabatic()
c = ubcpdk.components.y_adiabatic(name='ebeam_y_adiabatic')
c.plot()


Expand All @@ -242,5 +302,5 @@ y_splitter

import ubcpdk

c = ubcpdk.components.y_splitter()
c = ubcpdk.components.y_splitter(name='ebeam_y_1550')
c.plot()
4 changes: 2 additions & 2 deletions docs/write_components_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
"""
)

for name in sorted(ubcpdk.components.factory.keys()):
for name in sorted(ubcpdk.component_factory.keys()):
if name in skip or name.startswith("_"):
continue
print(name)
sig = inspect.signature(ubcpdk.components.factory[name])
sig = inspect.signature(ubcpdk.component_factory[name])
kwargs = ", ".join(
[
f"{p}={repr(sig.parameters[p].default)}"
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-e .
lygadgets
gdsfactory[full]==4.5.3
gdsfactory[full]==4.6.1
modes
12 changes: 10 additions & 2 deletions ubcpdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
"""UBC Siepic Ebeam PDK from edx course"""
import gdsfactory as gf
from gdsfactory.config import logger
from gdsfactory.cell import get_module_factories


from ubcpdk.config import CONFIG, PATH, module
from ubcpdk.tech import LAYER, strip
from ubcpdk import components
from ubcpdk import tech
from ubcpdk import data

from ubcpdk.components import component_factory
from ubcpdk.tech import cross_section_factory


gf.asserts.version(">=4.2.1")
gf.asserts.version(">=4.6.1")
lys = gf.layers.load_lyp(PATH.lyp)
__version__ = "1.3.9"

Expand All @@ -30,3 +32,9 @@


logger.info(f"Found UBCpdk {__version__!r} installed at {module!r}")
component_factory = get_module_factories(components)


if __name__ == "__main__":
f = component_factory
print(f.keys())
20 changes: 0 additions & 20 deletions ubcpdk/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,6 @@
straight,
)

component_factory = dict(
add_fiber_array=add_fiber_array,
bend_euler=bend_euler,
crossing=crossing,
dbr=dbr,
dbr_cavity=dbr_cavity,
dc_adiabatic=dc_adiabatic,
dc_broadband_te=dc_broadband_te,
dc_broadband_tm=dc_broadband_tm,
gc_te1310=gc_te1310,
gc_te1550=gc_te1550,
gc_te1550_broadband=gc_te1550_broadband,
gc_tm1550=gc_tm1550,
ring_with_crossing=ring_with_crossing,
spiral=spiral,
straight=straight,
y_adiabatic=y_adiabatic,
y_splitter=y_splitter,
)


__all__ = [
"add_fiber_array",
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion ubcpdk/tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from gdsfactory.component import Component
from gdsfactory.difftest import difftest
from pytest_regressions.data_regression import DataRegressionFixture
from ubcpdk.components import component_factory
from ubcpdk import component_factory


component_names = component_factory.keys()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
settings:
changed: {}
child: null
default:
coupler_straight:
function: coupler_straight
coupler_symmetric:
function: coupler_symmetric
cross_section:
function: cross_section
dx: 10
dy: 5
gap: 0.236
length: 20
full:
coupler_straight:
function: coupler_straight
coupler_symmetric:
function: coupler_symmetric
cross_section:
function: cross_section
dx: 10
dy: 5
gap: 0.236
length: 20
function_name: coupler
info:
length: 10.314
min_bend_radius: 9.451
info_version: 2
module: gdsfactory.components.coupler
name: coupler
version: 0.0.1
95 changes: 95 additions & 0 deletions ubcpdk/tests/test_components/test_pdk_settings_mzi_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
settings:
changed:
bend:
decorator:
- function: add_bbox_siepic
- function: add_pins_siepic
function: bend_euler
port_e0_combiner: opt3
port_e0_splitter: opt3
port_e1_combiner: opt2
port_e1_splitter: opt2
splitter:
decorator:
- function: add_ports_from_siepic_pins
- function: remove_pins
- - function: add_bbox_siepic
- function: add_pins_siepic
- function: add_siepic_labels_and_simulation_info
doc: Y junction TE1550 50/50 power.
function: import_gds
gdsdir: gds
gdspath: ebeam_y_1550.gds
model: ebeam_y_1550
name: ebeam_y_1550
opt1: opt_a1
opt2: opt_b1
opt3: opt_b2
child: null
default:
bend:
function: bend_euler
combiner: null
cross_section:
function: cross_section
delta_length: 10
length_x: 0.1
length_y: 2
nbends: 2
port_e0_combiner: o3
port_e0_splitter: o3
port_e1_combiner: o2
port_e1_splitter: o2
splitter:
function: mmi1x2
straight:
function: straight
straight_x_bot: null
straight_x_top: null
straight_y: null
with_splitter: true
full:
bend:
decorator:
- function: add_bbox_siepic
- function: add_pins_siepic
function: bend_euler
combiner: null
cross_section:
function: cross_section
delta_length: 10
length_x: 0.1
length_y: 2
nbends: 2
port_e0_combiner: opt3
port_e0_splitter: opt3
port_e1_combiner: opt2
port_e1_splitter: opt2
splitter:
decorator:
- function: add_ports_from_siepic_pins
- function: remove_pins
- - function: add_bbox_siepic
- function: add_pins_siepic
- function: add_siepic_labels_and_simulation_info
doc: Y junction TE1550 50/50 power.
function: import_gds
gdsdir: gds
gdspath: ebeam_y_1550.gds
model: ebeam_y_1550
name: ebeam_y_1550
opt1: opt_a1
opt2: opt_b1
opt3: opt_b2
straight:
function: straight
straight_x_bot: null
straight_x_top: null
straight_y: null
with_splitter: true
function_name: mzi
info: {}
info_version: 2
module: gdsfactory.components.mzi
name: mzi_f9d34325
version: 0.0.1
35 changes: 35 additions & 0 deletions ubcpdk/tests/test_components/test_pdk_settings_ring_single_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
settings:
changed: {}
child: null
default:
bend:
function: bend_euler
coupler_ring:
function: coupler_ring
cross_section:
function: cross_section
gap: 0.2
length_x: 4
length_y: 0.6
radius: 10
straight:
function: straight
full:
bend:
function: bend_euler
coupler_ring:
function: coupler_ring
cross_section:
function: cross_section
gap: 0.2
length_x: 4
length_y: 0.6
radius: 10
straight:
function: straight
function_name: ring_single
info: {}
info_version: 2
module: gdsfactory.components.ring_single
name: ring_single
version: 0.0.1

0 comments on commit d75869a

Please sign in to comment.