pub fn doppler_broaden_with_derivative(
energies: &[f64],
cross_sections: &[f64],
params: &DopplerParams,
) -> Result<(Vec<f64>, Vec<f64>), DopplerError>Expand description
Doppler-broaden cross-sections AND compute the analytical temperature derivative ∂σ_D/∂T in a single pass.
This computes the exact derivative by differentiating the FGM integral with respect to the Doppler width parameter u = √(k_B·T / AWR), then applying the chain rule: ∂σ_D/∂T = (∂σ_D/∂u) · u/(2T).
The derivative uses intermediate quantities already computed in the forward pass (b_k, exp(-b_k²), J₀, J₁, C_j, slope), adding only ~10 FLOPs per segment with NO extra broadening evaluations.
§Mathematical Derivation
Per segment [w_j, w_{j+1}]: M₀_j = b_{j+1}·exp(-b_{j+1}²) - b_j·exp(-b_j²) M₁_j = b_{j+1}²·exp(-b_{j+1}²) - b_j²·exp(-b_j²) ∂I_j/∂u = (C_j/u)·M₀_j - slope_j·J₁_j - slope_j·M₁_j
Full result (quotient rule on sum_y / (sum_g · v)): ∂σ_D/∂T = u/(2T·v) · (dsum_y·sum_g - sum_y·dsum_g) / sum_g²
SAMMY uses finite differences for this (mfgm4.f90 Xdofgm, Del=0.02). Our analytical approach is exact and avoids the 3× broadening cost.