Skip to content

Polarized reflectometry: only the pp cross-section is computed, silently #379

@rozyczko

Description

@rozyczko

Summary

With magnetism enabled, the refl1d wrapper computes and returns only the ++ (pp) cross-section: ALL_POLARIZATIONS = False at module level, and calculate picks polarized_reflectivity[0] (src/easyreflectometry/calculators/refl1d/wrapper.py:17, 233-245); the all_polarizations=True branch raises NotImplementedError. Spin-flip and -- channels are silently dropped — a caller can mistake pp for the full polarized signal. The only magnetism test asserts the pp channel of a zero-moment sample matches the unpolarized result, so real polarization is untested.

Additionally, _get_polarized_probe constructs PolarizedNeutronQProbe via __new__ plus manual _union_cache_key = None to dodge a refl1d initialization bug (:335-338) — this will break silently on a refl1d version bump.

Suggested fix

  • Short term: emit a clear warning (or document prominently) that magnetic mode yields the pp channel only.
  • Medium term: implement the four-cross-section path (the POLARIZED_ORSO_REV*.md design docs at repo root suggest this is planned) with a nonzero-moment validation test against refl1d reference output.
  • Pin the refl1d version or upstream the probe-initialization fix.

Found during deep code review (DEEP_ANALYSIS.md §4.7).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    Status
    Bugs

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions