Pressure of a system of particles

I'll derive the pressure of a system of particles, which would be used in a MD simulation for example, according to Allen's *Computer Simulation of Liquids* and show where my issue is.


Consider a Hamiltonian system with $N$ interacting particles and generalized coordinates $q\_k$. The virial theorem is:


$$ 
\langle q\_k \frac{\partial H}{\partial q\_k} \rangle = kT
$$


This implies that 


$$ 
\frac{1}{3} \langle \sum\_i \mathbf{r}\_i \cdot \mathbf{f}\_i^{tot} \rangle = NkT
$$


where $\mathbf{f}\_i^{tot}$ is the total force including interparticle and external forces. So we can split this force into *internal* and *external* contributions, $\mathbf{f}\_i^{tot} = \mathbf{f}\_i^{ext} + \mathbf{f}\_i^{int}$. The external part of the force defines the pressure on the system via


$$ 
\frac{1}{3} \langle \sum\_i \mathbf{r}\_i \cdot \mathbf{f}\_i^{ext} \rangle = -PV
$$


* What is the reasoning behind this equation?
* Why does the sum of dot products between particle position vectors and external forces equal $-PV$?


