|
| 1 | +"""Four channels on a grid, amplified, then demultiplexed. |
| 2 | +
|
| 3 | +The signal model has carried independently sampled bands since the first commit |
| 4 | +precisely so that this would be possible without a sample rate no machine can |
| 5 | +afford: four carriers 100 GHz apart span 300 GHz, but each is sampled only across |
| 6 | +its own 160 GHz and never on a common grid. Put those two lasers 6 THz apart |
| 7 | +instead and nothing about the run changes. |
| 8 | +
|
| 9 | +Three things are worth reading off the output. |
| 10 | +
|
| 11 | +**The demultiplexer is wavelength-selective, not an index lookup.** Each filter |
| 12 | +is tuned to one channel and rejects its neighbours by the response at their |
| 13 | +offset — a number the model produces rather than an assumption it makes. Tune one |
| 14 | +between two channels and it attenuates both. |
| 15 | +
|
| 16 | +**A filter is also the ASE gate.** The amplifier emits spontaneous emission |
| 17 | +across four terahertz and every hertz of it reaches a photodiode and beats there. |
| 18 | +The final table is what that costs: the same link, the same OSNR, and a factor of |
| 19 | +three in Q depending on whether anything filtered it first. |
| 20 | +
|
| 21 | +**OSNR does not see it.** The reference bandwidth is fixed at 12.5 GHz, so |
| 22 | +cutting ASE outside that band changes the noise power by orders of magnitude and |
| 23 | +the OSNR figure not at all. That is worth seeing once: the number everyone quotes |
| 24 | +is blind to the single cheapest improvement available to a receiver. |
| 25 | +""" |
| 26 | + |
| 27 | +from __future__ import annotations |
| 28 | + |
| 29 | +import math |
| 30 | + |
| 31 | +import numpy as np |
| 32 | + |
| 33 | +from oosim import Graph, SimulationContext |
| 34 | +from oosim.component import Component |
| 35 | +from oosim.components import ( |
| 36 | + EDFA, |
| 37 | + BERAnalyzer, |
| 38 | + Combiner, |
| 39 | + CWLaser, |
| 40 | + ElectricalFilter, |
| 41 | + Fiber, |
| 42 | + MachZehnderModulator, |
| 43 | + NRZDriver, |
| 44 | + OpticalFilter, |
| 45 | + OpticalSpectrumAnalyzer, |
| 46 | + OSNRMeter, |
| 47 | + PINPhotodiode, |
| 48 | + PowerMeter, |
| 49 | + PRBSGenerator, |
| 50 | +) |
| 51 | +from oosim.kernels import super_gaussian_response |
| 52 | +from oosim.units import C_LIGHT, wavelength_to_frequency |
| 53 | + |
| 54 | +ANCHOR = 1550.0 # nm — channel 0 |
| 55 | +SPACING = 100e9 # Hz |
| 56 | +CHANNELS = 4 |
| 57 | +BIT_RATE = 10e9 |
| 58 | +FILTER_WIDTH = 50.0 # GHz |
| 59 | +OSNR_REFERENCE = 12.5e9 |
| 60 | +RECEIVER_BANDWIDTH = 7.0 # GHz |
| 61 | + |
| 62 | + |
| 63 | +def channel_wavelength(index: int) -> float: |
| 64 | + """Wavelength of channel ``index`` on the grid [nm].""" |
| 65 | + return C_LIGHT / (wavelength_to_frequency(ANCHOR * 1e-9) + index * SPACING) * 1e9 |
| 66 | + |
| 67 | + |
| 68 | +def q_from_osnr(osnr_db: float) -> float: |
| 69 | + """Textbook Q for NRZ-OOK limited by ASE beat noise.""" |
| 70 | + ratio = 10.0 ** (osnr_db / 10.0) |
| 71 | + noise_bandwidth = RECEIVER_BANDWIDTH * 1e9 * math.sqrt(math.pi / (4.0 * math.log(2.0))) |
| 72 | + return ( |
| 73 | + 2.0 |
| 74 | + * math.sqrt(OSNR_REFERENCE / noise_bandwidth) |
| 75 | + * ratio |
| 76 | + / (1.0 + math.sqrt(1.0 + 4.0 * ratio)) |
| 77 | + ) |
| 78 | + |
| 79 | + |
| 80 | +def build(select: int | None, *, filtered: bool = True) -> tuple[Graph, dict[str, object]]: |
| 81 | + """A four-channel comb through one amplifier, optionally demultiplexed. |
| 82 | +
|
| 83 | + ``select`` picks which channel the receiver is tuned to; ``None`` leaves the |
| 84 | + whole comb on the detector, which is what a link without a demultiplexer |
| 85 | + would do and is included because the difference is the point. |
| 86 | + """ |
| 87 | + ctx = SimulationContext(bit_rate=BIT_RATE, samples_per_symbol=16, sequence_length=2048, seed=17) |
| 88 | + graph = Graph(ctx) |
| 89 | + combiner = graph.add(Combiner(CHANNELS, label="mux")) |
| 90 | + |
| 91 | + # Only the channel under test is modulated; the neighbours are unmodulated |
| 92 | + # carriers at the same power. That keeps the crosstalk number about the |
| 93 | + # filter's response rather than about someone else's data pattern. |
| 94 | + prbs = graph.add(PRBSGenerator(order=15.0, label="prbs")) |
| 95 | + driver = graph.add(NRZDriver(v_low=4.0, v_high=0.0, label="drv")) |
| 96 | + graph.connect(prbs["out"], driver["in"]) |
| 97 | + |
| 98 | + for index in range(CHANNELS): |
| 99 | + laser = graph.add( |
| 100 | + CWLaser(power=0.0, wavelength=channel_wavelength(index), label=f"ch{index}") |
| 101 | + ) |
| 102 | + if index == (select or 0): |
| 103 | + modulator = graph.add(MachZehnderModulator(v_pi=4.0, label=f"mzm{index}")) |
| 104 | + graph.connect(laser, modulator["optical_in"]) |
| 105 | + graph.connect(driver, modulator["electrical_in"]) |
| 106 | + graph.connect(modulator, combiner[f"in{index}"]) |
| 107 | + else: |
| 108 | + graph.connect(laser, combiner[f"in{index}"]) |
| 109 | + |
| 110 | + # Four spans, each amplified back to transparency. Without real loss to make |
| 111 | + # up there is no ASE worth speaking of and the last table has nothing to show. |
| 112 | + node: Component = combiner |
| 113 | + for span in range(4): |
| 114 | + fiber = graph.add(Fiber(length=80.0, attenuation=0.2, dispersion=0.0, label=f"f{span}")) |
| 115 | + amplifier = graph.add(EDFA(gain=16.0, noise_figure=6.0, label=f"edfa{span}")) |
| 116 | + graph.connect(node, fiber["in"]) |
| 117 | + graph.connect(fiber, amplifier["in"]) |
| 118 | + node = amplifier |
| 119 | + |
| 120 | + if filtered and select is not None: |
| 121 | + demux = graph.add( |
| 122 | + OpticalFilter( |
| 123 | + center_wavelength=channel_wavelength(select), |
| 124 | + bandwidth=FILTER_WIDTH, |
| 125 | + order=3.0, |
| 126 | + label="demux", |
| 127 | + ) |
| 128 | + ) |
| 129 | + graph.connect(node, demux["in"]) |
| 130 | + node = demux |
| 131 | + |
| 132 | + osa = graph.add( |
| 133 | + OpticalSpectrumAnalyzer( |
| 134 | + center_wavelength=channel_wavelength(1), |
| 135 | + span=800.0, |
| 136 | + points=4096, |
| 137 | + label="osa", |
| 138 | + ) |
| 139 | + ) |
| 140 | + meter = graph.add(PowerMeter(label="pm")) |
| 141 | + osnr = graph.add(OSNRMeter(label="osnr")) |
| 142 | + detector = graph.add(PINPhotodiode(label="pin")) |
| 143 | + receiver = graph.add(ElectricalFilter(bandwidth=RECEIVER_BANDWIDTH, label="lpf")) |
| 144 | + analyzer = graph.add(BERAnalyzer(label="ber")) |
| 145 | + graph.connect(node, osa["in"]) |
| 146 | + graph.connect(node, meter["in"]) |
| 147 | + graph.connect(node, osnr["in"]) |
| 148 | + graph.connect(node, detector["in"]) |
| 149 | + graph.connect(detector, receiver["in"]) |
| 150 | + graph.connect(receiver, analyzer["in"]) |
| 151 | + graph.connect(prbs["out"], analyzer["reference"]) |
| 152 | + |
| 153 | + return graph, {"osa": osa, "pm": meter, "osnr": osnr, "ber": analyzer} |
| 154 | + |
| 155 | + |
| 156 | +def main() -> None: |
| 157 | + print(f"{CHANNELS} channels on a {SPACING / 1e9:.0f} GHz grid from {ANCHOR:.1f} nm") |
| 158 | + print(f"four amplified 80 km spans, then a {FILTER_WIDTH:.0f} GHz third-order demultiplexer\n") |
| 159 | + |
| 160 | + # The shape itself, before any link is involved. At a 100 GHz spacing every |
| 161 | + # sensible order buries the neighbour far below any real component's |
| 162 | + # extinction, so what limits crosstalk on this grid is the floor and not the |
| 163 | + # skirt — which is why the floor is a parameter rather than an idealisation. |
| 164 | + print(" Passband shape: transmission against offset from centre") |
| 165 | + print(f" {'offset':>10} {'order 1':>10} {'order 3':>10} {'order 5':>10}") |
| 166 | + print(" " + "-" * 46) |
| 167 | + for offset_ghz in (0.0, 12.5, 25.0, 31.25, 37.5, 50.0): |
| 168 | + row = [] |
| 169 | + for order in (1, 2 + 1, 5): |
| 170 | + t = super_gaussian_response(np.array([offset_ghz * 1e9]), FILTER_WIDTH * 1e9, order)[0] |
| 171 | + db = 10.0 * math.log10(max(t**2, 1e-30)) |
| 172 | + row.append(f"{db:9.1f} " if db > -300 else " --- ") |
| 173 | + print(f" {offset_ghz:8.1f}GHz " + " ".join(row)) |
| 174 | + print(f" a neighbour sits {SPACING / 1e9:.0f} GHz out, past every column above —") |
| 175 | + print(" so the extinction floor, not the shape, is what it lands on.") |
| 176 | + print() |
| 177 | + |
| 178 | + print(" Demultiplexer selectivity — power in each channel after the filter") |
| 179 | + print(" tuned to ch0 ch1 ch2 ch3 worst rejection") |
| 180 | + print(" " + "-" * 74) |
| 181 | + for select in range(CHANNELS): |
| 182 | + graph, ports = build(select) |
| 183 | + reading = graph.run()[ports["pm"]] # type: ignore[index] |
| 184 | + by_frequency = sorted(reading.bands, key=lambda b: b.wavelength_nm, reverse=True) |
| 185 | + powers = [band.power_dbm for band in by_frequency] |
| 186 | + others = [p for i, p in enumerate(powers) if i != select] |
| 187 | + print( |
| 188 | + f" ch{select} " |
| 189 | + + "".join(f"{p:9.1f} " for p in powers) |
| 190 | + + f" {powers[select] - max(others):6.1f} dB" |
| 191 | + ) |
| 192 | + |
| 193 | + print("\n What the filter is worth at the receiver") |
| 194 | + print(f" {'link':>28} {'OSNR':>9} {'ASE power':>11} {'Q':>7} {'vs OSNR limit':>14}") |
| 195 | + print(" " + "-" * 78) |
| 196 | + for filtered, label in ((False, "no demultiplexer"), (True, f"{FILTER_WIDTH:.0f} GHz demux")): |
| 197 | + graph, ports = build(1, filtered=filtered) |
| 198 | + results = graph.run() |
| 199 | + osnr_db = float(results[ports["osnr"]]) # type: ignore[index] |
| 200 | + reading = results[ports["pm"]] # type: ignore[index] |
| 201 | + q = results[ports["ber"]].q_factor # type: ignore[index] |
| 202 | + print( |
| 203 | + f" {label:>28} {osnr_db:6.2f} dB {reading.noise_power_w * 1e3:8.4f} mW " |
| 204 | + f"{q:7.2f} {q / q_from_osnr(osnr_db):13.2f}x" |
| 205 | + ) |
| 206 | + |
| 207 | + print("\n The OSNR figure is identical either way. It is quoted in a fixed") |
| 208 | + print(" 12.5 GHz reference bandwidth, so it cannot see ASE removed outside it.") |
| 209 | + |
| 210 | + graph, ports = build(1) |
| 211 | + spectrum = graph.run()[ports["osa"]] # type: ignore[index] |
| 212 | + peak_frequency, peak_power = spectrum.peak() |
| 213 | + print( |
| 214 | + f"\n OSA: {len(spectrum.frequencies)} points, peak at " |
| 215 | + f"{C_LIGHT / peak_frequency * 1e9:.3f} nm, " |
| 216 | + f"{10.0 * math.log10(peak_power * 1e3):.2f} dBm per " |
| 217 | + f"{spectrum.resolution_bandwidth / 1e9:.1f} GHz" |
| 218 | + ) |
| 219 | + |
| 220 | + |
| 221 | +if __name__ == "__main__": |
| 222 | + main() |
0 commit comments