---
title: "Fiber pulse project: dispersion, solitons and compensation"
heading: Simulating pulses in optical fiber with the FFT, checking Gaussian broadening against the dispersion length, solving the nonlinear Schrödinger equation by the split-step Fourier method so that a fundamental soliton holds its shape, and designing dispersion compensation
eyebrow: S13 · Lesson 51 · Fiber pulse project
xp: 80
---

::: hook
Every long-haul fiber system was designed with a simulator built on the method in this project. Dispersion is easy in the frequency domain (a phase per frequency) and the Kerr effect is easy in the time domain (a phase per instant), so the split-step Fourier method alternates between them in small steps. You'll check it against lesson 43's closed forms, watch a soliton travel five dispersion lengths without changing, and size the compensating fiber that undoes 80 km of dispersion.
:::

::: predict
## In the split-step method with γ = 0, should the result depend on the number of steps?

- [x] No: pure dispersion is a single exact phase multiplication, however it's divided
- [ ] Yes, more steps are always more accurate
- [ ] Only for anomalous dispersion
- [ ] Yes, because the FFT introduces error each step

::: reveal
With no nonlinearity, every step multiplies the spectrum by $e^{j\beta_2\omega^2h/2}$, and those phases simply add up to $e^{j\beta_2\omega^2L/2}$. The test checks that 50 steps match one exact multiplication to 10⁻⁹. The step size only matters when the nonlinear phase, which doesn't commute with dispersion, is present.
:::
:::

::: nameit
## The equation

The pulse envelope A(z, t), in a frame moving at the group velocity, obeys the nonlinear Schrödinger equation

$$\frac{\partial A}{\partial z} = -\frac{j\beta_2}{2}\frac{\partial^2A}{\partial t^2} + j\gamma|A|^2A$$

with $|A|^2$ the power in watts.

## Dispersion alone

In the frequency domain each component just picks up a phase: $\tilde{A}(z, \omega) = \tilde{A}(0, \omega)e^{j\beta_2\omega^2z/2}$. A Gaussian of power $e^{-t^2/T_0^2}$ broadens by $\sqrt{1 + (z/L_D)^2}$ in RMS width.

## Split-step Fourier

Over a step h: half a dispersion step in the frequency domain, the nonlinear phase $e^{j\gamma|A|^2h}$ in the time domain, another half dispersion step. The symmetric split is accurate to second order in h.

## The soliton

With β₂ < 0 and γ > 0, the pulse $A = \sqrt{P_0}\,\text{sech}(t/T_0)$ with $P_0 = |\beta_2|/(\gamma T_0^2)$ is a fundamental soliton: dispersion and self-phase modulation cancel exactly.

## Compensation

Fiber with the opposite β₂ undoes accumulated dispersion: lengths satisfying $\beta_{2,1}L_1 + \beta_{2,2}L_2 = 0$ restore any pulse exactly, in the absence of nonlinearity.
:::

::: example
## What should the project's three checks give?

::: solution
1. **Dispersion check.** A 2 ps ($T_0$) Gaussian in fiber with β₂ = −21.7 ps²/km has
   $$\begin{aligned} L_D &= \frac{(2\ \text{ps})^2}{21.7\ \text{ps}^2/\text{km}} \\ &= 184\ \text{m} \end{aligned}$$
   and after 0.5 km it's 2.891 times wider.
2. **Soliton check.** A 1 ps soliton with β₂ = −20 ps²/km and γ = 2 W⁻¹km⁻¹ needs
   $$\begin{aligned} P_0 &= \frac{20}{2 \times 1^2}\ \text{W} \\ &= 10\ \text{W} \end{aligned}$$
   After 5 $L_D$ (0.25 km, 500 steps) its shape changes by less than 10⁻⁵ of its peak; without the nonlinearity it spreads 3.3 times.
3. **Compensation check.** 80 km at −21.7 ps²/km accumulates
   $$-21.7 \times 80 = -1736\ \text{ps}^2$$
   cancelled by
   $$\frac{1736\ \text{ps}^2}{100\ \text{ps}^2/\text{km}} = 17.36\ \text{km}$$
   of +100 ps²/km fiber.

**Answer:** $L_D$ = 184 m and the Gaussian is 2.891 times wider after 0.5 km; the soliton needs 10 W and holds its shape to 10⁻⁵ (3.3 times wider without the nonlinearity); 17.36 km of +100 ps²/km fiber compensates the 80 km.
:::
:::

