Improve Derivatives for Cubic Interpolation in Composition for Opacity
- Dominant language
- Fortran
- Stars
- 249
- Forks
- 82
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 3
Description
Right now, our default is to do linear interpolation in composition (X,Z) for opacity tables. Even though cubic interpolation returns more realistic opacities, it returns much worse derivatives. Turning on cubic interpolation by default results in a number of test suite failures: https://testhub.mesastar.org/test_kap_cubic_splines/commits
It seems a big part of the issue is that we interpolate the derivatives from the tables, rather than taking derivatives of the interpolants. This may require a fairly significant amount of effort to refactor and overhaul how the code approaches composition interpolation. https://github.com/MESAHub/mesa/blob/c0203203faadbbaeb218d5c9bf5a37d9aff29886/kap/private/kap_eval_fixed.f90#L518-L534
To get a sense of how bad the derivatives are, here are some dfridr plots from @Debraheem at X = 0.625, Z = 0 when using cubic interpolation.




Contributor guide
Research direction
Read the composition interpolation logic in kap/private/kap_eval_fixed.f90 around lines 518–534, then compare cubic-interpolation behavior with the test results at testhub.mesastar.org/test_kap_cubic_splines/commits. Use the referenced dfridr plots and existing test-suite failures to characterize the derivative problem. Done means cubic interpolation produces acceptable derivatives without the reported regressions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fortran
- Domain
- data
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100