Solution (source code)

= Solution

The room's nearly motionless upper reservoir has interface $z_i=H-h$. A doorway roof at height $D$ has available light-layer head $\delta=D-z_i=h-(H-D)>0$. Evaluate the <Bernoulli equation> in the room and at a freely controlled doorway: $E=-g'z_i$ upstream and $E=3g'h_c/2-g'D$ at its critical section. Therefore $h_c=2\delta/3$ and
$$
\boxed{Q=\left(\frac23\right)^{3/2}W_0\sqrt{g'}\,[h-(H-D)]^{3/2}.}
$$
This is the ideal <broad-crested weir> law, not a small-orifice law with $C_d$. A nonideal doorway would require its own measured loss correction.

When the floor heat source is on, <volume conservation> and <buoyancy flux> conservation still give $Q=B_0^{1/3}z_i^{5/3}/\gamma$ and $g'=\gamma B_0^{2/3}z_i^{-5/3}$. Combine these with the doorway relation to obtain the <plume-fed doorway ventilation> equilibrium:
$$
\boxed{z_i^5=\frac8{27}\gamma^3W_0^2(D-z_i)^3,\quad 0<z_i<D,\qquad
h=H-z_i,\quad \Delta\rho=\frac{\rho_0\gamma}{g}B_0^{2/3}z_i^{-5/3}.}
$$
There is one interface-height root in the indicated interval. The result is physically appropriate only if its upper outflow is thin enough for the one-layer doorway model to remain valid.

If $D<H$, air in the volume above the doorway is part of the upper thermal reservoir and can store heat and alter transients. But its extra depth $H-D$ does not add available head at the doorway: only $D-z_i$ enters the critical condition. In the steady ideal well-mixed model it shares the same density as the outflow. Treating the whole $h$ as the doorway head would overestimate discharge.