Skip to content

fix(simulate): build the refnx structure with each layer once - #15

Merged
NaNIsaac merged 1 commit into
mainfrom
fix/structure-layers-once
Oct 25, 2026
Merged

NaNIsaac merged 1 commit into
mainfrom
fix/structure-layers-once

Conversation

@NaNIsaac

Copy link
Copy Markdown
Owner

Closes #12.

build_structure put the n layers into Stack(name='MultiLayer', repeats=len(params)), so refnx repeated the whole n-layer stack n times: a 2-layer sample was simulated as 4 layers, a 3-layer sample as 9. Single-layer data were unaffected (repeats=1). Every multi-layer curve generated with this function therefore carried truth labels (thickness, roughness, SLD per layer) that did not describe the simulated structure. The structure is now air | layer 1 | ... | layer n | substrate.

Tests: the slab table holds each layer once in order; the curve equals the one refnx computes for the explicit structure (rtol 1e-10).

Affected data (inference from the code path): any HDF5 dataset made by simul_refnx with more than one layer; models trained on them learned mislabelled multi-layer examples. They need regeneration before multi-layer results are reported. Physics reviewed by boss.

local-ci: uv run pytest -q 27 passed, 1 skipped. GitHub Actions does not start (billing, DotFiles#184).

@NaNIsaac
NaNIsaac merged commit 15939bf into main Oct 25, 2026
6 checks passed
@NaNIsaac
NaNIsaac deleted the fix/structure-layers-once branch October 25, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

simul_refnx repeats the whole layer stack n times

1 participant