  The correspondence between the thermodynamic energy equation satisfied by a
closed co-moving volume and the conservation equation satisfied by the
energy-momentum tensor of the matter inside the co-moving volume is extended to
a more general system with an arbitrary cosmological horizon and a heat source.
The energy of the system consisting of a cosmological horizon and its internal
matter could be conserved by defining a surface energy on the horizons.
Therefore, energy conservation and energy-momentum tensor conservation can
always be consistent for such a system. On the other hand, from the perspective
of classical thermodynamics, one can define an effective pressure at the
cosmological horizon to guarantee that the thermodynamic energy equation inside
the horizon is consistent with the energy-momentum tensor conservation equation
of the matter inside the horizon. These systems can satisfy the generalized
second law of thermodynamics under appropriate conditions. The definitions of
the surface energy and the effective pressure are extended to the gravity
theory with non-minimal coupling between geometry and matter, in which geometry
could be regarded as a heat source.
