lanl / lanl/singularity-eos

`CheckRhoSieFromPT` is a bit weird

Open
#562 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

discussion Robustness Testing
Dominant language
C++
Stars
39
Forks
22
Avg merge
10h 22m
Merged PRs (30d)
3

Description

The subroutine in question is:

template <typename EOS, typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION bool
CheckRhoSieFromPT(EOS eos, Real rho, Real T,
                  Indexer_t &&lambda = static_cast<Real *>(nullptr)) {
  const Real P = eos.PressureFromDensityTemperature(rho, T, lambda);
  const Real sie = eos.InternalEnergyFromDensityTemperature(rho, T, lambda);
  Real rtest = 12; // set these to something
  Real etest = 1;
  eos.DensityEnergyFromPressureTemperature(P, T, lambda, rtest, etest);
  Real P_test = eos.PressureFromDensityTemperature(rtest, T, lambda);
  Real residual = P_test - P;
  Real frac_residual =
      std::min(std::abs(singularity::robust::ratio(residual, P)), std::abs(residual));
  bool results_good = (isClose(rho, rtest, 1e-8) && isClose(sie, etest, 1e-8))
                      // This is as good as it will get sometimes.
                      || (std::abs(frac_residual) <= 1e-8);
  if (!results_good) {
    printf("RhoSie of PT failure!\n"
           "\trho_true = %.14e\n"
           "\tsie_true = %.14e\n"
           "\tP        = %.14e\n"
           "\tT        = %.14e\n"
           "\trho      = %.14e\n"
           "\tsie      = %.14e\n"
           "\tP_test   = %.14e\n"
           "\tresidual = %.14e\n"
           "\tfracres  = %.14e\n",
           rho, sie, P, T, rtest, etest, P_test, residual, frac_residual);
  }
  return results_good;
}

As I understand it, is seems like this subroutine want to do the following. Initialize a state $(P_0, T_0)$, then to compute $\rho_0 := \rho(P_0,T_0)$ and $e_0 := e(P_0, T_0)$, and then check that the inversion is consistent $P(\rho_0, e_0) = P_0$ and $T(\rho_0, e_0) = T_0$. Basically, just check that inversion is consistent and there are no mistakes in the formula. I guess you could also start with $(\rho_0, e_0)$ and then do the reverse process.

I'm assuming the reason this might be happening this way is because certain EOS member function calls aren't available? What do we think?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing CheckRhoSieFromPT and the EOS member functions it calls. Determine which forward and inverse state conversions are available and how existing validation tests exercise them. Done means agreeing on a consistent inversion check and updating the subroutine and its tests accordingly.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
hpc
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.