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

Respect known inputs, constrained P and T solvers #156

Merged
merged 34 commits into from
Sep 8, 2022

Conversation

dholladay00
Copy link
Collaborator

@dholladay00 dholladay00 commented Jul 19, 2022

PR Summary

The get_sg_eos function did not properly take into account the knowns and unknowns for all possible input conditions, nor could it initialize mixed material regions with P-T, rho-T, or rho-P, inputs. There is now a different kernel for each different input condition and 2 new PTE solvers that can take into account when P or T are known but the internal energy is not known.

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

…arate kernel for each possible input condition and respects those conditions. In addition, 2 new PTE solvers have been added to support this re-write. Finding a PTE solution where either P or T is known and constrained. This will respect that constraint and find the appropriate internal energy. This is still being tested.
@dholladay00
Copy link
Collaborator Author

@jhp-lanl, please take a look at the new kernels and make sure the inputs are treated as inputs and the outputs are treated as outputs.

@Yurlungur, @jdolence, @chadmeyer, @jhp-lanl I gave the solvers my best shot. For now I have just commented out initbase and replaced them with different init bases that I think should work. I think there is still an issue in initialization at how to get good initial volume fraction / component density guesses yet still conserve mass.

Copy link
Collaborator

@Yurlungur Yurlungur left a comment

Choose a reason for hiding this comment

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

Great work, @dholladay00 ! A few comments:

  • Looks like you mostly copy-pasted into the new solver definitions. I think there's room to abstract some of that functionality out so there's less repeat code.
  • I didn't carefully cross check the equations against @jhp-lanl 's doc, but that should be done.
  • I am not 100% confident about the initial guesses you're setting up for the solvers. I think that's worth thinking carefully about.
  • We need some tests of these solvers. It should be pretty easy to set up a cross check We can use one of the full PTESolverDependsRhoT or PTESolverDependsRhoSie solvers to set up a system we know has an equilibrium solution, then pass in data to PTESolverFixed* to see if it can recover the same equilibrium.
  • Nice cleanup of the singularity_eos* file but I think it could still use some refactoring to clarify flow control and reduce repeated code.

singularity-eos/closure/mixed_cell_models.hpp Outdated Show resolved Hide resolved
singularity-eos/closure/mixed_cell_models.hpp Outdated Show resolved Hide resolved
singularity-eos/closure/mixed_cell_models.hpp Show resolved Hide resolved
singularity-eos/closure/mixed_cell_models.hpp Show resolved Hide resolved
singularity-eos/closure/mixed_cell_models.hpp Outdated Show resolved Hide resolved
singularity-eos/closure/mixed_cell_models.hpp Show resolved Hide resolved
singularity-eos/closure/mixed_cell_models.hpp Outdated Show resolved Hide resolved
singularity-eos/eos/singularity_eos.cpp Outdated Show resolved Hide resolved
singularity-eos/eos/singularity_eos.cpp Outdated Show resolved Hide resolved
singularity-eos/eos/singularity_eos.cpp Outdated Show resolved Hide resolved
@Yurlungur
Copy link
Collaborator

I gave the solvers my best shot. For now I have just commented out initbase and replaced them with different init bases that I think should work. I think there is still an issue in initialization at how to get good initial volume fraction / component density guesses yet still conserve mass.

Yeah let's all take a look at this at some point. I agree I think there's an issue as currently written.

@dholladay00
Copy link
Collaborator Author

I gave the solvers my best shot. For now I have just commented out initbase and replaced them with different init bases that I think should work. I think there is still an issue in initialization at how to get good initial volume fraction / component density guesses yet still conserve mass.

Yeah let's all take a look at this at some point. I agree I think there's an issue as currently written.

Are we talking about a correctness issue?

@Yurlungur
Copy link
Collaborator

I'm not sure, actually. I think just a little bit more communal staring/cross checking would be useful.

Copy link
Collaborator

@jhp-lanl jhp-lanl left a comment

Choose a reason for hiding this comment

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

I'll have to finish reviewing singularity_eos.cpp next week unfortunately

singularity-eos/closure/mixed_cell_models.hpp Outdated Show resolved Hide resolved
singularity-eos/closure/mixed_cell_models.hpp Outdated Show resolved Hide resolved
singularity-eos/closure/mixed_cell_models.hpp Outdated Show resolved Hide resolved
singularity-eos/closure/mixed_cell_models.hpp Outdated Show resolved Hide resolved
Comment on lines 931 to 935
rho_total = 0.0;
for (int m = 0; m < nmat; ++m) {
rhobar[m] = rho[m] * vfrac[m];
rho_total += rhobar[m];
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

My thinking (which could of course be incorrect) was that the only difference between the base class Init() and what's needed here is that the initialization of the pressure array isn't required.

singularity-eos/closure/mixed_cell_models.hpp Outdated Show resolved Hide resolved
singularity-eos/eos/singularity_eos.cpp Outdated Show resolved Hide resolved
@dholladay00
Copy link
Collaborator Author

@jhp-lanl @jdolence I just saw that new Tguess machinery was merged in. Now that I have function in the base class for obtaining a Tguess, should it be used there?

@jhp-lanl
Copy link
Collaborator

@jhp-lanl @jdolence I just saw that new Tguess machinery was merged in. Now that I have function in the base class for obtaining a Tguess, should it be used there?

Are you asking about your GetTguess() function? I don't think that's necessary. It looks like @jdolence intended ApproxTemperatureFromRhoMatU() to be used by the host code when an approximation for the PTE volume fractions and densities is already known (i.e. the host code decides when this is the case).

Your stuff is mainly for initialization where we wouldn't expect the material volumes or volume fractions to be known before the PTE solve, so your volume fraction guess is probably as good as any. I think your functions need to assume that only the bare minimum is known about a state. You still allow a temperature guess to be passed through right? I think that should be sufficient.

But I haven't thought about this code in a while so I could be forgetting key details.

Copy link
Collaborator

@jhp-lanl jhp-lanl left a comment

Choose a reason for hiding this comment

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

This looks good! I think you addressed all of my issues

@dholladay00 dholladay00 changed the title Draft: Respect known inputs, constrained P and T solvers Respect known inputs, constrained P and T solvers Aug 25, 2022
@dholladay00
Copy link
Collaborator Author

@Yurlungur I think this is ready, give this another look when you get a chance. Hoping to get this merged soon.

Copy link
Collaborator

@Yurlungur Yurlungur left a comment

Choose a reason for hiding this comment

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

You've addressed all my comments and this looks good. But before we merge, I asked @jdolence to run this branch in riot to make sure the changes to PTE didn't break anything.

test/test_pte.cpp Show resolved Hide resolved
singularity-eos/closure/mixed_cell_models.hpp Show resolved Hide resolved
singularity-eos/closure/mixed_cell_models.hpp Show resolved Hide resolved
singularity-eos/closure/mixed_cell_models.hpp Show resolved Hide resolved
singularity-eos/eos/singularity_eos.cpp Outdated Show resolved Hide resolved
singularity-eos/eos/singularity_eos.cpp Show resolved Hide resolved
@Yurlungur
Copy link
Collaborator

Oh also @dholladay00 and/or @jhp-lanl if we could add documentation regarding the two new PTE solvers, that would be helpful. Jeff's pdf should be enough, just dump it into sphinx in the right file.

@dholladay00
Copy link
Collaborator Author

@Yurlungur, in terms of using the cache, I do the offset calculation to figure out the cache location within the solver and create an accessor to it outside of the solve. It's not ideal but it doesn't mess with the current implementation of caching in the solvers and it allows me to take advantage of it when doing lookups after the PTE solve.

@jhp-lanl
Copy link
Collaborator

Oh also @dholladay00 and/or @jhp-lanl if we could add documentation regarding the two new PTE solvers, that would be helpful. Jeff's pdf should be enough, just dump it into sphinx in the right file.

I can do this @dholladay00 since you've been slogging through debugging and writing this code. It will come in a separate MR and I'll create an issue

@Yurlungur
Copy link
Collaborator

@Yurlungur, in terms of using the cache, I do the offset calculation to figure out the cache location within the solver and create an accessor to it outside of the solve. It's not ideal but it doesn't mess with the current implementation of caching in the solvers and it allows me to take advantage of it when doing lookups after the PTE solve.

👍 I think this good enough for now. With the issue we can resolve later.

I can do this @dholladay00 since you've been slogging through debugging and writing this code. It will come in a separate MR and I'll create an issue

Thanks, @jhp-lanl ! That works for me.

As soon as @jdolence confirms nothing breaks downstream in riot, I'm ready to merge.

@dholladay00
Copy link
Collaborator Author

@Yurlungur @jdolence is there a timeline for the downstream testing? I'd like to get this merged ASAP.

@dholladay00
Copy link
Collaborator Author

@Yurlungur and @jdolence I reiterate that this should be merged ASAP.

@Yurlungur
Copy link
Collaborator

Just spoke to @jdolence let's just merge it. Wil lmerge as soon as tests pass.

@Yurlungur Yurlungur merged commit 6ef8712 into main Sep 8, 2022
@Yurlungur Yurlungur deleted the dholladay00/eap_integration branch September 8, 2022 22:18
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.

3 participants