Solution (source code)

= Solution

The radial velocity and <velocity potential> are
$$
u(r,t)=\frac{Q(t)}{4\pi r^2},
\qquad
\phi(r,t)=-\frac{Q(t)}{4\pi r}.
$$
Choose the gauge in the <Unsteady Bernoulli equation> by evaluating it at infinity, where $u=0$, $\phi=0$, and $p=p_0$:
$$
\phi_t+\frac12u^2+\frac p\rho=\frac{p_0}\rho.
$$
At the cavity surface the vacuum pressure is zero, and the <kinematic boundary condition> gives $u(a,t)=\dot a$. Since
$$
\phi_t(a,t)=-\frac1{4\pi a}\frac{dQ}{dt},
$$
Bernoulli's equation becomes
$$
-\frac1{4\pi a}\frac{dQ}{dt}
+\frac{\dot a^2}{2}
=\frac{p_0}{\rho}.
$$
Therefore
$$
\boxed{
\frac1{4\pi a}\frac{dQ}{dt}
-\frac{\dot a^2}{2}
=-\frac{p_0}{\rho}
}.
$$