flow.energy_imbalance

flow.energy_imbalance(
    temperature,
    chi,
    velocity,
    power,
    config,
    wall=None,
    density=1.0,
)

What the steady solve fails to conserve, as a fraction of the power.

At steady state every watt put into the solid must leave through a boundary. This is the strongest check available without an analytic answer, because it is independent of the geometry and of the flow field’s accuracy: summing the discrete equations over every solved cell makes each interior face cancel against itself exactly – the coefficient P gives E and the flux P sends E telescope whatever the mass flux is doing – so what remains is the inlet plane, the outlet plane, and the source. A conservative scheme therefore satisfies this to the linear solver’s tolerance for any design and any velocity field, and a residual above that means the assembly is wrong, not that the flow is.

Both ends of the duct have to be counted in full, and that is the part it is easy to get wrong. The outlet carries enthalpy out at the cell’s own temperature. The inlet does two things: it carries enthalpy in at the first cell’s temperature, and it conducts heat back out upstream, through the same 2k half-cell conductance the assembly uses. Counting only “mass flux times inlet temperature” ignores both corrections and reports a couple of percent of spurious imbalance on a duct where the scheme is in fact conserving to round-off.

Parameters

Name Type Description Default
temperature jax.Array (NX, NY, NZ) temperature field. required
chi jax.Array Solid fraction, (NX, NY, NZ) – the conductivity the inlet conductance is built from. required
velocity jax.Array (3, NX, NY, NZ) velocity field. required
power Any Total power injected. required
config EnergyConfig The energy configuration. required
wall np.ndarray | None Boolean duct-wall mask, or None to build the default. None
density Any Density field or scalar, forming the mass flux. Must be the one the solve was assembled with. 1.0

Returns

Name Type Description
jax.Array Scalar (what leaves - what enters - power) / power.