Skip to content

Commit

Permalink
use pdk constants for information
Browse files Browse the repository at this point in the history
Former-commit-id: 5879dab
  • Loading branch information
joamatab committed Feb 9, 2023
1 parent edb426b commit e607c9d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
27 changes: 17 additions & 10 deletions gdsfactory/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -1597,7 +1597,7 @@ def _write_library(
logging: bool = True,
on_duplicate_cell: Optional[str] = "warn",
with_oasis: bool = False,
max_points: int = 4e3,
max_points: Optional[int] = None,
flatten_invalid_refs: bool = False,
**kwargs,
) -> Path:
Expand Down Expand Up @@ -1630,12 +1630,19 @@ def _write_library(
standard_properties: Store standard OASIS properties in the file.
"""
if flatten_invalid_refs:
self = flatten_invalid_refs_recursive(self)

from gdsfactory.pdk import get_grid_size
from gdsfactory.pdk import get_grid_size, get_constant

precision = precision or get_grid_size() * 1e-6
max_points = max_points or get_constant("max_points")
flatten_invalid_refs = flatten_invalid_refs or get_constant(
"flatten_invalid_refs"
)
precision = precision or get_constant("precision")
on_duplicate_cell = on_duplicate_cell or get_constant("on_duplicate_cell")

if flatten_invalid_refs:
self = flatten_invalid_refs_recursive(self)

gdsdir = (
gdsdir or pathlib.Path(tempfile.TemporaryDirectory().name) / "gdsfactory"
Expand Down Expand Up @@ -1708,7 +1715,7 @@ def write_gds(
logging: bool = True,
on_duplicate_cell: Optional[str] = "warn",
flatten_invalid_refs: bool = False,
max_points: int = 4000,
max_points: Optional[int] = None,
) -> Path:
"""Write component to GDS and returns gdspath.
Expand All @@ -1723,7 +1730,8 @@ def write_gds(
"error": throw a ValueError when attempting to write a gds with duplicate cells.
"overwrite": overwrite all duplicate cells with one of the duplicates, without warning.
flatten_invalid_refs: flattens component references which have invalid transformations.
max_points: Maximal number of vertices per polygon. Polygons with more vertices that this are automatically fractured.
max_points: Maximal number of vertices per polygon.
Polygons with more vertices that this are automatically fractured.
"""

return self._write_library(
Expand All @@ -1746,7 +1754,6 @@ def write_oas(
logging: bool = True,
on_duplicate_cell: Optional[str] = "warn",
flatten_invalid_refs: bool = False,
max_points: int = 4000,
**kwargs,
) -> Path:
"""Write component to GDS and returns gdspath.
Expand All @@ -1762,6 +1769,7 @@ def write_oas(
"error": throw a ValueError when attempting to write a gds with duplicate cells.
"overwrite": overwrite all duplicate cells with one of the duplicates, without warning.
None: do not try to resolve (at your own risk!)
flatten_invalid_refs: flattens component references which have invalid transformations.
Keyword Args:
compression_level: Level of compression for cells (between 0 and 9).
Expand All @@ -1782,7 +1790,6 @@ def write_oas(
on_duplicate_cell=on_duplicate_cell,
with_oasis=True,
flatten_invalid_refs=flatten_invalid_refs,
max_points=max_points,
**kwargs,
)

Expand Down Expand Up @@ -2517,6 +2524,6 @@ def hierarchy():
# c.plot_qt()
# c.ploth()
# c = test_extract()
c.write_oas("a.oas")
gf.show("a.oas")
gdspath = c.write_gds()
gf.show(gdspath)
# c.show()
3 changes: 2 additions & 1 deletion gdsfactory/generic_tech/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_generic_pdk():
from gdsfactory.components import cells
from gdsfactory.config import sparameters_path
from gdsfactory.cross_section import cross_sections
from gdsfactory.pdk import Pdk
from gdsfactory.pdk import Pdk, constants

return Pdk(
name="generic",
Expand All @@ -48,6 +48,7 @@ def get_generic_pdk():
layer_views=LAYER_VIEWS,
layer_transitions=LAYER_TRANSITIONS,
sparameters_path=sparameters_path,
constants=constants,
)


Expand Down
5 changes: 5 additions & 0 deletions gdsfactory/pdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
"fiber_spacing": 50.0,
"fiber_input_to_output_spacing": 200.0,
"metal_spacing": 10.0,
"max_points": 4000,
"unit": 1e-6,
"precision": 1e-9,
"flatten_invalid_refs": False,
"on_duplicate_cell": "warn",
}


Expand Down

0 comments on commit e607c9d

Please sign in to comment.