Skip to content

Use monotonic cubic Hermite interpolation for the NSE table - #2092

Merged
zingale merged 22 commits into
AMReX-Astro:developmentfrom
zingale:use_monotonic_cubic_interp
Nov 2, 2026
Merged

zingale merged 22 commits into
AMReX-Astro:developmentfrom
zingale:use_monotonic_cubic_interp

Conversation

@zingale

@zingale zingale commented Sep 12, 2026

Copy link
Copy Markdown
Member

This addresses an issue where even if the data were all positive, we could get negative values in the interpolation due to undershoots in the existing cubic interpolation.

There is one downside though -- because the limiting is nonlinear, it no longer guarantees that sum{X_i} = 1.

@zingale

zingale commented Sep 12, 2026

Copy link
Copy Markdown
Member Author

addresses #2072

I need to fix the behavior at the edge of tables.

I also need to deal with the species normalization -- we might just want to drop to linear for the species.

@zingale

zingale commented Sep 12, 2026

Copy link
Copy Markdown
Member Author

I also need to fix the T derivative of the interpolation. Because we are nonlinear, we need to do things in the same order as the original interpolation and for the final interpolation (now rho), we need to limit on the function values, not derivatives, from the second pass. So this would require a new interface.

@zingale zingale added the nse label Sep 14, 2026
@zingale
zingale changed the base branch from main to development September 14, 2026 13:45
@zingale

zingale commented Sep 21, 2026

Copy link
Copy Markdown
Member Author

I did a small run of massive_star with these changes and did not notice much difference with the old method. But this should be safer overall.

@zingale zingale changed the title [WIP] Use monotonic cubic Hermite interpolation for the NSE table Use monotonic cubic Hermite interpolation for the NSE table Oct 5, 2026
@zingale zingale linked an issue Oct 5, 2026 that may be closed by this pull request
Comment thread nse_tabular/nse_table.H

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me. I trust that combining cubic and cubic_deriv leads to less overall work.

indices of lowest corner of 4x4x4 cube: ir0 = 58, it0 = 16, ic0 = 26

cubic interpolation gives: e_nu = -4.353326582e+12
cubic interpolation gives: e_nu = 5.481706469e+12

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This troublesome state is the only value I've seen vary by more than 2%. Was this value originally negative because of non-monotonic cubic interpolation?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. All the values are positive, so there should never be a negative value.

std::cout << " 4 rho values: " << std::endl;

amrex::Real _d[] = {nse_table::abartab(nse_idx(ir0, it0, ic0)),
amrex::Real _d[] = {nse_table::abartab(nse_idx(ir0-1, it0, ic0)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a different location than before? Previously it0 and ic0 were decremented, now they are not

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where you mean previously. The point here is that we are just doing a slice in the "rho" direction through the data cube, extracting 4 values.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, here, previously you were extracting the value abartab(nse_idx( nse_get_logrho_index(logrho)-1, nse_get_logT_index(logT)-1, nse_get_ye_index(ye)-1 )) and now you are extracting the value abartab(nse_idx( nse_get_logrho_index(logrho)-1, nse_get_logT_index(logT), nse_get_ye_index(ye) )).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean. What has changed is that for the new cubic, the point lies between [ir0, ir0+1], while in the old method, it lied between [ir0+1, ir0+2]. So I go rid of the subtracting 1, since it was not needed. It does have the side-effect of shifting the point, but I don't think that matters for this test.

@zingale
zingale merged commit 8cfadf3 into AMReX-Astro:development Nov 2, 2026
33 checks passed
@zingale
zingale deleted the use_monotonic_cubic_interp branch November 2, 2026 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cubic NSE interpolation can turn neutrino cooling into heating

3 participants