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

thread lambda through pte #466

Merged
merged 11 commits into from
Feb 13, 2025
Merged

thread lambda through pte #466

merged 11 commits into from
Feb 13, 2025

Conversation

Yurlungur
Copy link
Collaborator

@Yurlungur Yurlungur commented Feb 13, 2025

PR Summary

I discovered that we never fully threaded lambda arguments through the PTE solver. This MR properly threads them through. To test it, I also switch the test_pte_ideal test from using ideal gas to using IdealElectrons, which adds code coverage there as well.

This change is needed to support EOS's that use the lambda, notably partially ionized EOS's, with PTE.

PR Checklist

  • Adds a test for any bugs fixed. Adds tests for new features.
  • Format your changes by using the make format command after configuring with cmake.
  • Document any new features, update documentation for changes made.
  • Make sure the copyright notice on any files you modified is up to date.
  • After creating a pull request, note it in the CHANGELOG.md file.
  • LANL employees: make sure tests pass both on the github CI and on the Darwin CI

If preparing for a new release, in addition please check the following:

  • Update the version in cmake.
  • Move the changes in the CHANGELOG.md file under a new header for the new release, and reset the categories.
  • Ensure that any when='@main' dependencies are updated to the release version in the package.py

@@ -76,7 +76,7 @@ void get_sg_eos_rho_p(const char *name, int ncell, indirection_v &offsets_v,
// calculate sie from single eos
auto p_from_t = [&](const Real &t_i) {
return eos_v(pte_idxs(tid, 0))
.PressureFromDensityTemperature(rho_pte(tid, 0), t_i, cache[0]);
.PressureFromDensityTemperature(rho_pte(tid, 0), t_i, cache);
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't this be cache[0] since this is the single material case and it is expecting the indexer of a material (the only material in this case)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oops yes that one should be. Good catch.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually I have been thinking about this a bit more. While this is correct in the vast majority of cases where npte == nmat == 1, there could be cases where 1 == npte < nmat. In this case we need to use the correct offsetting index for the density and the cache. Maybe this should be its own issue and in a separate PR, but thought I should point it out.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll create an issue. This code will also need to change in the same way I changed the C++ code to support non-trivial lambdas for, e.g., partial ionization at some point.

Copy link
Collaborator

Choose a reason for hiding this comment

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

all of the pte solver files likely suffer from this bug for the single material case. Wonder how many times its caused issues?

These are my fault, sorry about that this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's harmless right now, since the cache isn't filled with anything anyway for the EOS's used. But when threading through real lambdas, it will need to change. #467

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

all of the pte solver files likely suffer from this bug for the single material case. Wonder how many times its caused issues?

These are my fault, sorry about that this.

I will double check---I think it's not so bad right now because the cache is only used as an initial guess.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the rho index is also potentially incorrect though as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah actually no you're right it could be more serious. The eos index too?

@Yurlungur Yurlungur merged commit b2c6539 into main Feb 13, 2025
8 checks passed
@Yurlungur Yurlungur deleted the jmm/thread-lambda-through-pte branch February 13, 2025 20:56
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.

5 participants