::: example
## What if the compensating fiber is cut 1% short?

::: solution
1. **Residual dispersion.**
   $$-1736 + 0.99 \times 1736 = -17.4\ \text{ps}^2$$
2. **In dispersion lengths.** For a 2 ps pulse ($T_0^2$ = 4 ps²) that's
   $$\frac{17.36\ \text{ps}^2}{4\ \text{ps}^2} = 4.3$$
   dispersion lengths' worth.
3. **Broadening.**
   $$\sqrt{1 + (17.36/4)^2} = 4.45$$
   so the pulse comes out 4.45 times wider.
4. **Why it must be precise.** Compensation has to be precise to a fraction of a percent at high bit rates, which is why links use tunable compensators or, today, coherent receivers that compensate digitally.

**Answer:** the pulse comes out 4.45 times wider.
:::
:::

::: check
kind: python

## Step 1. Write `disperse`: linear dispersion in the frequency domain.

```python starter
import numpy as np

# Units: time in ps, distance in km, beta2 in ps^2/km, gamma in 1/(W km), power in W.
N, Tw = 2048, 80.0
dt = Tw/N
t = (np.arange(N) - N/2)*dt

def rms_width(A, t):
    P = abs(A)**2
    m = np.sum(t*P)/np.sum(P)
    return np.sqrt(np.sum((t - m)**2*P)/np.sum(P))

def disperse(A, dt, beta2, z):
    # Linear dispersion over length z: FFT the envelope A, multiply by exp(0.5j*beta2*w^2*z)
    # with w = 2 pi np.fft.fftfreq(len(A), dt), inverse FFT. Return the new envelope.
    return A

A = np.exp(-t**2/(2*2.0**2))
print(rms_width(disperse(A, dt, -21.7, 0.5), t)/rms_width(A, t))
```

```python solution
import numpy as np

# Units: time in ps, distance in km, beta2 in ps^2/km, gamma in 1/(W km), power in W.
N, Tw = 2048, 80.0
dt = Tw/N
t = (np.arange(N) - N/2)*dt

def rms_width(A, t):
    P = abs(A)**2
    m = np.sum(t*P)/np.sum(P)
    return np.sqrt(np.sum((t - m)**2*P)/np.sum(P))

def disperse(A, dt, beta2, z):
    w = 2*np.pi*np.fft.fftfreq(len(A), dt)
    return np.fft.ifft(np.fft.fft(A)*np.exp(0.5j*beta2*w**2*z))

A = np.exp(-t**2/(2*2.0**2))
print(rms_width(disperse(A, dt, -21.7, 0.5), t)/rms_width(A, t))
```

```python tests
T0, b2 = 2.0, -21.7
A = np.exp(-t**2/(2*T0**2))
LD = T0**2/abs(b2)
for z in (0.1, 0.5):
    r = rms_width(disperse(A, dt, b2, z), t)/rms_width(A, t)
    want = np.sqrt(1 + (z/LD)**2)
    assert abs(r - want) < 1e-9, f"After {z} km a Gaussian with T0 = 2 ps should be {want:.6f} times wider (L_D = {LD*1000:.1f} m); got {r:.6f}."
B = disperse(A, dt, b2, 0.3)
assert abs(np.sum(abs(B)**2)/np.sum(abs(A)**2) - 1) < 1e-12, "Dispersion conserves energy."
r1 = rms_width(disperse(A, dt, +21.7, 0.3), t)
r2 = rms_width(disperse(A, dt, -21.7, 0.3), t)
assert abs(r1 - r2) < 1e-9, "An unchirped pulse broadens equally in normal and anomalous dispersion."
```

::: right
Right. Gaussian broadening matches the dispersion-length formula to nine digits, with energy conserved.
:::
:::

::: check
kind: python

## Step 2. Write `split_step`: the nonlinear Schrödinger equation.

