You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tighten the crystal's depth-node rule: ceil(φ)+3 allocates 1.3–1.8× the Gauss–Legendre nodes needed #36
area: forward modelForward models, interactions, dispersion, smearing and collectionperformanceSlower or larger than it should be, with no wrong resultpriority: lowWorth doing, no hurry
croak.crystals.depth_points asks for ceil(φ) + 3 Gauss–Legendre depth nodes, with φ = max|Δk|·L/2 over the grid's component pairs, and the forward models refuse fewer (depth_points at 6800603, check_medium). The rule is safe but generous at large φ. The smallest count whose error stays below 10⁻⁶·L for every φ′ in [0, φ] (the accuracy the docstring promises):
φ (rad)
nodes needed
ceil(φ) + 3
20
18
23
40
30
43
60
41
63
120
74
123
250
142
253
Found by the review of #31 and reproduced independently (a NumPy scan of ∫₀¹ e^{−2iφ′u} du against the closed form, φ′ sampled at 2001 points in [0, φ]; run, 2026-11-17). Asymptotically Gauss–Legendre resolves an oscillation of half-phase φ with about eφ/4 ≈ 0.68φ nodes, consistent with the table.
Why it matters
The forward map and the hand adjoint cost scale linearly with the node count. A 1.5 fs grid with 500 µm of BBO crossed at 5.7° asks for about 260 nodes where about 145 would do, so every solver iteration pays about 1.8×. Because check_medium refuses counts below the rule, a user cannot opt out.
To do
Choose a tighter rule of the form a·φ + b(φ) (for example about φ/2 plus a slowly growing margin), and check it against the scan above extended to φ = 500.
Extend test_depth_rule_resolves_the_oscillation (tests/test_crystals.py) upward in φ (to at least 250) so it pins the new rule, including the worst φ′ below each φ, not only φ itself.
Update the depth_points docstring and the depth-resolution paragraph of docs/explanation/forward_model.md.
Must not change: the 10⁻⁶·L accuracy guarantee per pair; depth_points returning 1 at zero thickness; the arms' drift κ(ω₁−ω₂) being part of φ (added in Model SHG in a Type I crystal in the forward models #31 after the review).
Done when
The extended rule test passes for every φ in its range, the crystal forward-model tests (tests/test_forward_crystal.py) still agree with the exact pair sum at their tolerances, and the node count for the 1.5 fs / 500 µm / 5.7° case drops by at least 1.5×.
Follow-up to #31, part of #24. Drafted with Claude Code.
area: forward modelForward models, interactions, dispersion, smearing and collectionperformanceSlower or larger than it should be, with no wrong resultpriority: lowWorth doing, no hurry
Activity