MESAHub / MESAHub/mesa

Improve Derivatives for Cubic Interpolation in Composition for Opacity

Open
#593 5 comments 0 reactions 0 assignees View on GitHub
enhancement hackathon kap
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.

![image](https://github.com/MESAHub/mesa/assets/18405113/ba0446b8-fcd6-401e-a793-5c1dc1d15505)
![image](https://github.com/MESAHub/mesa/assets/18405113/4286f297-fda4-4aaa-9761-7ae416561fab)
![image](https://github.com/MESAHub/mesa/assets/18405113/c99eef79-84f9-4627-bfb0-c7386a1eccd9)
![image](https://github.com/MESAHub/mesa/assets/18405113/85c9cdeb-53ac-4bdd-9ecd-8b18979c9376)

Contributor guide

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.