# The physical and numerical model ## What is simulated A folded-boxcar transient-grating FROG. One input beam (the HE11 mode of a hollow capillary, collimated and refocused) passes a mask with holes at three corners of a square; the three beamlets cross in a thin fused-silica slab at the focus. Their interference writes a transient grating; degenerate four-wave mixing $k_\mathrm{sig} = k_{g2} - k_{g1} + k_t$ diffracts light into the fourth corner. Scanning the delay $\tau$ of the test beamlet and spectrally resolving the diffracted light through a collection aperture yields the measured trace $I(\omega, \tau)$. The self-diffraction layout (`Config.geometry = "sd"`, {mod}`pnps.geometry`) is the same propagation with a different input: two holes on one axis, the probe $E$ and the delayed gate $G$, and the signal $k_\mathrm{sig} = 2k_E - k_G$ one slot further out on the probe's side. Nothing about the measurement is imposed: the grating, the phase-matched signal, the geometric delay smearing and the chromatic response of every aperture emerge from the propagation. ## State and conventions The propagation state is the complex analytic envelope in the mixed spectral domain, `E[ky, kx, omega]` (omega last), the unnormalised 3-D FFT of $E(y, x, t)$ in V/m. Conventions: - **FFT sign convention** (NumPy = FFTW): every physical phase carries a minus sign in code — the linear phase is `exp(-1j beta z)`, a spectral phase $\phi(\omega)$ is applied as `exp(-1j phi)`. - `omega` is the *absolute* angular frequency, FFT-ordered (element 0 is the carrier $\omega_0$); `kx`, `ky` are `2*pi*fftfreq` axes. The TG signal quadrant ($k_x < 0$, $k_y < 0$) is the second half of each transverse index range; the self-diffraction signal region is the half-plane beyond the bisector with the probe ({func}`pnps.geometry.signal_region`). - The time axis is centred: index $n$ holds $t = (n - N/2)\,\delta t$, and the pulse peaks at $t = 0$. - **Delay convention "gate"**: the test arm is multiplied by $e^{+i\omega\tau}$ (advanced by $\tau$), equivalent to delaying the gate pair. Files record this; readers must not reverse the delay axis. - A stored spectrum is therefore the DFT of a *centred* field array, which carries an exact $(-1)^k$ ramp — very nearly $\pi$ per bin — relative to the centred-time transform $\sum_n E(t_n)e^{-i\omega t_n}$. Anything that unwraps or interpolates a stored phase must remove that ramp first ({func}`pnps.pulse.fit_spectral_chirp` and {func}`pnps.input_pulse.injected_spectrum` do). The same convention is what an injected source file is read in, and the Croak retrieval package reads these fields as `conj((-1)^n * stored)`: the ramp removed, and conjugated into its own $e^{+i\omega t}$ convention. ## The measure of energy A spectrometer records the energy per unit frequency crossing its aperture: the time-integrated Poynting flux. A plane-wave component $(k_\perp, \omega)$ of the state carries the axial flux $$ S_z = \frac{\varepsilon_0 c}{2}\,\eta\,|E|^2, \qquad \eta = \frac{c\,\mathrm{Re}\,k_z}{\omega}, $$ with $\eta = n\cos\theta$ the medium's axial admittance in a lossless medium, and zero on a column that does not propagate. This is solprop's measure (its design proposal SEP 34, listed among {doc}`solprop's proposals `) and the only one this package uses ({mod}`pnps.flux`). It fixes both ends of a run: - **The launch.** `Config.energy` is the energy of the beam in air before the mask, where $\eta_\mathrm{air} = \cos\theta_\mathrm{air}$. Each component then crosses into the slab keeping its flux, so its field is multiplied by $\sqrt{\eta_\mathrm{air}/\eta}$, about $1/\sqrt{n}$. The entrance face is ideal: no Fresnel reflection is modelled at either face. - **The observables.** The windowed, on-axis and full spectra, the energy, the absorbed powers and the recorded beamlet spectra weight $|E|^2$ by $\eta$. The on-axis spectrum pairs the coherent on-axis amplitude with its magnetic closure, $\mathrm{Re}(A\,G^*)$, where $G$ weights each element by $\eta^*$. Because $k_\perp$ is conserved across a planar face, the flux in the slab is the flux the spectrometer receives in air. The vacuum field norm $\tfrac{\varepsilon_0 c}{2}|E|^2$ would under-count the energy in silica by $n\cos\theta$: at a given pulse energy the field, and with it the Kerr phase, would be about $n \approx 1.5$ times too strong, the signal's absolute energy about $n^2$ too high, and the measured spectrum tilted by $n(\omega)$ (about 5 % across 200–330 nm). Every scan file records its measure (`/grid/measure`, `flux`). ## The propagation equation The 3-D free-space envelope UPPE with instantaneous Kerr nonlinearity: $$ \partial_z E = L E \;-\; \frac{i \omega \mu_0}{2\,\mathrm{Re}\,k_z}\, \widetilde{P}_{NL}, \qquad P_{NL} = \tfrac{3}{4}\varepsilon_0 \chi^{(3)} |E_t|^2 E_t $$ with $k_z = \sqrt{k(\omega)^2 - k_\perp^2}$ (principal complex root), $k(\omega) = n(\omega)\,\omega/c$ on the physical band (zero outside), and the linear operator $$ L = -i\left(\mathrm{Re}\,k_z - \beta_1\omega - \beta_0^{ref}\right) - |\mathrm{Im}\,k_z| - \gamma_\omega(\omega). $$ $\beta_1$ is the group slowness at the carrier (co-moving frame) and $\beta_0^{ref}$ the carrier propagation constant (slowly varying envelope phase). $|\mathrm{Im}\,k_z|$ is the decay of evanescent components (and, with `Config.absorption`, of the material loss), and $\gamma_\omega$ a smooth spectral absorbing ramp — see below. ### The silica model $n(\omega)$ is the real part of the fused-silica fit of [optmat](https://github.com/LupoLab/optmat): by default the slab is lossless. The fit carries silica's absorption edge too — $\kappa$ rises from below $10^{-10}$ at 260 nm to $6\times10^{-3}$ at 143 nm — and `Config.absorption=True` keeps it, as the imaginary part of the index; dropping it leaves the real part unchanged. $\chi^{(3)} = \tfrac{4}{3} n_2 \varepsilon_0 c n_0^2$ with $n_0$ the index at the carrier and $n_2$ the total Kerr index of optmat's silica nonlinear bundle at the carrier ({func}`pnps.materials.silica_n2`): $3.9\times10^{-20}\,$m²/W at 260 nm. optmat's Kerr fit is validated from 350 nm to 3500 nm, so at a deep-ultraviolet carrier this is the fit's extrapolation, rising towards the band gap as measured values do; it is a decided choice (`docs/dev/decisions.md`), and every scan file records it (`/grid/n2`, `/grid/n2_extrapolated`). Since the four-wave-mixing signal power scales as $n_2^2$, traces are about twice as strong as with a near-infrared value, $2.7\times10^{-20}\,$m²/W. With `Config.raman=True` (off by default) the response is split as in the generalised nonlinear Schrödinger equation: the instantaneous Kerr term keeps $(1-f_R)$ of $\chi^{(3)}$ and the delayed term carries $f_R = 0.2188$, the share the bundle pairs with its Kerr fit, convolved with Hollenbeck and Cantrell's shape $h_R$ of unit integral: $$ P = \tfrac34\varepsilon_0\chi^{(3)}\left[(1-f_R)\,|A|^2 + f_R\,(h_R * |A|^2)\right]A . $$ solprop's envelope Raman polarisation is written $\tfrac12\varepsilon_0 (h * |A|^2)A$, so its kernel integrates to $\tfrac32\chi^{(3)}$ for the same physics. A transverse-wavevector safety ramp $\gamma_k(k_\perp)$ damps the outer tenth of the momentum grid (`Config.transverse_absorber`, solprop's safety ramp): with $\rho = \max(|k_x|/k_{x,\max}, |k_y|/k_{y,\max})$ its power rate is $S P(\rho)$, $P$ a raised cosine from zero at $\rho = 0.9$ to one at the grid's edge, and it enters $L$ as the amplitude rate $\gamma_k = S P / 2$. $S$ is solprop's design, not a setting ({func}`pnps.absorber.transverse_strength`): about 10.5 nepers over the grid's half-width for content in the ramp's upper half, 9.9e3 /m on the production grid. Over a slab tens of micrometres thick that is a fraction of a neper, so the ramp is close to inert here. On this instrument's production grid, whose sizing rule keeps the momentum span 1.5 times clear of the mixing products, nothing reaches it (a ramp of up to 5e6 /m changed every observable by at most 1.3e-14 of peak, {doc}`dev/numerics`). It cannot remove an alias that in-band content generates: that is the grid's job. `absorb_k` reports the power it removes, and `alias_fraction` whether the field has reached where its cubic products fold back into band ({doc}`accuracy`). ## Design decisions **All dissipation lives inside $L$.** Multiplicative spectral or temporal windows applied *inside the step loop* would make the scheme non-convergent in the step size: the result would depend on how often the windows fire. Here the integrator solves one fixed ODE: the spectral absorber is folded into solprop's exactly-applied linear operator, and results converge cleanly in $h$. solprop caps evanescent decay at 200/m, but on this instrument no active $(\omega, k_\perp)$ pair is evanescent on the production grid, and on its 2x refinement the few that are lie far outside the band inside the absorber's full-strength region, so the cap cannot act ({doc}`dev/numerics`, "Evanescent census"). **No temporal window at all — a lap budget instead.** On a periodic time window, walked-off light is represented *exactly* and harmlessly: the Kerr response is local in time, and the observables are per-frequency reductions. The only true failure is light that wraps a full period and lands back on the pulse. Therefore only frequencies whose group-delay walk-off over the slab exceeds the lap budget (window length minus twice the protected `time_headroom` around $t=0$) are absorbed by $\gamma_\omega$. In silica this bites only the extreme-DUV band edge, where the group index rises steeply (at 260 nm carrier over 40 µm: 143 nm light trails by ~216 fs): a window much shorter than that, trimmed in the loop, would chop real spectral content the spectrometer records. A window of `3 time_headroom` plus the band's largest walk-off absorbs nothing the spectrometer would see ({func}`pnps.absorber.required_trange`, about 380 fs at 40 µm), and a shorter one is announced when the configuration is built, with the band it leaves untouched ({func}`pnps.absorber.lap_free_band`). The production run file keeps 250 fs, which leaves 143–160 nm to the absorber at the ends of the delay scan. What the lap budget removes is accounted for, per frequency bin and per delay (`lap_lost`, {func}`pnps.absorber.lap_loss_share`). Between two save planes each bin's spectrum obeys $dS/dz = G - \alpha S$, with $\alpha = 2\gamma_\omega$ and $G$ whatever else feeds or drains it; taking $G$ constant over the interval, the planes fix it and the absorber removed $G\,\Delta z - (S_1 - S_0)$. That is exact for a bin that only decays and for one fed at a steady rate, and it is what the absorber needs: light in an absorbed bin lives a fraction of a micrometre, so a trapezoid of $\alpha S$ over the planes would overcount it by about $\alpha\Delta z/2$ (by a factor 1.5–2 on the tiny test configuration). On that configuration a linear run's loss is the bins' decay to 1e-9, six and eleven planes agree to 3.4e-4, and the kept and lost energy together match what a window four times as long keeps, over the same frequency cells, to 3e-4 of the two grids' own sampling difference. **Which delays the window holds.** A delay point has only two pulse positions on the periodic window of length $T$: the delay-free arms and the delayed one, $|\tau|$ apart. Light leaving one at time $t_s$ (relative to it) reaches time $t_t$ of the other through the wrap once it has walked $x = T - |\tau| - |t_t - t_s|$, the shorter of the two ways round; on an infinite line it would never meet that pulse. A bin of walk-off $w$ over the slab of thickness $L$ (with $w \ge x$, or it never walks so far) must cross $xL/w$ of slab to do so, losing $\gamma_\omega xL/w$ amplitude e-folds to the whole spectral absorber. The least over those bins, {func}`pnps.absorber.wrap_attenuation` $A(x)$, is what any light that has walked $x$, input or generated, has lost at least. Where it lands it drives a Kerr polarization of at most its field times the intensity there, so $$ C(\tau) = \max_{t_s,\,t_t} \sqrt{P(t_s)}\,P(t_t)\,e^{-A(x)} $$ ({func}`pnps.absorber.wrap_coupling`), with $P$ the input's temporal power over its peak, bounds the nonlinear polarization that wrapped light can drive, in units of the input's peak. A pulse's wings count in proportion to their field and intensity, so a chirp or an injected field enters as it is, with no support to choose. The bound uses no property of a layout or a window: it holds for the self-diffraction layout, and for large collection windows that gather light other than the signal. A delay is admitted when $|\tau| \le 0.75\,$`time_headroom` (the rule the absorber is laid out by: the pulses stay inside the protected region, and wrapped light reaches them only where the lap budget is at full strength) or when $C(\tau) \le 10^{-5}$ ({data}`pnps.absorber.WRAP_COUPLING_LIMIT`). Light radiated by that polarization is at most $10^{-5}$ of the signal's peak amplitude, so its interference moves a trace by at most $2\times10^{-5}$ of the trace's peak, inside the $3\times10^{-5}$ the production step and windows are chosen for ({doc}`accuracy`). The check changes neither the absorber nor the input, so a delay that both rules admit gives the same result as before the bound was added. A scan checks all its delays before its first point. On the production window (`trange` 250 fs, 600 points, 260.18 fs; `time_headroom` 55 fs; 40 µm), the bound admits the 1 fs pulse to $|\tau| \le 96$ fs (2.6e-7 at 80 fs), the same pulse with a group-delay dispersion of ±2 fs² to 81.75 fs (5.5e-6 at 80 fs) and with a third-order dispersion of 2 fs³ to 62 fs. That chirp leaves a wing of extreme-UV light up to 35 fs behind the pulse, which walks late and reaches the other pulse after about 150 fs, where the lap budget only begins; a `time_headroom` of 65 fs admits it to 81.5 fs (5.6e-6 at 80 fs), leaving 153.8–600 nm untouched by the lap budget instead of 151.2–600 nm. The longest admitted delay grows by about 2 fs for each femtosecond of headroom, because the walk-off at which the lap budget starts, $T - 2\,$`time_headroom`, moves while the wrap stays where the delay puts it; a longer `trange` alone moves both and does not help. $P$ is that of the 1-D input spectrum every arm carries. The chromatic holes are not part of it. Their sharp spectral edges, per transverse sample, give the formed input a pedestal of about 1e-6 of its peak power that fills the window at every delay, zero included. Read through the formed input, the bound is 1e-3 at zero delay already (measured on the production instrument at 192²), so it would measure the holes and not the delay. The pedestal is also present at every delay the old rule admitted. It was checked directly: with exact windows at 384² on an NVIDIA A40, collected spectra over 151–600 nm at −60 to +80 fs on the production window agree with those on a 520 fs window (1200 points) to 1.2e-8 of the zero-delay peak in the 0.5 mm window, for the 1 fs pulse and for its three chirps. In the 2.5 mm window they agree to 5.9e-6, the same as at the delays the old rule admits. **Band-limited input, once.** The pulse's spectral tails are rolled off with a $C^\infty$ Planck taper over the band-edge regions at *setup* — a property of the source definition, not an in-loop filter — so the hard grid boundary never rings. **What solprop integrates, and how the bridge pins it.** solprop advances the same equation in the interaction picture, exact in the linear operator, *replaying* a fixed schedule: each interval between save positions is covered by the fewest equal steps not longer than `h_target`, every save position is a schedule edge, and there is no interpolation or dense output. The default march (`stepper="rk4ip"`) is solprop's low-storage interaction-picture RK4, fourth order in the nonlinear term, in about four field volumes; `stepper="dopri5"` replays the Dormand–Prince 5(4) pair instead, fifth order, in about fifteen. No step is ever rejected: error control is Richardson calibration on the extracted observables — see {doc}`accuracy`. The bridge ({mod}`pnps.bridge`) makes solprop's operator this package's operator, and checks it: - *grids* — solprop's envelope grid and collar-free Cartesian grid reproduce {func}`pnps.grids.time_grid` and {func}`pnps.grids.space_grid` sample for sample (band mask bit-identical, frequency and momentum axes to 1e-12, checked on every build); both store the unnormalised DFT in the same sign convention, so the input is handed over by a no-copy reshape; - *index* — optmat's fit as solprop's default silica ($k^2$ to 2e-13 of this package's, the rounding floor of optmat's evaluation being about 1e-13 in $n$); - *responses* — solprop's envelope Kerr response, with or without its scalar Raman response built from the same optmat bundle; - *frame* — pinned: $\beta_0 = \beta_0^{ref} + \beta_1^{ref}\omega_0$, $\beta_1 = \beta_1^{ref}$, so solprop's $\beta_0 + \beta_1(\omega-\omega_0)$ is this package's $\beta_1\omega + \beta_0^{ref}$; - *prefactor* — solprop writes $-i\omega^2/(2\varepsilon_0 c^2\,\mathrm{Re}\,k_z)$ where this package writes $-i\mu_0\omega^2/(2\,\mathrm{Re}\,k_z)$, with $\mu_0$ taken as $1/(\varepsilon_0 c^2)$ ({data}`pnps.reference.MU`): the same constant, so $\chi^{(3)}$ is handed over unchanged; - *absorbers* — $\gamma_\omega$, an amplitude rate, becomes solprop's power rate $2\gamma_\omega$ with zero temporal rates, and $\gamma_k$ its safety ramp (re-derived here and checked against solprop's to 1e-12); solprop applies its hard band limit outside the same $\omega_{min}/2 < \omega < 1.1\,\omega_{max}$, where the band-limited input is already zero. The validation ladder that shows the result is this package's model, to rounding where it should be and to truncation error where it cannot be, is in {doc}`accuracy`. **Windows computed on the fly.** Collection apertures use the same chromatic mapping as the input masks, $x = k_x z_m c/\omega$, and are evaluated per element inside the fused host reduction of each saved plane ({mod}`pnps.reduce_numba`) — no window arrays are materialised or stored. The input state is formed the same way ({mod}`pnps.form_input`): the beamlets are never stored. **Re-imaging without an FFT.** The on-axis re-imaged spectrum is the centre pixel of the 2-D inverse FFT of the windowed field, computed exactly (even grids) as the $(-1)^{i_y + i_x}$-weighted mean. ## Grids The temporal grid is fixed by the wavelength window: $\delta t$ is the envelope Nyquist limit for the blue edge (with 10% headroom), and the sample count rounds `trange` up to an even 2,3,5-smooth FFT size. The transverse grid is square and centred with a 10% half-width margin (the physical half-width is `r_max * 1.1`), and {func}`pnps.grids.optimal_spatial_grid` gives its size (containment: 5 Airy radii at the red edge; resolution: 10 samples per Airy lobe at the blue edge; momentum span: the third-order mixing products with 1.5x headroom), for either beam layout. ## Masks and windows How the holes of the input mask and the collection windows are rendered on the momentum grid, and why it matters, is on its own page: {doc}`windows`.