inire/inire/tests/catalog_device_set.py

44 lines
2.1 KiB
Python

"""The synthetic 4, 5, and 8 µm waveguide technology in the routing plan."""
from shapely.geometry import Polygon, box
from inire._catalog import BendVariant, Catalog, FixedVariant, Grid, Orientation, Pose, Profile, SBendVariant, StraightVariant, Variant
from inire._catalog_timing import DelayModel
GRID = Grid((0, 0), 100, 1e-9)
WAVELENGTH = 1.55e-6
ORIENTATIONS = tuple(Orientation(angle, reflected) for angle in (0, 90, 180, 270) for reflected in (False, True))
TRAVERSALS = (("a", "b"), ("b", "a"))
def synthetic_device_set() -> tuple[Catalog, DelayModel]:
variants: dict[str, Variant] = {
"straight-4": StraightVariant("4", 1.0),
"straight-5": StraightVariant("5", 0.5),
"straight-8": StraightVariant("8", 0.2),
}
for profile, radius, quarter_cost in (("4", 10_000, 0.01), ("8", 100_000, 0.1)):
for turns in (45, 90, 135, 180):
for sign in (-1, 1):
angle = turns * sign
variants[f"bend-{profile}-{angle}"] = BendVariant(
profile, angle, radius, quarter_cost * (2 if turns >= 135 else 1),
max_lead=200, sagitta=10,
)
span, shift = 4 * radius // GRID.pitch, radius // (2 * GRID.pitch)
variants[f"sbend-{profile}"] = SBendVariant(profile, radius, 2 * quarter_cost, ((span, shift), (span, -shift)), sagitta=10)
a = Pose(0, 0, 0, "4")
variants["4-to-5"] = FixedVariant(
"4-to-5", {"a": a, "b": Pose(10_000, 0, 180, "5")},
(Polygon(((0, -2000), (10_000, -2500), (10_000, 2500), (0, 2000))),),
TRAVERSALS, ORIENTATIONS, 0.01, 10_000,
)
variants["4-to-8"] = FixedVariant(
"4-to-8", {"a": a, "b": Pose(100_000, 200, 180, "8")}, (box(0, -5000, 100_000, 5000),),
TRAVERSALS, ORIENTATIONS, 0.2, 100_010,
(Polygon(((0, -2000), (100_000, -3800), (100_000, 4200), (0, 2000))),),
)
profiles = {name: Profile(f"ridge-{name}", int(name) * 1000) for name in ("4", "5", "8")}
timing = DelayModel(WAVELENGTH, group_indices={"4": 4, "5": 4, "8": 2}, variant_delays={"4-to-5": 40_000, "4-to-8": 300_030})
return Catalog("synthetic-4-5-8", profiles, variants), timing