luminescent 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- luminescent-0.1.0/LICENSE +21 -0
- luminescent-0.1.0/PKG-INFO +16 -0
- luminescent-0.1.0/README.md +0 -0
- luminescent-0.1.0/pyproject.toml +16 -0
- luminescent-0.1.0/src/luminescent/__init__.py +19 -0
- luminescent-0.1.0/src/luminescent/gplugins/__init__.py +1 -0
- luminescent-0.1.0/src/luminescent/gplugins/__pycache__/__init__.cpython-311.pyc +0 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/__init__.py +30 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/__pycache__/__init__.cpython-311.pyc +0 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/__pycache__/constants.cpython-311.pyc +0 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/__pycache__/gcells.cpython-311.pyc +0 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/__pycache__/generic_tech.cpython-311.pyc +0 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/__pycache__/inverse_design.cpython-311.pyc +0 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/__pycache__/layers.cpython-311.pyc +0 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/__pycache__/materials.cpython-311.pyc +0 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/__pycache__/picToGDS.cpython-311.pyc +0 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/__pycache__/prob.cpython-311.pyc +0 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/__pycache__/setup.cpython-311.pyc +0 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/__pycache__/sol.cpython-311.pyc +0 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/__pycache__/solve.cpython-311.pyc +0 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/__pycache__/sparams.cpython-311.pyc +0 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/__pycache__/utils.cpython-311.pyc +0 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/constants.py +3 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/gcells.py +176 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/generic_tech.py +84 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/inverse_design.py +124 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/layers.py +4 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/materials.py +16 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/pcells.py +119 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/picToGDS.py +109 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/run copy.jl +413 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/run.jl +411 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/setup.py +151 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/snapshot.jl +60 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/sol.py +73 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/sparams.py +62 -0
- luminescent-0.1.0/src/luminescent/gplugins/luminescent/utils.py +347 -0
- luminescent-0.1.0/src/luminescent/ppa.py +35 -0
- luminescent-0.1.0/src/luminescent/sparams.py +20 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Paul Shen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: luminescent
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Calculate word counts in a text file.
|
|
5
|
+
License: MIT
|
|
6
|
+
Author: Paul Shen
|
|
7
|
+
Requires-Python: >=3.9,<4.0
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "luminescent"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Calculate word counts in a text file."
|
|
5
|
+
authors = ["Paul Shen"]
|
|
6
|
+
license = "MIT"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
|
|
9
|
+
[tool.poetry.dependencies]
|
|
10
|
+
python = "^3.9"
|
|
11
|
+
|
|
12
|
+
[tool.poetry.dev-dependencies]
|
|
13
|
+
|
|
14
|
+
[build-system]
|
|
15
|
+
requires = ["poetry-core>=1.0.0"]
|
|
16
|
+
build-backend = "poetry.core.masonry.api"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from .gplugins.luminescent import *
|
|
2
|
+
# __all__= .gplugins.luminescent.__all__
|
|
3
|
+
#
|
|
4
|
+
__all__ = [
|
|
5
|
+
"LAYER_STACK",
|
|
6
|
+
"LAYER",
|
|
7
|
+
"LAYER_VIEWS",
|
|
8
|
+
"MATERIAL_LIBRARY",
|
|
9
|
+
"write_sparams",
|
|
10
|
+
"inverse_design_problem",
|
|
11
|
+
"sparams_problem",
|
|
12
|
+
"solve",
|
|
13
|
+
"apply_design",
|
|
14
|
+
"add_bbox",
|
|
15
|
+
"XMARGIN",
|
|
16
|
+
"YMARGIN",
|
|
17
|
+
"load_solution",
|
|
18
|
+
"gcells",
|
|
19
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# from luminescent
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# import gplugins.luminescent as gl
|
|
2
|
+
from .generic_tech import (
|
|
3
|
+
LAYER_STACK, LAYER, LAYER_VIEWS
|
|
4
|
+
|
|
5
|
+
)
|
|
6
|
+
from .setup import *
|
|
7
|
+
from .sol import *
|
|
8
|
+
from .sparams import *
|
|
9
|
+
from .inverse_design import *
|
|
10
|
+
from .materials import MATERIAL_LIBRARY
|
|
11
|
+
from .constants import *
|
|
12
|
+
from .utils import *
|
|
13
|
+
from . import gcells
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"LAYER_STACK",
|
|
17
|
+
"LAYER",
|
|
18
|
+
"LAYER_VIEWS",
|
|
19
|
+
"MATERIAL_LIBRARY",
|
|
20
|
+
"write_sparams",
|
|
21
|
+
"inverse_design_problem",
|
|
22
|
+
"sparams_problem",
|
|
23
|
+
"solve",
|
|
24
|
+
"apply_design",
|
|
25
|
+
"add_bbox",
|
|
26
|
+
"XMARGIN",
|
|
27
|
+
"YMARGIN",
|
|
28
|
+
"load_solution",
|
|
29
|
+
"gcells",
|
|
30
|
+
]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
luminescent-0.1.0/src/luminescent/gplugins/luminescent/__pycache__/generic_tech.cpython-311.pyc
ADDED
|
Binary file
|
luminescent-0.1.0/src/luminescent/gplugins/luminescent/__pycache__/inverse_design.cpython-311.pyc
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
|
|
2
|
+
from gdsfactory.cross_section import Section
|
|
3
|
+
from .generic_tech import LAYER_STACK, LAYER, LAYER_VIEWS
|
|
4
|
+
|
|
5
|
+
import gdsfactory as gf
|
|
6
|
+
import bson
|
|
7
|
+
# import .utils as utils
|
|
8
|
+
from .utils import *
|
|
9
|
+
from .constants import *
|
|
10
|
+
# from layers import *
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def bend(r, wwg=.5, lwg=1, LAYER=LAYER, **kwargs):
|
|
14
|
+
name = "bend"
|
|
15
|
+
design = gf.Component()
|
|
16
|
+
init = gf.Component()
|
|
17
|
+
test = gf.Component()
|
|
18
|
+
device = gf.Component()
|
|
19
|
+
device = gf.Component("bend")
|
|
20
|
+
prob = dict()
|
|
21
|
+
|
|
22
|
+
# if lwg == 0:
|
|
23
|
+
# lwg = 2*wwg
|
|
24
|
+
lstub = lwg/2
|
|
25
|
+
# Extrude the Path and the CrossSection
|
|
26
|
+
wg1 = device << gf.path.extrude(gf.path.straight(
|
|
27
|
+
length=lwg), layer=LAYER.WG, width=wwg)
|
|
28
|
+
wg2 = device << gf.path.extrude(gf.path.straight(
|
|
29
|
+
length=lwg), layer=LAYER.WG, width=wwg)
|
|
30
|
+
arc = device << gf.path.extrude(gf.path.arc(
|
|
31
|
+
r, start_angle=0), layer=LAYER.WG, width=wwg)
|
|
32
|
+
|
|
33
|
+
ld = wd = 2*r
|
|
34
|
+
design.add_polygon([(0, 0), (ld, 0), (ld, wd), (0, wd)],
|
|
35
|
+
layer=LAYER.DESIGN)
|
|
36
|
+
design.add_port(name="o1", center=(0, r), width=wwg,
|
|
37
|
+
orientation=180, layer=LAYER.WG)
|
|
38
|
+
design.add_port(name="o2", center=(r, 0), width=wwg,
|
|
39
|
+
orientation=-90, layer=LAYER.WG)
|
|
40
|
+
design = device << design
|
|
41
|
+
|
|
42
|
+
wg1.connect("o2", design.ports["o1"])
|
|
43
|
+
wg2.connect("o2", design.ports["o2"])
|
|
44
|
+
arc.connect("o1", wg2.ports["o2"])
|
|
45
|
+
|
|
46
|
+
device.add_port("o1", port=wg1.ports["o1"])
|
|
47
|
+
device.add_port("o2", port=wg2.ports["o1"])
|
|
48
|
+
|
|
49
|
+
# utils.write_img("device", device, DESIGN)
|
|
50
|
+
# utils.write_img("guess", init, DESIGN)
|
|
51
|
+
c = add_bbox(device, layers=[LAYER.WGCLAD, LAYER.BOX],
|
|
52
|
+
nonport_margin=0.4)
|
|
53
|
+
return c
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def mimo(l, w, wwg, m, n,
|
|
57
|
+
layer_wg=LAYER.WG, layer_wgclad=LAYER.WGCLAD, layer_box=LAYER.BOX, layer_design=LAYER.DESIGN,
|
|
58
|
+
**kwargs):
|
|
59
|
+
design = gf.Component()
|
|
60
|
+
|
|
61
|
+
c = gf.Component("mimo")
|
|
62
|
+
lwg = 2*wwg
|
|
63
|
+
p = [(0, 0), (l, 0), (l, w), (0, w)]
|
|
64
|
+
design.add_polygon(p, layer=layer_design)
|
|
65
|
+
c.add_polygon(p, layer=layer_wg)
|
|
66
|
+
|
|
67
|
+
din = w/m
|
|
68
|
+
dout = w/n
|
|
69
|
+
yin = din/2
|
|
70
|
+
yout = dout/2
|
|
71
|
+
for i in range(m):
|
|
72
|
+
name = "o"+str(i+1)
|
|
73
|
+
design.add_port(name=name, center=(0, yin), width=wwg,
|
|
74
|
+
orientation=180, layer=layer_wg)
|
|
75
|
+
wg = c << gf.components.straight(length=lwg, width=wwg, layer=layer_wg)
|
|
76
|
+
wg.connect("o2", design.ports[name])
|
|
77
|
+
c.add_port(name=name, port=wg.ports["o1"])
|
|
78
|
+
yin += din
|
|
79
|
+
for i in range(n):
|
|
80
|
+
name = "o"+str(i+1+m)
|
|
81
|
+
design.add_port(name=name, center=(l, yout), width=wwg,
|
|
82
|
+
orientation=0, layer=layer_wg)
|
|
83
|
+
wg = c << gf.components.straight(length=lwg, width=wwg, layer=layer_wg)
|
|
84
|
+
wg.connect("o2", design.ports[name])
|
|
85
|
+
c.add_port(name=name, port=wg.ports["o1"])
|
|
86
|
+
yout += dout
|
|
87
|
+
design = c << design
|
|
88
|
+
c = add_bbox(c, layers=[layer_wgclad, layer_box],
|
|
89
|
+
nonport_margin=XMARGIN)
|
|
90
|
+
return c
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
# def ubend_template(r, l, wwg, lwg=0,
|
|
94
|
+
# wavelength=1.55, dx=0.05,
|
|
95
|
+
# # ϵcore=ϵcore, ϵclad=ϵclad,
|
|
96
|
+
# dir="", init=None, lmin=0.1, LAYER=LAYER, **kwargs):
|
|
97
|
+
# name = "ubend"
|
|
98
|
+
# design = gf.Component("design")
|
|
99
|
+
# device = gf.Component("ubend")
|
|
100
|
+
# λ = wavelength
|
|
101
|
+
|
|
102
|
+
# if lwg == 0:
|
|
103
|
+
# lwg = 4*wwg
|
|
104
|
+
|
|
105
|
+
# # Extrude the Path and the CrossSection
|
|
106
|
+
# wg1 = device << gf.path.extrude(gf.path.straight(
|
|
107
|
+
# length=lwg), layer=LAYER.WG, width=wwg)
|
|
108
|
+
# wg2 = device << gf.path.extrude(gf.path.straight(
|
|
109
|
+
# length=lwg), layer=LAYER.WG, width=wwg)
|
|
110
|
+
|
|
111
|
+
# ld = l
|
|
112
|
+
# wd = 2*r+wwg
|
|
113
|
+
|
|
114
|
+
# design.add_polygon([(0, -wd/2), (ld, -wd/2), (ld, wd/2),
|
|
115
|
+
# (0, wd/2)], layer=DESIGN)
|
|
116
|
+
# if init is not None:
|
|
117
|
+
# xmin = design.xmin
|
|
118
|
+
# ymin = design.ymin
|
|
119
|
+
# init = design << init
|
|
120
|
+
# init.xmin = xmin
|
|
121
|
+
# init.ymin = ymin
|
|
122
|
+
# else:
|
|
123
|
+
# init = gf.Component()
|
|
124
|
+
# init.add_polygon([(0, -wd/2), (ld, -wd/2), (ld, wd/2),
|
|
125
|
+
# (0, wd/2)], layer=GUESS)
|
|
126
|
+
# init = design << init
|
|
127
|
+
|
|
128
|
+
# design.add_port(name="o1", center=(0, r), width=wwg,
|
|
129
|
+
# orientation=180, layer=LAYER.PORT)
|
|
130
|
+
# design.add_port(name="o2", center=(0, -r), width=wwg,
|
|
131
|
+
# orientation=180, layer=LAYER.PORT)
|
|
132
|
+
# # design = device << design
|
|
133
|
+
|
|
134
|
+
# wg1.connect("o2", design.ports["o1"], allow_layer_mismatch=True)
|
|
135
|
+
# wg2.connect("o2", design.ports["o2"], allow_layer_mismatch=True)
|
|
136
|
+
# # stub1.connect("o2", wg1.ports["o1"])
|
|
137
|
+
# # stub2.connect("o2", wg2.ports["o1"])
|
|
138
|
+
|
|
139
|
+
# device.add_port("o1", port=wg1.ports["o1"])
|
|
140
|
+
# device.add_port("o2", port=wg2.ports["o1"])
|
|
141
|
+
|
|
142
|
+
# # design = device << design
|
|
143
|
+
# device.add_ref(design, name="design")
|
|
144
|
+
# # device << gf.components.re
|
|
145
|
+
# # device << test
|
|
146
|
+
# device.show()
|
|
147
|
+
# # init.show()
|
|
148
|
+
# sources = {
|
|
149
|
+
# "o1": {
|
|
150
|
+
# "port": "o1",
|
|
151
|
+
# "wavelengths": [λ],
|
|
152
|
+
# "mode_numbers": [0],
|
|
153
|
+
# "powers": [1],
|
|
154
|
+
# "width": wwg,
|
|
155
|
+
# "endpoints": device.ports["o1"].endpoints.tolist(),
|
|
156
|
+
# "center": (device.ports["o1"].center),
|
|
157
|
+
# "orientation": device.ports["o1"].orientation,
|
|
158
|
+
# }}
|
|
159
|
+
# for k in sources:
|
|
160
|
+
# a = sources[k]["orientation"]/180*pi
|
|
161
|
+
# normal = [cos(a), sin(a)]
|
|
162
|
+
# sources[k]["normal"] = normal
|
|
163
|
+
# sources[k]["center"] -= .001*np.array(normal)
|
|
164
|
+
# sources[k]["center"] = sources[k]["center"].flatten().tolist()
|
|
165
|
+
|
|
166
|
+
# monitors = {
|
|
167
|
+
# "o2": {
|
|
168
|
+
# "powers": [1],
|
|
169
|
+
# "wavelengths": [λ],
|
|
170
|
+
# "mode_numbers": [0],
|
|
171
|
+
# "port": "o2"},
|
|
172
|
+
# # {"power": 1,"wavelength": λ,"port": "o1"},
|
|
173
|
+
# }
|
|
174
|
+
# # device.metadata["sources"] = sources
|
|
175
|
+
# # device.metadata["monitors"] = monitors
|
|
176
|
+
# return device, sources, monitors, design
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import gdsfactory as gf
|
|
2
|
+
from gdsfactory.generic_tech.layer_map import LAYER
|
|
3
|
+
from gdsfactory.technology import LogicalLayer, LayerStack, LayerLevel
|
|
4
|
+
import gdsfactory as gf
|
|
5
|
+
from gdsfactory.generic_tech import LAYER, LAYER_STACK
|
|
6
|
+
from gdsfactory.generic_tech.get_klayout_pyxs import get_klayout_pyxs
|
|
7
|
+
from gdsfactory.technology import LayerLevel, LayerStack, LayerViews, LayerMap
|
|
8
|
+
from gdsfactory.generic_tech import get_generic_pdk
|
|
9
|
+
|
|
10
|
+
from gdsfactory.config import PATH
|
|
11
|
+
from gdsfactory.technology import (
|
|
12
|
+
LayerLevel,
|
|
13
|
+
LayerStack,
|
|
14
|
+
LayerView,
|
|
15
|
+
LayerViews,
|
|
16
|
+
LayerMap,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
Layer = tuple[int, int]
|
|
20
|
+
|
|
21
|
+
# gf.generic_tech.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class MyLayerMap(LayerMap):
|
|
25
|
+
WG: Layer = (1, 0)
|
|
26
|
+
WGCLAD: Layer = (111, 0)
|
|
27
|
+
BOX: Layer = (112, 0)
|
|
28
|
+
PORT: Layer = (1, 10)
|
|
29
|
+
DESIGN: Layer = (200, 0)
|
|
30
|
+
GUESS: Layer = (201, 0)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
LAYER = MyLayerMap
|
|
34
|
+
|
|
35
|
+
nm = 1e-3
|
|
36
|
+
thickness_wg = 220 * nm
|
|
37
|
+
thickness_slab_deep_etch = 90 * nm
|
|
38
|
+
thickness_slab_shallow_etch = 150 * nm
|
|
39
|
+
box_thickness = 0.5
|
|
40
|
+
thickness_clad = 0.5
|
|
41
|
+
|
|
42
|
+
layer_core = LogicalLayer(layer=LAYER.WG)
|
|
43
|
+
layer_clad = LogicalLayer(layer=LAYER.WGCLAD)
|
|
44
|
+
layer_box = LogicalLayer(layer=LAYER.BOX)
|
|
45
|
+
layer_design = LogicalLayer(layer=LAYER.DESIGN)
|
|
46
|
+
|
|
47
|
+
LAYER_STACK.layers.update(dict(
|
|
48
|
+
core=LayerLevel(
|
|
49
|
+
layer=layer_core,
|
|
50
|
+
thickness=thickness_wg,
|
|
51
|
+
zmin=0,
|
|
52
|
+
material="Si",
|
|
53
|
+
mesh_order=2,
|
|
54
|
+
),
|
|
55
|
+
box=LayerLevel(
|
|
56
|
+
layer=layer_box,
|
|
57
|
+
thickness=box_thickness,
|
|
58
|
+
zmin=-box_thickness,
|
|
59
|
+
material="SiO2",
|
|
60
|
+
mesh_order=9,
|
|
61
|
+
),
|
|
62
|
+
clad=LayerLevel(
|
|
63
|
+
layer=layer_clad,
|
|
64
|
+
zmin=0.0,
|
|
65
|
+
material="SiO2",
|
|
66
|
+
thickness=thickness_clad,
|
|
67
|
+
mesh_order=10,
|
|
68
|
+
),
|
|
69
|
+
design=LayerLevel(
|
|
70
|
+
layer=layer_design,
|
|
71
|
+
zmin=0.0,
|
|
72
|
+
material=None,
|
|
73
|
+
thickness=.0001,
|
|
74
|
+
mesh_order=100,
|
|
75
|
+
),
|
|
76
|
+
))
|
|
77
|
+
|
|
78
|
+
pdk = get_generic_pdk()
|
|
79
|
+
pdk.activate()
|
|
80
|
+
LAYER_VIEWS = pdk.layer_views
|
|
81
|
+
LAYER_VIEWS.layer_views["WGCLAD"].visible = True
|
|
82
|
+
# for l in LAYER_STACK.layers.values():
|
|
83
|
+
# print(l.layer)
|
|
84
|
+
# print(l.layer.layer)
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
from copy import deepcopy
|
|
2
|
+
# from time import time
|
|
3
|
+
import datetime
|
|
4
|
+
import json
|
|
5
|
+
import subprocess
|
|
6
|
+
from functools import partial
|
|
7
|
+
from math import cos, pi, sin
|
|
8
|
+
import os
|
|
9
|
+
import wave
|
|
10
|
+
import matplotlib.pyplot as plt
|
|
11
|
+
import numpy as np
|
|
12
|
+
|
|
13
|
+
from gdsfactory.cross_section import Section
|
|
14
|
+
from sortedcontainers import SortedDict, SortedSet
|
|
15
|
+
from .generic_tech import LAYER_STACK, LAYER, LAYER_VIEWS
|
|
16
|
+
import gdsfactory as gf
|
|
17
|
+
import bson
|
|
18
|
+
import scipy as sp
|
|
19
|
+
from .utils import *
|
|
20
|
+
from .layers import *
|
|
21
|
+
from .constants import *
|
|
22
|
+
from .utils import *
|
|
23
|
+
from .setup import *
|
|
24
|
+
from .sparams import *
|
|
25
|
+
from .materials import MATERIAL_LIBRARY
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def inverse_design_problem(c, lmin=.1, symmetries=[],
|
|
29
|
+
tparam_targets={}, sparam_targets={},
|
|
30
|
+
maxiters=25, eta=.1,
|
|
31
|
+
design_region_layer=LAYER.DESIGN,
|
|
32
|
+
design_guess_layer=LAYER.GUESS,
|
|
33
|
+
design_layer=LAYER.WG,
|
|
34
|
+
void_layer=LAYER.WGCLAD,
|
|
35
|
+
layer_stack=LAYER_STACK,
|
|
36
|
+
plot=False, approx_2D=True, **kwargs):
|
|
37
|
+
if not approx_2D:
|
|
38
|
+
raise NotImplementedError(
|
|
39
|
+
"3D inverse design feature must be requested from Luminescent AI info@luminescentai.com")
|
|
40
|
+
|
|
41
|
+
if tparam_targets:
|
|
42
|
+
target_type = "tparams"
|
|
43
|
+
targets = tparam_targets
|
|
44
|
+
elif sparam_targets:
|
|
45
|
+
target_type = "sparams"
|
|
46
|
+
targets = sparam_targets
|
|
47
|
+
|
|
48
|
+
targets = {
|
|
49
|
+
wl: {
|
|
50
|
+
longname(k): v for k, v in d.items()
|
|
51
|
+
} for wl, d in targets.items()}
|
|
52
|
+
keys = sorted(set(sum([list(d.keys()) for d in targets.values()], [])))
|
|
53
|
+
wavelengths = sorted(targets.keys())
|
|
54
|
+
|
|
55
|
+
prob = sparams_problem(c, layer_stack=layer_stack, wavelengths=wavelengths,
|
|
56
|
+
keys=keys, approx_2D=approx_2D, ** kwargs)
|
|
57
|
+
prob["targets"] = targets
|
|
58
|
+
prob["target_type"] = target_type
|
|
59
|
+
prob["eta"] = eta
|
|
60
|
+
prob["study"] = "inverse_design"
|
|
61
|
+
polys = c.extract([design_region_layer]).get_polygons()
|
|
62
|
+
if not symmetries:
|
|
63
|
+
symmetries = [[]]*len(polys)
|
|
64
|
+
else:
|
|
65
|
+
if type(symmetries[0]) is int:
|
|
66
|
+
symmetries = [symmetries]*len(polys)
|
|
67
|
+
|
|
68
|
+
def _bbox(b):
|
|
69
|
+
return [[b.left/1e3, b.bottom/1e3], [b.right/1e3, b.top/1e3]]
|
|
70
|
+
prob["designs"] = [
|
|
71
|
+
{
|
|
72
|
+
"layer": design_layer,
|
|
73
|
+
"bbox": _bbox(p.bbox()),
|
|
74
|
+
"symmetries": s,
|
|
75
|
+
"guess": None,
|
|
76
|
+
"lmin": lmin,
|
|
77
|
+
} for p, s in zip(list(polys.values())[0], symmetries)
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
prob["design_config"] = dict()
|
|
81
|
+
# prob[""]
|
|
82
|
+
l = get_layer(layer_stack, design_layer)
|
|
83
|
+
d = {"thickness": l.thickness, "material": l.material, "zmin": l.zmin}
|
|
84
|
+
# d = vars(prob["design_layer"])
|
|
85
|
+
d["ϵ"] = MATERIAL_LIBRARY[d["material"]].epsilon
|
|
86
|
+
prob["design_config"]["fill"] = d
|
|
87
|
+
|
|
88
|
+
l = get_layer(layer_stack, void_layer)
|
|
89
|
+
d = {"thickness": l.thickness, "material": l.material, "zmin": l.zmin}
|
|
90
|
+
d["ϵ"] = MATERIAL_LIBRARY[d["material"]].epsilon
|
|
91
|
+
prob["design_config"]["void"] = d
|
|
92
|
+
|
|
93
|
+
prob["design_layer"] = d
|
|
94
|
+
prob["maxiters"] = maxiters
|
|
95
|
+
return prob
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def apply_design(c0, sol):
|
|
99
|
+
path = sol["path"]
|
|
100
|
+
a = gf.Component()
|
|
101
|
+
a.add_ref(c0)
|
|
102
|
+
dl = 0
|
|
103
|
+
for i, d in enumerate(sol["designs"]):
|
|
104
|
+
dl = d["layer"]
|
|
105
|
+
x0, y0 = d["bbox"][0]
|
|
106
|
+
x1, y1 = d["bbox"][1]
|
|
107
|
+
b = gf.Component()
|
|
108
|
+
b.add_polygon(
|
|
109
|
+
[(x0, y0), (x1, y0), (x1, y1), (x0, y1)], layer=dl)
|
|
110
|
+
a = gf.boolean(a, b, "not", layer=dl)
|
|
111
|
+
c = gf.Component()
|
|
112
|
+
c << a
|
|
113
|
+
for layer in c0.layers:
|
|
114
|
+
if layer != dl:
|
|
115
|
+
c.add_ref(c0.extract([layer]))
|
|
116
|
+
c.show()
|
|
117
|
+
pic2gds(os.path.join(path, f"design{i+1}.png"), sol["dx"])
|
|
118
|
+
g = gf.import_gds(os.path.join(path, f"design{i+1}.gds"), "TOP",
|
|
119
|
+
read_metadata=True)
|
|
120
|
+
g = c << g
|
|
121
|
+
g.drotate(90)
|
|
122
|
+
g.xmin = x0
|
|
123
|
+
g.ymin = y0
|
|
124
|
+
return c
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import gdsfactory as gf
|
|
2
|
+
from layers import *
|
|
3
|
+
core_layer = (1, 0)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def phase_shifter(l, wwg, nbends, ubend):
|
|
7
|
+
c = gf.Component()
|
|
8
|
+
ls = l-2*ubend.size[0]
|
|
9
|
+
s0 = c << gf.path.extrude(gf.path.straight(
|
|
10
|
+
length=ls), width=wwg, layer=core_layer)
|
|
11
|
+
s = s0
|
|
12
|
+
|
|
13
|
+
lu = ubend.size[0]
|
|
14
|
+
wdope = ubend.size[1]-wwg
|
|
15
|
+
sin = c << gf.path.extrude(gf.path.straight(
|
|
16
|
+
length=lu), width=wwg, layer=core_layer)
|
|
17
|
+
sin.connect("o2", s.ports["o1"])
|
|
18
|
+
|
|
19
|
+
for i in range(nbends+2):
|
|
20
|
+
if 0 < i < nbends+1:
|
|
21
|
+
u_ = (c << ubend)
|
|
22
|
+
p1 = "o1" if i % 2 == 1 else "o2"
|
|
23
|
+
p2 = "o2" if i % 2 == 1 else "o1"
|
|
24
|
+
u_.connect(p1, s.ports["o2"])
|
|
25
|
+
s_ = (c << gf.path.extrude(gf.path.straight(
|
|
26
|
+
length=ls), width=wwg, layer=core_layer))
|
|
27
|
+
s_.connect("o1", u_.ports[p2])
|
|
28
|
+
s = s_
|
|
29
|
+
|
|
30
|
+
pn = "p" if i % 2 == 0 else "n"
|
|
31
|
+
pn_layer = p_layer if pn == "p" else n_layer
|
|
32
|
+
label = "p doping" if pn == "p" else "n doping"
|
|
33
|
+
|
|
34
|
+
pn = c << gf.components.rectangle(size=(l, wdope), layer=pn_layer)
|
|
35
|
+
pn.xmin = c.xmin
|
|
36
|
+
if i < nbends+1:
|
|
37
|
+
pn.ymin = s.center[1]
|
|
38
|
+
else:
|
|
39
|
+
pn.ymax = s.center[1]
|
|
40
|
+
c.add_label(label, position=pn.center, layer=(501, 0))
|
|
41
|
+
|
|
42
|
+
sout = c << gf.path.extrude(gf.path.straight(
|
|
43
|
+
length=lu), width=wwg, layer=core_layer)
|
|
44
|
+
sout.connect("o1", s.ports["o2"])
|
|
45
|
+
|
|
46
|
+
heater_margin = 0.1
|
|
47
|
+
center = c.center
|
|
48
|
+
heater = c << gf.components.rectangle(
|
|
49
|
+
size=(l+2*heater_margin, c.size[1]+2*heater_margin), layer=(61, 0))
|
|
50
|
+
heater.center = center
|
|
51
|
+
c.add_label("heater pad", position=heater.bbox_np()[1], layer=(502, 0))
|
|
52
|
+
|
|
53
|
+
c.add_label("zigzag phase shifter", position=(
|
|
54
|
+
c.center[0], c.ymax), layer=(500, 0))
|
|
55
|
+
c.show()
|
|
56
|
+
return c
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def ubend_resonator(l, wwg, ubend):
|
|
60
|
+
c = gf.Component()
|
|
61
|
+
arm = gf.Component()
|
|
62
|
+
quarter = gf.Component()
|
|
63
|
+
|
|
64
|
+
r = 1
|
|
65
|
+
common_left_pad_amount = 8
|
|
66
|
+
lsb = 6
|
|
67
|
+
ls = (l-common_left_pad_amount-2*lsb-2*ubend.size[0])/2
|
|
68
|
+
|
|
69
|
+
su = quarter << gf.components.straight(
|
|
70
|
+
length=ls, width=wwg, layer=core_layer) # Straight section
|
|
71
|
+
sc = quarter << gf.components.straight(
|
|
72
|
+
length=common_left_pad_amount/2, width=wwg, layer=core_layer) # Straight section
|
|
73
|
+
sb = quarter << gf.components.bend_s(
|
|
74
|
+
(lsb, 1), 32, gf.cross_section.strip(wwg), )
|
|
75
|
+
sb.mirror(p1=(0, 0), p2=(1, 0))
|
|
76
|
+
sb.connect("o2", sc.ports["o1"])
|
|
77
|
+
su.connect("o2", sb.ports["o1"])
|
|
78
|
+
quarter.add_port("o1", port=su.ports["o1"])
|
|
79
|
+
quarter.add_port("o2", port=sc.ports["o2"])
|
|
80
|
+
|
|
81
|
+
coupler_margin = .15
|
|
82
|
+
|
|
83
|
+
sw = arm << quarter
|
|
84
|
+
sw.ymin = +wwg/2+coupler_margin
|
|
85
|
+
sw.xmax = 0
|
|
86
|
+
|
|
87
|
+
se = arm << quarter
|
|
88
|
+
se = se.mirror()
|
|
89
|
+
se.connect("o2", sw.ports["o2"])
|
|
90
|
+
|
|
91
|
+
arm.add_port("o1", port=sw.ports["o1"])
|
|
92
|
+
arm.add_port("o2", port=se.ports["o1"])
|
|
93
|
+
south = c << arm
|
|
94
|
+
|
|
95
|
+
ubend1 = c << ubend
|
|
96
|
+
ubend2 = c << ubend
|
|
97
|
+
ubend1.connect("o1", south.ports["o1"])
|
|
98
|
+
ubend2.connect("o2", south.ports["o2"])
|
|
99
|
+
|
|
100
|
+
north = (c << arm)
|
|
101
|
+
# north.mirror(p1=(0,0),p2=(1,0))
|
|
102
|
+
north.connect("o2", ubend1.ports["o2"])
|
|
103
|
+
|
|
104
|
+
xmin = c.xmin
|
|
105
|
+
ymin = c.ymin
|
|
106
|
+
ymax = c.ymax
|
|
107
|
+
|
|
108
|
+
leg1 = c << gf.components.straight(length=l, width=wwg, layer=core_layer)
|
|
109
|
+
# c.add_port(name="o1", center=(0, 0), width=wwg, orientation=0)
|
|
110
|
+
leg1.ymax = ymin-coupler_margin
|
|
111
|
+
leg1.xmin = xmin
|
|
112
|
+
|
|
113
|
+
leg2 = c << gf.components.straight(length=l, width=wwg, layer=core_layer)
|
|
114
|
+
leg2.ymin = ymax+coupler_margin
|
|
115
|
+
leg2.xmin = xmin
|
|
116
|
+
|
|
117
|
+
c.add_label("zigzag resonator", position=c.center)
|
|
118
|
+
c.show()
|
|
119
|
+
return c
|