  The study of open quantum systems often relies on approximate master
equations derived under the assumptions of weak coupling to the environment.
However when the system is made of several interacting subsystems such a
derivation is in many cases very hard. An alternative method, employed
especially in the modelling of transport in mesoscopic systems, consists in
using {\it local} master equations containing Lindblad operators acting locally
only on the corresponding subsystem. It has been shown that this approach
however generates inconsistencies with the laws of thermodynamics. In this
paper we demonstrate that using a microscopic model of local master equations
based on repeated collisions all thermodynamic inconsistencies can be resolved
by correctly taking into account the breaking of global detailed balance
related to the work cost of maintaining the collisions. We provide examples
based on a chain of quantum harmonic oscillators whose ends are connected to
thermal reservoirs at different temperatures. We prove that this system behaves
precisely as a quantum heat engine or refrigerator, with properties that are
fully consistent with basic thermodynamics.
