Skip to content

Commit 69f3c6f

Browse files
Change search region for spiner (#566)
* Change search region for spiner * Fix issue where we weren't taking the log --------- Co-authored-by: Jonah Miller <jonahm@lanl.gov>
1 parent d850d0c commit 69f3c6f

2 files changed

Lines changed: 18 additions & 22 deletions

File tree

singularity-eos/eos/eos_spiner_rho_sie.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ SpinerEOSDependsRhoSieTransformable<TransformerT>::lRhoFromPlT_(
769769
const RootFinding1D::RootCounts *pcounts =
770770
(memoryStatus_ == DataStatus::OnDevice) ? nullptr : &counts;
771771
RootFinding1D::Status status = RootFinding1D::Status::SUCCESS;
772+
const Real rhopmin = spiner_common::to_log(rho_at_pmin_.interpToReal(lT), lRhoOffset_);
773+
772774
Real lRho;
773775
Real dPdRhoMax = dPdRhoMax_.interpToReal(lT);
774776
Real PMax = PlRhoMax_.interpToReal(lT);
@@ -779,14 +781,14 @@ SpinerEOSDependsRhoSieTransformable<TransformerT>::lRhoFromPlT_(
779781
pcounts->increment(0);
780782
}
781783
} else {
782-
Real lRhoGuess = reproducible_ ? lRhoMin_ : 0.5 * (lRhoMin_ + lRhoMax_);
784+
Real lRhoGuess = reproducible_ ? lRhoMax_ : 0.5 * (rhopmin + lRhoMax_);
783785
Real lRho_cache;
784786
IndexerUtils::SafeGet<IndexableTypes::LogDensity>(lambda, Lambda::lRho, lRho_cache);
785-
if ((lRhoMin_ <= lRho_cache) && (lRho_cache <= lRhoMax_)) {
787+
if ((rhopmin <= lRho_cache) && (lRho_cache <= lRhoMax_)) {
786788
lRhoGuess = lRho_cache;
787789
}
788790
const callable_interp::l_interp PFunc(dependsRhoT_.P, lT);
789-
status = SP_ROOT_FINDER(PFunc, P, lRhoGuess, lRhoMin_, lRhoMax_, robust::EPS(),
791+
status = SP_ROOT_FINDER(PFunc, P, lRhoGuess, rhopmin, lRhoMax_, robust::EPS(),
790792
robust::EPS(), lRho, pcounts);
791793
if (status != RootFinding1D::Status::SUCCESS) {
792794
#if SPINER_EOS_VERBOSE
@@ -798,7 +800,7 @@ SpinerEOSDependsRhoSieTransformable<TransformerT>::lRhoFromPlT_(
798800
<< "lRhoGuess = " << lRhoGuess << std::endl;
799801
EOS_ERROR(errorMessage.str().c_str());
800802
#endif // SPINER_EOS_VERBOSE
801-
lRho = reproducible_ ? lRhoMin_ : lRhoGuess;
803+
lRho = reproducible_ ? lRhoMax_ : lRhoGuess;
802804
}
803805
}
804806
IndexerUtils::SafeSet<IndexableTypes::LogDensity>(lambda, Lambda::lRho, lRho);

singularity-eos/eos/eos_spiner_rho_temp.hpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ class SpinerEOSDependsRhoT : public EosBase<SpinerEOSDependsRhoT> {
312312

313313
int numRho_, numT_;
314314
Real lRhoMin_, lRhoMax_, rhoMax_;
315-
Real lRhoMinSearch_;
316315
Real lTMin_, lTMax_, TMax_;
317316
Real PMin_;
318317
Real rhoNormal_, TNormal_, sieNormal_, PNormal_;
@@ -494,9 +493,6 @@ inline herr_t SpinerEOSDependsRhoT::loadDataboxes_(const std::string &matid_str,
494493
TMax_ = from_log(lTMax_, lTOffset_);
495494

496495
Real rhoMin = from_log(lRhoMin_, lRhoOffset_);
497-
Real rhoMinSearch = std::max(
498-
rhoMin, std::max(std::abs(robust::EPS()) * 10, std::abs(robust::EPS() * rhoMin)));
499-
lRhoMinSearch_ = to_log(rhoMinSearch, lRhoOffset_);
500496

501497
// bulk modulus can be wrong in the tables. Use FLAG's approach to
502498
// fix the table.
@@ -920,40 +916,38 @@ template <typename Indexer_t>
920916
PORTABLE_INLINE_FUNCTION Real SpinerEOSDependsRhoT::lRhoFromPlT_(
921917
const Real P, const Real lT, TableStatus &whereAmI, Indexer_t &&lambda) const {
922918
RootFinding1D::Status status = RootFinding1D::Status::SUCCESS;
919+
Real rhopmin = lRho_(rho_at_pmin_.interpToReal(lT));
923920

924921
Real lRho;
925-
Real lRhoGuess = reproducible_ ? lRhoMax_ : 0.5 * (lRhoMin_ + lRhoMax_);
922+
Real lRhoGuess = reproducible_ ? lRhoMax_ : 0.5 * (rhopmin + lRhoMax_);
926923
// Real lRhoGuess = lRhoMin_ + 0.9*(lRhoMax_ - lRhoMin_);
927924
const RootFinding1D::RootCounts *pcounts =
928925
(memoryStatus_ == DataStatus::OnDevice) ? nullptr : &counts;
929926

930927
Real lRho_cache;
931928
IndexerUtils::SafeGet<IndexableTypes::LogDensity>(lambda, Lambda::lRho, lRho_cache);
932-
if ((lRhoMin_ <= lRho_cache) && (lRho_cache <= lRhoMax_)) {
929+
if ((rhopmin <= lRho_cache) && (lRho_cache <= lRhoMax_)) {
933930
lRhoGuess = lRho_cache;
934931
}
935932

936933
if (lT <= lTMin_) { // cold curve
937934
whereAmI = TableStatus::OffBottom;
938935
const callable_interp::interp PFunc(PCold_);
939-
status =
940-
SP_ROOT_FINDER(PFunc, P, lRhoGuess,
941-
// lRhoMin_, lRhoMax_,
942-
lRhoMinSearch_, lRhoMax_, ROOT_THRESH, ROOT_THRESH, lRho, pcounts);
936+
status = SP_ROOT_FINDER(PFunc, P, lRhoGuess,
937+
// lRhoMin_, lRhoMax_,
938+
rhopmin, lRhoMax_, ROOT_THRESH, ROOT_THRESH, lRho, pcounts);
943939
} else if (lT >= lTMax_) { // ideal gas
944940
whereAmI = TableStatus::OffTop;
945941
const callable_interp::prod_interp_1d PFunc(gm1Max_, dEdTMax_, lT);
946-
status =
947-
SP_ROOT_FINDER(PFunc, P, lRhoGuess,
948-
// lRhoMin_, lRhoMax_,
949-
lRhoMinSearch_, lRhoMax_, ROOT_THRESH, ROOT_THRESH, lRho, pcounts);
942+
status = SP_ROOT_FINDER(PFunc, P, lRhoGuess,
943+
// lRhoMin_, lRhoMax_,
944+
rhopmin, lRhoMax_, ROOT_THRESH, ROOT_THRESH, lRho, pcounts);
950945
} else { // on table
951946
whereAmI = TableStatus::OnTable;
952947
const callable_interp::l_interp PFunc(P_, lT);
953-
status =
954-
SP_ROOT_FINDER(PFunc, P, lRhoGuess,
955-
// lRhoMin_, lRhoMax_,
956-
lRhoMinSearch_, lRhoMax_, ROOT_THRESH, ROOT_THRESH, lRho, pcounts);
948+
status = SP_ROOT_FINDER(PFunc, P, lRhoGuess,
949+
// lRhoMin_, lRhoMax_,
950+
rhopmin, lRhoMax_, ROOT_THRESH, ROOT_THRESH, lRho, pcounts);
957951
}
958952
if (status != RootFinding1D::Status::SUCCESS) {
959953
#if SPINER_EOS_VERBOSE

0 commit comments

Comments
 (0)