Skip to content

Commit 39a3909

Browse files
authored
Ensure FixedT and FixedP PTE solvers use sensible uscale (#568)
* Ensure fixedT and fixedP uscale values make sense * P -> Pequil * Update changelog * Add protections gainst divide by zero for uscale
1 parent d670685 commit 39a3909

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- [[PR561]](https://github.com/lanl/singularity-eos/pull/561) Fix logic for kokkos-kernels in spackage so that it is only required for closure models on GPU
1212
- [[PR563]](https://github.com/lanl/singularity-eos/pull/563) Fixed DensityFromPressureTemperature for the Carnahan-Starling EOS.
1313
- [[PR564]](https://github.com/lanl/singularity-eos/pull/564) Fix logic for numerical vs type indices by adding safeGet(), safeSet(), safeMustGet(), and safeMustSet() helpers
14+
- [[PR568]](https://github.com/lanl/singularity-eos/pull/568) Fix bug in FixedT and FixedP PTE solvers when materials have negative energies at the initial guess
1415

1516
### Changed (changing behavior/API/variables/...)
1617

singularity-eos/closure/mixed_cell_models.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,10 +1428,12 @@ class PTESolverFixedT
14281428
// this change in volume fraction
14291429
rho[m] = robust::ratio(rhobar[m], vfrac[m]);
14301430
sie[m] = eos[m].InternalEnergyFromDensityTemperature(rho[m], Tequil, lambda[m]);
1431-
uscale += sie[m] * rho[m];
1431+
// Guess uscale from initial density guess. Make sure it's positive
1432+
uscale += std::abs(sie[m]) * rho[m];
14321433
// note the scaling of pressure
14331434
press[m] = eos[m].PressureFromDensityTemperature(rho[m], Tequil, lambda[m]);
14341435
}
1436+
uscale = std::max(uscale, 1.0e-14);
14351437
for (std::size_t m = 0; m < nmat; ++m) {
14361438
press[m] = robust::ratio(press[m], uscale);
14371439
u[m] = sie[m] * robust::ratio(rhobar[m], uscale);
@@ -1641,13 +1643,12 @@ class PTESolverFixedP
16411643
const Real Tguess = this->GetTguess();
16421644
// set the temperature normalization
16431645
Tnorm = Tguess;
1644-
// calculate u normalization as internal energy guess
1645-
uscale = 0.0;
1646+
// Assume pressure and energy scales are similar
1647+
uscale = std::max(std::abs(Pequil), 1.0e-14);
16461648
for (std::size_t m = 0; m < nmat; m++) {
16471649
// scaled initial guess for temperature is just 1
16481650
temp[m] = 1.0;
16491651
sie[m] = eos[m].InternalEnergyFromDensityTemperature(rho[m], Tguess, lambda[m]);
1650-
uscale += sie[m] * rho[m];
16511652
}
16521653

16531654
// note the scaling of the material internal energy densities

0 commit comments

Comments
 (0)