Solution (source code)

= Solution

For the <barotropic equation of state> $P=w\rho$, the continuity equation separates as
$$
\frac{d\rho}{\rho}=-3(1+w)\frac{da}{a}.
$$
Since $a(t_0)=1$,
$$
\rho=\rho_0a^{-3(1+w)},
\qquad \rho_0=\rho(t_0),
$$
which is the <constant-equation-of-state density scaling>.

When $Q=0$, the expanding branch satisfies
$$
\dot a=\sqrt{\frac{8\pi G\rho_0}{3c^2}}
 a^{-(1+3w)/2}=H_0a^{-(1+3w)/2},
$$
where $H_0=\dot a(t_0)>0$. Because $w>-1$, integration gives
$$
a(t)^{3(1+w)/2}
=1+\frac32(1+w)H_0(t-t_0),
$$
and hence the <flat constant-equation-of-state scale factor>
$$
\boxed{
a(t)=\left[1+\frac32(1+w)H_0(t-t_0)\right]^{2/[3(1+w)]}
}.
$$
It vanishes at
$$
\boxed{t_*=t_0-\frac{2}{3(1+w)H_0}<t_0},
$$
as $|w|<1$ ensures $1+w>0$.