Skip to content
Edit this page

ictdesigntools.optical.dispersion

Chromatic dispersion and polarization mode dispersion along a link of fibre spans.

A link is a sequence of Spans, each a length of one optical.media category, with any dispersion compensation (a compensating module, or a coherent receiver's electronic compensation) as a negative compensation_ps_per_nm.

Chromatic dispersion (CD) adds linearly: each span contributes its coefficient times its length, in ps/nm. A category allows a range of coefficients, so the link's CD is a range too; chromatic_dispersion() returns it, and check() compares its worst end with a receiver's tolerance.

PMD adds in quadrature: the differential group delay of independent sections combines as the square root of the sum of squares, so the link design value is sqrt(Σ PMDQ_i² · L_i) ps for spans of PMD link design value PMDQ_i (ps/√km) and length L_i (km).

>>> link = [Span("G.652.D", 40), Span("G.652.D", 40)]
>>> cd = chromatic_dispersion(link, 1550)
>>> round(cd.min_ps_per_nm), round(cd.max_ps_per_nm)
(1064, 1488)
>>> round(pmd_ps(link), 2)
1.79
>>> check(link, 1550, cd_tolerance_ps_per_nm=(-800, 1600), pmd_tolerance_ps=10).passes
True

DispersionError

Bases: ValueError

A span or tolerance that cannot be worked out.

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).

Dispersion dataclass

Dispersion(
    wavelength_nm: float,
    min_ps_per_nm: float,
    max_ps_per_nm: float,
)

A link's accumulated chromatic dispersion range, ps/nm.

worst_ps_per_nm property

worst_ps_per_nm: float

The end of the range furthest from zero, with its sign.

Check dataclass

Check(
    dispersion: Dispersion,
    pmd_ps: float,
    cd_tolerance_ps_per_nm: tuple[float, float] | None,
    pmd_tolerance_ps: float | None,
)

cd_margin_ps_per_nm property

cd_margin_ps_per_nm: float | None

How far the link's range sits inside the tolerance at its closer edge (negative when outside).

chromatic_dispersion

chromatic_dispersion(
    spans, wavelength_nm: float
) -> Dispersion

The link's accumulated CD range at wavelength_nm, from each span's category limits and its compensation. Raises DispersionError when a category sets no limit there.

Source code in src/ictdesigntools/optical/dispersion.py
def chromatic_dispersion(spans, wavelength_nm: float) -> Dispersion:
    """The link's accumulated CD range at ``wavelength_nm``, from each span's category limits
    and its compensation. Raises ``DispersionError`` when a category sets no limit there."""
    lo = hi = 0.0
    for s in spans:
        found = s.category.dispersion_ps_per_nm_km(wavelength_nm)
        if found is None:
            raise DispersionError(
                f"{s.category.name} sets no dispersion limit at {wavelength_nm:g} nm."
            )
        d_lo, d_hi = found
        if s.category.dispersion_sign == "either":  # the bounds hold for D or -D
            d_lo = -d_hi
        lo += d_lo * s.length_km + s.compensation_ps_per_nm
        hi += d_hi * s.length_km + s.compensation_ps_per_nm
    return Dispersion(wavelength_nm, lo, hi)

pmd_ps

pmd_ps(spans) -> float

The link's PMD design value, ps: the spans' values added in quadrature.

Source code in src/ictdesigntools/optical/dispersion.py
def pmd_ps(spans) -> float:
    """The link's PMD design value, ps: the spans' values added in quadrature."""
    return math.sqrt(sum(s.category.pmdq_ps_per_sqrt_km**2 * s.length_km for s in spans))

check

check(
    spans,
    wavelength_nm: float,
    cd_tolerance_ps_per_nm=None,
    pmd_tolerance_ps: float | None = None,
) -> Check

The link's CD and PMD against a receiver's tolerances. cd_tolerance_ps_per_nm is a (lowest, highest) pair, or one number for ±that; pmd_tolerance_ps the largest PMD (mean DGD) the receiver accepts. Either may be None to skip it.

Source code in src/ictdesigntools/optical/dispersion.py
def check(spans, wavelength_nm: float, cd_tolerance_ps_per_nm=None,
          pmd_tolerance_ps: float | None = None) -> Check:  # fmt: skip
    """The link's CD and PMD against a receiver's tolerances. ``cd_tolerance_ps_per_nm`` is a
    (lowest, highest) pair, or one number for ±that; ``pmd_tolerance_ps`` the largest PMD
    (mean DGD) the receiver accepts. Either may be None to skip it."""
    tol = cd_tolerance_ps_per_nm
    if tol is not None and not isinstance(tol, tuple | list):
        tol = (-abs(tol), abs(tol))
    if tol is not None:
        tol = (float(tol[0]), float(tol[1]))
        if tol[0] > tol[1]:
            raise DispersionError("The CD tolerance's lowest value is above its highest.")
    return Check(chromatic_dispersion(spans, wavelength_nm), pmd_ps(spans), tol,
                 pmd_tolerance_ps)  # fmt: skip