Solution (source code)

= Solution

The density has the form
$$
\rho=C r^{p-2}\Psi^{2p+1},
\qquad
\beta=1-\frac p2.
$$
Insert the ansatz $\sigma_r^2=k\Psi$ into the <Spherical Jeans equation>
$$
\frac{d(\rho\sigma_r^2)}{dr}
+\frac{2\beta}{r}\rho\sigma_r^2
=\rho\frac{d\Psi}{dr}.
$$
The radial-power derivative cancels the anisotropy term because $p-2+2\beta=0$, leaving $k(2p+2)=1$. Thus
$$
\boxed{
\sigma_r^2=\frac{\Psi}{2(p+1)},
\qquad
\sigma_\theta^2=\sigma_\phi^2
=\frac{p\Psi}{4(p+1)}}.
$$
Their sum is independent of $p$:
$$
\langle v^2\rangle
=\sigma_r^2+\sigma_\theta^2+\sigma_\phi^2
=\frac\Psi2=-\frac\Phi2.
$$
Therefore the local kinetic-energy density and gravitational potential-energy density are
$$
K=\frac12\rho\langle v^2\rangle=-\frac14\rho\Phi,
\qquad
W=\frac12\rho\Phi,
$$
and they satisfy the <local virial relation of the hypervirial model>
$$
\boxed{2K+W=0}
$$
at every radius. This pointwise identity is not generic. The ordinary <virial theorem> constrains suitable global integrals, with boundary terms when the system is truncated, but does not normally impose a virial balance shell by shell.