Skip to content

EOSX/Con2PrimFactory: correct tabulated energy and temperature handling (Phase A) - #175

Open
jaykalinani wants to merge 10 commits into
EinsteinToolkit:devfrom
jaykalinani:eos_updates
Open

jaykalinani wants to merge 10 commits into
EinsteinToolkit:devfrom
jaykalinani:eos_updates

Conversation

@jaykalinani

Copy link
Copy Markdown
Collaborator

Summary

This is the first phase of the incremental EOS updates based on dev.
It addresses inconsistent energy bounds and temperature handling.

Tabulated EOSs can contain negative physical specific internal energy.
Treating that energy as necessarily positive, or using atmosphere energy
as a universal minimum, can alter otherwise valid thermodynamic states.

Changes

A1 — Preserve physical tabulated energy bounds

  • Remove the artificial positive minimum for physical eps.
  • Keep the energy shift confined to logarithmic interpolation.
  • Bound inverse-energy inputs at both global endpoints before taking
    log(eps + shift), retaining the existing local temperature-edge bounds.

A2 — Keep tabulated initial thermodynamics consistent

  • Bound rho, temperature and Ye to the table domain.
  • Derive pressure, eps and entropy from the same bounded state.
  • Remove independent pressure and energy floors after EOS evaluation.
  • Preserve existing atmosphere selection, density grading and incoming
    atmosphere temperature handling.
  • Report invalid EOS results through a device failure flag and host error.

A3 — Use local EOS energy bounds in Palenzuela

  • Replace the atmosphere-energy floor with the local EOS energy interval
    at the trial/recovered rho and Ye, retaining the existing use_temp gate.
  • Track clipping for conservative recomputation.
  • Accept EOS-valid negative energy while preserving the existing
    nonpositive-energy fallback policy for nonnegative EOSs.
  • Retain the existing Lorentz-factor guard.

A4 — Allow EOS-valid negative energy in RePrimAnd

  • Use h0 = 1 + min(0, eps_min) as the global enthalpy lower bound,
    assuming nonnegative pressure.
  • Reject unsupported nonfinite eps_min or eps_min <= -1.
  • Check recovered density and raw energy, and track local energy clipping.
  • Retain the existing root solver and tolerances.

A5 — Make conservative energy repair EOS-aware

  • Include the global physical-energy minimum in the tau repair trigger.
  • Query the local EOS minimum only when a repair is needed.
  • Retain tauFluid_atmo as an undensitized repair margin.
  • Skip conservative limiting after completed atmosphere/excision resets.
  • Leave the momentum-limiting formula unchanged.

Retain negative physical energies and bound inverse inputs before taking log(eps + energy_shift). Keep the shift internal to interpolation.

Add opt-in EOSX tests for shifted table bounds, temperature round trips, ideal-gas controls and active-EOS device queries.

Patch and whitespace checks passed. Compilation and runtime tests were not run, as requested.
Bound rho, temperature and Ye before deriving pressure, physical energy and table entropy. Remove independent pressure and energy floors and declare the entropy write.

Preserve the existing atmosphere selection, grading and non-finite-temperature fallback. Record invalid selected inputs or EOS outputs on the device and report them with CCTK_ERROR on the host after synchronization.

Add an optional read-only check of the converted grid values. Approved-patch and whitespace checks passed; no compilation or runtime tests were run.
Replace the atmosphere-energy floor with the local EOS interval in the existing temperature path. Preserve raw recovered energy, accept EOS-valid negative energy, and mark clipping for conservative recomputation without broadening the nonnegative-EOS fallback policy.

Add host-side tabulated and ideal-gas regression tests in the existing thorn test file. Preserve the pre-existing Wminus2 clamps, root tolerances and bracketing.

Approved patch and whitespace checks passed. No compilation or runtime tests were run.
Use a conservative global enthalpy lower bound instead of sampling the EOS at minimum density and forcing h0 above unity. Preserve the existing nonpositive-energy fallback for nonnegative EOSs, and accept negative physical energy within the local EOS range.

Add synthetic tabulated and ideal-gas regression cases for the root bracket, recovery, clipping, and invalid energy input. Reviewed and whitespace-checked; not compiled or run.
Screen tau using the global physical energy bound, then query the local EOS minimum only when repair is needed. Preserve valid negative energies and clarify tauFluid_atmo as an undensitized repair margin.

AsterX: skip pre-C2P limiting after atmosphere or excision resets. Add synthetic-table and ideal-gas conservative-limiter regressions, including boundary and invalid-input checks. Reviewed patch applied exactly; not compiled or run.

@acwen11 acwen11 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a generic comment

h0 = fmax(h0, CCTK_REAL(1.0) + std::numeric_limits<CCTK_REAL>::epsilon());
// For P >= 0, h >= 1 + eps_min over the entire EOS domain. Sampling
// h at rho_min is not a global bound; negative physical eps permits h < 1.
// solve checks eps_min > -1 before constructing the root function.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a generic comment, I feel like AI is leaving a lot of comments in the code referencing either the prompt or previous code that is now deleted, and that is cluttering up the code a bit. I think we should avoid leaving these comments in whenever possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants