Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up linear interpolation #2664

Merged
merged 28 commits into from
Dec 26, 2023
Merged

Conversation

zingale
Copy link
Member

@zingale zingale commented Nov 30, 2023

The locate() function was returning the index of the zone that is higher than the input coordinate r. The logic in interpolate accounted for this, but things were more complex than they need be. This simplifies locate and the linear interpolation.

It also adds a unit test to help understand what's happening.

PR summary

PR motivation

PR checklist

  • test suite needs to be run on this PR
  • this PR will change answers in the test suite to more than roundoff level
  • all newly-added functions have docstrings as per the coding conventions
  • the CHANGES file has been updated, if appropriate
  • if appropriate, this change is described in the docs

@zingale
Copy link
Member Author

zingale commented Nov 30, 2023

closes #2663

@zingale
Copy link
Member Author

zingale commented Dec 18, 2023

There are now a bunch of unit tests in Castro/util/model_parser

These test what happens when you ask for an r outside of the model range and if you get exactly the model data (to roundoff) if you ask for an r which is exactly a model point.

@zingale
Copy link
Member Author

zingale commented Dec 18, 2023

okay, looking at this more. The old interpolation did work fine, in the sense that it had a general enough scheme to check if we need to use i, i-1 or i, i+1 for the bulk of the interpolation.

In fact, the test suite is just roundoff diffs now:

http://groot.astro.sunysb.edu/Castro/test-suite/gfortran/2023-12-17/index.html

@zingale zingale changed the title fix an offset in the interpolation clean up linear interpolation Dec 18, 2023

}
// safety check to make sure interp lies within the bounding points
Real minvar = std::min(model::profile(model_index).state(id+1, var_index),
Copy link
Member

Choose a reason for hiding this comment

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

Do we want this for r < profile.r(0)?

Copy link
Member Author

Choose a reason for hiding this comment

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

indeed, probably not. That's a good point.

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

@zingale
Copy link
Member Author

zingale commented Dec 26, 2023

@zingale zingale merged commit c3509d4 into AMReX-Astro:development Dec 26, 2023
20 checks passed
@zingale zingale deleted the fix_interp branch December 26, 2023 19:16
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.

2 participants