Conversation
|
The main thing missing now is the spiner EOS and tests for the EOSPAC eos. The former I will add in a later PR. The latter I will add once the CI is working again. |
…ingularity-eos into jmm/pt-derivatives-from-preferred
|
I'll try to review this today or tomorrow |
Thanks @jhp-lanl ! I'm also still debugging. |
…al functions are more likely to agree with linear
jhp-lanl
left a comment
There was a problem hiding this comment.
Minor comments. Looks good! I think this will be really useful for computing multimaterial mixture derivatives.
| temp * temp_unit_, lambda, dedP_T, drdP_T, dedT_P, | ||
| drdT_P); | ||
| // scale outputs | ||
| dedP_T *= robust::ratio(press_unit_, temp_unit_); |
There was a problem hiding this comment.
| dedP_T *= robust::ratio(press_unit_, temp_unit_); | |
| dedP_T *= robust::ratio(press_unit_, energy_unit_); |
| table = EofRT_table_; | ||
| eosSafeInterpolate(&table, nxypairs, R, T, z, dx, dy, "EofRT", Verbosity::Quiet); | ||
| const Real dedr_T = sieFromSesame(dx[0]); | ||
| const Real dedT_r = sieFromSesame(temperatureToSesame(dy[0])); | ||
|
|
||
| table = RofPT_table_; | ||
| eosSafeInterpolate(&table, nxypairs, P, T, z, dx, dy, "RofPT", Verbosity::Quiet); | ||
| drdP_T = pressureToSesame(dx[0]); // dividing by pressure means inverse conversion | ||
| drdT_P = temperatureToSesame(dy[0]); // ditto | ||
| dedP_T = dedr_T * drdP_T; | ||
| dedT_P = dedT_r + dedr_T * drdT_P; |
There was a problem hiding this comment.
There are actually a few ways to skin this cat. Whichever you choose, I'd want a justification for why that's the method of choice. For example, I can think of two other ways that have significant advantages:
- Compute
$e(\rho, T)$ and$P(\rho, T)$ and use the resulting derivatives in thermodynamic identities to compute the desired P-T derivatives. - Ask EOSPAC for derivative quantities that are close to what you want. E.g. you could use the following (check my math):
-
EOS_BTt_DTgets you the isothermal bulk modulus that can be converted intodrdP_T -
EOS_ALPHAt_DTgets you the thermal expansion coefficient, which can be converted todrdT_P - Use
EOS_CPt_DTandEOS_ALPHAt_DTwith$(\partial e/ \partial T)_P = C_P - PV\alpha$ - Use
EOS_BTt_DTandEOS_ALPHAt_DTwith$(\partial e/ \partial P)_T = TV\alpha - PV / B_T$
-
The first method is likely the fastest with only two lookups, but I would suspect that the second could be the most accurate, but will be at least twice as expensive (four lookups). Both are subject to the assumption of thermodynamic consistency of course. I would assume that the lookups in (2) are doing thermo identities under the hood, so it may actually not be more accurate if errors compound as EOSPAC does thermo identities and then you use those in a different relation to get different quantities. I'd lean towards the first method I present here, but I could be convinced that your method is superior (although it does involve a root find).
| or temperature fixed. Density, energy, pressure, and temperature, must | ||
| all be passed into this function, to maximize the ability for the | ||
| underlying EOS to perform this calculation performantly. The intended |
There was a problem hiding this comment.
| or temperature fixed. Density, energy, pressure, and temperature, must | |
| all be passed into this function, to maximize the ability for the | |
| underlying EOS to perform this calculation performantly. The intended | |
| or temperature fixed. Each EOS model expects consistent density, | |
| energy, pressure and temperature values to be provided so that it | |
| can perform this calculation performantly. The intended |
I think it's important to emphasize that all four must be valid even if you know that a certain EOS doesn't have two as preferred inputs.
| DensityEnergyFromPressureTemperature(const Real press, const Real temp, | ||
| Indexer_t &&lambda, Real &rho, Real &sie) const; | ||
| /* | ||
| // TODO(JMM): For now using FD. Fix this. |
There was a problem hiding this comment.
My second approach for EOSPAC could actually be the preferred method for spiner. Either that or you can fall back on the Menikoff and Plohr relations that rely on the derivatives that spiner already tabulates.
| eos_); | ||
| } | ||
|
|
||
| // TODO(JMM): Do we need a vectorized version of this call? |
There was a problem hiding this comment.
Maybe in the future? In my head, I'd pair a vectorized version of this call with a vectorized PTE solver.
| device_eos.PTDerivativesFromPreferred(rho, sie, P, T, | ||
| static_cast<Real *>(nullptr), dedP_T, | ||
| drdP_T, dedT_P, drdT_P); | ||
| singularity::eos_base::PTDerivativesByFiniteDifferences( |
PR Summary
This MR resolves #598 by adding @jhp-lanl 's suggested function
PTDerivativesFromPreferred, which I think does make sense. To robustly test, and provide a sensible fallback for methods that don't implement the function, I also implement a finite differences approach.This MR isn't finished (and we can't merge until our internal CI is back up anyway), but I believe it is ready for feedback. The major todos at this point are:
PR Checklist
make formatcommand after configuring withcmake.If preparing for a new release, in addition please check the following: