|
| 1 | +"""SAX Isolator and Circulator Models.""" |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +import jax |
| 6 | +import jax.numpy as jnp |
| 7 | +from pydantic import validate_call |
| 8 | + |
| 9 | +import sax |
| 10 | + |
| 11 | + |
| 12 | +@jax.jit |
| 13 | +@validate_call |
| 14 | +def isolator( |
| 15 | + *, |
| 16 | + wl: sax.FloatArrayLike = sax.WL_C, |
| 17 | + insertion_loss_dB: sax.FloatArrayLike = 0.0, |
| 18 | + isolation_dB: sax.FloatArrayLike = 40.0, |
| 19 | +) -> sax.SDict: |
| 20 | + """Optical isolator model (non-reciprocal). |
| 21 | +
|
| 22 | + Transmits light in the forward direction (in0 -> out0) with low loss |
| 23 | + while blocking the reverse direction (out0 -> in0). |
| 24 | +
|
| 25 | + ```{svgbob} |
| 26 | + in0 out0 |
| 27 | + o1 ====>====== o2 |
| 28 | + ``` |
| 29 | +
|
| 30 | + Args: |
| 31 | + wl: Wavelength in micrometers. |
| 32 | + insertion_loss_dB: Forward insertion loss in dB. Defaults to 0.0 dB. |
| 33 | + isolation_dB: Reverse isolation in dB. Higher values mean better |
| 34 | + blocking of backward-propagating light. Defaults to 40.0 dB. |
| 35 | +
|
| 36 | + Returns: |
| 37 | + S-matrix dictionary for the isolator. |
| 38 | +
|
| 39 | + Examples: |
| 40 | + Isolator with 1 dB insertion loss and 30 dB isolation: |
| 41 | +
|
| 42 | + ```python |
| 43 | + # mkdocs: render |
| 44 | + import matplotlib.pyplot as plt |
| 45 | + import numpy as np |
| 46 | + import sax |
| 47 | +
|
| 48 | + sax.set_port_naming_strategy("optical") |
| 49 | +
|
| 50 | + wl = sax.wl_c() |
| 51 | + s = sax.models.isolator( |
| 52 | + wl=wl, |
| 53 | + insertion_loss_dB=1.0, |
| 54 | + isolation_dB=30.0, |
| 55 | + ) |
| 56 | + fwd = np.abs(s[("o1", "o2")]) ** 2 |
| 57 | + bwd = np.abs(s[("o2", "o1")]) ** 2 |
| 58 | + plt.figure() |
| 59 | + plt.plot(wl, 10 * np.log10(fwd), label="forward") |
| 60 | + plt.plot(wl, 10 * np.log10(bwd + 1e-10), label="backward") |
| 61 | + plt.xlabel("Wavelength [μm]") |
| 62 | + plt.ylabel("Transmission [dB]") |
| 63 | + plt.legend() |
| 64 | + ``` |
| 65 | + """ |
| 66 | + one = jnp.ones_like(jnp.asarray(wl)) |
| 67 | + forward = jnp.asarray(10 ** (-insertion_loss_dB / 20), dtype=complex) * one |
| 68 | + backward = jnp.asarray(10 ** (-isolation_dB / 20), dtype=complex) * one |
| 69 | + return { |
| 70 | + ("o1", "o2"): forward, |
| 71 | + ("o2", "o1"): backward, |
| 72 | + } |
| 73 | + |
| 74 | + |
| 75 | +@jax.jit |
| 76 | +@validate_call |
| 77 | +def circulator( |
| 78 | + *, |
| 79 | + wl: sax.FloatArrayLike = sax.WL_C, |
| 80 | + insertion_loss_dB: sax.FloatArrayLike = 0.0, |
| 81 | + isolation_dB: sax.FloatArrayLike = 40.0, |
| 82 | +) -> sax.SDict: |
| 83 | + """Optical circulator model (non-reciprocal 3-port device). |
| 84 | +
|
| 85 | + Routes light in a circular fashion: port 1 -> port 2 -> port 3 -> port 1. |
| 86 | + Light traveling in the reverse direction is strongly attenuated. |
| 87 | +
|
| 88 | + ```{svgbob} |
| 89 | + o2 |
| 90 | + * |
| 91 | + / \\ |
| 92 | + / \\ |
| 93 | + / --> \\ |
| 94 | + *-------* |
| 95 | + o1 o3 |
| 96 | + ``` |
| 97 | +
|
| 98 | + Args: |
| 99 | + wl: Wavelength in micrometers. |
| 100 | + insertion_loss_dB: Insertion loss in dB for the forward circulation |
| 101 | + path. Defaults to 0.0 dB. |
| 102 | + isolation_dB: Isolation in dB between non-adjacent ports (reverse |
| 103 | + direction). Defaults to 40.0 dB. |
| 104 | +
|
| 105 | + Returns: |
| 106 | + S-matrix dictionary for the circulator. |
| 107 | +
|
| 108 | + Examples: |
| 109 | + 3-port circulator: |
| 110 | +
|
| 111 | + ```python |
| 112 | + # mkdocs: render |
| 113 | + import matplotlib.pyplot as plt |
| 114 | + import numpy as np |
| 115 | + import sax |
| 116 | +
|
| 117 | + sax.set_port_naming_strategy("optical") |
| 118 | +
|
| 119 | + wl = sax.wl_c() |
| 120 | + s = sax.models.circulator( |
| 121 | + wl=wl, |
| 122 | + insertion_loss_dB=0.5, |
| 123 | + isolation_dB=30.0, |
| 124 | + ) |
| 125 | + fwd_12 = np.abs(s[("o1", "o2")]) ** 2 |
| 126 | + fwd_23 = np.abs(s[("o2", "o3")]) ** 2 |
| 127 | + iso_21 = np.abs(s[("o2", "o1")]) ** 2 |
| 128 | + plt.figure() |
| 129 | + plt.plot(wl, 10 * np.log10(fwd_12), label="o1→o2") |
| 130 | + plt.plot(wl, 10 * np.log10(fwd_23), label="o2→o3") |
| 131 | + plt.plot(wl, 10 * np.log10(iso_21 + 1e-10), label="o2→o1 (isolated)") |
| 132 | + plt.xlabel("Wavelength [μm]") |
| 133 | + plt.ylabel("Transmission [dB]") |
| 134 | + plt.legend() |
| 135 | + ``` |
| 136 | + """ |
| 137 | + one = jnp.ones_like(jnp.asarray(wl)) |
| 138 | + forward = jnp.asarray(10 ** (-insertion_loss_dB / 20), dtype=complex) * one |
| 139 | + isolated = jnp.asarray(10 ** (-isolation_dB / 20), dtype=complex) * one |
| 140 | + return { |
| 141 | + # Forward circulation: o1 -> o2 -> o3 -> o1 |
| 142 | + ("o1", "o2"): forward, |
| 143 | + ("o2", "o3"): forward, |
| 144 | + ("o3", "o1"): forward, |
| 145 | + # Reverse (isolated): o2 -> o1, o3 -> o2, o1 -> o3 |
| 146 | + ("o2", "o1"): isolated, |
| 147 | + ("o3", "o2"): isolated, |
| 148 | + ("o1", "o3"): isolated, |
| 149 | + } |
0 commit comments