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 that is proportional to the induced nonlinearity. A quadrant detector detects the deflection as an energy difference between the two sides of the detector . Scanning the excitation-probe delay using a mechanical stage maps the temporal response.
The beam deflection technique is described in more detail here.
Modeling experimental data
The equation governing the propagation of the probe field through the sample in normalized coordinates is
with
where is the convolution of the NLO response function with the irradiance of the excitation .
Solving for the electric field of the probe at the back of the sample gives us
The functions and are the real and imaginary parts of the overlap integral which gives the accumulated effect of the nonlinearity on the probe pulse.
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 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 and fall 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.


Propagation and detection
This calculation runs on a four-dimensional grid over transverse spatial coordinates ( and ), time within the pulse (), and excitation-probe delay (). The electric field is propagated to the detector via Fresnel propagation.
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.
The transmission is calculated from the total energy on the detector normalized by dividing by the total energy at a negative delay.
The excitation and probe pulses are typically at different wavelengths, so they travel through the sample at different group velocities and walk off from each other in time. This Group Velocity Mismatch (GVM) is determined by the group index difference and the sample thickness.
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.
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.

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.

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).