Skip to content

post_process gas internal energy diagnostic drops pi_inf and qv, and hard-codes fluid 2 #1781

Description

@sbryngelson

s_write_energy_data_file (src/post_process/m_data_output.fpp:1238) accumulates the gas internal
energy as

Egint = Egint + q_prim_vf(eqn_idx%E + 2)%sf(i, j, k)*(gammas(2)*pres)*dV

The shared operator for exactly this quantity is

f_phase_internal_energy(pres, alpha, alpha_rho, gamma, pi_inf, qv) = alpha*(gamma*pres + pi_inf) + alpha_rho*qv

so the diagnostic drops both the alpha*pi_inf term and the alpha_rho*qv term, and hard-codes
fluid 2 rather than deriving which phase it means.

Consequences:

  • Correct only when fluid 2 has pi_inf == 0 and qv == 0. For a stiffened-gas or an energetic
    phase in slot 2, the reported gas internal energy is wrong by alpha_2*pi_inf_2 + alpha_rho_2*qv_2.
  • Silently wrong if a case orders its fluids differently, since nothing checks that fluid 2 is the
    gas. The variable name Egint is the only thing asserting it.

This is written output rather than solver state, so it does not affect the evolution - the same class
as #1773.

Suggested fix: call f_phase_internal_energy with fluid 2's coefficients, which restores the two
missing terms and makes the phase choice explicit at the call site. If fluid 2 really is a required
convention here, it deserves a comment saying so, or a validator rule.

Found while sweeping for the last equation-of-state expressions still written by hand for #1762 /
#1638. Two others remain, and both look deliberate rather than defective: the Tait isentrope applied
inline at m_riemann_solver_hllc.fpp:406-408, and the mixture-coefficient time derivative at
m_cbc.fpp:848-850.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions