A Hanbury Brown–Twiss (HBT) interferometer splits a photon stream on a 50/50 beamsplitter and time-correlates the clicks on the two output detectors A and B. The result is the normalized second-order correlation function:
g²(τ) = ⟨n̂A(t) n̂B(t+τ)⟩ / (⟨n̂A⟩⟨n̂B⟩)
A single photon cannot be detected at both outputs at once, so a perfect single-photon source gives g²(0) = 0 — a dip at zero delay ("antibunching"), while an uncorrelated / classical source gives g²(τ) ≈ 1 everywhere. Real quantum-dot sources have g²(0) > 0 because of two effects modeled here each trigger pulse:
- Multi-photon probability — re-excitation of the dot during one pulse occasionally emits two photons instead of one; if they split to different arms they register as a fake same-pulse coincidence.
- Dark counts — uncorrelated detector background clicks that occasionally land on both arms in the same pulse window by chance.
Single-photon purity is reported as P = 1 − g²(0). Because dark counts are spread uniformly in time while genuine photon arrivals are sharply peaked around the expected delay, gating detection to a narrow window around that peak — heralding — rejects far more background than signal. This simulator's "Narrow"/"Tight" gates cut the effective dark-count rate by ×0.4 / ×0.12 at the cost of ×0.92 / ×0.78 collection efficiency (a photon can jitter outside a tight gate and be missed) — exactly the efficiency-vs-purity trade-off used to characterize real quantum-dot single-photon sources.
Each simulated trigger pulse independently: (1) decides 1 vs 2 emitted photons, (2) routes each photon 50/50 to arm A or B, applying the gate's efficiency loss, (3) adds an independent dark-count chance to each detector at the gate's reduced rate. Running sums of ⟨n̂A n̂B⟩ at zero delay and at ±1…±4 pulse-period lags build the live coincidence histogram and g²(0) estimate — the same estimator used on real time-tagged HBT data.