Summary
GradientLayer discretizes the SLD ramp once, at construction: _prepare_gradient_layers (src/easyreflectometry/sample/assemblies/gradient_layer.py:188-217) snapshots front_material.sld.value / back_material.sld.value into independent Material objects. The stored front_material/back_material are never wired into the sublayers, so mutating or fitting the end-material SLDs has no effect on the computed reflectivity.
Additional issues in the same class
_linear_gradient's comment says "Both front and back values are included", but only indices 0..N-1 are used, so the last sublayer sits one full step short of the back SLD (gradient_layer.py:179-185, 206). Midpoint sampling (front + (i+0.5)*step) would halve the discretization error for the same N.
discretisation_elements < 2 raises "must be greater than 2" (:60-61) — message contradicts the check.
Suggested fix
Constrain each sublayer SLD via the existing dependency machinery, e.g. make_dependent_on('f + i_frac * (b - f)', {...}) with f/b the end-material SLD parameters — the same pattern the assemblies already use for thickness/roughness. Alternatively, document loudly that the gradient is frozen at construction and exclude the end materials from the parameter tree.
Found during deep code review (DEEP_ANALYSIS.md §4.5).
Summary
GradientLayerdiscretizes the SLD ramp once, at construction:_prepare_gradient_layers(src/easyreflectometry/sample/assemblies/gradient_layer.py:188-217) snapshotsfront_material.sld.value/back_material.sld.valueinto independentMaterialobjects. The storedfront_material/back_materialare never wired into the sublayers, so mutating or fitting the end-material SLDs has no effect on the computed reflectivity.Additional issues in the same class
_linear_gradient's comment says "Both front and back values are included", but only indices0..N-1are used, so the last sublayer sits one full step short of the back SLD (gradient_layer.py:179-185, 206). Midpoint sampling (front + (i+0.5)*step) would halve the discretization error for the same N.discretisation_elements < 2raises "must be greater than 2" (:60-61) — message contradicts the check.Suggested fix
Constrain each sublayer SLD via the existing dependency machinery, e.g.
make_dependent_on('f + i_frac * (b - f)', {...})withf/bthe end-material SLD parameters — the same pattern the assemblies already use for thickness/roughness. Alternatively, document loudly that the gradient is frozen at construction and exclude the end materials from the parameter tree.Found during deep code review (DEEP_ANALYSIS.md §4.5).