Repository navigation
Thread the SHG crystal through the solvers, sessions and GUI, with BBO - #37
Open
chrisbrahms wants to merge 15 commits into
Open
chrisbrahms wants to merge 15 commits into
chrisbrahms wants to merge 15 commits into
Conversation
The solvers, the covariance and the pipeline forward material to the forward models, so a CrystalSetup works once their types admit it. The thickness bootstrap raises each draw's depth nodes to what its crystal thickness needs. Tests drive every registered solver with a crystal, check that the crystal model fits its own 100 um trace better than ideal SHG, and that a thick bootstrap draw is resolved rather than refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WM2AxN7Kx14WFWk3qbzDq5
TraceData.marginal_corrected says whether load_and_clean rescaled the trace's rows onto the spectrum-predicted SHG marginal. That correction already divides out an estimate of the phase-matching response, so retrieve_from_tracedata refuses a crystal on such a trace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WM2AxN7Kx14WFWk3qbzDq5
builtin_crystal(name) builds a UniaxialCrystal from optmat's recommended models of both rays, with the range both hold over as its transparency. BBO (Tamosauskas et al. 2018) phase-matches 800 nm SHG at 29.226 degrees, consistent with the paper's nominal 29.2 degree cut and optmat's pin. materials.optmat_index, the wrapper of an optmat model, is now public so both modules use it. Needs optmat with BBO (LupoLab/optmat#48); the dependency bump follows its release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WM2AxPM9w8Mg7mfKikaeCX
RetrieveParams gains the crystal (built-in name), its cut angle, the angle mode (phase-matched wavelength or external tilt), the fundamental's polarisation relative to the crossing plane, the delayed beam's side and the beam separation, which with focal_f_mm sets the crossing angle (0 is collinear). For an SHG trace with dispersive set, the session builds the CrystalSetup and passes it, with at least the depth nodes it needs, to the retrieval, the bootstraps, the covariance and the thickness uncertainty; PG and SD keep their material slab. The polarisation defaults to the crossing plane, where the trace stays symmetric. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WM2AxPM9w8Mg7mfKikaeCX
For an SHG trace the Retrieve stage shows a Nonlinear crystal group (on/off and thickness shared with the slab, crystal, cut angle, phase-matched wavelength or external tilt, polarisation relative to the crossing plane, delayed beam's side) and a Beam geometry group (beam separation and the focal length the focal mixture also uses), in place of the material slab. A read-out gives the internal angle, the tilt, the path and the depth nodes, or why the settings give no crystal. Thickness fitting stays off for a crystal (LupoLab#26). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WM2AxPM9w8Mg7mfKikaeCX
The Synthetic stage can make an SHG trace through the nonlinear crystal the Retrieve stage describes, at a thickness set there, so a trace made in a crystal and its retrieval share one description of the crystal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WM2AxPM9w8Mg7mfKikaeCX
A how-to page covers describing the crystal (built-in or custom indices, cut angle with a tilt or a phase-matched wavelength, the beam geometry and depth nodes), the polarisation and the delayed beam's side, the session and GUI settings, what is not modelled yet (SHG smearing, fitting the crystal, marginal-corrected traces) and how the model compares with full-field simulations. The models guide, the feature list, the GUI and thickness-fitting pages point to it; a release-note fragment records the change. The formatter also rewrapped one test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WM2AxPM9w8Mg7mfKikaeCX
- A crystal gets the depth nodes its phase mismatch needs, not the slab's tied count, and its thickness is not fitted (as without dispersive). - A session retrieval crossing in the principal plane runs check_tilt on the retrieved spectrum. - The thickness uncertainty raises a clear error when dispersive propagation is off. - An optmat without a built-in crystal's models raises a ValueError, which the GUI read-out shows. - The GUI keeps the crystal's thickness, focal length and switch in step with the slab and the focal mixture, shows the slab alone before a trace is loaded, uses the same ranges for the shared settings, and shows an unknown stored setting as it is, with the read-out saying why. - The Synthetic stage's note wraps to its column. - Tests check that every solver receives the crystal and run a covariance through it; the docs give the smearing width as rms and FWHM, the tilt check, the defaults and the sources of the full-field figures. 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
crystal_tilt_error estimates what the first-order tilt model leaves out on the part of the grid the pulse occupies (its live band, doubled), so it no longer costs seconds on wide grids, and returns None where there is nothing to check instead of raising after the retrieval. run_retrieval warns from it unless check_tilt=False; the GUI worker turns that off, since capturing warnings in a thread is unsafe, and sends the estimate to the Retrieve stage as a notice. The per-solver test now checks that each solver's own model trace is the crystal model's, which a solver ignoring the crystal fails. 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
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WM2AxPM9w8Mg7mfKikaeCX
This was referenced Nov 17, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
This PR is part of a stack. Each PR builds on the one before it. Review and merge them in this order:
croak.crystalsand the forward modelsThis PR's base is #31's branch (
feature/shg-crystal-core), so its diff shows only its own changes. Merge the PRs bottom-up. After each merge, retarget the next PR ontomain.What changed
The second part of #24. It threads the Type I crystal from #31 through the rest of croak and adds BBO.
retrieve_from_tracedata, the bootstraps, the covariance and the thickness uncertainty accept aCrystalSetupasmaterial. The thickness bootstrap gives each drawn thickness the depth nodes it needs.croak.crystals.builtin_crystal). It uses optmat's Tamošauskas et al. 2018 ordinary and extraordinary indices. This raises the requirement tooptmat[gas]>=0.10.0, the first optmat release that includes BBO.crystal,cut_angle_deg,angle_mode,tilt_deg,phase_match_nm,polarization,delayed_beamandbeam_separation_mm. OneTwoBeamGeometryholds the crossing angle.TraceData.marginal_correctedrecords whether a trace was corrected, and a crystal model refuses a corrected trace. Predict and correct the SHG marginal through a crystal #39 relaxes this.Not in this PR: two-beam SHG delay smearing (#38, stacked on this) and the crystal-aware marginal check (#39). Fitting the crystal stays refused for SHG (#26).
Verification
uv run poe checkon the final commit, against the released optmat 0.10.0: lint, format, pyright, codespell, the changelog check and the full suite at 100 % statement and branch coverage.uv run poe docsbuilds without warnings.qtbot. Session round-trips cover every new key.Related
Part of #24. Stacked on #31; #38 and #39 build on it. Follow-ups: #26 and #36.
Drafted by Claude (AI).
🤖 Generated with Claude Code
https://claude.ai/code/session_01WM2AxPM9w8Mg7mfKikaeCX