This code is an interactive simulator and data fitting tool for beam deflection excitation-probe measurements that computes the both the absorption and deflection cross-correlation signals from first principles. The code calculates the probe field at the back of the sample accounting for group velocity mismatch, excitation depletion and up to seven simultaneous physical Nonlinear (NLO) response mechanisms and then Fresnel-propagates the field to a quadrant detector. Ported from MATLAB to Python, with a desktop graphical user interface (GUI) and a diagnostics view that calculates and displays each mechanism’s contribution separately along with the total contribution.

This code is based on work performed during graduate school at the University of Central Florida and further developed at the Air Force Institute of Technology. The code can be downloaded from the Poesjelabs Gitea site under the GPL 3.0 open source license.

Deam deflection measurement

In beam deflection measurements an strong excitation pulse creates a prism-like transient index gradient in the sample, and a weaker probe positioned on the wing of that gradient is deflected by some angle θ\theta that is proportional to the induced nonlinearity. A quadrant detector detects the deflection as an energy difference between the two sides of the detector ΔEp\Delta E_p. Scanning the excitation-probe delay using a mechanical stage maps the temporal response.

(left) Schematic of the beam deflection experiment with the displaced probe. (center) Diagram of the irradiance profiles of the excitation and probe pulses. (right) When the probe is centered on the quad-segmented photodiode the signal is zero, when a beam is deflected a signal is present.

The beam deflection technique is described in more detail here.

Modeling experimental data

The equation governing the propagation of the probe field ap[Z,τ]a_p[Z,\tau] through the sample in normalized coordinates is

∂ap[Z,τ]∂Z+ρ∂ap[Z,τ]∂τ=f[Z,τ]ap[Z,τ]\frac{\partial a_p[Z,\tau]}{\partial Z} + \rho\,\frac{\partial a_p[Z,\tau]}{\partial \tau} = f[Z,\tau]\,a_p[Z,\tau]

with

f[Z,τ]=−σ+iG[Z,τ]f[Z,\tau] = -\sigma + i\,G[Z,\tau]
G[Z,τ]=∫−∞+∞R[τ′−τ]Ie[Z,τ′]dτ′G[Z,\tau] = \int_{-\infty}^{+\infty} R[\tau’-\tau]\,I_e[Z,\tau’]\,\mathrm{d}\tau’

where G[Z,τ]G[Z,\tau] is the convolution of the NLO response function with the irradiance of the excitation Ie[Z,τ′]I_e[Z,\tau’].

Solving for the electric field of the probe at the back of the sample gives us

ap[X,Y,1,τ]=Aexp⁡[−X2+Y2W2−(ρ−τ+τd)22T2−e−2(X−X0)2−2Y2(iH′′[τ]+H′[τ])]a_p[X,Y,1,\tau]=A\exp\!\left[-\frac{X^2+Y^2}{W^2} – \frac{(\rho-\tau+\tau_d)^2}{2T^2} – e^{-2(X-X_0)^2-2Y^2}\bigl(i\,H”[\tau] + H'[\tau]\bigr)\right]

The functions H′[τ]H'[\tau] and H′′[τ]H”[\tau] are the real and imaginary parts of the overlap integral which gives the accumulated effect of the nonlinearity on the probe pulse.

H[τ]=∫01iG[0,Z′,τ+ρ(Z′−1)]dZ′=H′[τ]+iH′′[τ]H[\tau] = \int_0^1 i\,G\bigl[0, Z’, \tau + \rho(Z’-1)\bigr]\,dZ’ = H'[\tau] + i\,H”[\tau]

Response mechanisms

The total nonlinear response of material can be composed of several physical processes superimposed each with its own temporal evolution. The simulator provides seven mechanism slots, each assignable from ten types:

  • Electronic — a δ[t]\delta [t] function bound-electronic response, instantaneous on the timescale of the pulse, contributing to both refraction and absorption.
  • Collisional, reorientational, vibrational, librational — non-instantaneous molecular contributions, each with characteristic rise and fall times.
  • Excited-state absorption — a three-level system with an intersystem-crossing pathway to a triplet manifold, which solves coupled population rate equations.
  • Generic exponential rise/decay — non-instantaneous refractive and absorptive response with characteristic exponential rise times τr\tau_r and fall τf\tau_f times.

Each non-instantaneous mechanism contributes a response function that is convolved with the excitation pulse, and the results summed. The code calculates each individual and the total response functions, along with the associated index and absorption changes in the material over time. Plots of these responses can be turned on via the diagnostics flag.

Raw response functions, plotted per mechanism. Refractive and absorptive response functions are shown separately.
The same mechanisms after convolution with the excitation envelope to calculate the change in absorption and refraction.

Propagation and detection

This calculation runs on a four-dimensional grid over transverse spatial coordinates (XX and YY), time within the pulse (τ\tau), and excitation-probe delay (τd\tau_d). The electric field is propagated to the detector via Fresnel propagation.

ap[X,Y,Z,τ]=eikZiλZexp⁡[ik2Z(X2+Y2)]ℱ{ap[X′,Y′,0,τ]exp⁡[ik2Z(X′2+Y′2)]}a_p[X,Y,Z,\tau] = \frac{e^{ikZ}}{i\lambda Z}\, \exp\!\left[\frac{ik}{2Z}(X^2+Y^2)\right] \mathcal{F}\Bigl\{a_p[X’,Y’,0,\tau]\, \exp\!\left[\frac{ik}{2Z}(X’^2+Y’^2)\right]\Bigr\}

At the detector plane, the difference in energy deposited on the left and right sides of the detector are calculated, along with the total energy as a function of delay.

Ep[τd]=EL[τd]+ER[τd]E_p[\tau_d] = E_L[\tau_d] + E_R[\tau_d]
ΔEp/Ep[τd]=(EL[τd]−ER[τd])/Ep[τd]\Delta E_p / E_p[\tau_d] = (E_L[\tau_d] – E_R[\tau_d])/E_p[\tau_d]

The transmission is calculated from the total energy on the detector normalized by dividing by the total energy at a negative delay.

T[τd]=Ep[τd]/Ep[τd<<0]T[\tau_d] = E_p[\tau_d]/E_p[\tau_d<<0]

The excitation and probe pulses are typically at different wavelengths, so they travel through the sample at different group velocities vgv_g and walk off from each other in time. This Group Velocity Mismatch (GVM) is determined by the group index difference and the sample thickness.

ρ=Lcτp(ng−ng,p)\rho = \frac{L}{c\,\tau_p}\left(n_g – n_{g,p}\right)

When the GVM is non-negligible the probe samples the response over a range of effective delays rather than one, so the response is integrated across the walk-off window instead of evaluated at a single instant. Group indices are computed from the refractive index and its dispersion at each wavelength, following from previously measured material properties.

When the excitation undergoes absorption, its intensity falls as it propagates and the induced response varies through the sample depth, so an attenuation profile is integrated across the walk-off window rather than assuming a constant excitation. This results in a lower signal at negative delays, as by the time the probe catches up to the excitation, the excitation has already been attenuated by the material.

Limitations

The code accounts for GVM, but not Group Velocity Dispersion (GVD). GVM causes the pulses to travel at different speeds within the material. This is reflected in the signal expanding from the expected Gaussian shape to a rounded trapezoidal shape.

Deflection signal for increasing GVM (black to red).

On the other hand, GVD induced chirp causes the pulse duration to increase as the pulse travels through the material. In the data, this shows as a further reduction of the signal at negative delay. This effect is not currently modeled by the code. Users should be aware of this effect and not try to adjust parameters to fit for this phenomena.

Pump-probe mode

The beam deflection method is a variation of pump-probe (or excite-probe) with the probe offset from the excitation, deflecting the probe. The deflection is measured in the difference channel of the quadrant photodiode. Centering the probe beam on the excitation and using the total channel of the quad cell replicates the pump-probe experiment. The code has a pump-probe mode in the GUI that applies this configuration automatically.

Performance enhancement

The original was written in MATLAB, then translated to Python using Claude Code. The following performance enhancements were made to speed up simulation:

  • Sparse coordinate grids. Every expression on the four-dimensional grid is element wise, so broadcastable one-dimensional views give identical results to dense arrays. The dense form spends roughly 1.7 GB and about a second purely on storing coordinates.
  • FFT-based convolution for the response functions, replacing the direct method. On the 16k-point arrays involved that’s around four times faster, agreeing with the MATLAB version to about 10⁻¹².
  • Multithreaded batched FFT. The propagation transform is the single largest cost at realistic grid sizes and is parallel across the batch dimensions, so it runs across all available cores.
  • One shift instead of two. Shifting both FFT axes in a single call is the same permutation as two nested calls but makes one copy of a potentially several-hundred-megabyte array rather than two.
  • Vectorized time delay. Walk-off integration was also vectorized across the entire time-delay grid instead of looping cell by cell implemented as whole-array operations.

Graphical user interface

The GUI allows the user to input the data file properties, beam parameters, material properties at both excitation and probe wavelengths, system geometry, and simulation grid resolution. Nonlinear mechanism parameters are entered through a dialog that allows the user to select the mechanism and specify the mechanism parameters.

Simulated transmission and deflection signals overlaid on measured data.

The simulation runs on a background thread typically taking a few seconds. Once the calculation completes, the results appear across three tabs: the fit against imported data, the diagnostics plots, and a parameter log recording every input, derived value, and simulation grid settings.

The parameter log. Recording derived quantities alongside the raw inputs means a run can be reconstructed later without re-deriving anything or guessing at what the app computed internally.

Implementation

The code is written in Python with NumPy, SciPy, and mpmath for the polylogarithm, Matplotlib for figures, and Tkinter for the interface. The simulation engine and GUI are separate modules: the engine contains no display code, takes a single parameter dataclass, and returns arrays plus an optional diagnostics bundle, so it can be driven from a script as readily as from the window. The code can be downloaded at the Poesjelabs Gitea site.

References

  • M. Reichert, H. Hu, M. R. Ferdinandus, M. Seidel, P. Zhao, T. R. Ensley, D. Peceli, J. M. Reed, D. A. Fishman, S. Webster, D. J. Hagan, and E. W. Van Stryland, “Temporal, spectral, and polarization dependence of the nonlinear optical response of carbon disulfide: erratum,” Optica 3, 657–658 (2016).
  • M. Reichert, H. Hu, M. R. Ferdinandus, M. Seidel, P. Zhao, T. R. Ensley, D. Peceli, J. M. Reed, D. A. Fishman, S. Webster, D. J. Hagan, and E. W. Van Stryland, “Temporal, spectral, and polarization dependence of the nonlinear optical response of carbon disulfide,” Optica 1, 436–445 (2014).
  • M. R. Ferdinandus, H. Hu, M. Reichert, D. J. Hagan, and E. W. Van Stryland, “Beam deflection measurement of time and polarization resolved ultrafast nonlinear refraction,” Opt. Lett. 38, 3518–3521 (2013).