diff --git a/README.md b/README.md index e15e737..448ad5c 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,10 @@ entered by hand, and only the calculated curves are plotted and exported. offers only the mechanisms that can change the transmission. - Fitting and simulation run modes. Simulation computes the signal with no data imported, over a delay range entered in the panel. +- Two interchangeable algorithms. Fresnel propagation carries the exit field to + the detector by FFT; the semi-analytical method uses closed-form detector + power expressions instead, needing no spatial grid and running about 32x + faster, at the cost of holding only to first order in the nonlinear response. - Optional diagnostic figures showing each mechanism's response function before and after convolution, plus the ESA populations and beam transmissions. - Export of the data/fit comparison, a full parameter log, and figures at @@ -71,8 +75,9 @@ right: **Fitting**, **Diagnostics**, and **Parameter log**. Fitting a measured scan: -1. Under **Operation mode**, choose **Beam deflection** or **Pump probe**, and - leave the second toggle on **Fitting**. +1. Under **Operation mode**, choose **Beam deflection** or **Pump probe**, + leave the second toggle on **Fitting**, and pick an algorithm on the third: + **Fresnel propagation** or the faster **Semi-analytical**. 2. Set the **Data columns** to match your file, and the delimiter. 3. Press **Import…** and choose a scan. The plots show the measured data. 4. Fill in the beam, material and geometry parameters, and configure one or @@ -83,7 +88,8 @@ Fitting a measured scan: Simulating without a measurement: 1. Under **Operation mode**, choose **Simulation**. **Import…** and the data - column fields are disabled, and **Fit** becomes **Simulate**. + column fields are disabled, and **Fit** becomes **Simulate**. The algorithm + toggle works the same way as in Fitting mode. 2. Set `T_d_min` and `T_d_max` in **Simulation parameters** to the delay range to compute over. In Fitting mode these come from the imported file, so they are editable only here. @@ -108,11 +114,11 @@ deflection needs three columns and pump probe two; which ones is set in the **Data columns** box, so extra columns can be present and ignored. Each quantity must come from a different column. -| Quantity | Units | Default column | Needed in | -| --- | --- | --- | --- | -| `τ_d` | fs | 1 | both modes | -| `ΔE/E` | fractional | 2 | Beam deflection only | -| `T` | fractional (1.0 = no change) | 3 | both modes | +| Quantity | Units | Default column | Needed in | +|----------|------------------------------|----------------|----------------------| +| `τ_d` | fs | 1 | both modes | +| `ΔE/E` | fractional | 2 | Beam deflection only | +| `T` | fractional (1.0 = no change) | 3 | both modes | The delimiter field takes a single character, `\t` for a tab, or is left blank to split on any run of whitespace. @@ -121,92 +127,147 @@ to split on any run of whitespace. ### Data columns (1-indexed) -| Variable | Default | Column contents | -|-------------------|---------|---------------------------------------| -| `tau_d column` | `1` | Delay column (fs) | -| `T column` | `3` | Transmission data column | -| `DeltaEoE column` | `2` | Deflection data column | -| `Delimiter` | `,` | Data column delimiter character | +| Variable | Default | Column contents | +|-------------------|---------|---------------------------------| +| `tau_d column` | `1` | Delay column (fs) | +| `T column` | `3` | Transmission data column | +| `DeltaEoE column` | `2` | Deflection data column | +| `Delimiter` | `,` | Data column delimiter character | ### Operation mode -| Option | Effect | -|-------------------|-------------------------------------------------| -| `Beam deflection` | Transmission and deflection, offset probe | -| `Pump probe` | Transmission only, centered probe | -| `Fitting` | Compare the calculation against an imported scan | -| `Simulation` | Calculate without a scan, over an entered range | +Three independent toggles. Any combination is valid. + +| Toggle | Option | Effect | +|-------------|-----------------------|--------------------------------------------------| +| Measurement | `Beam deflection` | Transmission and deflection, offset probe | +| | `Pump probe` | Transmission only, centered probe | +| Run | `Fitting` | Compare the calculation against an imported scan | +| | `Simulation` | Calculate without a scan, over an entered range | +| Algorithm | `Fresnel propagation` | Propagate the exit field to the detector by FFT | +| | `Semi-analytical` | Closed-form detector power, no spatial grid | + +#### Algorithm + +**Fresnel propagation** is the original method. The field at the exit face is +built on an (x, y) grid, propagated to the detector by FFT, and integrated over +the detector halves to get the power difference and total at each instant. + +**Semi-analytical** skips the propagation. It evaluates closed-form expressions +for the detector power difference `dP` and total `P`, already integrated over +the detector plane, then integrates each over time at every delay to get the +energy difference `dE` and total `E`. The deflection is `dE/E` and the +transmission is `E` normalised. With no spatial grid to size, `X_num` and +`X_max` are greyed out; every other parameter, `Delta_n` included, is +unaffected. On the four-layer example it runs in 0.11 s against 3.65 s, about +**32x faster**. + +The trade-off is that `dP` is **first order in the nonlinear response**, where +the Fresnel path keeps every order. The two therefore agree only while the +phase is small, which the `eta (peak)` line of the parameter log reports: + +| `eta (peak)` | Peak of `DeltaEoE` displaced by | +|--------------|---------------------------------| +| 0.14 rad | 0.0003 tau_e | +| 1.41 rad | 0.0035 tau_e | +| 5.64 rad | 0.077 tau_e | +| 14.1 rad | 0.36 tau_e | + +Below roughly 1 rad the two are interchangeable, and the four-layer example sits +at 0.049 rad with a correlation of 1.000000 and amplitudes within 0.5%. Above a +few rad the semi-analytical curve shifts noticeably and is no longer a +substitute. Sample thickness, walk-off and pump absorption do not themselves +affect the agreement once `eta (peak)` is held fixed. + +The remaining 0.5% amplitude offset is the on-axis approximation: the Fresnel +path attenuates by `exp(-2 a_e^2 Gamma)` across the probe profile, where `a_e` +is the pump amplitude profile, while the semi-analytical form uses the on-axis +`exp(-2 x_0^2)`. + +One coefficient in `dP`'s absorptive term, `SA_ABSORPTIVE_FACTOR`, is at present +fitted against the Fresnel path rather than derived. It is isolated in a single +function in `bd_fresnel_core.py`, with the measurements behind it recorded +there. + +The transmission needs a reference delay, taken from before the pump arrives. +In **Fitting** mode it is the first delay point of the imported scan; in +**Simulation** mode it is `min(-3 rho, -3)` tau_e, which follows the walk-off +when that is the larger scale and is three pulse widths otherwise, so a thin +sample still normalises away from the peak. ### Simulation parameters -| Variable | Default | Column contents | -|----------------|---------|---------------------------------------| -| `X_num` | `50` | Number of spatial points | -| `X_max` | `5.0` | Range of spatial sampling (w_0) | -| `T_num` | `100` | Number of temporal points | -| `T_max` | `5.0` | Range of temporal sampling (tau_p) | -| `T_d_num` | `150` | Number of delay points over range | -| `T_d_min` | `-5.0` | Delay range start (tau_p), Simulation only | -| `T_d_max` | `5.0` | Delay range end (tau_p), Simulation only | +| Variable | Default | Column contents | +|-----------|---------|-------------------------------------------------| +| `X_num` | `50` | Number of spatial points, Fresnel only | +| `X_max` | `5.0` | Range of spatial sampling (w_0_p), Fresnel only | +| `T_num` | `100` | Number of temporal points | +| `T_max` | `5.0` | Range of temporal sampling (tau_e) | +| `T_d_num` | `150` | Number of delay points over range | +| `T_d_min` | `-5.0` | Delay range start (tau_e), Simulation only | +| `T_d_max` | `5.0` | Delay range end (tau_e), Simulation only | + +`X_num` and `X_max` size the spatial grid the Fresnel method propagates, so the +semi-analytical method greys them out. ### Excitation beam parameters -| Variable | Default | Column contents | -|----------------|---------|---------------------------------------| -| `E_p` | `1.36` | Excitation pulse energy (uJ) | -| `tau_p_FWHM` | `55.0` | Excitation pulse duration (fs) | -| `w_0p` | `246.0` | Excitation beam waist (um) | -| `lambda_p` | `800.0` | Excitation pulse wavelength (nm) | +| Variable | Default | Column contents | +|--------------|---------|----------------------------------| +| `E_e` | `1.36` | Excitation pulse energy (uJ) | +| `tau_e_FWHM` | `55.0` | Excitation pulse duration (fs) | +| `w_0_e` | `246.0` | Excitation beam waist (um) | +| `lambda_e` | `800.0` | Excitation pulse wavelength (nm) | ### Probe beam parameters -| Variable | Default | Column contents | -|----------------|---------|---------------------------------------| -| `tau_FWHM` | `60.0` | Probe pulse duration (fs) | -| `w_0` | `43.0` | Probe beam waist (um) | -| `lambda` | `650.0` | Probe pulse wavelength (nm) | +| Variable | Default | Column contents | +|--------------|---------|-----------------------------| +| `tau_p_FWHM` | `60.0` | Probe pulse duration (fs) | +| `w_0_p` | `43.0` | Probe beam waist (um) | +| `lambda_p` | `650.0` | Probe pulse wavelength (nm) | ### Material parameters at excitation wavelength -| Variable | Default | Column contents | -|----------------|-------------|-----------------------------------| -| `R_p` | `0.0` | Reflectivity | -| `alpha_p` | `0.0` | Linear absorption (cm^-1) | -| `n_p` | `1.4533` | Linear index | -| `dndl_p` | `-0.017284` | First order dispersion (um^-1) | -| `alpha_2d` | `0.0` | 2 photon absorption (e-11 m/W) | +| Variable | Default | Column contents | +|--------------|-------------|--------------------------------| +| `R_e` | `0.0` | Reflectivity | +| `alpha_e` | `0.0` | Linear absorption (cm^-1) | +| `n_e` | `1.4533` | Linear index | +| `dndl_e` | `-0.017284` | First order dispersion (um^-1) | +| `alpha_2d_e` | `0.0` | 2 photon absorption (e-11 m/W) | ### Material parameters at probe wavelength -| Variable | Default | Column contents | -|----------------|-------------|-----------------------------------| -| `R` | `0.0` | Reflectivity | -| `alpha` | `0.0` | Linear absorption (cm^-1) | -| `n` | `1.4565` | Linear index | -| `dndl` | `-0.027158` | First order dispersion (um^-1) | +| Variable | Default | Column contents | +|-----------|-------------|--------------------------------| +| `R_p` | `0.0` | Reflectivity | +| `alpha_p` | `0.0` | Linear absorption (cm^-1) | +| `n_p` | `1.4565` | Linear index | +| `dndl_p` | `-0.027158` | First order dispersion (um^-1) | ### Measurement parameters -| Variable | Default | Column contents | -|----------------|-------------|-----------------------------------| -| `l` | `1.0` | Sample thickness (mm) | -| `d` | `15.0` | Distance to detector (cm) | -| `shift` | `0.0` | Temporal shift (fs) | -| `x_0` | `0.5` | Displacement of probe (w_0p) | +| Variable | Default | Column contents | +|----------|---------|-------------------------------| +| `l` | `1.0` | Sample thickness (mm) | +| `d` | `15.0` | Distance to detector (cm) | +| `shift` | `0.0` | Temporal shift (fs) | +| `x_0` | `0.5` | Displacement of probe (w_0_e) | ## Mechanisms -| Mechanism | Parameters | -| --- | --- | -| Electronic (both) | 2 | -| Collisional (NLR) | 3 | -| Librational (NLR) | 4 | -| Reorientational (NLR) | 3 | -| Vibrational (NLR) | 3 | -| ESA – 3 level + triplet (both) | 10 | -| Exponential rise/decay (NLA) | 3 | -| Exponential rise/decay (NLR) | 3 | -| Exponential rise/decay (both) | 4 | +| Mechanism | Parameters | +|--------------------------------|------------| +| Electronic (both) | 2 | +| Collisional (NLR) | 3 | +| Librational (NLR) | 4 | +| Reorientational (NLR) | 3 | +| Vibrational (NLR) | 3 | +| ESA – 3 level + triplet (both) | 10 | +| Exponential rise/decay (NLA) | 3 | +| Exponential rise/decay (NLR) | 3 | +| Exponential rise/decay (both) | 4 | `NLR` denotes a purely refractive response, `NLA` a purely absorptive one, and `both` a mechanism carrying each. @@ -221,14 +282,14 @@ is still empty. Exporting to `_fit.txt` also writes, in the same directory: -| File | Contents | -| --- | --- | -| `_fit.txt` | delay, data and fit for `T`, `ΔE/E` and `Δn`; in Pump probe, delay and `T` only. In Simulation, the calculated signals alone | -| `_fit_log.txt` | every parameter, plus a manifest of the files written | -| `_fit_combined.jpg` / `.svg` | transmission and deflection, 6.5 in at 300 dpi (Beam deflection) | -| `_fit_transmission.jpg` / `.svg` | transmission only, 3.25 in at 300 dpi (Pump probe) | -| `_fit_raw_response.jpg` | each mechanism's `R[t]` and `A[t]` | -| `_fit_convolved_response.jpg` | the same after convolution, plus the total | +| File | Contents | +|----------------------------------------|------------------------------------------------------------------------------------------------------------------------------| +| `_fit.txt` | delay, data and fit for `T`, `ΔE/E` and `Δn`; in Pump probe, delay and `T` only. In Simulation, the calculated signals alone | +| `_fit_log.txt` | every parameter, plus a manifest of the files written | +| `_fit_combined.jpg` / `.svg` | transmission and deflection, 6.5 in at 300 dpi (Beam deflection) | +| `_fit_transmission.jpg` / `.svg` | transmission only, 3.25 in at 300 dpi (Pump probe) | +| `_fit_raw_response.jpg` | each mechanism's `R[t]` and `A[t]` | +| `_fit_convolved_response.jpg` | the same after convolution, plus the total | The last two appear only when *Show diagnostic plots during Fit* is ticked. @@ -244,25 +305,23 @@ path and data column sections are omitted, having nothing to describe. ## Files -| File | Role | -| --- | --- | -| `bd_fresnel_core.py` | physics: field propagation, mechanism responses, ESA solver, parameter dataclass, settings I/O. No display dependencies. | -| `bd_fresnel_gui.py` | Tkinter interface, plotting, import/export, logging. Entry point. | -| `set_params_dialog.py` | modal dialog for entering one mechanism's parameters. | +| File | Role | +|------------------------|--------------------------------------------------------------------------------------------------------------------------| +| `bd_fresnel_core.py` | physics: field propagation, mechanism responses, ESA solver, parameter dataclass, settings I/O. No display dependencies. | +| `bd_fresnel_gui.py` | Tkinter interface, plotting, import/export, logging. Entry point. | +| `set_params_dialog.py` | modal dialog for entering one mechanism's parameters. | ## References Please cite the following when using results from this program. -1. Reichert, M., et al. (2014). "Temporal, spectral, and polarization - dependence of the nonlinear optical response of carbon disulfide." - *Optica* **1**(6): 436. -2. Reichert, M., et al. (2014). "Temporal, spectral, and polarization - dependence of the nonlinear optical response of carbon disulfide: - supplementary material." *Optica* **1**(6): 436. -3. Ferdinandus, M. R., et al. (2013). "Beam deflection measurement of time and - polarization resolved ultrafast nonlinear refraction." *Opt. Lett.* - **38**(18): 3518–3521. +1. 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). +2. 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). ## License diff --git a/requirements.txt b/requirements.txt index ba1a891..024e284 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,4 +9,9 @@ numpy>=2.0 scipy>=1.6 matplotlib>=3.4 + +# Optional. Only needed for the pump two-photon absorption term +# (alpha_2d_e != 0), which uses the polylogarithm Li_3/2. The core +# imports it lazily, so the program runs without it until that term is +# used, and then says so. mpmath>=1.2