Add mass fraction multi-phase table to sesame2spiner#600
Add mass fraction multi-phase table to sesame2spiner#600adamdempsey90 wants to merge 13 commits intomainfrom
Conversation
Yurlungur
left a comment
There was a problem hiding this comment.
Nice! Glad it was a simple change. Regarding adding mass fractions to every EOS class... Broadly I'd be supportive of this, if we had an error message/stub in the base class as the default behavior. Clearly mass fractions aren't sensible for all EOS's but they are for enough EOS's we might want this.
It looks like the |
I believe Helmholtz does too... or if it doesn't, it could be exposed. |
…ssFraction and fill the string rather than the other way around
…d use the generic functions to do it
| std::vector<EOS_REAL> rhos, Ts, phs; | ||
| makeInterpPoints(rhos, lRhoBounds); | ||
| makeInterpPoints(Ts, lTBounds); |
There was a problem hiding this comment.
I am re-using the EOS rho-T grid for this but in testing we are seeing that maybe that isn't great, e.g., instead of clustering around STP, we probably want to cluster the points around phase transitions. I could add another set of parameters to the inputs that describe the grid decomp for just mass fractions?
There was a problem hiding this comment.
I think that makes a lot of sense. Yeah there's no reason the two grids have to be the same.
There was a problem hiding this comment.
If you're going to use different grids, I would just use the sesame grid. (piecewise linear). eospac just does bilinear interpolation for mass fractions so we should not need higher density than sesame.
There was a problem hiding this comment.
My suggestion for now is you add a TODO to this effect, but we don't let this desired functionality block the merge.
…lease enter a commit message to explain why this merge is necessary,
|
Updated to include the mass fraction query in the spiner EOS object. The unit test I added passes on my CPU machine, but not sure about the GPU machines (mostly the EOSPAC paths...) |
|
Would you like me to do review now? I could also maybe get eospac paths working through the CI? |
yes please. |
| Indexer_t &&lambda = static_cast<Real *>(nullptr)) const; | ||
| template <typename Indexer_t = Real *> | ||
| PORTABLE_INLINE_FUNCTION void MassFractionsFromDensityTemperature( | ||
| const Real rho, const Real T, Real *scratch, | ||
| Indexer_t &&lambda = static_cast<Real *>(nullptr)) const; | ||
| template <typename Indexer_t = Real *> | ||
| PORTABLE_INLINE_FUNCTION void MassFractionsFromDensityInternalEnergy( | ||
| const Real rho, const Real sie, Real *scratch, | ||
| Indexer_t &&lambda = static_cast<Real *>(nullptr)) const; |
There was a problem hiding this comment.
I should probably add this functionality to the eospac EOS
There was a problem hiding this comment.
Agreed, but it can wait to another PR. Maybe just add a TODO?
Yurlungur
left a comment
There was a problem hiding this comment.
@adamdempsey90 sorry for the delay. Some comments below. Did you want to mess with the paths yourself or did you want me to look at that? I'm happy to poke at it. Should have some time to do so tomorrow.
| source ${BUILD_ENV} | ||
| pushd ${BUILD_DIR} | ||
| if [[ -f ./sesame2spiner/sesame2spiner ]]; then | ||
| echo "/usr/projects/data/eos/eos-developmental/Sn2162/v01/sn2162-v01.bin" > sesameFilesDir.txt |
There was a problem hiding this comment.
I think this actually probably is sufficient to getting the paths to work on device.
There was a problem hiding this comment.
Yeah, the gpu tests are working. Although this path shouldn't be correct for LLNL, so I don't know about that
There was a problem hiding this comment.
Ah. We may need a general solution for that. Probably the same problem will show up for the KPT tests. My suggestion is that we set these paths as environment variables in re-git then they can be automatically slurped up here. But before we go down that path... let's ping Richard.
@rbberger what are your thoughts?
There was a problem hiding this comment.
We could also have some project level env script that gets loaded by the CI and sets those paths
| eosCheckError(errorCode, "eos_GetTableCmnts", eospacWarn); | ||
| } | ||
|
|
||
| void eosSafeTableMetaData(EOS_INTEGER *table, EOS_INTEGER infoItem, EOS_CHAR *infoString, |
| } | ||
| } | ||
|
|
||
| int eosCheckTableExistence(EOS_INTEGER tableType_, int matid_, Verbosity eospacWarn) { |
| void eosColdCurveMask(int matid, const Bounds &lRhoBounds, const int numSie, | ||
| const DataBox &sieColdCurve, DataBox &mask, | ||
| Verbosity eospacWarn = Verbosity::Quiet); | ||
| bool eosMassFraction(int matid, const Bounds &lRhoBounds, const Bounds &lTBounds, |
There was a problem hiding this comment.
using a boolean return code here is clever. 👍
| std::vector<EOS_REAL> rhos, Ts, phs; | ||
| makeInterpPoints(rhos, lRhoBounds); | ||
| makeInterpPoints(Ts, lTBounds); |
There was a problem hiding this comment.
My suggestion for now is you add a TODO to this effect, but we don't let this desired functionality block the merge.
| Indexer_t &&lambda = static_cast<Real *>(nullptr)) const; | ||
| template <typename Indexer_t = Real *> | ||
| PORTABLE_INLINE_FUNCTION void MassFractionsFromDensityTemperature( | ||
| const Real rho, const Real T, Real *scratch, | ||
| Indexer_t &&lambda = static_cast<Real *>(nullptr)) const; | ||
| template <typename Indexer_t = Real *> | ||
| PORTABLE_INLINE_FUNCTION void MassFractionsFromDensityInternalEnergy( | ||
| const Real rho, const Real sie, Real *scratch, | ||
| Indexer_t &&lambda = static_cast<Real *>(nullptr)) const; |
There was a problem hiding this comment.
Agreed, but it can wait to another PR. Maybe just add a TODO?
| bool has_mf = false; | ||
| // Need to hold the phase names for multiphase EOS | ||
| // This isn't great, but the class needs to be trivially copyable | ||
| // I've chosen something reasonable, e.g., 15 phases with 32 character names | ||
| char phase_names[480]; | ||
| int numphases = 1; |
There was a problem hiding this comment.
See my comment in eos_spiner_rho_temp
| PORTABLE_INLINE_FUNCTION void | ||
| SpinerEOSDependsRhoSieTransformable<TransformerT>::MassFractionsFromDensityTemperature( | ||
| const Real rho, const Real T, Real *scratch, Indexer_t &&lambda) const { | ||
| if (!has_mf) { | ||
| *scratch = 1.0; | ||
| return; | ||
| } | ||
| const Real lRho = spiner_common::to_log(rho, lRhoOffset_); | ||
| const Real lT = spiner_common::to_log(T, lTOffset_); | ||
| IndexerUtils::SafeSet<IndexableTypes::LogDensity>(lambda, Lambda::lRho, lRho); | ||
| DataBox mf1d(scratch, numphases); | ||
| mf1d.interpFromDB(mF_, lRho, lT); | ||
| } | ||
|
|
||
| template <template <class> class TransformerT> | ||
| template <typename Indexer_t> | ||
| PORTABLE_INLINE_FUNCTION void | ||
| SpinerEOSDependsRhoSieTransformable<TransformerT>::MassFractionsFromDensityInternalEnergy( | ||
| const Real rho, const Real sie, Real *scratch, Indexer_t &&lambda) const { | ||
| if (!has_mf) { | ||
| *scratch = 1.0; | ||
| return; | ||
| } | ||
| const Real lRho = spiner_common::to_log(rho, lRhoOffset_); | ||
| const Real lE = spiner_common::to_log(sie, lEOffset_); | ||
| const Real T = T_.interpToReal(lRho, lE); | ||
| const Real lT = spiner_common::to_log(T, lTOffset_); | ||
| DataBox mf1d(scratch, numphases); | ||
| mf1d.interpFromDB(mF_, lRho, lT); | ||
| } |
There was a problem hiding this comment.
See my comment in eos_spiner_rho_temp
| return H5Gopen(file, name, property); | ||
| } | ||
|
|
||
| inline void h5_safe_read_string(hid_t &file, const char *grp, const char *name, |
There was a problem hiding this comment.
I'm not sure how much this matters, given who would stick a string in a dataset, but perhaps name this h5_safe_read_str_attr or something? Just to emphasize it's an attribute?
| } | ||
| // We have to allocate sadly | ||
| char *tmp = new char[strlen + 1]; | ||
| std::memset(tmp, 0, strlen + 1); |
There was a problem hiding this comment.
I would prefer not to do the temporary allocation this way. I have a comment in the spiner EOS constructor about how you could do something evil with char* and actually return the pointer to memory allocated here. But if you don't choose to go down that route, why not this?
std::vector<char> tmp(0, strlen + 1);and then you pass in tmp.data() as needed and RAII takes care of cleanup
PR Summary
This adds the mass fraction SESAME table to the spiner tables that sesame2spiner outputs (if it exists). Tested in a downstream code.
Putting this up now for an initial review.
I still need to add the mass fractions to the spiner EOS class. Are we okay with adding new
MassFractionFromDensityTemperaturefunctions to all EOS classes?Still TODO:
PR Checklist
make formatcommand after configuring withcmake.If preparing for a new release, in addition please check the following: