aidancrilly / aidancrilly/NeSST
LAW7 outgoing energy distributions ignore the ENDF interpolation law (Be9 n2n is histogram, read as lin-lin)
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 13
- Forks
- 2
- Avg merge
- 18m
- Merged PRs (30d)
- 3
Description
Summary
doubledifferentialcrosssection_data interpolates the LAW7 outgoing energy distributions f(Eout) linearly for every table, regardless of the interpolation law the evaluation declares. Be9 declares histogram, so its n2n distributions are being read incorrectly.
This is pre-existing behaviour on master, not introduced by the JAX port. Raised as follow up from #68.
Evidence
The endf package exposes the interpolation codes; the shipped LAW7 data says:
| material (file) | E_int (over Ein) |
mu_int (over cos) |
f(Eout) |
|---|---|---|---|
D (n-001_H_002.cendl) |
2 = lin-lin | 2 = lin-lin | 2 = lin-lin, all 1258 tables |
Be9 (n-004_Be_009.endf) |
2 = lin-lin | 2 = lin-lin | 1 = histogram, all 504 tables |
import endf
from NeSST.constants import ENDF_dir
m = endf.Material(ENDF_dir + "n-004_Be_009.endf")
d = m.section_data[6, 16]["products"][0]["distribution"]
codes = {
int(mm["f"].interpolation[0])
for i in range(d["NE"])
for mm in d["distribution"][i]["mu"]
}
print(codes) # {1} -> histogram
cross_sections.py builds every f(Eout) interpolant with method="linear" and never reads Tabulated1D.interpolation, so Be9's step functions are being linearly interpolated between bin edges.
D is unaffected in practice since it genuinely is lin-lin.
Consequences
Beyond the direct fidelity error on the Be9 n2n spectrum, this interacts with the unit base resampling added in #68: Be9's resampling error came out about ten times worse than D's (6.4e-5 vs 2.3e-6 relative L2 on the n2n dNdE at the default unit_base_N = 4096). Resampling a linear interpolation of what should be a step function smears the steps, so part of that gap is likely an artefact of this bug rather than of the resampling itself.
Suggested fix
Plumb Tabulated1D.interpolation (and breakpoints, for multi region tables) through endf_interface.convert_to_NeSST_LAW7_format into NeSST_DDX, and have LAW7Table evaluate histogram vs lin-lin as declared. The unit base resampling would need a matching histogram aware path so steps are preserved rather than smeared.
Worth checking the same for the elastic/inelastic cross sections and the SDX tables, which are also hardcoded to method="linear" today. All the shipped Tabulated1D cross sections checked so far report code 2, so those look fine, but the code should not be assuming it.
Note this changes Be9 n2n results, so it needs its own validation rather than riding along with a performance change.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in cross_sections.py and trace endf_interface.convert_to_NeSST_LAW7_format into NeSST_DDX and LAW7Table. Run the Be9 inspection shown in the issue, then check how interpolation and breakpoints reach the LAW7 tables and unit-base resampling. Done means declared histogram and lin-lin laws are preserved for Be9 n2n, with validation for the changed results and a check of the other hardcoded linear paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100