```python starter
import numpy as np

# Units: time in ps, distance in km, beta2 in ps^2/km, gamma in 1/(W km), power in W.
N, Tw = 2048, 80.0
dt = Tw/N
t = (np.arange(N) - N/2)*dt

def rms_width(A, t):
    P = abs(A)**2
    m = np.sum(t*P)/np.sum(P)
    return np.sqrt(np.sum((t - m)**2*P)/np.sum(P))

def split_step(A, dt, beta2, gamma, L, nsteps):
    # Symmetric split-step Fourier solution of dA/dz = -(j beta2/2) d2A/dt2 + j gamma |A|^2 A
    # over length L in nsteps steps of h = L/nsteps: half a dispersion step (multiply the
    # spectrum by exp(0.25j*beta2*w^2*h)), a full nonlinear step (A *= exp(1j*gamma*|A|^2*h)),
    # then another half dispersion step. Return the final envelope.
    return A

T0, b2, g = 1.0, -20.0, 2.0
P0 = abs(b2)/(g*T0**2)
A = np.sqrt(P0)/np.cosh(t/T0)
B = split_step(A, dt, b2, g, 5*T0**2/abs(b2), 500)
print("largest change:", np.max(abs(abs(B) - abs(A)))/np.sqrt(P0))
```

```python solution
import numpy as np

# Units: time in ps, distance in km, beta2 in ps^2/km, gamma in 1/(W km), power in W.
N, Tw = 2048, 80.0
dt = Tw/N
t = (np.arange(N) - N/2)*dt

def rms_width(A, t):
    P = abs(A)**2
    m = np.sum(t*P)/np.sum(P)
    return np.sqrt(np.sum((t - m)**2*P)/np.sum(P))

def split_step(A, dt, beta2, gamma, L, nsteps):
    h = L/nsteps
    w = 2*np.pi*np.fft.fftfreq(len(A), dt)
    half = np.exp(0.25j*beta2*w**2*h)
    for _ in range(nsteps):
        A = np.fft.ifft(np.fft.fft(A)*half)
        A = A*np.exp(1j*gamma*abs(A)**2*h)
        A = np.fft.ifft(np.fft.fft(A)*half)
    return A

T0, b2, g = 1.0, -20.0, 2.0
P0 = abs(b2)/(g*T0**2)
A = np.sqrt(P0)/np.cosh(t/T0)
B = split_step(A, dt, b2, g, 5*T0**2/abs(b2), 500)
print("largest change:", np.max(abs(abs(B) - abs(A)))/np.sqrt(P0))
```

```python tests
T0, b2, g = 1.0, -20.0, 2.0
P0 = abs(b2)/(g*T0**2)
LD = T0**2/abs(b2)
A = np.sqrt(P0)/np.cosh(t/T0)
B = split_step(A, dt, b2, g, 5*LD, 500)
dev = np.max(abs(abs(B) - abs(A)))/np.sqrt(P0)
assert dev < 1e-4, f"A fundamental soliton (P0 = |β2|/γT0² = {P0} W) should keep its shape over 5 dispersion lengths; it changed by {dev:.2e} of its peak."
C = split_step(A, dt, b2, 0.0, 5*LD, 50)
w = 2*np.pi*np.fft.fftfreq(N, dt)
ref = np.fft.ifft(np.fft.fft(A)*np.exp(0.5j*b2*w**2*5*LD))
assert np.max(abs(C - ref)) < 1e-9, "With γ = 0 the split-step result must equal pure dispersion."
r_lin = rms_width(C, t)/rms_width(A, t)
r_norm = rms_width(split_step(A, dt, -b2, g, 5*LD, 500), t)/rms_width(A, t)
assert r_lin > 3 and r_norm > r_lin + 1, f"Without nonlinearity the pulse should spread ({r_lin:.2f}×), and with normal dispersion the Kerr effect should spread it further ({r_norm:.2f}×)."
```

::: right
Right. The soliton holds its shape to 10⁻⁵ over five dispersion lengths, and your γ = 0 limit is exact.
:::
:::

::: check
kind: python

## Step 3. Write `compensate`: undo a span's dispersion.

```python starter
import numpy as np

# Units: time in ps, distance in km, beta2 in ps^2/km, gamma in 1/(W km), power in W.
N, Tw = 2048, 80.0
dt = Tw/N
t = (np.arange(N) - N/2)*dt

def rms_width(A, t):
    P = abs(A)**2
    m = np.sum(t*P)/np.sum(P)
    return np.sqrt(np.sum((t - m)**2*P)/np.sum(P))

def disperse(A, dt, beta2, z):
    w = 2*np.pi*np.fft.fftfreq(len(A), dt)
    return np.fft.ifft(np.fft.fft(A)*np.exp(0.5j*beta2*w**2*z))

def compensate(A, dt, b_smf, L_smf, b_dcf, fraction=1.0):
    # Send A through L_smf km of fiber with b_smf, then through dispersion-compensating fiber
    # with b_dcf, of the length that cancels the accumulated dispersion, times fraction.
    # Return (L_dcf, output envelope), where L_dcf is the full-compensation length.
    return 0.0, A

A = np.exp(-t**2/(2*2.0**2))
L, B = compensate(A, dt, -21.7, 80.0, 100.0)
print(L, np.max(abs(B - A)))
```

```python solution
import numpy as np

# Units: time in ps, distance in km, beta2 in ps^2/km, gamma in 1/(W km), power in W.
N, Tw = 2048, 80.0
dt = Tw/N
t = (np.arange(N) - N/2)*dt

def rms_width(A, t):
    P = abs(A)**2
    m = np.sum(t*P)/np.sum(P)
    return np.sqrt(np.sum((t - m)**2*P)/np.sum(P))

def disperse(A, dt, beta2, z):
    w = 2*np.pi*np.fft.fftfreq(len(A), dt)
    return np.fft.ifft(np.fft.fft(A)*np.exp(0.5j*beta2*w**2*z))

def compensate(A, dt, b_smf, L_smf, b_dcf, fraction=1.0):
    L_dcf = -b_smf*L_smf/b_dcf
    return L_dcf, disperse(disperse(A, dt, b_smf, L_smf), dt, b_dcf, fraction*L_dcf)

A = np.exp(-t**2/(2*2.0**2))
L, B = compensate(A, dt, -21.7, 80.0, 100.0)
print(L, np.max(abs(B - A)))
```

```python tests
T0 = 2.0
A = np.exp(-t**2/(2*T0**2))
L, B = compensate(A, dt, -21.7, 80.0, 100.0)
assert abs(L - 17.36) < 1e-9, f"80 km at −21.7 ps²/km accumulates −1736 ps²; DCF at +100 ps²/km needs 17.36 km; got {L}."
assert np.max(abs(B - A)) < 1e-9, f"Full compensation must restore the pulse exactly; the largest error is {np.max(abs(B - A)):.2e}."
L, B = compensate(A, dt, -21.7, 80.0, 100.0, fraction=0.99)
resid = -21.7*80.0 + 100.0*0.99*17.36
want = np.sqrt(1 + (resid/T0**2)**2)
r = rms_width(B, t)/rms_width(A, t)
assert abs(r - want) < 1e-6, f"With 99% compensation the residual dispersion is {resid:.2f} ps², broadening the pulse {want:.4f}×; got {r:.4f}×."
```

::: right
Right. Exact restoration at full compensation, and the right broadening when it falls short.
:::
:::

::: explain
## Why does the split-step method need small steps when the Kerr effect is present but not when it isn't?

::: model
Dispersion and the Kerr effect are each exactly solvable alone: dispersion is a phase on each frequency, the Kerr effect a phase on each instant. Together they don't commute: applying dispersion and then the nonlinear phase gives a different result from the reverse order, because the nonlinear phase depends on the pulse shape that dispersion is changing. Splitting the propagation into short steps and alternating keeps that ordering error small, of order the square of the step for the symmetric scheme, so it vanishes as the steps shrink. With no nonlinearity there's nothing to interleave, and one step of any length is exact.
:::
:::

::: practice

::: check
given: b = 5 | 21.7; L = 20 | 80 | 120; d = 80 | 120
answer: b*L/d
unit: km
tolerance: 0.5%

## A span of {L} km has |β₂| = {b} ps²/km. What length of compensating fiber with |β₂| = {d} ps²/km, of the opposite sign, cancels it?

::: misses
- [any] $|\beta_{2,1}L_1|/|\beta_{2,2}|$.
:::
:::

::: check
given: b = 5 | 30; g = 1 | 5; t = 0.5 | 3
answer: b/(g*t^2)
unit: W
tolerance: 0.5%

## Soliton power: |β₂| = {b} ps²/km, γ = {g} W⁻¹km⁻¹, $T_0$ = {t} ps?

::: misses
- [any] $|\beta_2|/(\gamma T_0^2)$.
:::
:::

::: check
given: t = 1 | 5; b = 5 | 30; z = 0.05 | 2
answer: sqrt(1 + (z/(t^2/b))^2)
tolerance: 0.5%

## Broadening factor: $T_0$ = {t} ps, |β₂| = {b}, {z} km?

::: misses
- [any] $\sqrt{1 + (z/L_D)^2}$.
:::
:::
:::
