Skip to content
Edit this page

ictdesigntools.optical.interfaces

Optical interfaces (transceivers) and whether a planned link meets them, from data/interfaces.toml.

Each interface gives its transmitter's launch power, its receiver's sensitivity, the path attenuation and penalty it is specified for, and what it tolerates: chromatic dispersion at each end of its wavelength range, differential group delay and, for amplified links, OSNR.

assess() takes a link of optical.dispersion.Spans plus its connections and splices and reports, item by item, whether the interface works over it:

  • Attenuation: fibre loss at the worst wavelength in the interface's range, plus connections, splices, other loss and a margin, against the interface's maximum (and its minimum, below which the receiver may overload).
  • Chromatic dispersion at each end of the range, against the tolerance there.
  • PMD: the chance that the instantaneous DGD exceeds the receiver's tolerance, from the Maxwellian distribution of DGD about the link's mean, against outage_probability.
>>> from ictdesigntools.optical.dispersion import Span
>>> a = assess("p1l1-2d2", [Span("G.652.D", 60)], connections=2, splices=6)
>>> a.passes, round(a.attenuation_db, 2)
(True, 19.6)
>>> a = assess("p1l1-2d2", [Span("G.652.D", 100)])
>>> a.passes, [r.what for r in a.results if not r.passes]
(False, ['attenuation', 'chromatic dispersion at 1530 nm', 'chromatic dispersion at 1565 nm'])

Span dataclass

Span(
    fiber: str,
    length_km: float,
    compensation_ps_per_nm: float = 0.0,
)

length_km of one fibre category, with compensation_ps_per_nm added at its end (negative to compensate positive dispersion).

InterfaceError

Bases: ValueError

An unknown interface, or a link it cannot be assessed over.

Interface dataclass

Interface(
    slug: str,
    name: str,
    family: str,
    nm: tuple[float, float],
    launch_min_dbm: float,
    launch_max_dbm: float,
    sensitivity_dbm: float,
    source: str,
    overload_dbm: float | None = None,
    attenuation_db: tuple[float, float] | None = None,
    path_penalty_db: float = 0.0,
    cd_max_ps_per_nm: tuple[float, float] | None = None,
    cd_min_ps_per_nm: float | None = None,
    dgd_max_ps: float | None = None,
    osnr_db: float | None = None,
    pre_fec_ber: float | None = None,
    fiber: str = "",
)

amplified property

amplified: bool

An amplified (DWDM) interface: its reach is set by OSNR, not by attenuation.

max_attenuation_db property

max_attenuation_db: float

The most path attenuation the interface works over: its specified maximum, or what its worst-case launch power, sensitivity and path penalty leave.

min_attenuation_db property

min_attenuation_db: float

The least path attenuation it needs so the receiver does not overload.

Assessment dataclass

Assessment(
    interface: Interface,
    attenuation_db: float,
    results: tuple[Result, ...] = (),
    notes: tuple[str, ...] = (),
)

margin_db property

margin_db: float

Attenuation left before the interface's maximum.

dgd_exceed_probability

dgd_exceed_probability(
    dgd_ps: float, mean_dgd_ps: float
) -> float

The chance that a Maxwellian-distributed DGD of mean mean_dgd_ps exceeds dgd_ps.

Source code in src/ictdesigntools/optical/interfaces.py
def dgd_exceed_probability(dgd_ps: float, mean_dgd_ps: float) -> float:
    """The chance that a Maxwellian-distributed DGD of mean ``mean_dgd_ps`` exceeds
    ``dgd_ps``."""
    if mean_dgd_ps <= 0:
        return 0.0
    a = mean_dgd_ps / (2 * math.sqrt(2 / math.pi))  # the distribution's scale
    x = dgd_ps / a
    return math.erfc(x / math.sqrt(2)) + math.sqrt(2 / math.pi) * x * math.exp(-x * x / 2)

assess

assess(
    iface: str | Interface,
    spans,
    connections: int = 0,
    splices: int = 0,
    other_loss_db: float = 0.0,
    margin_db: float = 0.0,
    connection_loss_db: float = CONNECTION_LOSS_DB,
    splice_loss_db: float = SPLICE_LOSS_DB,
    outage_probability: float = OUTAGE_PROBABILITY,
) -> Assessment

Whether iface works over a link of spans with connections mated pairs, splices, other_loss_db (splitters, filters) and margin_db.

Source code in src/ictdesigntools/optical/interfaces.py
def assess(iface: str | Interface, spans, connections: int = 0, splices: int = 0,
           other_loss_db: float = 0.0, margin_db: float = 0.0,
           connection_loss_db: float = CONNECTION_LOSS_DB,
           splice_loss_db: float = SPLICE_LOSS_DB,
           outage_probability: float = OUTAGE_PROBABILITY) -> Assessment:  # fmt: skip
    """Whether ``iface`` works over a link of ``spans`` with ``connections`` mated pairs,
    ``splices``, ``other_loss_db`` (splitters, filters) and ``margin_db``."""
    i = iface if isinstance(iface, Interface) else interface(iface)
    spans = list(spans)
    if not spans:
        raise InterfaceError("Give at least one span.")
    ends = sorted(set(i.nm))
    fibre = []
    for nm in (*ends, sum(i.nm) / 2):
        try:
            fibre.append(_fibre_db(spans, nm))
        except FiberError:
            continue
        if len(fibre) == len(ends):
            break
    if not fibre:
        raise InterfaceError(f"The link's fibre sets no attenuation in {i.nm[0]:g}-{i.nm[1]:g} nm.")
    loss = (max(fibre) + connections * connection_loss_db + splices * splice_loss_db
            + other_loss_db + margin_db)  # fmt: skip
    results, notes = [], []
    if i.amplified:
        notes.append(
            f"Amplified interface: span loss is limited by OSNR (≥ {i.osnr_db:g} dB in "
            "0.1 nm at the receiver), not by the transmitter-to-receiver power budget."
        )
    else:
        results.append(Result("attenuation", loss, f"≤ {i.max_attenuation_db:g} dB",
                              loss <= i.max_attenuation_db + 1e-9))  # fmt: skip
    if i.min_attenuation_db and not i.amplified:
        results.append(Result(
            "minimum attenuation", loss, f"≥ {i.min_attenuation_db:g} dB",
            loss >= i.min_attenuation_db - 1e-9,
            "add an attenuator so the receiver does not overload",
        ))  # fmt: skip
    if i.cd_max_ps_per_nm:
        for nm, tol in zip(i.nm, i.cd_max_ps_per_nm, strict=True):
            low = -tol if i.cd_min_ps_per_nm is None else i.cd_min_ps_per_nm
            try:
                cd = chromatic_dispersion(spans, nm)
            except DispersionError as e:
                results.append(Result(f"chromatic dispersion at {nm:g} nm", math.nan,
                                      f"{low:g} to {tol:g} ps/nm", False, str(e)))  # fmt: skip
                continue
            ok = low <= cd.min_ps_per_nm and cd.max_ps_per_nm <= tol
            results.append(Result(f"chromatic dispersion at {nm:g} nm", cd.worst_ps_per_nm,
                                  f"{low:g} to {tol:g} ps/nm", ok))  # fmt: skip
    if i.dgd_max_ps:
        mean = pmd_ps(spans)
        p = dgd_exceed_probability(i.dgd_max_ps, mean)
        results.append(Result("PMD (mean DGD)", mean, f"DGD ≤ {i.dgd_max_ps:g} ps",
                              p <= outage_probability,
                              f"chance of exceeding {p:.1e}"))  # fmt: skip
    return Assessment(i, loss, tuple(results), tuple(notes))