  The Layzer-Irvine equation describes energy conservation for a pressure less
fluid interacting though quasi-Newtonian gravity in an expanding Universe. We
here derive a Layzer-Irvine equation for scalar field theories where the scalar
field is coupled to the matter fields, and show applications of this equation
by applying it to N-body simulations of modified gravity theories. There it can
be used as both a dynamical test of the accuracy of the solution and the
numerical implementation when solving the equation of motion. We also present
an equation that can be used as a new static test for an arbitrary matter
distribution. This allows us to test the N- body scalar field solver using a
matter distribution which resembles what we actually encounter in numerical
simulations.
