Optics — Photonic Stochastic Computing¶
End-to-end photonic stack for SC-NeuroCore: truly-random bitstream
generation via laser interference, compilation of SC IR onto
Mach-Zehnder cascades, FDTD co-simulation (1D absorbing boundary + 2D
split-field Berenger PML), coupled-mode crosstalk analysis for
parallel waveguide banks, and GDSII export via gdsfactory.
Install the Rust acceleration + layout tooling with:
pip install "sc-neurocore[optics]"
The Rust engine (libsc_neurocore_engine) exposes parallel Rayon
kernels for the crosstalk analysis; a pure-Python fallback mirrors the
same math to 1e-9 parity when the engine wheel is absent.
1. Mathematical formalism¶
1.1 Photonic bitstream generation¶
Two coherent laser beams $I_1, I_2$ with independent phase noise $\varphi \sim \mathrm{Uniform}(0, 2\pi)$ interfere. Intensity:
$$ I(\varphi) = I_1 + I_2 + 2\sqrt{I_1 I_2}\,\cos\varphi. $$
With balanced beams $I_1 = I_2$:
$$ I_\text{norm}(\varphi) = \tfrac{1}{2}!\left(1 + \cos\varphi\right). $$
A bit is emitted as $1$ if $I_\text{norm} < p$ (the input probability), else $0$. Since $\cos\varphi$ is uniformly distributed, $I_\text{norm}$ is distributed as $U = (1 + \cos\varphi)/2$; its CDF at $p$ is exactly $p$, so $\Pr[\text{bit} = 1] = p$ — the photodetector + comparator pair produces a bitstream with mean activity equal to the input probability.
1.2 Coupled-mode theory for parallel waveguides¶
Two parallel single-mode waveguides separated by gap $g$ exchange power via evanescent coupling. Let $n_c, n_s$ be the core and cladding refractive indices at wavelength $\lambda$ (all units consistent). The transverse decay length of the evanescent field follows the Marcatili approximation:
$$ L_\text{decay}(\lambda, n_c, n_s) = \frac{\lambda}{2\pi\sqrt{n_c^2 - n_s^2}}. $$
The effective-index difference between the even and odd supermodes decays exponentially with the gap:
$$ \Delta n_\text{eff}(g) = 0.1\, e^{-g / L_\text{decay}}. $$
The prefactor $0.1$ is an empirical normalisation matched to Si waveguides at 1550 nm in SiO₂ cladding and bears the units of an unscaled index split; it is consistent with the tabulated values in Okamoto (2006, Ch. 4).
The coupling coefficient per unit length is:
$$ \kappa(g) = \frac{\pi\,\Delta n_\text{eff}(g)}{\lambda} \qquad \text{(units: } \mu\text{m}^{-1}\text{ when }\lambda\text{ in }\mu\text{m)}. $$
The power coupling ratio after a uniform directional coupler of length $L$:
$$ \eta(g, L) = \sin^2!\big(\kappa(g)\, L\big). $$
The isolation in dB between the adjacent ports:
$$ \mathrm{iso}\text{dB}(g, L) = -10\,\log\eta(g, L). $$
1.3 Transfer matrix for a single coupler¶
The $2\times 2$ unitary transfer matrix for two adjacent waveguides coupled over length $L$ (power-preserving):
$$ T(g, L) = \begin{pmatrix} \cos(\kappa L) & j\sin(\kappa L) \ j\sin(\kappa L) & \cos(\kappa L) \end{pmatrix}. $$
Output field amplitudes: $\mathbf{a}\text{out} = T(g, L)\,\mathbf{a}\text{in}$. Because $T T^\dagger = I$ by construction, $|a_\text{out,1}|^2 + |a_\text{out,2}|^2 = |a_\text{in,1}|^2 + |a_\text{in,2}|^2$ — power is exactly conserved per coupler, as required.
1.4 FDTD: 1D Yee discretisation¶
Maxwell's equations in a source-free, non-magnetic medium reduce in 1D to two coupled PDEs:
$$ \frac{\partial E_z}{\partial t} = -\frac{1}{\varepsilon}\frac{\partial H_y}{\partial x}, \qquad \frac{\partial H_y}{\partial t} = -\frac{1}{\mu_0}\frac{\partial E_z}{\partial x}. $$
On a staggered Yee grid with $E_z$ sampled at integer cells and $H_y$ at half-integer cells, the leap-frog update is:
$$ \begin{aligned} H_y^{n+1/2}[i+\tfrac{1}{2}] &= H_y^{n-1/2}[i+\tfrac{1}{2}] - \frac{\Delta t}{\mu_0 \Delta x}\big(E_z^{n}[i+1] - E_z^{n}[i]\big), \ E_z^{n+1}[i] &= E_z^{n}[i] - \frac{\Delta t}{\varepsilon_i \Delta x} \big(H_y^{n+1/2}[i+\tfrac{1}{2}] - H_y^{n+1/2}[i-\tfrac{1}{2}]\big). \end{aligned} $$
SC-NeuroCore's 1D solver adds a multiplicative absorbing boundary at each end — a quadratic-ramp taper $s_i = 1 - 0.8\,((N-i)/N)^2$ over the outermost $N$ cells:
$$ E_z[i] \leftarrow s_i\, E_z[i], \qquad H_y[i] \leftarrow s_i\, H_y[i], \qquad 0 \le i < N \text{ or } N_x - N \le i < N_x. $$
This is not a split-field Berenger PML. 1D has no transverse dimension into which energy could scatter, so the σ-matched split formulation is neither required nor implemented. Reflection is < −30 dB for wavelengths much smaller than the boundary depth.
1.5 FDTD: 2D split-field Berenger PML¶
The 2D TE-mode solver uses the full split-field formulation of Berenger (1994). The $E_z$ field is split into $E_{zx}$ + $E_{zy}$; each component carries its own electric conductivity $\sigma_x(x), \sigma_y(y)$, matched by magnetic conductivities
$$ \sigma^_x = \sigma_x \cdot \frac{\mu_0}{\varepsilon_0}, \qquad \sigma^_y = \sigma_y \cdot \frac{\mu_0}{\varepsilon_0}. $$
The matched-impedance condition guarantees that the wave enters the PML without reflection. The split-field updates, using Taflove-Hagness discretisation:
$$ \begin{aligned} E_{zx}^{n+1}[i,j] &= c^a_x[i,j]\, E_{zx}^n[i,j] + c^b_x[i,j]\, \big(H_y^{n+1/2}[i,j] - H_y^{n+1/2}[i-1,j]\big), \ E_{zy}^{n+1}[i,j] &= c^a_y[i,j]\, E_{zy}^n[i,j] - c^b_y[i,j]\, \big(H_x^{n+1/2}[i,j] - H_x^{n+1/2}[i,j-1]\big), \ E_z^{n+1}[i,j] &= E_{zx}^{n+1}[i,j] + E_{zy}^{n+1}[i,j], \end{aligned} $$
with coefficient arrays
$$ c^a_x[i,j] = \frac{\varepsilon_{i,j} - \sigma_x[i,j]\,\Delta t/2} {\varepsilon_{i,j} + \sigma_x[i,j]\,\Delta t/2}, \qquad c^b_x[i,j] = \frac{\Delta t} {(\varepsilon_{i,j} + \sigma_x[i,j]\,\Delta t/2)\,\Delta x}, $$
and analogously for $c^a_y, c^b_y$. The conductivity profile inside the PML uses a cubic ramp, $\sigma(i) = \sigma_\text{max}\,((P-i)/P)^3$, over $P$ PML layers. $\sigma_\text{max} = 5 / (120\pi\,\Delta x)$ is the standard Taflove-Hagness recommendation for < −60 dB reflection.
1.6 CFL stability¶
The 2D CFL condition used by the solver:
$$ \Delta t \le \frac{\mathrm{CFL}}{c_0 \sqrt{2}}\cdot \min(\Delta x, \Delta y), \qquad \mathrm{CFL} = 0.5 \text{ by default}. $$
The 1D solver uses $\Delta t = \mathrm{CFL}\cdot\Delta x / c_0$ — same
condition collapsed to 1D. Both are verified by the
test_step_preserves_finiteness_under_cfl test group.
2. Theoretical context¶
Photonic stochastic computing replaces the standard LFSR bitstream source with an optical one — two interfering coherent beams whose phase noise is genuinely quantum-mechanical, so the produced bits are Bernoulli-distributed with no pseudo-random correlations at any lag (Abhari et al. 2019). For SC neural networks this removes the PCC (pseudo-random cross-correlation) penalty that limits deep LFSR-driven SC networks to ~8 bits of effective precision.
The photonic compiler translates SC bitstreams onto Mach-Zehnder interferometers (MZIs). Each MZI implements a tunable 2×2 unitary; cascading them realises any small unitary mesh. The compiler's job is to pick the right phase for each MZI given a target output bitstream. This is the photonic analogue of the Lightmatter / Lightelligence silicon-photonic accelerators (Shen et al. 2017) but runs in bitstream domain instead of analogue amplitude.
The FDTD solvers verify that the compiled layout actually propagates the bitstream correctly through the physical waveguide geometry — Yee's algorithm (Yee 1966) with Berenger's PML (Berenger 1994) for open-boundary simulation. These are decades-old, implementation-settled numerical methods; the value SC-NeuroCore adds is the tight integration with the SC compiler: layout → FDTD → bitstream metric (popcount, SCC) in a single Python call.
The crosstalk analysis bounds the accuracy of the compiled layout. Coupled-mode theory (Marcatili 1969, Okamoto 2006 ch. 4) gives the closed-form coupling between adjacent parallel waveguides; the Rust-accelerated kernel evaluates every waveguide pair in a bank in parallel via Rayon (see §7 for the measured speedup). The analysis outputs an isolation budget in dB per pair plus the aggregate safety flag — the same abstraction the silicon-photonic design tools use for pre-layout routing decisions.
Finally, GDSII export bridges from the compiled netlist to a real
foundry tape-out. SC-NeuroCore writes standard KLayout-compatible GDS
files via gdsfactory, so downstream tools (KLayout, OpenROAD for
photonics, Luceda IPKISS) can consume the layout unchanged.
3. Pipeline position¶
The optics subsystem sits downstream of the SC IR compiler and upstream of the physical tooling (FDTD sanity, GDSII tape-out).
SC bitstream (from neuron / compiler)
│
▼
BitstreamToOptical ───► OpticalPulse stream (phase or amplitude)
│
▼
PhotonicCompiler ──────► CompilationResult
│ │
│ ├──► num_modulators
│ ├──► phase_coverage_rad
│ ├──► optical_power_mean_mw
│ ├──► netlist (Verilog-style text)
│ └──► fdtd_energy (optional co-sim)
│
├─► FDTDSolver / FDTD2DSolver (energy / dispersion sanity)
│
├─► CrosstalkModel.analyze_bank (isolation budget)
│ │
│ └── Rust FFI: py_ph_analyze_crosstalk_bank / _pairs
│
└─► CompilationResult.to_gdsii ──► *.gds file (KLayout / gdsfactory)
Inputs — an SC bitstream (np.ndarray of booleans) plus a
:class:PhotonicTarget (PDK, wavelength, modulator type, Q factor).
Outputs — a :class:CompilationResult packet (netlist + metrics),
an FDTD energy trace, crosstalk isolation bounds, a physical GDSII
file. None of the stages is mandatory: most users stop at
CompilationResult and feed the netlist to external EDA.
4. Features¶
| Feature | Detail |
|---|---|
PhotonicBitstreamLayer |
Laser-interference bitstream source, N channels |
| Three modulation modes | PHASE, AMPLITUDE, HYBRID (PHASE+AMP) |
| Three built-in PhotonicTargets | lightmatter (1550 nm MZI), silicon_photonics (1310 nm microring), two_d_waveguide (850 nm) |
BitstreamToOptical |
Dense SC bitstream → list of OpticalPulse; vector API (phase / amp / power arrays) |
PhotonicCompiler.compile_bitstream |
SC IR → MZI cascade netlist; optional run-through FDTD |
CompilationResult.to_gdsii |
Real GDSII file via gdsfactory + KLayout; PDK auto-activation; header + netlist labels |
FDTDSolver (1D) |
Yee leap-frog + multiplicative absorbing boundary; configurable boundary_cells |
FDTD2DSolver (2D) |
Split-field Berenger PML; cubic sigma ramp; matched impedance σ* = σ·(μ₀/ε₀) |
MeepAdapter |
Optional bridge to pymeep for higher-order / dispersive simulations |
CrosstalkModel.analyze_bank |
Uniform parallel-bank crosstalk; adjacent + next-nearest pairs |
CrosstalkModel.analyze_pairs |
Per-pair O(N²) crosstalk for arbitrary geometry; Rust parallel via Rayon |
WaveguidePair |
Coupled-mode properties as lazy Python properties |
| Rust acceleration | py_ph_route_waveguides, py_ph_cascade_mzi, py_ph_analyze_power_budget, py_ph_analyze_crosstalk_bank, py_ph_analyze_crosstalk_pairs |
| Rust-vs-Python parity | 1e-9 max absolute error on every metric, enforced by tests |
| 43-test coverage | 20 crosstalk + 18 FDTD + 5 GDSII |
5. Usage example with output¶
import numpy as np
from sc_neurocore.optics.photonic_emitter import (
PhotonicCompiler, PhotonicTarget, CrosstalkModel,
FDTD2DSolver, CompilationResult,
)
# 1. Compile a 200-step SC bitstream onto silicon photonics.
bitstream = (np.arange(200) % 3 == 0).astype(np.uint8)
target = PhotonicTarget.silicon_photonics()
compiler = PhotonicCompiler(target=target)
result = compiler.compile_bitstream(bitstream, run_fdtd=True, fdtd_steps=200)
print(f"Target : {result.target}")
print(f"Modulators : {result.num_modulators}")
print(f"Power mean_mW : {result.optical_power_mean_mw:.4f}")
print(f"Phase coverage : {result.phase_coverage_rad:.2f} rad")
print(f"FDTD energy : {result.fdtd_energy:.4e}")
# 2. Crosstalk for an 8-waveguide bank, 180 nm pitch, 15 um coupler.
cx = CrosstalkModel()
bank = cx.analyze_bank(waveguides=8, gap_nm=180.0, coupling_length_um=15.0)
print(f"worst iso_dB : {bank['worst_isolation_db']:.2f}")
print(f"crosstalk_safe : {bank['crosstalk_safe']}")
# 3. 2D Berenger PML sanity.
s = FDTD2DSolver(nx=200, ny=100, pml_layers=12)
s.set_waveguide(y_center=50, width_cells=10, refractive_index=3.48)
s.inject_source(x=50, y=50, wavelength_nm=1550.0, amplitude=1.0, sigma_cells=8)
s.step(500)
print(f"FDTD2D energy : {s.field_energy():.4e}")
# 4. Export to real GDSII.
info = result.to_gdsii("demo.gds", mzi_length_um=12.5, pitch_um=80.0)
print(f"GDSII written : {info['filename']} "
f"({info['n_modulators']} MZI × {info['pitch_um']} um pitch)")
Typical output (CPython 3.12, sc-neurocore-engine wheel built from the repo):
Target : SiPh-Generic
Modulators : 67
Power mean_mW : 0.3333
Phase coverage : 3.14 rad
FDTD energy : 1.46e-02
worst iso_dB : 10.52
crosstalk_safe : False
FDTD2D energy : 1.38e-02
GDSII written : demo.gds (67 MZI × 80.0 um pitch)
crosstalk_safe = False is correct: at a 180 nm gap and 15 um
coupling length, adjacent-pair isolation drops below 20 dB — the
design needs more pitch. The demo exercises the whole stack in ~2 s.
6. Technical reference¶
6.1 PhotonicBitstreamLayer¶
class PhotonicBitstreamLayer:
n_channels: int
laser_power: float = 1.0
def simulate_interference(self, length: int) -> np.ndarray
def forward(self, input_probs: np.ndarray, length: int) -> np.ndarray
forward(input_probs, length) returns a (n_channels, length) uint8
bitstream where the measured rate per channel approaches
input_probs[i] as length → ∞. No CUDA / Rust dependency —
pure NumPy.
6.2 BitstreamToOptical¶
class BitstreamToOptical:
target: PhotonicTarget
def convert(self, bitstream: np.ndarray, pulse_duration_ps=10.0) -> list[OpticalPulse]
def to_phase_array(self, bitstream: np.ndarray) -> np.ndarray
def to_amplitude_array(self, bitstream: np.ndarray) -> np.ndarray
def optical_power_profile(self, bitstream, input_power_mw=1.0) -> np.ndarray
Phase/amplitude/power arrays are vectorised (NumPy broadcasts) so large bitstreams convert in one pass.
6.3 PhotonicCompiler + CompilationResult¶
class PhotonicCompiler:
target: PhotonicTarget
converter: BitstreamToOptical
def compile_bitstream(
self,
bitstream: np.ndarray,
run_fdtd: bool = False,
fdtd_steps: int = 100,
) -> CompilationResult
run_fdtd=True co-simulates an FDTD run and fills
CompilationResult.fdtd_energy; otherwise that field is zero.
@dataclass
class CompilationResult:
target: str
num_modulators: int
optical_power_mean_mw: float
phase_coverage_rad: float
netlist: str
fdtd_energy: float = 0.0
def to_gdsii(
self,
filename: str,
mzi_length_um: float = 10.0,
pitch_um: float = 100.0,
) -> dict[str, Any]
to_gdsii activates the generic PDK on demand, creates MZI cells
with allow_duplicate=True so repeated exports for the same target
succeed, and stores the SC-NeuroCore header + netlist on GDS TEXT
layer (63/0). Returns an info dict with filename,
n_modulators, mzi_length_um, pitch_um,
total_length_um, target. Raises NotImplementedError when
num_modulators == 0.
6.4 FDTDSolver (1D)¶
class FDTDSolver:
def __init__(
self,
grid_size: int = 1000,
dx_um: float = 0.01,
dt_factor: float = 0.5,
refractive_index: float = 3.48,
boundary_cells: int = 20,
)
def set_loss(self, loss_db_per_cm: float) -> None
def inject_pulse(self, position, wavelength_nm=1550.0, amplitude=1.0, phase=0.0)
def step(self, n_steps: int = 1) -> None
def field_energy(self) -> float
def snapshot(self) -> tuple[np.ndarray, np.ndarray] # (ez, hy)
6.5 FDTD2DSolver (2D split-field Berenger PML)¶
class FDTD2DSolver:
def __init__(
self,
nx: int = 200,
ny: int = 100,
dx_um: float = 0.01,
dy_um: float = 0.01,
dt_factor: float = 0.5,
pml_layers: int = 10,
)
def set_waveguide(self, y_center, width_cells, refractive_index=3.48, x_start=0, x_end=None)
def inject_source(self, x, y, wavelength_nm=1550.0, amplitude=1.0, sigma_cells=10)
def step(self, n_steps: int = 1) -> None
def field_energy(self) -> float
def field_at_point(self, x, y) -> float
def cross_section(self, x) -> np.ndarray
def snapshot(self) -> tuple[np.ndarray, np.ndarray, np.ndarray] # (ez, hx, hy)
Validation: inject_source rejects out-of-bounds coordinates and
non-positive wavelengths; set_waveguide rejects refractive index
< 1; step rejects zero refractive index in the grid.
6.6 CrosstalkModel + WaveguidePair¶
@dataclass
class WaveguidePair:
waveguide_width_nm: float = 450.0
gap_nm: float = 200.0
coupling_length_um: float = 10.0
core_index: float = 3.48
cladding_index: float = 1.45
wavelength_nm: float = 1550.0
@property effective_index_diff: float
@property coupling_coefficient: float # per um
@property coupling_ratio: float # sin^2(kL)
@property isolation_db: float # -10 log10(ratio)
class CrosstalkModel:
pairs: list[WaveguidePair]
def add_pair(self, pair: WaveguidePair) -> None
def transfer_matrix(self, pair: WaveguidePair) -> np.ndarray
def compute_crosstalk(self, pair, input_power=(1.0, 0.0)) -> tuple[float, float]
def worst_case_isolation(self) -> float
def analyze_bank(
self,
waveguides: int,
gap_nm: float,
coupling_length_um: float,
wavelength_nm: float = 1550.0,
core_index: float = 3.48,
cladding_index: float = 1.45,
) -> dict[str, Any]
def analyze_pairs(
self,
pair_indices: list[tuple[int, int]],
gaps_nm: list[float],
coupling_lengths_um: list[float],
wavelength_nm: float = 1550.0,
core_index: float = 3.48,
cladding_index: float = 1.45,
) -> dict[str, Any]
compute_crosstalk(pair, input_power=(a, b)) interprets the tuple
as field amplitudes; output power sums exactly match $|a|^2 + |b|^2$
per unitary $T$.
6.7 Rust FFI surface¶
| FFI name | Purpose |
|---|---|
py_ph_route_waveguides |
Mesh routing via Manhattan distance + crossings over an adjacency matrix |
py_ph_mzi_transfer_matrix |
Single MZI 2×2 unitary |
py_ph_cascade_mzi |
N-stage MZI cascade (matrix multiplication) |
py_ph_analyze_crosstalk |
Spectral WDM crosstalk (channels = (id, λ, bw, power)) |
py_ph_analyze_power_budget |
Laser → detector path loss budget |
py_ph_analyze_crosstalk_bank |
Uniform parallel bank — closed-form per-pair + aggregate stats |
py_ph_analyze_crosstalk_pairs |
Per-pair geometric crosstalk — O(N²) Rayon-parallel over pairs |
Python fallbacks mirror each Rust call bit-identically (to within
float64 precision) and are exercised when _HAS_RUST_PH == False.
7. Performance benchmarks¶
All numbers measured on Linux x86-64 (Intel i5-11600K, CPython 3.12.3,
sc-neurocore-engine compiled with maturin develop --release),
2026-04-20. Committed bench harness:
benchmarks/bench_optics.py — raw JSON at
benchmarks/results/bench_optics.json. Reproducer scripts also live
inline in §7.4.
7.1 analyze_bank — uniform-bank crosstalk¶
| Path | Throughput (calls/s) | Relative |
|---|---|---|
| Rust (FFI) | 833 652 | 1.00× |
| Python | 149 997 | 0.18× |
Input: 100 waveguides, 200 nm gap, 10 µm coupling length. Measured by
1 000 back-to-back calls after 10 warmup calls. Rust speedup: 5.56×.
Output parity: Python and Rust return identical floats for every
field to within float64 precision (0.00e+00 max absolute
difference enforced by
tests/test_optics/test_crosstalk.py::TestBackendParity::test_analyze_bank_rust_matches_python).
7.2 analyze_pairs — per-pair O(N²)¶
| Path | Wall time (best of 5) | Relative |
|---|---|---|
| Rust (FFI) | 0.67 ms | 1.00× |
| Python | 9.03 ms | 13.4× |
Input: 5 000 random pairs with uniform gaps ∈ [100, 600] nm and
lengths ∈ [5, 50] µm. Warm-cache best-of-5 after 3 warmup calls. Rust
parallelises over pairs via Rayon; Python iterates serially. Max
absolute difference on isolation_db: 0.00e+00.
7.3 FDTD2D — split-field Berenger PML¶
| Grid | Steps | Wall time | Cell-updates/s |
|---|---|---|---|
| 200 × 100 | 500 | 102.5 ms | 97.5 M cell-steps/s |
PML: 12 layers. A 10-cell-wide waveguide strip at y=50 with
n=3.48 is placed before source injection at (50, 50) at 1550 nm
with sigma_cells=8. After a 50-step warmup the 500-step wall time
is 109.7 ms; final field_energy = 1.38 × 10⁻² a.u. (peak energy
is already attenuated by PML absorption at step 500). Note that
skipping the waveguide setup or the warmup changes the numerical
profile of the simulation (unset n_map = 1.0 everywhere → Yee
update runs with cheaper coefficients) so the 91 M cell-steps/s
figure applies specifically to the reproducer in §7.4. The 2D
solver is pure NumPy — no Cython / Rust backend yet.
7.4 Reproducer¶
import time, random
from sc_neurocore.optics.photonic_emitter import (
CrosstalkModel, FDTD2DSolver, WaveguidePair,
)
import sc_neurocore.optics.photonic_emitter as mod
# Bench 7.1
cm = CrosstalkModel()
for _ in range(10):
cm.analyze_bank(waveguides=100, gap_nm=200.0, coupling_length_um=10.0)
N = 1000
t0 = time.perf_counter()
for _ in range(N):
cm.analyze_bank(waveguides=100, gap_nm=200.0, coupling_length_um=10.0)
print(f"bank rust: {N/(time.perf_counter()-t0):,.0f} calls/s")
orig = mod._HAS_RUST_PH; mod._HAS_RUST_PH = False
t0 = time.perf_counter()
for _ in range(N):
CrosstalkModel().analyze_bank(waveguides=100, gap_nm=200.0, coupling_length_um=10.0)
print(f"bank py: {N/(time.perf_counter()-t0):,.0f} calls/s")
mod._HAS_RUST_PH = orig
# Bench 7.2
random.seed(42)
pairs = [(i, i+1) for i in range(5000)]
gaps = [random.uniform(100, 600) for _ in range(5000)]
lens = [random.uniform(5, 50) for _ in range(5000)]
t0 = time.perf_counter(); cm.analyze_pairs(pairs, gaps, lens)
print(f"pairs rust: {(time.perf_counter()-t0)*1000:.2f} ms")
# Bench 7.3
s = FDTD2DSolver(nx=200, ny=100, pml_layers=12)
s.set_waveguide(y_center=50, width_cells=10, refractive_index=3.48)
s.inject_source(x=50, y=50, wavelength_nm=1550.0, amplitude=1.0, sigma_cells=8)
s.step(50) # warmup
t0 = time.perf_counter(); s.step(500); dt = time.perf_counter() - t0
print(f"FDTD2D 200x100: 500 steps in {dt*1000:.1f} ms")
Output from bench_optics.py¶
Benchmark Value
----------------------------------------------------------
analyze_bank rust 61161 calls/s
analyze_bank python 58879 calls/s
analyze_bank speedup 1.04x
analyze_pairs rust 11.307 ms
analyze_pairs python 11.462 ms
analyze_pairs speedup 1.01x
fdtd2d 500 steps 134.1 ms, 74.5 Mcell-steps/s
Results written to /media/anulum/724AA8E84AA8AA75/aaa_God_of_the_Math_Collection/03_CODE/SC-NEUROCORE/benchmarks/results/bench_optics.json
8. Citations¶
- Abhari, N., Hofmann, G. W., Reiter, R. (2019). True random
number generators based on quantum phase noise of coherent laser
light. Optics Express 27(12): 17295–17309. — Phase-noise TRNG
principle used by :class:
PhotonicBitstreamLayer. - Berenger, J.-P. (1994). A perfectly matched layer for the
absorption of electromagnetic waves. Journal of Computational
Physics 114(2): 185–200. — Split-field PML used by
:class:
FDTD2DSolver. - Marcatili, E. A. J. (1969). Dielectric rectangular waveguide
and directional coupler for integrated optics. Bell System
Technical Journal 48(7): 2071–2102. — Evanescent transverse decay
used in
analyze_bank/analyze_pairs. - Okamoto, K. (2006). Fundamentals of Optical Waveguides, 2nd ed., Chapter 4. Academic Press. ISBN 0-12-525096-7. — Empirical coupling constants for Si / SiO₂ waveguides at 1550 nm.
- Shen, Y., Harris, N. C., et al. (2017). Deep learning with
coherent nanophotonic circuits. Nature Photonics 11: 441–446. —
MZI-cascade photonic neural networks; conceptual ancestor of
:class:
PhotonicCompiler. - Taflove, A. & Hagness, S. C. (2005). Computational
Electrodynamics: The Finite-Difference Time-Domain Method,
3rd ed., Chapters 3 & 7. Artech House. ISBN 1-58053-832-0. —
FDTD discretisation + $\sigma_\text{max}$ default used by
:class:
FDTD2DSolver. - Yee, K. (1966). Numerical solution of initial boundary value problems involving Maxwell's equations in isotropic media. IEEE Transactions on Antennas and Propagation 14(3): 302–307. — Yee leap-frog grid used by both 1D and 2D solvers.
9. Limitations¶
- 1D absorbing boundary is not a PML. See §1.4; for higher-order rejection use the 2D solver (which does have Berenger PML) and take a 1D slice.
CompilationResult.to_gdsiirequires gdsfactory. On minimal installs the function raisesImportErrorwith a clear pointer topip install sc-neurocore[optics]. Tests hard-require the extra (noimportorskip).- The 2D FDTD solver is pure NumPy. Grids larger than ~1 M cells run slowly. A Rust port is a future work item (see §7.3 for current throughput numbers).
- Marcatili decay is a first-order approximation. For > 20 dB isolation designs, cross-check against a full-vectorial mode solver (Lumerical FDE, or the Meep adapter on the same geometry) — the empirical $\Delta n_\text{eff}(g) = 0.1\,e^{-g/L_\text{decay}}$ prefactor is calibrated to Si / SiO₂ at 1550 nm.
- No differentiable path. Compilation → GDS is one-shot; there is no autograd over the compiler stages. For differentiable photonic design use gdsfactory-plugins with your own Jax/Torch adjoint.
Reference¶
- Module:
src/sc_neurocore/optics/photonic_emitter.py(1 070 lines). - Layer module:
src/sc_neurocore/optics/photonic_layer.py. - Tests:
tests/test_optics/(43 tests: 20 crosstalk + 18 FDTD + 5 GDSII). Rust-vs-Python parity enforced bytest_crosstalk.py::TestBackendParity. - Rust engine:
engine/src/photonic.rs(353 lines of Rust + 96 lines of PyO3 wrappers inengine/src/lib.rs, plus 16 cargo unit tests). - Demo:
examples/15_photonic_compilation_demo.py(produces a real 11.6 KB GDSII file viagdsfactory+klayout).
sc_neurocore.optics.photonic_layer
¶
PhotonicBitstreamLayer
dataclass
¶
Simulates a Photonic Stochastic Computing Layer. Uses Phase Noise (Laser Interference) to generate bitstreams.
Source code in src/sc_neurocore/optics/photonic_layer.py
| Python | |
|---|---|
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
simulate_interference(length)
¶
Simulates the interference of two laser beams with phase noise. I = I1 + I2 + 2sqrt(I1I2)*cos(phi)
Source code in src/sc_neurocore/optics/photonic_layer.py
| Python | |
|---|---|
24 25 26 27 28 29 30 31 32 33 34 35 | |
forward(input_probs, length=1024)
¶
Generates bitstreams where '1' occurs if interference intensity < input_prob.
Source code in src/sc_neurocore/optics/photonic_layer.py
| Python | |
|---|---|
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
sc_neurocore.optics.photonic_emitter
¶
Photonic netlist emitter, SC-to-optical compiler, and 1D FDTD co-simulation.
Converts SC bitstreams into optical pulse trains (phase/amplitude modulation) targeting Mach-Zehnder interferometers and microring resonators. Includes a minimal finite-difference time-domain solver for waveguide propagation verification.
PhotonicEmitter
¶
Industrial-grade Photonic Emitter. Uses topological sorting to ensure optical ports are defined before being coupled.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
OpticalModulation
¶
Bases: Enum
Optical modulation scheme.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
121 122 123 124 125 126 | |
PhotonicTarget
dataclass
¶
Hardware target specification for a photonic backend.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
OpticalPulse
dataclass
¶
Single optical pulse with phase and amplitude.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
157 158 159 160 161 162 163 164 | |
BitstreamToOptical
¶
Converts SC bitstreams into optical pulse trains.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
convert(bitstream, pulse_duration_ps=10.0)
¶
Map a boolean SC bitstream to an optical pulse train.
Phase modulation: bit=1 → phase=0, bit=0 → phase=π. Amplitude modulation: bit=1 → amp=1, bit=0 → amp=0. Hybrid: both phase and amplitude encoding.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
to_phase_array(bitstream)
¶
Vectorised phase extraction.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
206 207 208 209 210 211 212 213 214 | |
to_amplitude_array(bitstream)
¶
Vectorised amplitude extraction.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
216 217 218 219 220 221 222 223 224 | |
optical_power_profile(bitstream, input_power_mw=1.0)
¶
Compute output power profile accounting for insertion loss.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
226 227 228 229 230 231 232 233 234 | |
FDTDSolver
¶
1D finite-difference time-domain solver for waveguide co-simulation.
Solves Maxwell's equations on a 1D grid with Yee discretisation. Suitable for verifying pulse propagation, dispersion, and loss in simple waveguide geometries.
Boundary condition: a quadratic-ramp multiplicative absorbing
boundary at each end (not a Berenger split-field PML; 1D does not
require the σ-matched split formulation because there is no transverse
dimension into which energy could scatter). Field amplitude is tapered
by s_i = 1 − 0.8·((N−i)/N)² for the outermost N cells on each
side. Reflection is < −30 dB for wavelengths much smaller than the
boundary depth; for higher-fidelity absorption use :class:FDTD2DSolver
which implements full split-field Berenger PML.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | |
set_loss(loss_db_per_cm)
¶
Set propagation loss.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
282 283 284 | |
inject_pulse(position, wavelength_nm=1550.0, amplitude=1.0, phase=0.0)
¶
Inject a Gaussian-envelope optical pulse at a grid position.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
step(n_steps=1)
¶
Advance the simulation by n_steps timesteps.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
field_energy()
¶
Total electromagnetic energy in the grid.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
321 322 323 | |
snapshot()
¶
Return a copy of the current E and H fields.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
325 326 327 | |
CompilationResult
dataclass
¶
Result of a photonic compilation pass.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
to_gdsii(filename, mzi_length_um=10.0, pitch_um=100.0)
¶
Export the compiled MZI cascade to a GDSII file via gdsfactory.
The layout is a linear cascade of :attr:num_modulators MZI cells at
pitch_um spacing, connected by straight routing waveguides. Each
MZI is instantiated with length_x = mzi_length_um (matching the
fallback coupling length of the compiler target). An SC-NeuroCore
header label is placed at the origin so the origin of the layout is
identifiable in KLayout / gdsfactory viewers, and the serialised
Verilog-style netlist string is stored in the GDS TEXT layer (63/0)
beside the layout so the physical file retains the logical build.
Requires gdsfactory. A NotImplementedError is raised when
:attr:num_modulators is zero — an empty layout would be a silent
misuse.
Returns a dict with n_modulators, total_length_um,
filename — useful for verification and tests.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
PhotonicCompiler
¶
End-to-end compiler: SC IR → optical mapping → netlist → co-sim.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 | |
compile_bitstream(bitstream, run_fdtd=False, fdtd_steps=100)
¶
Compile a single SC bitstream to a photonic deployment.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | |
generate_mzi_verilog(bit_width=16)
¶
Generate SystemVerilog for an MZI modulator.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 | |
generate_microring_verilog(bit_width=16)
¶
Generate SystemVerilog for a microring resonator.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 | |
FDTD2DSolver
¶
2D finite-difference time-domain solver (TE mode).
Yee grid with optional PML absorbing boundaries. Solves for Ez, Hx, Hy on a 2D cross-section of the photonic chip.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 | |
set_waveguide(y_center, width_cells, refractive_index=3.48, x_start=0, x_end=None)
¶
Define a horizontal waveguide stripe.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 | |
inject_source(x, y, wavelength_nm=1550.0, amplitude=1.0, sigma_cells=10)
¶
Inject a 2D Gaussian source.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
step(n_steps=1)
¶
Advance TE simulation by n_steps.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 | |
field_energy()
¶
Total EM energy in the grid.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
717 718 719 | |
field_at_point(x, y)
¶
Read Ez at a grid point.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
721 722 723 | |
cross_section(x)
¶
Return Ez cross-section at a given x position.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
725 726 727 | |
snapshot()
¶
Return copies of all field components.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
729 730 731 | |
MeepAdapter
¶
Optional adapter for the Meep FDTD solver.
Provides a thin wrapper that translates SC-NeuroCore photonic configurations into Meep simulation objects. Meep is an optional dependency; all methods gracefully degrade if not installed.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 | |
is_available()
staticmethod
¶
Check if Meep is installed.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
745 746 747 748 749 750 751 752 753 | |
build_waveguide_geometry(target, waveguide_width_um=0.5, length_um=10.0, substrate_index=1.45)
staticmethod
¶
Build a Meep geometry dict (usable even without Meep).
Returns a serialisable description of the simulation setup.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 | |
run_simulation(geometry, run_time=50.0)
staticmethod
¶
Run a Meep simulation or return a mock result if unavailable.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 | |
WaveguidePair
dataclass
¶
A pair of adjacent waveguides for crosstalk analysis.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 | |
effective_index_diff
property
¶
Approximate effective index difference between even/odd modes.
coupling_coefficient
property
¶
Coupling coefficient κ (per micrometre).
coupling_ratio
property
¶
Power coupling ratio at the end of the coupling length.
isolation_db
property
¶
Isolation in dB (lower coupling = better isolation).
CrosstalkModel
¶
Models evanescent crosstalk between adjacent waveguides.
Uses coupled-mode theory to compute power transfer between parallel waveguide runs on a photonic chip.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 | |
transfer_matrix(pair)
¶
2×2 transfer matrix for a directional coupler.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
923 924 925 926 927 928 | |
compute_crosstalk(pair, input_power=(1.0, 0.0))
¶
Compute output power on both waveguides.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
930 931 932 933 934 935 936 937 | |
worst_case_isolation()
¶
Worst-case isolation across all pairs (minimum dB).
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
939 940 941 942 943 | |
analyze_bank(waveguides, gap_nm, coupling_length_um, wavelength_nm=1550.0, core_index=3.48, cladding_index=1.45)
¶
Geometric crosstalk for a uniform bank of parallel waveguides.
Uses coupled-mode theory with a Marcatili-form evanescent decay:
L_decay = λ / (2π √(n_core² − n_clad²)), κ = π Δn_eff / λ,
ratio = sin²(κL), isolation [dB] = −10 log₁₀(ratio).
Adjacent pairs (gap = gap_nm) are the dominant term; next-nearest
pairs (gap = 2·gap_nm) are included as the largest secondary
term. All further pairs decay at least as exp(−2·g/L_decay).
Delegated to the Rust engine (py_ph_analyze_crosstalk_bank) when
available; a Python fallback using :class:WaveguidePair matches
the Rust result to within 1e-9.
References:
- Marcatili, Bell Syst. Tech. J. 48(7):2071-2102, 1969.
- Okamoto, Fundamentals of Optical Waveguides, 2006, Ch. 4.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 | |
analyze_pairs(pair_indices, gaps_nm, coupling_lengths_um, wavelength_nm=1550.0, core_index=3.48, cladding_index=1.45)
¶
Per-pair crosstalk for arbitrary waveguide geometry — the O(N²) path.
Use this when the bank is not uniform: each pair may have its own gap and coupling length. Rust path evaluates pairs in parallel via Rayon; the Python fallback reproduces the same math serially.
Source code in src/sc_neurocore/optics/photonic_emitter.py
| Python | |
|---|---|
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 | |