-
Notifications
You must be signed in to change notification settings - Fork 183
/
cross_section.py
1218 lines (1058 loc) · 40.9 KB
/
cross_section.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""You can define a path as list of points.
To create a component you need to extrude the path with a cross-section.
"""
import inspect
import sys
from collections.abc import Iterable
from functools import partial
from inspect import getmembers
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
import pydantic
from pydantic import BaseModel, Field
from typing_extensions import Literal
from gdsfactory.add_pins import add_bbox_siepic, add_pins_siepic_optical_2nm
from gdsfactory.tech import TECH, Section
LAYER = TECH.layer
Layer = Tuple[int, int]
Layers = Tuple[Layer, ...]
WidthTypes = Literal["sine", "linear"]
LayerSpec = Union[Layer, int, str, None]
LayerSpecs = Union[List[LayerSpec], Tuple[LayerSpec, ...]]
Floats = Tuple[float, ...]
port_names_electrical = ("e1", "e2")
port_types_electrical = ("electrical", "electrical")
cladding_layers_optical = ((68, 0),) # for SiEPIC verification
cladding_offsets_optical = (0,) # for SiEPIC verification
class CrossSection(BaseModel):
"""Waveguide information to extrude a path.
cladding_layers follow path shape, while bbox_layers are rectangular.
Parameters:
layer: main Section layer. Main section name = '_default'.
width: main Section width (um) or function parameterized from 0 to 1.
the width at t==0 is the width at the beginning of the Path.
the width at t==1 is the width at the end.
offset: main Section center offset (um) or function from 0 to 1.
the offset at t==0 is the offset at the beginning of the Path.
the offset at t==1 is the offset at the end.
radius: main Section bend radius (um).
width_wide: wide waveguides width (um) for low loss routing.
auto_widen: taper to wide waveguides for low loss routing.
auto_widen_minimum_length: minimum straight length for auto_widen.
taper_length: taper_length for auto_widen.
bbox_layers: list of layers for rectangular bounding box.
bbox_offsets: list of bounding box offsets.
cladding_layers: list of layers to extrude.
cladding_offsets: list of offset from main Section edge.
sections: list of Sections(width, offset, layer, ports).
port_names: for input and output ('o1', 'o2').
port_types: for input and output: electrical, optical, vertical_te ...
min_length: defaults to 1nm = 10e-3um for routing.
start_straight_length: straight length at the beginning of the route.
end_straight_length: end length at the beginning of the route.
snap_to_grid: Optional snap points to grid when extruding paths (um).
aliases: dict of cross_section aliases.
decorator: function when extruding component. For example add_pins.
info: dict with extra settings or useful information.
name: cross_section name.
add_center_section: whether a section with `width` and `layer`
is added during extrude.
"""
layer: LayerSpec
width: Union[float, Callable]
offset: Union[float, Callable] = 0
radius: Optional[float] = None
width_wide: Optional[float] = None
auto_widen: bool = False
auto_widen_minimum_length: float = 200.0
taper_length: float = 10.0
bbox_layers: List[LayerSpec] = Field(default_factory=list)
bbox_offsets: List[float] = Field(default_factory=list)
cladding_layers: Optional[LayerSpecs] = None
cladding_offsets: Optional[Floats] = None
sections: List[Section] = Field(default_factory=list)
port_names: Tuple[str, str] = ("o1", "o2")
port_types: Tuple[str, str] = ("optical", "optical")
min_length: float = 10e-3
start_straight_length: float = 10e-3
end_straight_length: float = 10e-3
snap_to_grid: Optional[float] = None
decorator: Optional[Callable] = None
add_pins: Optional[Callable] = None
add_bbox: Optional[Callable] = None
info: Dict[str, Any] = Field(default_factory=dict)
name: Optional[str] = None
add_center_section: bool = True
class Config:
extra = "forbid"
fields = {
"decorator": {"exclude": True},
"add_pins": {"exclude": True},
"add_bbox": {"exclude": True},
}
def copy(self, width: Optional[float] = None):
xs = super().copy()
xs.decorator = self.decorator
xs.add_pins = self.add_pins
xs.add_bbox = self.add_bbox
if width:
xs.width = width
return xs
@property
def aliases(self) -> Dict[str, Section]:
s = dict(
_default=Section(
width=self.width,
offset=self.offset,
layer=self.layer,
port_names=self.port_names,
port_types=self.port_types,
name="_default",
)
)
sections = self.sections or []
for section in sections:
if section.name:
s[section.name] = section
return s
def add_bbox_layers(
self,
component,
top: Optional[float] = None,
bottom: Optional[float] = None,
right: Optional[float] = None,
left: Optional[float] = None,
):
"""Add bounding box layers to a component.
Args:
component: to add layers.
top: top padding.
bottom: bottom padding.
right: right padding.
left: left padding.
"""
from gdsfactory.add_padding import get_padding_points
c = component
x = self
if x.bbox_layers and x.bbox_offsets:
padding = []
for offset in x.bbox_offsets:
points = get_padding_points(
component=c,
default=0,
top=top or offset,
bottom=bottom or offset,
left=left or offset,
right=right or offset,
)
padding.append(points)
for layer, points in zip(x.bbox_layers, padding):
c.add_polygon(points, layer=layer)
return c
class Transition(CrossSection):
"""Waveguide information to extrude a path between two CrossSection.
cladding_layers follow path shape, while bbox_layers are rectangular.
Parameters:
cross_section1: input cross_section.
cross_section2: output cross_section.
width_type: sine or linear.
Sets the type of width transition used if any widths are different
between the two input CrossSections.
sections: list of Sections(width, offset, layer, ports).
layer: main Section layer. Main section name = '_default'.
width: main Section width (um) or function parameterized from 0 to 1.
the width at t==0 is the width at the beginning of the Path.
the width at t==1 is the width at the end.
offset: main Section center offset (um) or function from 0 to 1.
the offset at t==0 is the offset at the beginning of the Path.
the offset at t==1 is the offset at the end.
radius: main Section bend radius (um).
width_wide: wide waveguides width (um) for low loss routing.
auto_widen: taper to wide waveguides for low loss routing.
auto_widen_minimum_length: minimum straight length for auto_widen.
taper_length: taper_length for auto_widen.
bbox_layers: list of layers for rectangular bounding box.
bbox_offsets: list of bounding box offsets.
cladding_layers: list of layers to extrude.
cladding_offsets: list of offset from main Section edge.
port_names: for input and output ('o1', 'o2').
port_types: for input and output: electrical, optical, vertical_te ...
min_length: defaults to 1nm = 10e-3um for routing.
start_straight_length: straight length at the beginning of the route.
end_straight_length: end length at the beginning of the route.
snap_to_grid: Optional snap points to grid when extruding paths (um).
aliases: dict of cross_section aliases.
decorator: function when extruding component. For example add_pins.
info: dict with extra settings or useful information.
name: cross_section name.
add_center_section: whether a section with `width` and `layer`
is added during extrude.
"""
cross_section1: CrossSection
cross_section2: CrossSection
width_type: WidthTypes = "sine"
sections: List[Section]
layer: Optional[LayerSpec] = None
width: Optional[Union[float, Callable]] = None
@pydantic.validate_arguments
def cross_section(
width: Union[Callable, float] = 0.5,
offset: Union[float, Callable] = 0,
layer: LayerSpec = "WG",
width_wide: Optional[float] = None,
auto_widen: bool = False,
auto_widen_minimum_length: float = 200.0,
taper_length: float = 10.0,
radius: Optional[float] = 10.0,
sections: Optional[Tuple[Section, ...]] = None,
port_names: Tuple[str, str] = ("o1", "o2"),
port_types: Tuple[str, str] = ("optical", "optical"),
min_length: float = 10e-3,
start_straight_length: float = 10e-3,
end_straight_length: float = 10e-3,
snap_to_grid: Optional[float] = None,
bbox_layers: Optional[List[LayerSpec]] = None,
bbox_offsets: Optional[List[float]] = None,
cladding_layers: Optional[LayerSpecs] = None,
cladding_offsets: Optional[Floats] = None,
info: Optional[Dict[str, Any]] = None,
decorator: Optional[Callable] = None,
add_pins: Optional[Callable] = None,
add_bbox: Optional[Callable] = None,
add_center_section: bool = True,
) -> CrossSection:
"""Return CrossSection.
Args:
width: main Section width (um) or function parameterized from 0 to 1.
the width at t==0 is the width at the beginning of the Path.
the width at t==1 is the width at the end.
offset: main Section center offset (um) or function from 0 to 1.
the offset at t==0 is the offset at the beginning of the Path.
the offset at t==1 is the offset at the end.
layer: main section layer.
width_wide: wide waveguides width (um) for low loss routing.
auto_widen: taper to wide waveguides for low loss routing.
auto_widen_minimum_length: minimum straight length for auto_widen.
taper_length: taper_length for auto_widen.
radius: bend radius (um).
sections: list of Sections(width, offset, layer, ports).
port_names: for input and output ('o1', 'o2').
port_types: for input and output: electrical, optical, vertical_te ...
min_length: defaults to 1nm = 10e-3um for routing.
start_straight_length: straight length at the beginning of the route.
end_straight_length: end length at the beginning of the route.
snap_to_grid: can snap points to grid when extruding the path.
bbox_layers: list of layers for rectangular bounding box.
bbox_offsets: list of bounding box offsets.
cladding_layers: list of layers to extrude.
cladding_offsets: list of offset from main Section edge.
info: settings info.
decorator: function to run when converting path to component.
add_pins: optional function to add pins to component.
add_bbox: optional function to add bounding box to component.
add_center_section: whether a section with `width` and `layer`
is added during extrude.
.. plot::
:include-source:
import gdsfactory as gf
xs = gf.cross_section.cross_section(width=0.5, offset=0, layer='WG')
p = gf.path.arc(radius=10, angle=45)
c = p.extrude(xs)
c.plot()
"""
return CrossSection(
width=width,
offset=offset,
layer=layer,
width_wide=width_wide,
auto_widen=auto_widen,
auto_widen_minimum_length=auto_widen_minimum_length,
taper_length=taper_length,
radius=radius,
bbox_layers=bbox_layers or [],
bbox_offsets=bbox_offsets or [],
cladding_layers=cladding_layers,
cladding_offsets=cladding_offsets,
sections=sections or (),
min_length=min_length,
start_straight_length=start_straight_length,
end_straight_length=end_straight_length,
snap_to_grid=snap_to_grid,
port_types=port_types,
port_names=port_names,
info=info or {},
decorator=decorator,
add_bbox=add_bbox,
add_pins=add_pins,
add_center_section=add_center_section,
)
strip = partial(
cross_section,
add_pins=add_pins_siepic_optical_2nm,
add_bbox=add_bbox_siepic,
cladding_layers=("DEVREC",), # for SiEPIC verification
cladding_offsets=(0,), # for SiEPIC verification
)
strip_auto_widen = partial(strip, width_wide=0.9, auto_widen=True)
# Rib with rectangular slab
rib = partial(
strip,
bbox_layers=["SLAB90"],
bbox_offsets=[3],
)
# Rib with with slab that follows the waveguide core
rib_conformal = partial(
strip,
sections=(Section(width=6, layer="SLAB90", name="slab"),),
)
nitride = partial(strip, layer="WGN", width=1.0)
strip_rib_tip = partial(
strip, sections=(Section(width=0.2, layer="SLAB90", name="slab"),)
)
def slot(
width: float = 0.5,
layer: LayerSpec = "WG",
slot_width: float = 0.04,
**kwargs,
) -> CrossSection:
"""Return CrossSection Slot (with an etched region in the center).
Args:
width: main Section width (um) or function parameterized from 0 to 1.
the width at t==0 is the width at the beginning of the Path.
the width at t==1 is the width at the end.
layer: main section layer.
Keyword Args:
offset: main Section center offset (um) or function from 0 to 1.
the offset at t==0 is the offset at the beginning of the Path.
the offset at t==1 is the offset at the end.
width_wide: wide waveguides width (um) for low loss routing.
auto_widen: taper to wide waveguides for low loss routing.
auto_widen_minimum_length: minimum straight length for auto_widen.
taper_length: taper_length for auto_widen.
radius: bend radius (um).
sections: list of Sections(width, offset, layer, ports).
port_names: for input and output ('o1', 'o2').
port_types: for input and output: electrical, optical, vertical_te ...
min_length: defaults to 1nm = 10e-3um for routing.
start_straight_length: straight length at the beginning of the route.
end_straight_length: end length at the beginning of the route.
snap_to_grid: can snap points to grid when extruding the path.
bbox_layers: list of layers for rectangular bounding box.
bbox_offsets: list of bounding box offsets.
cladding_layers: list of layers to extrude.
cladding_offsets: list of offset from main Section edge.
info: settings info.
decorator: function to run when converting path to component.
add_pins: optional function to add pins to component.
add_bbox: optional function to add bounding box to component.
add_center_section: whether a section with `width` and `layer`
is added during extrude.
.. plot::
:include-source:
import gdsfactory as gf
xs = gf.cross_section.slot(width=0.5, slot_width=0.05, layer='WG')
p = gf.path.arc(radius=10, angle=45)
c = p.extrude(xs)
c.plot()
"""
rail_width = (width - slot_width) / 2
rail_offset = (rail_width + slot_width) / 2
sections = [
Section(width=rail_width, offset=rail_offset, layer=layer, name="left rail"),
Section(width=rail_width, offset=-rail_offset, layer=layer, name="right rail"),
]
info = dict(
width=width,
layer=layer,
slot_width=slot_width,
**kwargs,
)
return strip(
width=width,
layer=layer,
sections=tuple(sections),
info=info,
add_center_section=False,
**kwargs,
)
metal1 = partial(
cross_section,
layer="M1",
width=10.0,
port_names=port_names_electrical,
port_types=port_types_electrical,
)
metal2 = partial(
metal1,
layer="M2",
)
metal3 = partial(
metal1,
layer="M3",
)
heater_metal = partial(
metal1,
width=2.5,
layer="HEATER",
)
@pydantic.validate_arguments
def pin(
width: float = 0.5,
layer: LayerSpec = "WG",
layer_slab: LayerSpec = "SLAB90",
layers_via_stack1: LayerSpecs = ("PPP",),
layers_via_stack2: LayerSpecs = ("NPP",),
bbox_offsets_via_stack1: Tuple[float, ...] = (0, -0.2),
bbox_offsets_via_stack2: Tuple[float, ...] = (0, -0.2),
via_stack_width: float = 9.0,
via_stack_gap: float = 0.55,
slab_gap: float = -0.2,
layer_via: LayerSpec = None,
via_width: float = 1,
via_offsets: Optional[Tuple[float, ...]] = None,
**kwargs,
) -> CrossSection:
"""Rib PIN doped cross_section.
Args:
width: ridge width.
layer: ridge layer.
layer_slab: slab layer.
layers_via_stack1: P++ layer.
layers_via_stack2: N++ layer.
bbox_offsets_via_stack1: for via left.
bbox_offsets_via_stack2: for via right.
via_stack_width: in um.
via_stack_gap: offset from via_stack to ridge edge.
slab_gap: extra slab gap (negative: via_stack goes beyond slab).
layer_via: for via.
via_width: in um.
via_offsets: in um.
kwargs: other cross_section settings.
https://doi.org/10.1364/OE.26.029983
.. code::
layer
|<----width--->|
_______________ via_stack_gap slab_gap
| |<----------->| <-->
___ ____________________| |__________________________|___
| | | | | |
| | P++ | undoped silicon | N++ | |
|___|_________|_______________________________________|____________|___|
<----------->
via_stack_width
<---------------------------------------------------------------------->
slab_width
.. plot::
:include-source:
import gdsfactory as gf
xs = gf.cross_section.pin(width=0.5, via_stack_gap=1, via_stack_width=1)
p = gf.path.arc(radius=10, angle=45)
c = p.extrude(xs)
c.plot()
"""
slab_width = width + 2 * via_stack_gap + 2 * via_stack_width - 2 * slab_gap
via_stack_offset = width / 2 + via_stack_gap + via_stack_width / 2
sections = [Section(width=slab_width, layer=layer_slab, name="slab")]
sections += [
Section(
layer=layer,
width=via_stack_width + 2 * cladding_offset,
offset=+via_stack_offset,
)
for layer, cladding_offset in zip(layers_via_stack1, bbox_offsets_via_stack1)
]
sections += [
Section(
layer=layer,
width=via_stack_width + 2 * cladding_offset,
offset=-via_stack_offset,
)
for layer, cladding_offset in zip(layers_via_stack2, bbox_offsets_via_stack2)
]
if layer_via and via_width and via_offsets:
sections += [
Section(
layer=layer_via,
width=via_width,
offset=offset,
)
for offset in via_offsets
]
info = dict(
width=width,
layer=layer,
layer_slab=layer_slab,
layers_via_stack1=layers_via_stack1,
layers_via_stack2=layers_via_stack2,
bbox_offsets_via_stack1=bbox_offsets_via_stack1,
bbox_offsets_via_stack2=bbox_offsets_via_stack2,
via_stack_width=via_stack_width,
via_stack_gap=via_stack_gap,
slab_gap=slab_gap,
layer_via=layer_via,
via_width=via_width,
via_offsets=via_offsets,
**kwargs,
)
return strip(
width=width,
layer=layer,
sections=tuple(sections),
info=info,
**kwargs,
)
@pydantic.validate_arguments
def pn(
width: float = 0.5,
layer: LayerSpec = "WG",
layer_slab: LayerSpec = "SLAB90",
gap_low_doping: float = 0.0,
gap_medium_doping: Optional[float] = 0.5,
gap_high_doping: Optional[float] = 1.0,
width_doping: float = 8.0,
width_slab: float = 7.0,
layer_p: LayerSpec = "P",
layer_pp: LayerSpec = "PP",
layer_ppp: LayerSpec = "PPP",
layer_n: LayerSpec = "N",
layer_np: LayerSpec = "NP",
layer_npp: LayerSpec = "NPP",
port_names: Tuple[str, str] = ("o1", "o2"),
bbox_layers: Optional[List[Layer]] = None,
bbox_offsets: Optional[List[float]] = None,
cladding_layers: Optional[Layers] = cladding_layers_optical,
cladding_offsets: Optional[Floats] = cladding_offsets_optical,
) -> CrossSection:
"""Rib PN doped cross_section.
Args:
width: width of the ridge in um.
layer: ridge layer.
layer_slab: slab layer.
gap_low_doping: from waveguide center to low doping.
gap_medium_doping: from waveguide center to medium doping.
None removes medium doping.
gap_high_doping: from center to high doping. None removes it.
width_doping: in um.
width_slab: in um.
layer_p: p doping layer.
layer_pp: p+ doping layer.
layer_ppp: p++ doping layer.
layer_n: n doping layer.
layer_np: n+ doping layer.
layer_npp: n++ doping layer.
bbox_layers: list of layers for rectangular bounding box.
bbox_offsets: list of bounding box offsets.
port_names: for input and output ('o1', 'o2').
bbox_layers: list of layers for rectangular bounding box.
bbox_offsets: list of bounding box offsets.
.. code::
layer
|<------width------>|
____________________
| | | |
___________________| | | |__________________________|
P | | N |
width_p | | width_n |
<----------------------->| |<------------------------------>|
|<->|
gap_low_doping
| | N+ |
| | width_np |
| |<------------------------>|
|<------->|
gap_medium_doping
.. plot::
:include-source:
import gdsfactory as gf
xs = gf.cross_section.pn(width=0.5, gap_low_doping=0, width_doping=2.)
p = gf.path.arc(radius=10, angle=45)
c = p.extrude(xs)
c.plot()
"""
slab = Section(width=width_slab, offset=0, layer=layer_slab)
sections = [slab]
offset_low_doping = width_doping / 2 + gap_low_doping
width_low_doping = width_doping - gap_low_doping
n = Section(width=width_low_doping, offset=+offset_low_doping, layer=layer_n)
p = Section(width=width_low_doping, offset=-offset_low_doping, layer=layer_p)
sections.append(n)
sections.append(p)
if gap_medium_doping is not None:
width_medium_doping = width_doping - gap_medium_doping
offset_medium_doping = width_medium_doping / 2 + gap_medium_doping
np = Section(
width=width_medium_doping,
offset=+offset_medium_doping,
layer=layer_np,
)
pp = Section(
width=width_medium_doping,
offset=-offset_medium_doping,
layer=layer_pp,
)
sections.append(np)
sections.append(pp)
if gap_high_doping is not None:
width_high_doping = width_doping - gap_high_doping
offset_high_doping = width_high_doping / 2 + gap_high_doping
npp = Section(
width=width_high_doping, offset=+offset_high_doping, layer=layer_npp
)
ppp = Section(
width=width_high_doping, offset=-offset_high_doping, layer=layer_ppp
)
sections.append(npp)
sections.append(ppp)
bbox_layers = bbox_layers or []
bbox_offsets = bbox_offsets or []
for layer_cladding, cladding_offset in zip(bbox_layers, bbox_offsets):
s = Section(
width=width_slab + 2 * cladding_offset, offset=0, layer=layer_cladding
)
sections.append(s)
info = dict(
width=width,
layer=layer,
bbox_layers=bbox_layers,
bbox_offsets=bbox_offsets,
gap_low_doping=gap_low_doping,
gap_medium_doping=gap_medium_doping,
gap_high_doping=gap_high_doping,
width_doping=width_doping,
width_slab=width_slab,
)
return CrossSection(
width=width,
offset=0,
layer=layer,
port_names=port_names,
info=info,
sections=sections,
cladding_offsets=cladding_offsets,
cladding_layers=cladding_layers,
)
@pydantic.validate_arguments
def strip_heater_metal_undercut(
width: float = 0.5,
layer: LayerSpec = "WG",
heater_width: float = 2.5,
trench_width: float = 6.5,
trench_gap: float = 2.0,
layer_heater: LayerSpec = "HEATER",
layer_trench: LayerSpec = "DEEPTRENCH",
**kwargs,
) -> CrossSection:
"""Returns strip cross_section with top metal and undercut trenches on both sides.
dimensions from https://doi.org/10.1364/OE.18.020298
Args:
width: waveguide width.
layer: waveguide layer.
heater_width: of metal heater.
trench_width: in um.
trench_gap: from waveguide edge to trench edge.
layer_heater: heater layer.
layer_trench: tench layer.
kwargs: cross_section settings.
.. code::
|<-------heater_width--------->|
______________________________
| |
| layer_heater |
|______________________________|
|<------width------>|
____________________ trench_gap
| |<----------->| |
| | | undercut |
| width | | |
| | |<------------>|
|___________________| | trench_width |
| |
| |
.. plot::
:include-source:
import gdsfactory as gf
xs = gf.cross_section.strip_heater_metal_undercut(width=0.5, heater_width=2, trench_width=4, trench_gap=4)
p = gf.path.arc(radius=10, angle=45)
c = p.extrude(xs)
c.plot()
"""
trench_offset = trench_gap + trench_width / 2 + width / 2
info = dict(
width=width,
layer=layer,
heater_width=heater_width,
trench_width=trench_width,
trench_gap=trench_gap,
layer_heater=layer_heater,
layer_trench=layer_trench,
**kwargs,
)
return strip(
width=width,
layer=layer,
sections=(
Section(
layer=layer_heater,
width=heater_width,
port_names=port_names_electrical,
port_types=port_types_electrical,
),
Section(layer=layer_trench, width=trench_width, offset=+trench_offset),
Section(layer=layer_trench, width=trench_width, offset=-trench_offset),
),
info=info,
**kwargs,
)
@pydantic.validate_arguments
def strip_heater_metal(
width: float = 0.5,
layer: LayerSpec = "WG",
heater_width: float = 2.5,
layer_heater: LayerSpec = "HEATER",
**kwargs,
) -> CrossSection:
"""Returns strip cross_section with top heater metal.
dimensions from https://doi.org/10.1364/OE.18.020298
Args:
width: waveguide width (um).
layer: waveguide layer.
heater_width: of metal heater.
layer_heater: for the metal.
.. plot::
:include-source:
import gdsfactory as gf
xs = gf.cross_section.strip_heater_metal(width=0.5, heater_width=2)
p = gf.path.arc(radius=10, angle=45)
c = p.extrude(xs)
c.plot()
"""
info = dict(
width=width,
layer=layer,
heater_width=heater_width,
layer_heater=layer_heater,
**kwargs,
)
return strip(
width=width,
layer=layer,
sections=(
Section(
layer=layer_heater,
width=heater_width,
port_names=port_names_electrical,
port_types=port_types_electrical,
),
),
info=info,
**kwargs,
)
@pydantic.validate_arguments
def strip_heater_doped(
width: float = 0.5,
layer: LayerSpec = "WG",
heater_width: float = 2.0,
heater_gap: float = 0.8,
layers_heater: LayerSpecs = ("WG", "NPP"),
bbox_offsets_heater: Tuple[float, ...] = (0, 0.1),
**kwargs,
) -> CrossSection:
"""Returns strip cross_section with N++ doped heaters on both sides.
Args:
width: in um.
layer: wavguide spec.
heater_width: in um.
heater_gap: in um.
layers_heater: for doped heater.
bbox_offsets_heater: for each layers_heater.
kwargs: cross_section settings.
.. code::
|<------width------>|
____________ ___________________ ______________
| | | undoped Si | | |
|layer_heater| | intrinsic region |<----------->| layer_heater |
|____________| |___________________| |______________|
<------------>
heater_gap heater_width
.. plot::
:include-source:
import gdsfactory as gf
xs = gf.cross_section.strip_heater_doped(width=0.5, heater_width=2, heater_gap=0.5)
p = gf.path.arc(radius=10, angle=45)
c = p.extrude(xs)
c.plot()
"""
heater_offset = width / 2 + heater_gap + heater_width / 2
sections = [
Section(
layer=layer,
width=heater_width + 2 * cladding_offset,
offset=+heater_offset,
)
for layer, cladding_offset in zip(layers_heater, bbox_offsets_heater)
]
sections += [
Section(
layer=layer,
width=heater_width + 2 * cladding_offset,
offset=-heater_offset,
)
for layer, cladding_offset in zip(layers_heater, bbox_offsets_heater)
]
return strip(
width=width,
layer=layer,
sections=tuple(sections),
**kwargs,
)
strip_heater_doped_via_stack = partial(
strip_heater_doped,
layers_heater=(LAYER.WG, LAYER.NPP, LAYER.VIAC),
bbox_offsets_heater=(0, 0.1, -0.2),
)
@pydantic.validate_arguments
def rib_heater_doped(
width: float = 0.5,
layer: LayerSpec = "WG",
heater_width: float = 2.0,
heater_gap: float = 0.8,
layer_heater: LayerSpec = "NPP",
layer_slab: LayerSpec = "SLAB90",
slab_gap: float = 0.2,
with_top_heater: bool = True,
with_bot_heater: bool = True,
**kwargs,
) -> CrossSection:
"""Returns rib cross_section with N++ doped heaters on both sides.
dimensions from https://doi.org/10.1364/OE.27.010456
.. code::
|<------width------>|
____________________ heater_gap slab_gap
| |<----------->| <-->
___ _______________________| |__________________________|___
| | | undoped Si | | |
| |layer_heater| intrinsic region |layer_heater| |
|___|____________|____________________________________________|____________|___|
<---------->
heater_width
<------------------------------------------------------------------------------>
slab_width
.. plot::
:include-source:
import gdsfactory as gf
xs = gf.cross_section.rib_heater_doped(width=0.5, heater_width=2, heater_gap=0.5, layer_heater='NPP')
p = gf.path.arc(radius=10, angle=45)
c = p.extrude(xs)
c.plot()
"""
heater_offset = width / 2 + heater_gap + heater_width / 2
if with_bot_heater and with_top_heater:
slab_width = width + 2 * heater_gap + 2 * heater_width + 2 * slab_gap
slab_offset = 0
elif with_top_heater:
slab_width = width + heater_gap + heater_width + slab_gap
slab_offset = -slab_width / 2
elif with_bot_heater:
slab_width = width + heater_gap + heater_width + slab_gap
slab_offset = +slab_width / 2
sections = []
if with_bot_heater:
sections += [
Section(layer=layer_heater, width=heater_width, offset=+heater_offset)
]
if with_top_heater:
sections += [
Section(layer=layer_heater, width=heater_width, offset=-heater_offset)
]
sections += [
Section(width=slab_width, layer=layer_slab, offset=slab_offset, name="slab")
]
return strip(
width=width,
layer=layer,
sections=tuple(sections),
**kwargs,
)
@pydantic.validate_arguments
def rib_heater_doped_via_stack(
width: float = 0.5,