reflectometry/refl1d

allow overriding the wavelength used to calculate Material.sld

Opened this issue · 0 comments

Currently, we don't have support for wavelength-dependent Material layers (for multiple wavelengths in the same Probe object)

  • Slab.render(probe, slabs) calls
    • Material.sld(probe) which then calls
      • probe.scattering_factors(self.formula, density) which then calls
        • periodictable.nsf.neutron_sld(formula, wavelength=self.unique_L[0], density)

The choice of self.unique_L[0] was made just to be the simplest possible arbitrary choice of a wavelength to pick, as we do not currently properly support calculating for all the wavelengths (would require calculating a separate profile for each unique_L)

workarounds used:

To calculate models with wavelength-dependent SLD, users are creating Probe objects with coarse-grained wavelength grouping, and setting the SLD for the layers to something close to the expected value for that average wavelength. For example, a single angle of an ISIS dataset is broken up into multiple Probe objects by wavelength, and then the Parameters of the probes are tied together manually.

change suggested:

We could allow one of the objects in the call tree to specify an override_wavelength to manually set the wavelength used specifically for SLD calculation, while still leaving the L and dL columns intact for calculating resolution. My first thought is to add it to the Material class, so that you can create e.g. Eu = Material("Eu", override_wavelength=5.0), and that this wavelength is then passed to probe.scattering_factors as an optional argument, which is then used instead of Probe.unique_L[0] This would enable the current workaround to be implemented in a much saner fashion, and would preserve existing behavior for users that don't add the new override_wavelength keyword argument.

On the other hand, if override_wavelength is attached to the Probe object instead, then you could easily reuse the same Layers with different Probes that then set the SLD according a the specified wavelength. Would it be too confusing to have two different wavelengths specified on a Probe object?

alternative:

We could just fix it so that calculating for all wavelengths works properly (again - I think it did once). The issue then was that if you used Material with any element that was even slightly wavelength-dependent, the time to calculate increased dramatically so that it became unusable (need to calculate a profile and a separate reflectivity for each Q value, without reusing anything). Paul has suggested calculating a mesh of reflectivities vs. wavelength and interpolating.