From 76f06d5c7f05f9375386ece54717800b17ca181a Mon Sep 17 00:00:00 2001 From: Jonah Miller Date: Wed, 17 Sep 2025 14:58:47 -0400 Subject: [PATCH 1/2] Change search region for spiner --- singularity-eos/eos/eos_spiner_rho_sie.hpp | 10 ++++--- singularity-eos/eos/eos_spiner_rho_temp.hpp | 30 +++++++++------------ 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/singularity-eos/eos/eos_spiner_rho_sie.hpp b/singularity-eos/eos/eos_spiner_rho_sie.hpp index 8c0a035b042..3364d43aac6 100644 --- a/singularity-eos/eos/eos_spiner_rho_sie.hpp +++ b/singularity-eos/eos/eos_spiner_rho_sie.hpp @@ -769,6 +769,8 @@ SpinerEOSDependsRhoSieTransformable::lRhoFromPlT_( const RootFinding1D::RootCounts *pcounts = (memoryStatus_ == DataStatus::OnDevice) ? nullptr : &counts; RootFinding1D::Status status = RootFinding1D::Status::SUCCESS; + const Real rhopmin = rho_at_pmin_.interpToReal(lT); + Real lRho; Real dPdRhoMax = dPdRhoMax_.interpToReal(lT); Real PMax = PlRhoMax_.interpToReal(lT); @@ -779,14 +781,14 @@ SpinerEOSDependsRhoSieTransformable::lRhoFromPlT_( pcounts->increment(0); } } else { - Real lRhoGuess = reproducible_ ? lRhoMin_ : 0.5 * (lRhoMin_ + lRhoMax_); + Real lRhoGuess = reproducible_ ? lRhoMax_ : 0.5 * (rhopmin + lRhoMax_); Real lRho_cache; IndexerUtils::SafeGet(lambda, Lambda::lRho, lRho_cache); - if ((lRhoMin_ <= lRho_cache) && (lRho_cache <= lRhoMax_)) { + if ((rhopmin <= lRho_cache) && (lRho_cache <= lRhoMax_)) { lRhoGuess = lRho_cache; } const callable_interp::l_interp PFunc(dependsRhoT_.P, lT); - status = SP_ROOT_FINDER(PFunc, P, lRhoGuess, lRhoMin_, lRhoMax_, robust::EPS(), + status = SP_ROOT_FINDER(PFunc, P, lRhoGuess, rhopmin, lRhoMax_, robust::EPS(), robust::EPS(), lRho, pcounts); if (status != RootFinding1D::Status::SUCCESS) { #if SPINER_EOS_VERBOSE @@ -798,7 +800,7 @@ SpinerEOSDependsRhoSieTransformable::lRhoFromPlT_( << "lRhoGuess = " << lRhoGuess << std::endl; EOS_ERROR(errorMessage.str().c_str()); #endif // SPINER_EOS_VERBOSE - lRho = reproducible_ ? lRhoMin_ : lRhoGuess; + lRho = reproducible_ ? lRhoMax_ : lRhoGuess; } } IndexerUtils::SafeSet(lambda, Lambda::lRho, lRho); diff --git a/singularity-eos/eos/eos_spiner_rho_temp.hpp b/singularity-eos/eos/eos_spiner_rho_temp.hpp index 3015fbd7a55..e34da79a1e0 100644 --- a/singularity-eos/eos/eos_spiner_rho_temp.hpp +++ b/singularity-eos/eos/eos_spiner_rho_temp.hpp @@ -312,7 +312,6 @@ class SpinerEOSDependsRhoT : public EosBase { int numRho_, numT_; Real lRhoMin_, lRhoMax_, rhoMax_; - Real lRhoMinSearch_; Real lTMin_, lTMax_, TMax_; Real PMin_; Real rhoNormal_, TNormal_, sieNormal_, PNormal_; @@ -494,9 +493,6 @@ inline herr_t SpinerEOSDependsRhoT::loadDataboxes_(const std::string &matid_str, TMax_ = from_log(lTMax_, lTOffset_); Real rhoMin = from_log(lRhoMin_, lRhoOffset_); - Real rhoMinSearch = std::max( - rhoMin, std::max(std::abs(robust::EPS()) * 10, std::abs(robust::EPS() * rhoMin))); - lRhoMinSearch_ = to_log(rhoMinSearch, lRhoOffset_); // bulk modulus can be wrong in the tables. Use FLAG's approach to // fix the table. @@ -920,40 +916,38 @@ template PORTABLE_INLINE_FUNCTION Real SpinerEOSDependsRhoT::lRhoFromPlT_( const Real P, const Real lT, TableStatus &whereAmI, Indexer_t &&lambda) const { RootFinding1D::Status status = RootFinding1D::Status::SUCCESS; + Real rhopmin = rho_at_pmin_.interpToReal(lT); Real lRho; - Real lRhoGuess = reproducible_ ? lRhoMax_ : 0.5 * (lRhoMin_ + lRhoMax_); + Real lRhoGuess = reproducible_ ? lRhoMax_ : 0.5 * (rhopmin + lRhoMax_); // Real lRhoGuess = lRhoMin_ + 0.9*(lRhoMax_ - lRhoMin_); const RootFinding1D::RootCounts *pcounts = (memoryStatus_ == DataStatus::OnDevice) ? nullptr : &counts; Real lRho_cache; IndexerUtils::SafeGet(lambda, Lambda::lRho, lRho_cache); - if ((lRhoMin_ <= lRho_cache) && (lRho_cache <= lRhoMax_)) { + if ((rhopmin <= lRho_cache) && (lRho_cache <= lRhoMax_)) { lRhoGuess = lRho_cache; } if (lT <= lTMin_) { // cold curve whereAmI = TableStatus::OffBottom; const callable_interp::interp PFunc(PCold_); - status = - SP_ROOT_FINDER(PFunc, P, lRhoGuess, - // lRhoMin_, lRhoMax_, - lRhoMinSearch_, lRhoMax_, ROOT_THRESH, ROOT_THRESH, lRho, pcounts); + status = SP_ROOT_FINDER(PFunc, P, lRhoGuess, + // lRhoMin_, lRhoMax_, + rhopmin, lRhoMax_, ROOT_THRESH, ROOT_THRESH, lRho, pcounts); } else if (lT >= lTMax_) { // ideal gas whereAmI = TableStatus::OffTop; const callable_interp::prod_interp_1d PFunc(gm1Max_, dEdTMax_, lT); - status = - SP_ROOT_FINDER(PFunc, P, lRhoGuess, - // lRhoMin_, lRhoMax_, - lRhoMinSearch_, lRhoMax_, ROOT_THRESH, ROOT_THRESH, lRho, pcounts); + status = SP_ROOT_FINDER(PFunc, P, lRhoGuess, + // lRhoMin_, lRhoMax_, + rhopmin, lRhoMax_, ROOT_THRESH, ROOT_THRESH, lRho, pcounts); } else { // on table whereAmI = TableStatus::OnTable; const callable_interp::l_interp PFunc(P_, lT); - status = - SP_ROOT_FINDER(PFunc, P, lRhoGuess, - // lRhoMin_, lRhoMax_, - lRhoMinSearch_, lRhoMax_, ROOT_THRESH, ROOT_THRESH, lRho, pcounts); + status = SP_ROOT_FINDER(PFunc, P, lRhoGuess, + // lRhoMin_, lRhoMax_, + rhopmin, lRhoMax_, ROOT_THRESH, ROOT_THRESH, lRho, pcounts); } if (status != RootFinding1D::Status::SUCCESS) { #if SPINER_EOS_VERBOSE From 55683164eae3d1d94dc795c482e1957ab4802ee3 Mon Sep 17 00:00:00 2001 From: Jonah Miller Date: Wed, 17 Sep 2025 15:29:04 -0400 Subject: [PATCH 2/2] Fix issue where we weren't taking the log --- singularity-eos/eos/eos_spiner_rho_sie.hpp | 2 +- singularity-eos/eos/eos_spiner_rho_temp.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/singularity-eos/eos/eos_spiner_rho_sie.hpp b/singularity-eos/eos/eos_spiner_rho_sie.hpp index 3364d43aac6..4eed94e7ae9 100644 --- a/singularity-eos/eos/eos_spiner_rho_sie.hpp +++ b/singularity-eos/eos/eos_spiner_rho_sie.hpp @@ -769,7 +769,7 @@ SpinerEOSDependsRhoSieTransformable::lRhoFromPlT_( const RootFinding1D::RootCounts *pcounts = (memoryStatus_ == DataStatus::OnDevice) ? nullptr : &counts; RootFinding1D::Status status = RootFinding1D::Status::SUCCESS; - const Real rhopmin = rho_at_pmin_.interpToReal(lT); + const Real rhopmin = spiner_common::to_log(rho_at_pmin_.interpToReal(lT), lRhoOffset_); Real lRho; Real dPdRhoMax = dPdRhoMax_.interpToReal(lT); diff --git a/singularity-eos/eos/eos_spiner_rho_temp.hpp b/singularity-eos/eos/eos_spiner_rho_temp.hpp index e34da79a1e0..79332d90e5a 100644 --- a/singularity-eos/eos/eos_spiner_rho_temp.hpp +++ b/singularity-eos/eos/eos_spiner_rho_temp.hpp @@ -916,7 +916,7 @@ template PORTABLE_INLINE_FUNCTION Real SpinerEOSDependsRhoT::lRhoFromPlT_( const Real P, const Real lT, TableStatus &whereAmI, Indexer_t &&lambda) const { RootFinding1D::Status status = RootFinding1D::Status::SUCCESS; - Real rhopmin = rho_at_pmin_.interpToReal(lT); + Real rhopmin = lRho_(rho_at_pmin_.interpToReal(lT)); Real lRho; Real lRhoGuess = reproducible_ ? lRhoMax_ : 0.5 * (rhopmin + lRhoMax_);