Skip to content

Lagrange bubble initialization silently overwrites the user-supplied global pref #1710

Description

@sbryngelson

Summary

s_add_bubbles assigns the module-level global pref — a documented, user-settable case parameter — from the initial gas pressure of whichever Lagrangian bubble happens to be added last. The user's configured value is silently discarded.

Location

src/simulation/m_bubbles_EL.fpp:381-384

gas_p(bub_id, 1) = pliq + 2._wp*(1._wp/Web)/bub_R0(bub_id)
if (.not. f_approx_equal((1._wp/Web), 0._wp)) then
    pref = gas_p(bub_id, 1)
end if

There is no local pref in m_bubbles_EL.fpp; this writes the global declared alongside rhoref and defaulted in m_global_parameters_common.fpp:378.

Why this looks wrong

  • pref is a user input. It is registered at toolchain/mfc/params/definitions.py:739, described as "Reference pressure", documented in case.md (line 137, and line 876 as "Reference pressure for bubble models"), and required by model_eqns = 4 (definitions.py:405). Overwriting it discards a value the user set.

  • It is per-bubble, in a loop. s_add_bubbles is called once per bubble, so the surviving value is whatever the last-added bubble produced. It has no defined meaning — with one bubble it is that bubble's pressure, with a cloud it is an arbitrary member's.

  • It is read by the EOS. s_compute_pressure uses it in the four-equation Tait branch (m_variables_conversion.fpp:105):

    pres = (pref + pi_inf)*(energy/(rhoref*(1 - alf)))**(1/gamma + 1) - pi_inf

    It is also pushed to the device in the GPU_UPDATE list at m_global_parameters.fpp:916, so the overwritten value reaches GPU kernels.

  • It is conditional on surface tension. The assignment only happens when 1/Web is not approximately zero, so whether a user's pref survives depends on whether surface tension is active — a coupling with no evident justification.

Impact

Unclear, and that is the problem. Whether it currently causes wrong results depends on whether any supported configuration combines Lagrangian bubbles, nonzero surface tension, and a later consumer of pref. The four-equation model is the obvious candidate. Even where nothing reads it, a user-supplied parameter being silently replaced is a trap.

How this surfaced

While reviewing #1709. That PR corrects pliq by including the qv term, which changes gas_p, which changes whatever pref gets overwritten with. The fix is right on its own terms, but it made this assignment visible.

Suggested direction

If the intent is a bubble-model reference pressure derived from initial conditions, it should be its own module variable with a name that says so, not the user-facing pref. If the intent is to honour a user-supplied pref, this assignment should be deleted. Either way it should not depend on whether surface tension is enabled.

Flagging rather than fixing, since the intent is not recoverable from the code and the right resolution depends on what the EL model is supposed to do here.

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