Virial theorem and variational method: a question I have an hydrogenic atom, knowing that its ground-state wavefunction has the standard form 
$$
\psi = A e^{-\beta r} 
$$
with $A = \frac{\beta^3}{\pi}$, I have to find the best value for $\beta$ (using the variational method). After having included the Darwin correction 
$$
H_D = D\delta(r)
$$
with $D = \frac{\alpha^2\pi Z}{2}$, into the Hamiltonian 
$$
H_0 = -\frac12\nabla^2-\frac{Z}{r}
$$
I calculated 
$$\langle\psi(\beta)|-\frac{\nabla^2}{2}|\psi(\beta)\rangle  = \langle \psi(\beta)|T|\psi(\beta)\rangle  = \frac{\beta^2}{2}$$
 then I thought to use the virial theorem to calculate the part $\langle V\rangle $:
$$
\langle \psi(\beta)|-\frac{Z}{r}|\psi(\beta)\rangle  = \langle \psi(\beta)|V|\psi(\beta)\rangle  = -2\langle \psi(\beta)|T|\psi(\beta)\rangle  = -\beta^2
$$
with the Darwin part left to be easily calculated.
Looking at the solutions that my professor wrote, I've just found a different result:

$$\langle V\rangle  = \langle \psi(\beta)|-\frac{Z}{r}|\psi(\beta)\rangle  = \frac{Z}{\beta}\langle \psi(\beta)|-\frac{\beta}{r}|\psi(\beta)\rangle  = -2\frac{Z}{\beta}\frac{\beta^2}{2} = -\beta Z$$

Why's that? Is this somehow related to the fact that I'm going to use the variational method later? Please, help me understand.
 A: In summary, you can either find a $|\psi\rangle$ that solves the schrodinger equation (and hence the virial theorem) or does not solve the schrodinger equation and then minimize $E(\beta)=\langle \psi(\beta)|H|\psi(\beta)\rangle$. 
If you've solved the schrodinger equation then there is nothing to minimize. If you have guessed the right functional form of $|\psi(\beta)\rangle$ then that function will solve the schrodinger equation only at the minimum value $E(\beta)$.
What you have is (ignoring the constant $A$ for now) the right functional form of $|\psi(\beta)\rangle$ which does not satisfy the conditions the virial theorem for all values of $\beta$ because it does not solve the schrodinger equation for all values of $\beta$. We can illustrate this last point.
Calculating $H|\psi\rangle$ for arbitrary $\beta$ (and ignoring the darwin term),
$$H|\psi\rangle= \left(\frac{\beta}{r}-\frac{\beta^2}{2}-\frac{Z}{r}\right)|\psi\rangle$$
(up to a multiplicative constant.) Since $E$ must be independent of $r$ we find that $\beta$ must equal $Z$. This is what you've found by demanding that the virial theorem holds. This leaves you with the familiar result that 
$$E=-\frac{Z^2}{2}.$$
Notice that if you try to apply the virial theorem and then the variational method, the total energy $E(\beta) \sim -\beta^2$, which as you can see is unbounded from below. You can't minimize this! Your professor's approach is correct -- show yourself that you can minimize $\langle T \rangle + \langle V \rangle$ to conclude that $\beta = Z$.
