  We derive, using the spherical collapse model, a generalized Layzer-Irvine
equation which can be used to describe the gravitational collapse of cold dark
matter in a dark energy background. We show that the usual Layzer-Irvine
equation is valid if the dark matter and the dark energy are minimally coupled
to each other and the dark energy distribution is homogeneous, independently of
its equation of state. We compute the corrections to the standard Layzer-Irvine
equation which arise in the presence of dark energy inhomogeneities. We show
that, in the case of a dark energy component with a constant equation of state
parameter consistent with the latest observational constraints, these
corrections are expected to be small, even if the dark energy has a negligible
sound speed. However, we find that, in more general models, the impact of dark
energy perturbations on the dynamics of clusters of galaxies, which will be
constrained by ESA's Euclid mission with unprecedented precision, might be
significant.
