Skip to content

Two-beam delay smearing for SHG FROG - #38

Open
chrisbrahms wants to merge 11 commits into
LupoLab:feature/shg-crystal-integrationfrom
chrisbrahms:feature/shg-smearing
Open

chrisbrahms wants to merge 11 commits into
LupoLab:feature/shg-crystal-integrationfrom
chrisbrahms:feature/shg-smearing

Conversation

@chrisbrahms

@chrisbrahms chrisbrahms commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Important

This PR is part of a stack. Each PR builds on the one before it. Review and merge them in this order:

  1. Model SHG in a Type I crystal in the forward models #31: SHG crystal core: croak.crystals and the forward models
  2. Thread the SHG crystal through the solvers, sessions and GUI, with BBO #37: threading through solvers, sessions and GUI; BBO
  3. Two-beam delay smearing for SHG FROG #38: two-beam SHG delay smearing ← this PR
  4. Predict and correct the SHG marginal through a crystal #39: SHG marginal through a crystal

This PR's base is #37's branch (feature/shg-crystal-integration), so its diff shows only its own changes. Merge the PRs bottom-up. After each merge, retarget the next PR onto main.

What changed

The third part of #24: two-beam delay smearing for SHG FROG, with or without a crystal.

  • croak.smearing.shg_two_beam_kernel builds the delay blur of two crossing Gaussian beams. It takes the same TwoBeamGeometry the crystal uses, now with a beam_diameter. The RMS width is w0 tan α / (√2 c) = λd / (√2 π D c), after Taft et al. 1996. The forward models, the solvers and fit_smearing accept this kernel for SHG. check_kernel refuses a kernel with a shape parameter for SHG.
  • A split smearing fit (fit_smearing_split) is refused for a kernel without a shape channel (sigma_p = 0). That covers the two-beam SD kernel and the new SHG kernel. Before, the shape multiplier could not move the trace, so it stayed at its start value and the covariance reported it as exact. The changelog records this under changed.
  • Sessions take beam_diameter_mm. The kernel is built from the crystal's own beams at the pulse's wavelength, so phase matching and smearing cannot use different angles.
  • GUI. The Beam geometry group gains the beam diameter, the smearing switch and a width read-out.
  • Docs. A two-beam SHG section in the geometric-smearing how-to, and a changelog fragment.

Verification

  • uv run poe check passes on the final commit: the full suite at 100 % statement and branch coverage. uv run poe docs builds without warnings.
  • A test compares the kernel against a brute-force transverse integral. NumPy and JAX agree, and the normalised JAX path is tested.
  • The full-field comparison in Model SHG in a Type I crystal in the forward models #31 averaged this smearing in, for beams crossing at the entrance face, the mid-plane and the exit face.
  • An independent review and a re-review were done, and their findings were fixed.

Related

Part of #24. Stacked on #37.

Drafted by Claude (AI).

🤖 Generated with Claude Code

https://claude.ai/code/session_01WM2AxPM9w8Mg7mfKikaeCX

chrisbrahms and others added 11 commits November 13, 2026 15:05
With two beams only the relative delay varies across the focus, so the
smeared trace is the unsmeared one convolved along delay.
shg_two_beam_kernel gives its width from the beam geometry, sigma =
w0 sin(alpha) / (sqrt 2 c) with w0 the Gaussian focal waist (lambda d /
(sqrt 2 pi D c) for small angles), as a SmearingKernel with no shape
parameter; check_kernel refuses a shaped kernel for SHG. Both forward
models convolve the unsmeared SHG trace, built with each arm's own
propagator so that a crystal's arm drift is kept, and the smearing scale
works as for PG/SD. Tests compare the model with a brute-force average
over the focus, with and without a crystal, and NumPy with JAX.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WM2AxPM9w8Mg7mfKikaeCX
beam_geometry is the one place a session's beams come from, for the
crystal and for the smearing: RetrieveParams gains beam_diameter_mm. With
smearing on, an SHG trace gets the two-beam kernel at the pulse's
wavelength (the measured spectrum's centroid, else the carrier), with the
fixed width multiplier as for PG/SD; collinear beams have none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WM2AxPM9w8Mg7mfKikaeCX
For SHG data the Beam geometry group takes the beams' diameter and a
switch for the delay smearing (the same switch as the mask group's, which
is hidden for SHG), and reads out the width in rms and FWHM at the pulse's
wavelength. The extras read-out reports SHG's width like PG/SD's. The
visibility update runs once every group exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WM2AxPM9w8Mg7mfKikaeCX
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WM2AxPM9w8Mg7mfKikaeCX
- The width uses tan(alpha): each beam's profile across the crossing plane
  carries cos(alpha) (Taft et al. 1996, Eq. 7), which makes it exactly
  lambda d / (sqrt 2 pi D c). A test integrates two tilted beams for it.
- The Baltuska figure is the same result (sigma_delta / sqrt 2), not a
  different one; the validity list names the crystal's angular acceptance.
- A split smearing fit is refused for a kernel with no shape channel (two
  beams, SHG or SD), which it could not move.
- The session fits the width only when there is a kernel (not for collinear
  SHG beams) and does not apply the mask's fixed multiplier to SHG.
- The GUI enables SHG smearing only for crossing beams and a capable
  solver, keeps one smearing switch in both groups, unticks it for the
  focal mixture, hides the focal mixture for SHG, and greys the width fit
  without a kernel.
- Tests no longer compare femtosecond widths in seconds within approx's
  default absolute tolerance; an end-to-end retrieval checks the kernel.
- Solver docstrings, a settings comment, the module overview and the README
  describe the two-beam kernel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WM2AxPM9w8Mg7mfKikaeCX
- A focal mixture left on from PG/SD data is switched off, with a notice,
  when SHG data arrives: it cannot be modelled for SHG and its box is
  hidden.
- The refused split fit is tested for the two-beam SD kernel in every
  solver that fits extras and in the covariance, documented in the split
  section and its table, and recorded as a changed behaviour.
- The changelog gives the tan(alpha) width; the Baltuska match is stated
  for rms durations and 1/e^2 diameters.
- The SHG smearing gate takes the solver's parameters, dropping an
  unreachable branch; a typo in the docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WM2AxPM9w8Mg7mfKikaeCX
@read-the-docs-community

Copy link
Copy Markdown

@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: forward model Forward models, interactions, dispersion, smearing and collection enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant