Quantum and Information Thermodynamics: A Unifying Framework based on Repeated Interactions

We expand the standard thermodynamic framework of a system coupled to a thermal reservoir by considering a stream of independently prepared units repeatedly put into contact with the system. These units can be in any nonequilibrium state and interact with the system with an arbitrary strength and duration. We show that this stream constitutes an effective resource of nonequilibrium free energy and identify the conditions under which it behaves as a heat, work or information reservoir. We also show that this setup provides a natural framework to analyze information erasure ("Landauer's principle") and feedback controlled systems ("Maxwell's demon"). In the limit of a short system-unit interaction time, we further demonstrate that this setup can be used to provide a thermodynamically sound interpretation to many effective master equations. We discuss how non-autonomously driven systems, micromasers, lasing without inversion, and the electronic Maxwell demon, can be thermodynamically analyzed within our framework. While the present framework accounts for quantum features (e.g. squeezing, entanglement, coherence), we also show that quantum resources do not offer any advantage compared to classical ones in terms of the maximum extractable work.


I. INTRODUCTION
Thermodynamics was traditionally designed to understand the laws which govern the behavior of macroscopic systems at equilibrium in terms of few macroscopic variables (e.g. temperature, pressure, chemical potential, energy, volume, particle number, etc.) containing very limited information about the microscopic state of the system. Remarkable progress has been done over the last decades to understand under which conditions the laws of thermodynamics emerge for small-scale systems where quantum and stochastic effects dominate and which are usually far away from thermal equilibrium. This includes a consistent thermodynamic framework for driven systems weakly coupled to large and fast thermal reservoirs, which are described by a microscopically derived (quantum) master equation (ME) [1][2][3][4]. Such MEs can be also used as a basis to establish universal fluctuation relations which replace the traditional second law formulated as an inequality by an exact symmetry that fluctuations must satisfy arbitrarily far from equilibrium [5][6][7][8][9]. This theory has been very successful to study small systems in a large variety of fields ranging from biophysics to electronics and many of its predictions have been verified experimentally [10][11][12][13][14][15][16].
In this paper, we extend the traditional framework of thermodynamics by considering a system which, in addition of being in contact with a thermal reservoir, interacts with a stream of external systems which we call "units". Each independently prepared unit interacts for a certain time with the system before being replaced by another one and no additional assumption about the state of the units nor the system-unit interaction is required. In the most general picture, this stream of units will be shown to constitute a resource of nonequilibrium free energy modifying the traditional energetic and entropic balances. We will study the limits in which the stream of units effectively reproduces the effect of a heat, work or information reservoir. We will also explore limits giving rise to an effective closed dynamics for the system which still allows for a consistent thermodynamic description. We will focus on the ensemble averaged description and not on fluctuations.
The benefit of our generalized thermodynamic framework is that it provides a unified perspective and encompasses many previously considered setups. In modern physics, such setups have probably first been used in quantum optics, theoretically as well as experimentally, to model a maser in which a stream of atoms is injected into a cavity in order to macroscopically populate it [31][32][33]. Such setups have also been used to stabilize photon number states via measurement based quantum feedback control [34]. In theoretical works, an "information reser- Q is the heat flowing from the reservoir at inverse temperature β = T −1 (kB ≡ 1) and W is the work done on the system. Furthermore, ΣS denotes the entropy production and IS:U the mutual information between system and unit. The picture of the Mandal-Jarzynski engine was taken from Ref. [35].
voir" made of a stream of bits was proposed to extract work from a single heat reservoir [35,36], a picture that also closely resembles a Turing machine [17,37]. The setup is also close to resource theoretic formulations of thermodynamics, in which one investigates which system transformations are possible given a set of freely available states and resources (all other states) [38,39]. Further analogies can be drawn with biomolecular motors or enzymes [11] which manipulate, e.g. nucleic acids (units) on a DNA strand, or with scattering theory where incoming and outgoing wave packets (units) interact for a short time with the scatterer (the system) [40,41].

Outline
The structure of the paper and some of its main results are summarized in Fig. 1. We start very generally in Sec. II by considering two interacting systems and review under what conditions the laws of thermodynamics can be established if one of the systems is initially in a thermal state and plays the role of the reservoir while the other is the driven system of interest. Besides establishing notation, this section also sets the basis for Sec. III, were the system now also interacts with an external stream of units. Generalized laws of thermodynamics are established which show that the stream of units effectively constitutes a resource of nonequilibrium free energy. We then consider various limiting cases in Sec. IV where the stream of units respectively behaves as a heat, work and information reservoir. Furthermore, Landauer's principle is derived as well as a quantum version of the second law of thermodynamics under feedback control. We go one step further in Sec. V by considering scenarios leading to a closed reduced dynamics for the system when tracing out the units, but where one still retains a consistent thermodynamic description. More specifically, we consider the limit of infinitesimally short interactions which are either Poissonian or regularly distributed and which lead to effective MEs. We also analyze the limit where the units effectively generate a timedependent Hamiltonian for the system. Specific models, apparently unrelated in the literature, are then analyzed within our unifying framework in the subsequent section (Sec. VI). These include the Mandal-Jarzynski engine, the micromaser, lasing without inversion where work is extracted from quantum coherence, and the electronic Maxwell demon. We finally close the paper with Sec. VII, where we first show that our generalized second law of thermodynamics does not conflict with the traditional Kelvin-Planck statement of the second law, we then prove that quantum thermodynamics offers a priori no advantages compared to classical thermodynamics within our framework, and we finally give a short summary and outlook.

I. Introduction 1
To introduce important concepts and notation, we start by considering two interacting systems X and Y , which are initially (at time t = 0) decorrelated, i.e.
Here, ρ XY denotes the density operator of the compound system X and Y whereas ρ X (ρ Y ) describes the reduced state of X (Y ). In order to make a statement about the first law of thermodynamics, we associate a Hamiltonian to the setup which we decompose as Here, 1 X (1 Y ) denotes the identity on the Hilbert space of system X (Y ), which we usually suppress to simplify notation, and H XY (t) describes the interaction between system X and Y . Furthermore, all terms can, in principle, be explicitly time-dependent. The time evolution of the compound system is governed by the Liouville-von Neumann equation which is in general correlated.
To obtain the reduced state of system X, we must trace over system Y . Using the spectral decomposition of the initial density matrix of system Y , ρ Y (0) = l p l |l Y l|, we arrive at where T kl ≡ √ p l k|U τ |l Y . The T kl are still operators in the Hilbert space of system X and fulfill the completeness relation The map Φ X (τ ) in Eq. (4) is known as a Kraus map or quantum operation and it is the most general map (preserving the density matrix properties) for a quantum system which was initially uncorrelated [42][43][44][45]. We note that the representation of Φ X in terms of the Kraus operators T kl is not unique. The energy of the compound system at any point in time is E XY (t) ≡ tr XY {H tot (t)ρ XY (t)}. Because the compound system is isolated, the dynamics is unitary and the energy change is solely due to the time dependence in the Hamiltonian and can thus be identified as work d t E XY (t) = tr XY {ρ XY (t)d t H tot (t)} ≡Ẇ (t). (6) The rate of work injectionẆ is positive if it increases the energy of the compound system. Eq. (6) is the first law of thermodynamics for an isolated system. We now consider the entropy balance by defining the von Neumann entropy of a system X, which we interpret as a measure for our lack of knowledge about the state ρ X , as usual by Because the joint von Neumann entropy S XY (t) ≡ −tr XY {ρ XY (t) ln ρ XY (t)} does not change under unitary time evolution, we have S XY (τ ) = S XY (0). We further introduce the non-negative (quantum) mutual information which measures the amount of correlations shared between X and Y [43]. For the initially decorrelated state (1) we have S XY (0) = S X (0) + S Y (0). Hence, in terms of the mutual information we can write that Thus, the mutual information tells us how the sum of the marginal entropies ∆S X (τ ) ≡ S X (τ ) − S X (0) and Introducing the relative entropy between two density matrices ρ and σ [43] D(ρ||σ) ≡ tr{ρ(ln ρ − ln σ)} ≥ 0 (10) which is non-negative by Klein's inequality, the mutual information can also be written as By measuring the local entropy changes in X and Y , the mutual information is therefore also a measure of the information lost when disregarding the correlation established over time t between X and Y while keeping full knowledge of X and of Y separately in the description. Note that relative entropy is not symmetric, i.e. D(ρ||σ) = D(σ||ρ) in general, but mutual information fulfills I X:Y = I Y :X . Furthermore, it is important to mention that the action of any Kraus map Φ can never increase the relative entropy [44,46], i.e.
B. System coupled to a thermal reservoir To make further contact with thermodynamics we now consider the case where the system Y is supposed to play the role of a thermal reservoir. For this purpose we relabel Y by R and make the two assumptions that the Hamiltonian H R is time-independent and that the initial state of the reservoir is thermal: Similar treatments were presented, e.g. in Refs. [47][48][49][50].
Following the rational of Eq. (6), the energy change in the total system is identified as the work done by the external time dependent driving on the system The energy flowing out of the reservoir is in turn identified as the heat flow into the system X at time t (positive if it increases the system energy) Consequently, the internal energy of the system X is identified as This constitutes the first law of thermodynamics for a closed system. We use the conventional terminology of thermodynamics where a system exchanging only energy (but not matter) with a reservoir is called "closed" though one would rather call it "open" from the perspective of open quantum system theory. An "open" system in the thermodynamic sense (exchanging also matter with its environment) can be considered by introducing a chemical potential for reservoir R, which is then described by an initial grand canonical equilibrium state. Integrating the first law over an interval [0, τ ] gives with By analogy with the second law of phenomenological nonequilibrium thermodynamics [51] which states that the non-negative entropy production characterizing the irreversibility of a process is given by the sum of the entropy change in the system and in the (macroscopic ideal and always equilibrated) reservoir, we follow Ref. [47] and define entropy production as Since the initial reservoir state (13) is thermal, the nonnegativity of Σ can be shown by noting the identities [47] It relies on the assumption that the initial total system state is decorrelated. We emphasize that Σ(τ ) ≥ 0 holds for any reservoir size and can thus not be considered as strictly equivalent to the phenomenological second law of nonequilibrium thermodynamics. We also note that expression (21) provides interesting insight into the difference between the way in which we treated the reservoir R in this section compared to the way in which we treated system Y in the previous section: the entropy production does not only measure the information lost in the correlations between the system and the reservoir via the mutual information I X:R , it also measures the information lost in not knowing the state of the reservoir after the interaction via D[ρ R (τ )||ρ R β ]. This translates the obvious fact in thermodynamics that one has no access to the state of the reservoir and that one only knows the energy that has flown in it as heat.
We define an ideal heat reservoir as a reservoir which remains close to thermal equilibrium during its interaction with the system, i.e. ρ R (τ ) = ρ R β + σ R , where is a small parameter and tr R (σ R ) = 0. Using the exact identity this means that the information lost by not knowing the reservoir state becomes negligible because 1 Consequently, the entropy change in the reservoir can be solely expressed in terms of the heat flowing in it via Clausius equality, i.e. ∆S R (τ ) = −βQ(τ ) where these two quantities are generically of first order in and only differ from each other to second order in . Using (21), it also means that the entropy production due to an ideal heat reservoir coincides (to second order in ) with the lost mutual information between the system and the reservoir, i.e. Σ(τ ) = I X:R (τ ).
Finally, it will turn out to be useful to introduce the concept of a nonequilibrium free energy. Following Refs. [47,[52][53][54], we define where T is the temperature of the initial reservoir attached to the system. Since it is fixed, dF X (t) is still an exact differential. Using this quantity, we can write the second law as Explicit processes where Σ(τ ) can be made arbitrarily close to zero have been considered, e.g. in Refs. [49,[54][55][56][57].

C. The weak coupling limit and master equations
The results above provide a general way to formally derive the laws of thermodynamics as exact identities. Remarkably, these relations hold even if the reservoir R is arbitrarily small and strongly influenced by the presence of the system. However, while the entropy production Σ(τ ) is proven to be nonnegative, its rate can be negative. Indeed, as finite-size quantum systems evolve quasiperiodically, the exact rate of entropy production must become negative at some time to restore the initial state. Furthermore, these identities are also of limited practical use because computing any particular expression requires to solve the full Liouville-von Neumann dynamics for the joint system and reservoir.
The weak coupling limit between the system and the reservoir circumvents these limitations and is of great practical relevance. It has been used since a long time to study quantum thermodynamics [58,59] (see also Refs. [1,3] for recent reviews). Within this limit the system does not perturb the reservoir over any relevant time-scale and it is further assumed that the reservoir behaves memory-less (i.e. Markovian). This allows to close the equation of motion for the system density matrix ρ X (t). The resulting dynamics is called a (quantum) master equation (ME). In this limit, the general results of Sec. II B reduce to the well-known ME formulation of quantum thermodynamics [47], where all thermodynamic quantities can be expressed solely in terms of system operators.
More specifically, after applying the Born-Markovsecular approximations [1,2,5,58,60] which is usually justified in the weak coupling limit, the ME can be put into the form 2 where L β (t) and L X (t) denote superoperators which act linearly on the space of system operators. In order to derive Eq. (25) one also has to assume that the driving of H X (t) is slow compared to the relaxation time of the reservoir, though this does not imply that the driving must be adiabatic [61,62]. 3 For a system-reservoir coupling of the form H XR = k A k ⊗ B k with hermitian 2 As a technical sideremark one should note that the system Hamiltonian H X (t) usually gets renormalized due to Lamb shift terms [60]. In the following we will not explicitly mention them tacitly assuming that they were already conveniently absorbed in the definition of H X (t). 3 Other MEs can be derived for (strong) periodic driving using Floquet theory [1,3,60] and also give rise to a consistent nonequi-system and reservoir operators A k and B k , the superoperator L β (t) reads (see, e.g. Sec. 3.3 in Ref. [60] for a microscopic derivation) Here, {ω = − } denotes the set of transition frequencies of the Hamiltonian H S (t) = (t)Π (t) with instantaneous eigenenergies (t) and corresponding projection operators Π (t) . Omitting the explicit time-dependence in the notation, A k (ω) is defined as Furthermore, the rate γ k (ω) is the Fourier transformed reservoir correlation function which can be shown to be non-negative [60]. The thermal generator (26) fulfills two important properties. First, it is of so-called Lindblad form [66,67]. This means that the time evolution of Eq. (25), (or simply ρ X (τ ) = e L X τ ρ X (0) if L X is timeindependent), can be written as a Kraus map (4). Whereas each Lindblad ME defines a particular Kraus map, the inverse is not necessarily true, i.e. for a given Kraus map we cannot associate a unique ME in Lindblad form. Second, and very important from the thermodynamic point of view, the rates satisfy the property of local detailed balance which follows from the Kubo-Martin-Schwinger (KMS) relation of the reservoir correlation functions [1,2,5,58,60]. It also plays a crucial role to establish a consistent nonequilibrium thermodynamics for classical stochastic processes [8,9]. More importantly for us here, it implies that the steady state of the system corresponds to the canonical equilibrium (or Gibbs) state [60]: librium thermodynamics [1,3,63,64]. If the driving is neither slow nor periodic, no method is currently known to derive a ME although the thermodynamic quantities defined here remain meaningful, see also Ref. [65].
Since the system-reservoir interaction is now negligible, the system energy reads E X (t) ≡ tr{H X (t)ρ X (t)} and the first law takes the usual form, where the work rate on the system is given bẏ and the heat flow into the system is caused by the dissipative part of the evolutioṅ The second law is now more stringent since it not only ensures the nonnegativity of the entropy production but also of its rateΣ Mathematically, this result follows from Spohn's inequality [68] − This is true for any superoperator L X (t) of Lindblad form with steady stateρ X (t), i.e. L X (t)ρ X (t) = 0, and corresponds to the differential version of Eq. (12). For the case considered here, we haveρ X (t) = ρ X β (t) [see Eq. (31)] and Spohn's inequality gives after a straightforward manipulation (35).

A. Idea
Traditional thermodynamic setups consist of a system in contact with thermal reservoirs, as reviewed in the previous section. However, as motivated in the introduction, many experimental (and theoretical) setups today do not fit into this picture and make use of much more structured resources. For instance, a micromaser (as reviewed in Sec. VI B) makes use of a stream of flying atoms prepared in non-equilibrium states interacting sequentially with a cavity. Another example is the measurement and subsequent manipulation of a device by an external observer ("Maxwell's demon"), see Secs. IV E and VI D.
Although both examples are quite different, we will see that we can treat them within a unified framework by introducing a new form of "reservoir" which can be prepared in arbitrary non-equilbrium states. The basic setup consists of a stream of additional systems which we will generically call "units". These units are identically and independently prepared and interact one after another with the device (i.e. the system of interest) without ever coming back. This framework of repeated interactions provides sufficient structure to formulate a meaningful and tractable dynamics and thermodynamics, as we will now demonstrate.

B. Formal setup
The system X that we considered until now is split in two as X = S ⊕ U , where S denotes the system of interest whereas U is an auxiliary system called the unit. We assume that this unit interacts with the system S for a time τ and is afterwards decoupled from it and replaced at time τ > τ by a new unit. This new unit interacts with S from τ to τ + τ before it is replaced by yet another new unit at 2τ . The process is then repeated over and over. This means that the system is interacting sequentially with a stream of units {U n }, where the index n refers to the n'th interaction taking place in the interval [nτ, nτ + τ ) as sketched in Fig. 2.
The Hamiltonian H X (t) of the joint system and all units can be formally written as where the system Hamiltonian H S (t) may or may not be time dependent. The Hamiltonian of the stream of (non-interacting) units can be written as a sum of (timeindependent) single unit Hamiltonians H and the system-unit interaction as where V (n) SU (t) is an arbitrary interaction between the system and the n'th unit. The Heaviside step function explicitly reads This means that the interaction between the system and the n'th unit is switched on at time t = nτ and switched off at t = nτ + τ with 0 < τ < τ as explained above. During this interaction time the system and unit are both coupled to the reservoir R. Their dynamics can be described exactly or by a ME of the form (25) in the weak coupling limit. However, before or after the interaction with the system, when the unit is not in contact with the system, it will evolve freely (i.e. unitarily) with H      U (t)} will remain constant. Our setup is meant to model situations where an experimentalist can prepare independent units in any desired state. Therefore, a crucial but reasonable assumption that we use is that the incoming units are decorrelated (i.e. independently prepared) and that their statistical description is stationary in time, i.e. the density matrix of the incoming units fulfills ρ  n, m. 4 We further assume that the interaction Hamiltonian V (n) SU (t) has always the same form (of course it acts on different unit Hilbert spaces but for simplicity we will always denote it by V SU (t)).
Our goal will now be to formulate thermodynamic laws for the system where one regards the stream of units as a nonequilibrium reservoir, and to understand to what extend this latter modifies the traditional thermodynamic laws. In the next section, we will focus on one fixed interval where the system interacts with a single unit only. For simplicity we choose the interval [0, τ ) and drop the index n = 0. Sec. III D then discusses what happens if the system is repeatedly put into contact with subsequent units and whether one can expect the system to reach a stroboscopic steady state.

C. Modified energy and entropy balance
To obtain the first law of thermodynamics, we can either take Eq. (18) or integrate Eq. (32), where care has to be taken with the definition of the time interval to correctly capture boundary effects. Thus, we define the global change of system and unit energy as such that the interaction term does not contribute. Here, ∆E S = tr S {H S (τ )ρ S (τ )} − tr S {H S (0)ρ S (0)} and analogously for ∆E U . Integrating the rate of work yields two The first term is standard and results from the smooth time-dependence of H S (t) during the full interval and of V SU (t) during the interaction, i.e.
The second term, to which we will refer as the switching work, is a boundary term resulting from the sudden switching on and off of the interaction and reads Mathematically, it follows from d t Θ(t) = δ(t) where δ(t) is a Dirac delta distribution. Physically, we can interpret W sw as the work needed to pull the stream of units along the system (we assume that the other units which do not interact with the system move in a frictionless way). Finally, by integrating the heat flow [Eqs. (19) or (34)] we get and the first law of thermodynamics takes the form Using the second law of thermodynamics, Eq. (20) or Eq. (35) as well as the factorization of the initial condition ρ X (0) = ρ S (0)ρ U (0), the entropy production of the system and unit during each interaction period reads where the unit entropy change ∆S U and the final systemunit correlations I S:U (τ ) modify what would otherwise be the traditional second law for the system in contact with its reservoir. In view of our interpretation of Eq. (20), Eq. (47) describes the dissipation of the joint system SU to the reservoir. The units and the system are thus treated on the same footing. However, since each unit only interacts once with the system, the mutual information that they established by interacting with the system is never used or recovered. 5 A more meaningful definition of entropy production for our setup which accounts for these losses is thus This entropy production not only measures the lost information as system-reservoir mutual information and as relative entropy between the nonequilibrium and equilibrium reservoir state after the interaction (compare with Eq. (21)), but it also accounts for the information lost as mutual information by the units which never come back. Obviously, Σ S ≥ Σ. In the special case where the coupling to the reservoir is switched off, Q = 0 and Σ = 0, the entropy production is solely given by the mutual information Σ S = I S:U lost in our setup. Using the first law (46) together with the definition of the nonequilibrium free energy (23) with respect to the reservoir temperature β, (48) can be rewritten as This form of the modified second law allows us to draw the important conclusion that the stream of units in its most general sense is nothing else than a resource of nonequilibrium free energy.

D. Steady state regime
We derived our modified laws of thermodynamics for an arbitrary initial system state over a single interaction interval. To treat many interaction intervals, we have to link the (thermo)dynamics between successive interaction intervals, i.e. the final system state ρ S (nτ ) of the n'th interaction interval has to be taken as the initial condition for the (n + 1)'th interval. Because the incoming units are statistically independent and identically prepared, we can treat each interaction interval as above.
A particularly important case is the limit of multiple interactions where it is reasonable to assume that the system will eventually reach a stroboscopic steady state, given that the time-dependence (if any) of the system Hamiltonian H S (t) and of the interaction Hamiltonian H XR (t) with the heat reservoir is also τ -periodic. We will often resort to this steady state assumption for the applications considered in this article, which reads and implies ∆E S = 0 and ∆S S = 0. Then, the laws of thermodynamics simplify to To justify this steady state assumption, we assume that the reservoir is always in the same initial state at the beginning of every interaction interval n so that the system and unit evolve according to the same Kraus map Φ SU over each interaction interval. Physically this means that the reservoir remains virtually unaffected by the interactions with the system and unit. This assumption is for instance implicit if the system-unit dynamics is described by a ME. Without this reservoir resetting assumption, justifying existence of the steady state regime is a much harder task. Proceeding with this assumption, it is easy to show that there also exists a Kraus map Φ S for the system alone (53) Importantly, Φ S does not depend on the interaction interval n because the initial state of the unit ρ U (nτ ) is always the same and because all relevant Hamiltonians are assumed τ -periodic. Therefore, if a unique steady state exits, it must be τ -periodic. The existence of a steady state is guaranteed by Eqs. (10) and (12) and its uniqueness can be proven if we have a strict inequality 6 A precise mathematical condition for this strict inequality was worked out in Ref. [69] but is hard to translate physically. For instance, if additional symmetries are present or for pure dephasing interactions (commuting with the system Hamiltonian), it is well known that there is no unique steady state [60]. Nevertheless, for most relevant scenarios the strict inequality (54) will be satisfied.
In some examples to be considered below, the existence of a unique steady state is also a well-established experimental fact (e.g. for the micromaser treated in Sec. VI B). Finally, let us stress that even when the steady state regime is guaranteed, solving the combined system-unit dynamics exactly is often out of reach, especially when the system and unit are complicated systems by themselves. This is why in Sec. V we go one step further and describe various limiting regimes (corresponding to special types of interaction H SU (t)) where an effective ME can be derived for the system alone, with its corresponding thermodynamic interpretation.

E. Discussion
Let us summarize what we have achieved. By allowing the system to interact with units, we showed that a new term arises in the system energy and entropy balance, (46) and (48) respectively. It describes the unit energy and entropy changes, ∆E U and ∆S U respectively, in addition to the traditional terms describing the energy and entropy changes in the reservoir in terms of heat. Consequently, the entropy production Σ S , which measures the irreversible losses in the system dynamics, now displays a new term which is given by the free energy change 6 The proof is easily carried out by, first, noting that any system state must asymptotically (i.e. for n → ∞) reach some steady state because the sequence fn ≡ D[Φ n S (ρ S )||σ S ] for some steady state σ S is monotonically decreasing and bounded from below, and second, by realizing that the existence of two different steady states σ S and σ * S contradicts Eq. (54).
of the unit ∆F U . This term enables new transformations that would have been impossible without the units. From an operational perspective, evaluating this free energy requires preparing the units in a known state before the interaction and measuring their state after the interaction has ended. We will examine in the next section whether ∆E U and ∆S U can be linked to traditional thermodynamic notions of work or heat. Since our generalized second law Σ S ≥ 0 provides a bound on the possibility to extract work or to convert different states into each other, it is worth mentioning that a number of different bounds have been established recently within the framework of resource theories [70][71][72][73][74][75][76]. These studies also explicitly show ways to saturate these bounds. While the setups they consider share some similarities with ours, the bounds obtained are in general different from our second law and are derived under additional restrictions imposed on the setup. For instance, within the "resource theory of thermal operations" (see Ref. [39] for an overview about different resource theories), it is assumed that the global time evolution commutes respectively with the bare Hamiltonian of the system, of the unit, and of the reservoir. This assumption is not needed within the approach presented in this section. Given that our sole restriction is to consider initially decorrelated system-unit states, the problem of finding specific protocols which saturate the bound in Eq. (49) is in principle equivalent to finding protocols saturating the bound (24) because the former is a consequence of the latter (see, e.g. Refs. [49,[54][55][56][57] for such optimal protocols). These optimal protocols might however correspond to highly idealized, if not unrealistic, situations. Instead of following a resource theory strategy by imposing restrictions from the start, we kept a general level of discussion in this section and will consider specific physical setups of greater experimental relevance in Sec. VI.

A. Thermal units and ideal heat reservoir
We consider thermal units initially prepared in an equilibrium state at an inverse temperature We say that these units behave as an ideal heat reservoir when More insight is obtained using an argument similar to the one used in section II B to define an ideal heat reservoir.
Using the identity we see that Eq. (55) is fulfilled when the state of the unit remains close to thermal equilibrium after the interaction, i.e. when ρ U (τ ) = ρ U β + σ U where is a small parameter and tr U (σ U ) = 0. Indeed, we then get that whereas ∆E U and ∆S U are in general non-zero and equal to first order in . Since the unit energy change can be interpreted as heat, ∆E U = −Q U , the second law (48) We remark that saturating Eq. (55) away from the weakcoupling limit is in general non-trivial, but see Sec. V A 4 for another class of ideal heat reservoirs.
As a simple application, we operate our setup in the steady state regime with hot thermal units T > T . Using (56) in (49), the entropy production bound implies . (57) This shows that to operate as a heat engine, where work is extracted (W < 0), energy must be extracted from the units (∆E U < 0). For thermal units constituting an ideal heat reservoirs, the thermodynamic efficiency of the engine is defined as η = −W/∆E U and is upper bounded by the Carnot efficiency η ≤ 1 − T /T due to (57), which reduces to W −(1−T /T )∆E U ≥ 0 in that case. However, non-ideal thermal units decreases the efficiency bound as While realizing that a thermal stream of unit can behave as an ideal reservoir is interesting, the importance of our setup is that it allows to treat units initially prepared out-of-equilibrium. One way to do it here is to consider an initial state ρ U β with negative β . The efficiency of the heat engine can then formally exceed 1 without violating the second law of thermodynamics because the entropy production (47) is still non-negative. However, in this case -as the work output has to be compared with the total energy put into the system -the first law of thermodynamics tells us that a correctly defined efficiency would still be bound by one.

B. Work reservoir
To make the units act as a work source, we should engineer their state and interaction with the system in such a way that only energy is exchanged but not entropy. Thus, we define For finite ∆E U this implies that the change in nonequilibrium free energy is given by ∆F U = ∆E U and (49) becomes at steady state (∆F S = 0) This means that we can extract work from the energy initially stored in the units, but not by extracting heat from the reservoir since Eq. (60) implies due to the first law that Q < 0. Definition (59) can be fulfilled for many different situations depending on the precise nature of the interaction and the state and Hamiltonian of the units (we will treat particular examples in Secs. V A 3, V C and VI B). Let us note that for the special case of an ideal heat reservoir which is thermal before and after the interaction (as discussed above), the form of Eqs. (59) and (60) can be obtained by choosing T → ∞ in Eqs. (55) or (56) while keeping ∆F U finite. This confirms the colloquial saying that a work reservoir corresponds to an infinite temperature heat reservoir. 7 Finally, we note that the notion of work for small systems is subtle and has been debated [6,[78][79][80][81][82][83][84][85]. This originates from the desire to explain work microscopically in contrast to the standard approach where it is usually incorporated "by hand" as a time-dependent part of the system Hamiltonian. We see that the repeated interaction framework brings an interesting perspective on this issue by defining work as the part of the energy exchange that does not induce any entropy change in the units. This approach agrees with the point of view advertised in Refs. [80,81,83]. In Sec. V C, we will provide an explicit model where the units effectively mimic a timedependent system Hamiltonian and fulfill Eq. (59).

C. Information reservoir
We now consider the regime where the units operate as a pure information source by demanding that the exchange of energy ∆E U vanishes whereas the exchange of entropy ∆S U remains finite. Thus, in contrast to Eq. (59), we demand that Then, ∆F U = −T ∆S U and the second law of thermodynamics (49) becomes at steady state (∆F S = 0) This shows that it is possible to extract work (W < 0) while writing information to the units (∆S U > 0) in an energy neutral fashion (∆E U = 0). Note that for this interpretation we have tacitly equated the entropy of a system with its information content in spirit of Shannon's fundamental work [86]. Engines which are able to extract work only at the expense of information are also called information-driven engines [87].
The idea that an information reservoir represents the opposite of a work reservoir also becomes manifest by considering the case of an ideal heat reservoir in the limit T → 0. Rearranging Eq. (56) yields In the limit of an ideal reservoir the second term on the right-hand side becomes negligibly small. However, in order to keep ∆S U finite while T → 0 we automatically see that we obtain the requirement ∆E U → 0. This can be achieved, for instance, by scaling the Hamiltonian of the units as H U = T H U (note thatH U is dimensionless now). The same conclusion was also reached in Ref. [88].
The notion of an "information reservoir" was introduced in a classical context by Deffner and Jarzynski in Ref. [48], where each single informational state corresponds to a set of microscopic states which are assumed to internally rapidly equilibrate. If the free energy barriers between the different informational states are large, this enables a stable encoding of the information. Here instead, we equate each microstate of the unit with an informational state. In this respect we do not impose any stability condition on our information, but also take all changes at the microscopic level into account. A correspondence between the two approaches can be established using a coarse graining procedure similar to Ref. [89]. Furthermore, the thermodynamics of information reservoirs has attracted a lot of attention recently as number of model studies shows [35,36,88,[90][91][92][93][94][95][96]. In Sec. VI A we will propose a microscopic model for the Mandal-Jarzynski engine [35] where the extracted work is shown to correspond to W sw (44).
An overview of the the last three sections is represented in Fig. 3.

D. Landauer's principle
Landauer's principle colloquially states that logically irreversible computation, more specifically the erasure of a bit, has a fundamental work cost. This result was first derived for a particular model by Landauer in 1961 [97]. Since then many groups made this statement more precise by deriving it from a more general context, partly also within a repeated interaction framework, and by extending it to finite-time operations [17,20,49,50,54,[98][99][100][101][102][103][104][105][106][107][108]. The modern understanding is that this principle immediately follows from the nonequilibrium version of the second law as we will show below. There is also growing experimental evidence in favor of it [109][110][111][112][113][114][115]. It nevertheless remains debated [116].
Within our framework, Landauer's principle can be formulated as follows: Changing the information content (that is to say the Shannon or von Neumann entropy) of a unit by −∆S U > 0 requires a work expenditure of at least: In general, the interaction can be arbitrary, but if the initial state of the units is thermal, they can mimic an ideal heat reservoir when they fulfill the Clausius equality (55). In the limiting case where T → ∞ we obtain a work reservoir (Sec. IV B). The converse is not true, i.e. not every work reservoir can be obtained as a limiting case of a heat reservoir. Similarly, we can obtain an information reservoir (Sec. IV C) out of a heat reservoir for T → 0, but again the converse is not true. We note that some setups do not fit in either of the three categories.
This statement immediately follows from our generalized second law (49), where ∆E S = 0 because we focus on the steady state regime. Note that, i.e. we lower the Shannon or von Neumann entropy of the unit. Furthermore, we see that we recover the standard statement βW ≥ −∆S U for ∆E U = 0, which is automatically fulfilled if the states of the units are energetically degenerate as it is usually assumed (treatments including energetic changes can be found in Refs. [54,103] and are in agreement with our result and were also confirmed experimentally in Ref. [115]). We emphasize that the initial product state of the system and unit, ρ X (0) = ρ S (0)ρ U (0), is essential for deriving Landauer's bound. In fact, we regard the unit (functioning as a memory in this case) as an auxiliary system to which the experimenter has free access. If the memory was initially correlated with the system, it should be treated as part of the system instead [45]. In presence of initial correlations, it is well-known that Landauer's bound does not hold [49,117]. 8 We end with some remarks. As pointed out in Ref. [20], erasing information is not necessarily a thermodynamically irreversible process because when reaching the equality in Eq. (64), the process becomes thermodynamically reversible (i.e. with no entropy production). The inverse operation of erasure corresponds to a randomization of the memory back to its initial state while absorbing heat from the reservoir. This can be viewed as creating information in the sense of Shannon. However, it is not a computational process, i.e. a deterministic operation on the set of logical states which cannot increase the Shannon entropy of the state during computation. 9 It is only in this sense that a logically irreversible computer can be said to produce irretrievable losses of energy. In fact, the information-driven engines introduced in Sec. IV C can be seen as an implementation of the reverse process. The duality between work extraction and information erasure was also noticed in Refs. [35,36,48,88,91,[93][94][95][96].
E. The second law of thermodynamics for discrete feedback control Feedback control describes setups where one manipulates the dynamics of a system based on the information that one obtains by measuring it. Several groups have established that for a system undergoing feedback control in contact with a thermal reservoir at inverse temperature β, the amount of extractable work W fb is bounded by (details about the assumptions are stated below) [55,[118][119][120][121][122][123][124][125][126][127][128][129] − βW fb ≤ I ms S:U , where I ms S:U is the classical mutual information (which can be obtained from Eq. (11) by replacing the von Neumann by the Shannon entropy) between the system and the memory in which the measurement result is stored after the measurement. Eq. (65) is also called the second law of thermodynamics for discrete feedback control. It was confirmed experimentally in Refs. [130][131][132].
To be more specific, the inequality (65) holds under special conditions. For instance, the bound is known to be different for quantum systems [55], and even classically, additional requirements are imposed on the measurement which are seldomly stated explicitly. Within our framework, we will show that we are able to provide a very transparent and clean proof of Eq. (65).
The memory used to store the measurement of the system will be a unit in our setup. The assumption of an initially decorrelated system-memory state complies with the notion of a memory used in Sec. IV D. We assume that the Hamiltonian H U of the memory is completely degenerate so that the change in energy of the memory is always zero, ∆E U = 0. The stream of memories can thus be viewed as the information reservoir introduced in Sec. IV C. Including changes in the energy of the memory poses no fundamental challenge, but would just lengthen the equations below.
We now divide the interaction interval in two parts Fig. 4. The measurement is performed during [0, t ms ) whereas the feedback step is performed during [t ms , τ ).
One possibility is to treat an instantaneous measurement, t ms → 0. In this case, the measurement consists of a delta-function time dependence of the interaction Hamiltonian, H SU (t) = δ(t)V ms SU , which generates a sudden unitary operation U ms acting on the joint systemmemory space. The state of the system and memory after such a measurement reads where U ms = exp(−iV ms SU ) and ρ ms SU will be in general correlated. During this short time window the system and memory are effectively decoupled from the reservoir and the measurement acts in an entropy-preserving fashion. As a result during [0, t ms ), the first and second law respectively read The non-negative mutual information which has been created during the measurement step, I ms S:U , will constitute the resource during the feedback step.
On the other hand, if the measurement time t ms remains finite, we are effectively implementing an "environmentally-assisted measurement". If L ms (t) denotes the superoperator governing the time evolution of the system and memory in weak contact with the reservoir during [0, t ms ), then their initial state will be mapped into the generically correlated state [see Eq. (29)] In this case heat exchanges with the reservoir Q ms will occur and the first and second law respectively read By combining these two laws, we find that the measurement work is bounded by A reversible implementation of the measurement, Σ ms = 0, is possible in the limit t ms → ∞ as examined explicitly by Bennett and others [17,87,98,99]. We remark that from the system's perspective, the measurement simply changes its state from ρ S (0) to ρ ms , where Φ ms S denotes the Kraus map of the measurement. So far our approach is very general since it includes any kind of measurement scenario (including measurements on classical systems) compatible with an initially decorrelated system-memory state [43,45]. We now turn to the feedback step. In a macroscopic setting, the observer would make a projective measurement of the memory in the computational basis |o U . After reading out the outcome o of the measurement, she would subsequently perform a feedback step by accordingly changing the system Hamiltonian and/or the system-reservoir coupling. In the inclusive approach which we now follow, invoking a macroscopic agent is not necessary since the same resulting dynamics can be obtained by using a total Hamiltonian of the form 10 Here, Π o = |o U o| denotes the projector onto the unit subspace corresponding to outcome o. The unit plays the role of a minimal description of the external agent or feedback controller. We note that the idea to describe a measured and feedback controlled system in a larger space without having to rely on explicit measurements is not new and is at the heart of coherent or autonomous feedback in quantum mechanics [133][134][135]. It also works classically [136]. More details on such descriptions and on strategies to optimize work extraction can be found in Ref. [55]. We now proceed with the first and second law of thermodynamics during the feedback step which take the form (independently of the measurement scheme) 11 Σ fb S = ∆S fb S + ∆S fb U − βQ fb + I ms S:U ≥ I fb S:U ≥ 0, (75) where I ms S:U is the system-memory mutual information at the end of the measurement interval while I fb S:U ≡ I S:U (τ ) 10 The unitary evolution operator associated to H fb (t) is then of SR acts exclusively in the system-reservoir space and the reduced system-reservoir state is obtained by tracing over the unit Hilbert space. 11 We note that Eq. (75) does not rely on the assumption that the system-unit state is decorrelated at the beginning of the feedback interval (see Eqs. (20) or (35)). This assumption is only used initially (before the measurement) and enables us to consider a regime of repeated interactions.
is the remaining mutual information at the end of the entire interval. We note that this latter is a left out resource which will always diminish the amount of extractable work. By combining Eq. (75) with Eq. (74), we get − βW fb ≤ −β∆F fb S + ∆S fb U + I ms S:U .
Assuming now that we operate in the steady state regime where ∆F S = ∆F ms S + ∆F fb S = 0, Eq. (76) becomes This result can be regarded as the generalized second law for discrete feedback control.
To recover (65) from (77), one needs to consider a nondisturbing classical measurement in which the state of the system before and after the measurement is the same [45] and the information stored in the memory is classical. These assumptions have been used implicitly or explicitly in the classical context [118][119][120][122][123][124][125][126][127][128][129] whereas for quantum treatments only the information stored in the memory was treated classically [55,121]. Indeed, the first property of a non-disturbing measurement implies that ∆F ms S = 0 while the assumption of a classical memory implies that, after the measurement, the memory is diagonal in its computational basis |o U . Therefore, the evolution caused by the Hamiltonian (73) will leave the entropy of the memory constant, i.e. ∆S fb U = 0. Hence, we recover (65), but having clearly identified the necessary additional assumptions. It is worth pointing out that even classical measurements can also be disturbing [45] as in fact any real measurement is. Then, ∆F ms S = 0 and the amount of extractable work changes. We conclude this section by noting that (77) gives a bound on the extractable work during the feedback process but neglects the work invested during the measurement step (which however can be zero). When adding (77) to (72), we find that the total extractable work is bounded by minus the entropy change in the unit This result is equivalent to Eq. (62) and shows that our feedback control scheme (implemented by a stream of memories) is equivalent to the information reservoir described in Sec. IV C. This connection between feedback control and information-driven engines was debated in Refs. [95,[137][138][139] but is unambiguous here. A summary of the thermodynamics of feedback control within our framework is given in Fig. 4. A model-system application will also be provided in Sec. VI D.

V. EFFECTIVE MASTER EQUATIONS
The thermodynamic framework introduced in Sec. III is very general and allowed us to derive important exact identities. But in practice, it can only be used if one is able to solve the reduced dynamics of the joint systemunit complex. This is usually not an easy task. Our goal in this section will be to derive a closed reduced description for the system only, which includes its dynamics and thermodynamics. We will derive effective MEs for the system which do not rely on the weak coupling approximation, contrary to the results of Sec. II C. These MEs often have an apparent non-thermal character. For instance they do not obey the condition (31). Establishing a consistent thermodynamics for these MEs, when solely considered as mathematical objects, can thus be challenging and often requires the ad hoc introduction of effective new quantities, which lack a solid physical interpretation [140][141][142][143]. Progress has been achieved when the MEs result from the coarse graining of a larger network of states which originally obeys a thermodynamically consistent ME, especially if the network is bipartite [89,[144][145][146][147][148], or for particular information-driven engines [95] and "boundary-driven" MEs [149][150][151][152]. Our approach is similar in spirit since we will derive effective MEs starting from the framework of repeated interaction for which we established a consistent thermodynamics.
In this section the energy and entropy of the system at the effective level will always be given by We will also allow the time interval τ between successive system-unit interactions to fluctuate according to the waiting time distribution w(τ ). The duration of the interaction itself τ ≤ τ will be specified on a case by case basis. The time evolution of the system over a interval τ is given by some generic Kraus map Φ S (τ ). We introduce the conditional density matrix ρ where t 0 < t is an arbitrary initial time. The unconditional state of the system is recovered by summing over n: ρ S (t) = n ρ (n)

S (t).
A. Poisson-distributed interaction times

Setup
In this subsection, we consider an exponential waiting time distribution w(τ ) = γe −γτ . This means that the number N of units with which the system interacts during a fixed time window T is Poisson-distributed, i.e. P N (T ) = (γT ) N N ! e −γT . The average time between successive interactions is therefore  Furthermore, we assume that the system-unit interactions are very strong and short, but happen very rarely. In this way, we can assure that the units have a finite influence on the evolution of the density matrix. More specifically, if the random times at which a new unit interaction occur are denoted t n (n = 0, 1, 2, . . . ), the systemunit interaction Hamiltonian is a sum of delta kicks as sketched in Fig. 5. This interaction creates an instantaneous unitary operation U at times t = t n such that the system-unit state right after an interaction reads Putting aside the brief system-unit interactions, most of the time the system will evolve in weak contact with a large thermal reservoir at inverse temperature β. Its dynamics will thus obey a ME of the form (25) (84) where L β is the standard dissipator caused by the thermal reservoir. For notational simplicity we keep the timedependence of superoperators implicit, L = L(t).
Overall, the system evolution over an entire interval τ is given by the Kraus map where Thus, Eq. (85) describes the short kick felt by the system due to the interaction with the unit (J S ) followed by the dissipative evolution of the system in contact with the reservoir (e L0τ ). If L 0 is time-dependent, we have to replace e L0τ by the corresponding time-ordered generator, see Eq. (29). For later convenience, we also introduce the superoperator describing the effect of a system-unit interaction on the unit has not yet reached its steady state, but J S is not. Using Eq. (85) in Eq. (81) and substituting τ = t − t to make the dependence on the actual time t explicit, we obtain ρ (n) (88) By taking the time derivative, we find (89) and by summing over n, we finally obtain the effective ME ruling the averaged time-evolution of the system We can make the new part γ(J S − 1) of the ME (90) more explicit by writing the initial state of the unit as where {|k U } is an arbitrary set of eigenstates of ρ U (not necessarily energy eigenstates of H U ). Then, we see that has the form of a Kraus map (4) where the system operators defined as A kl ≡ √ p k l|U |k U fulfill the completeness relation k,l A † kl A kl = 1 S . Therefore, we can write where D[A]ρ ≡ AρA † − 1 2 {A † A, ρ}, thus explicitly showing that L new is of Lindblad form [60,66,67]. By choosing ρ U and V SU appropriately we can create arbitrary A kl 's as long as they fulfill the completeness relation. Note that the class of generators L new created this way is not equivalent to the class of thermal generators (26). In general, relations (30) or (31) will not be fulfilled for L new . Furthermore, we remark that including multiple independent streams of units can be easily done within this scenario because the probability of a simultaneous interaction with more than one unit is negligible.
In summary, the new ME (90) can be written as

Thermodynamics
We now turn to the thermodynamic description corresponding to the setup above.
We start by considering energy and entropy changes in the units. During a short time interval dt, the probability that a unit interacts (resp. does not interact) is given by γdt 1 (resp. 1 − γdt). In the former case the unit state changes from ρ U to J U ρ U while it remains in ρ U in the latter case. Since an energy and entropy change in the unit only occurs when an interaction takes place, the rates of unit energy and entropy change are given by We now turn to the rate of work injected in the joint system-unit, which we again split into two partṡ wherė The first part is the work due to the time-dependence in the system Hamiltonian H S (t) while the second part is due to the system-unit interaction when it occurs. Since this latter gives rise to a unitary dynamics in the systemunit space which produces no heat, it is given by the energy change in the system and unit due to the systemunit interaction. The overall change in the energy of the system is naturally given by and the heat entering the system from the reservoir iṡ Noting thatẆ SU (t) − d t E U (t) = γtr S {H S (t)L new ρ S (t)}, we obtain the first law of thermodynamics which constitutes the differential version of the general result Eq. (46). We now proceed to show that the differential version of the generalized second law (48), also holds and that its non-negativity is ensured. Using the fact that d t S S (t) = −tr {[d t ρ S (t)] ln ρ S (t)} together with (90), we find that Combining this with (101), we can rewrite (103) aṡ where we used Spohn's inequality (36) at the end. Using (96) the remaining part can be expressed aṡ Using now the fact that entropy does not change under unitary transformation so that we can prove the non-negativity ofΣ S (t) sincė The present analysis underlines that our generalized thermodynamic framework of repeated interactions can be carried over to the limiting situation considered in this section of very short and Poisson-distributed systemunit interactions. The resulting description is closed in terms of the system density matrix obeying the dynamics (94) and the non-negativity of the differential form of the second law (103) is a stronger result than the original integrated one (47).
A crucial point to emphasize is that knowing the physical mechanism underlying a ME dynamics such as (94) is essential to establish its correct thermodynamics. Indeed, without the additional information about the units at hand, the thermodynamic analysis would be very different. Presupposing that we were able to disentangle the two dissipative mechanisms caused by L β and L new , we would need to define an effective heat floẇ Q eff (t) ≡ tr{H S L new ρ S (t)} to explain the discrepancy in the first law. From our inclusive approach above, however, we know thatQ eff (t) =Ẇ SU (t) − d t E U (t). The effect on the second law would even be more drastic. Using Spohn's inequality (36), we know that the quantitẏ would be always non-negative as a sum of two nonnegative terms. Here,ρ new denotes the steady state of L new , i.e. L newρnew = 0. In fact, if L new would correspond to the dissipator caused by a standard thermal reservoir, Eq. (108) would correspond to the standard entropy production. However, this is not the case and thus,Σ eff S is not only numerically different fromΣ S , but also lacks any a priori thermodynamic interpretation.

Heat, work and information dominated interactions
Following the line of Secs. IV A-IV C, we now consider specific scenarios which have a clear thermodynamic interpretation.
We start by studying the case of initially thermal units at inverse temperature β as in Sec. IV A. Then, using (95) and (96), we deduce in accordance with Eq. (56) that Thus, in contrast to a weakly coupled macroscopic reservoir the units in general do not mimic an ideal heat reservoir unless additional assumptions are used, as we will see in Sec. V A 4. The difference between the effective ME (90) compared to the weak coupling ME from Sec. II C also becomes apparent by noting that the generator L new is not of the form of L β in Eq. (26). Thus, initially thermal units will typically not imply that L new ρ S β (t) = 0. One very specific way to enforce it is to assume that the units and the system have identical Hamiltonians, H S = k E k |E k S E k | and H U = k E k |E k U E k |, and that their delta kick interaction gives rise to a unitary evolution of the form U = k,l |E k S E l | ⊗ |E l U E k |, which swaps energy between the system and the unit.
For the work reservoir, we require that d t S U = 0 while d t E U = 0. For initially thermal units this can be again ensured by choosing β → 0 as in Sec. IV B. But in general, to ensure that the entropy of the unit remains constant while its energy can change, the effective unit dynamics should be given by a unitary oper- Beside the trivial choice U = U S ⊗ U U , finding such conditions might not be easy.
In turn, the limit of an information reservoir where d t E U = 0 and d t S U (t) = 0 can be easily achieved for any interaction by considering a fully degenerate unit Hamiltonian, naturally always implying d t E U = 0. A last important class of interactions are those generated by the unitary operator where U (k) S is an arbitrary unitary operator in the system Hilbert space whereas |k U denotes the eigenvectors of ρ U (91). One easily verifies that the unit state does not change during the interaction, ρ U = J U ρ U , and hence its energy and entropy also stays constant, d t E U = 0, d t S U = 0. In this case, the units are neither a work nor an information reservoir. Instead, the system state changes according to where p k = k|ρ U |k . This interaction will therefore in general inject energy as well as entropy into the system. Using (106), we see that the change in the system entropy caused by such a system-unit interaction is given by the mutual information established between the system and the unit after the interaction Thus, the interaction (111) can be seen as a measurement of the unit by the system. Indeed, depending on the unit state |k U , the system will in general change its state to U S ) † . Vice versa, by exchanging the labels U and S above, we can also implement a measurement of the system by the units. This will be used in Sec. VI D.

Ensemble of units and ideal heat reservoir
In Sec. V A 2, we considered the energy and entropy changes of those units which interacted with the system. An interesting alternative approach consists in evaluating energy and entropy changes with respect to a statistical ensemble composed of both, the units which did and did not interact. One physically relevant scenario for this is the case where units are frequently sent to the system, but only a small Poisson-distributed fraction of them interacts whereas the rest remains unchanged.
Mathematically, let us assume that every time-step dt a unit passes the system with certainty, but only interacts with it with probability γdt 1, which is assumed to be infinitesimal such that the average evolution of the system is still differentiable and coincides with Eq. (94). If we do not record the precise interaction times, each outgoing unit ρ U must be described by the state where ρ U describes the initial state as usual. The change in unit entropy per time-step dt then becomes Here, we used a bar to distinguish this definition from the previous case, Eq. (104), in which every unit passing the system also interacts with the system. The difference between both is exactly which can be interpreted as the entropy increase caused by mixing the units which interacted with the system with those which did not. In contrast, since the energy E U (t) of the units is a linear functional of ρ U (t), we easily deduce that d tĒU (t) = d t E U (t). In other words, while the entropy balance differs between the two approaches, the energy balance remains the same. Since heat is also unaffected, the difference in entropy production between the two approaches readṡ An important implication of the present approach is that when considering units which are initially thermal ρ U = ρ U β , we find that in contrast to Eq. (109). Thus, the notion of an ideal heat reservoir requires to not only focus on those units which interacted but to consider the statistical mixture of units which did and did not interact. This picture is also supported by an alternative approach. Consider a reservoir made of an initial population of N 0 1 identical and independent units. Let us assume that the particle content of the reservoir decays exponentially, N t = N 0 e −γt , and produces the sequence of units which all eventually interact with the system. In contrast to the case in Sec. V A 2, after having interacted, we sent back the units to the reservoir and let them mix with the remaining N t fresh units. The mixed state of this reservoir can be described as where we assumed that J U is time-independent for simplicity. For such a process we have d t N t = −γN t and thus Considering times over which N t ≈ N 0 to remain consistent with the assumption that only fresh units interact with the system, it is possible to recover the same mathematical results as above. Thus, physically separating the units from the system and dividing them into an incoming and outgoing stream is not essential in this picture. One could equally well consider a gas of noninteracting units surrounding the system and interacting with it at Poisson random times.

Setup
There is another class of the repeated interaction framework which has often been considered to derive MEs [149-152, 155, 157, 158]. Its thermodynamics has been considered as well [149][150][151][152]. In this scenario the duration between two consecutive system-unit interactions τ is taken constant as in Sec. III and equal to the duration of the system-unit interaction τ . Furthermore, the duration is short and τ = τ ≡ δt is used as a small expansion parameter where the interaction is assumed of the form This Hamiltonian models very short, but permanent and strong interactions. The fact that every unit is replaced after a time δt implies Markovianity. Furthermore, for a clean derivation of the ME, in this setting one has to assume no coupling to a thermal reservoir. Therefore, the system and unit evolve unitarily over one period via the operator where it is further assumed that δt is much smaller than the rate of change of H S (t). Finally, one needs to expand the evolution of ρ S (t) up to first order in δt under the assumption that tr{Ṽ ρ U } = 0. Instead of following such a derivation, which is presented elsewhere [149-152, 155, 157, 158], we follow an alternative route by considering the setup of Sec. V A in the limit of an infinitely fast Poisson process. This procedure yields identical mathematical results. More specifically, we consider the limit where the Poisson rate scales as γ = −1 while at the same time assuming that the unitary interaction (83) scales as U = exp(−i √ Ṽ ), i.e. V SU = √ Ṽ in Eq. (82). Furthermore, we explicitly neglect the reservoir, i.e. we set L β = 0 in the results of Sec. V A. The Kraus map (85) then reads Our goal will now be to derive an effective ME in the limit → 0. We start with Eq. (86) by expanding U ρ S (t)ρ U U † in powers of √ . This yields In order to derive a meaningful differential equation we now also have to demand that the interactionṼ or the initial unit state ρ U is chosen such that tr U {Ṽ ρ U } = 0, which removes the term proportional to √ . Then, we consider Eq. (93) which becomes We can make this effective ME more explicit by writ-ingṼ = k A k ⊗ B k where A k and B k are arbitrary operators in the system and unit space such thatṼ is hermitian. Then, after taking into account the influence of the possibly time-dependent system Hamiltonian, we get from Eq. (94) with L β = 0 our final ME It agrees with Refs. [149-151, 155, 157] and will be further used in Sec. VI C. Treating multiple streams of units can also be easily done within this setup. We finally note that this ME is very similar (but not identical) to the singular coupling ME [60].

Thermodynamics
A thermodynamic analysis of such "boundary driven MEs" (125) was given in Ref. [151] for the case of initially thermal units ρ U = ρ U β . We will now approach this problem from our perspective demonstrating that the thermodynamic framework in Ref. [151] is consistent, but overestimates the entropy production.
For tr U {Ṽ ρ U } = 0 it follows immediately that (in the following we consider only the leading order terms) Thus, it is clear that all thermodynamic quantities defined in Sec. V A for the system (i.e. d t E S (t) and d t S S (t)) are well-behaved (i.e. do not diverge for → 0), but for the unit this is less clear. We start by looking at unit-related quantities in the first law. For instance for Eq. (95) (the same terms appear inẆ SU (t) too), where we replaced γ = −1 and used (127 demonstrating that d t E U (t) andẆ SU (t) remain wellbehaved. Furthermore, we can identifyẆ SU (t) =Ẇ sw (t) by using definition (44) and some straightforward algebraic manipulations.
Turning to the entropy change, we see from our result (109) that the only term which could cause a divergence is −1 D(J U ρ U ρ U ). With the use of Footnote 1 and Eq. (127) we find, however, that D(J U ρ U ρ U ) = O( ) and thus, also the entropy change of the units is well-behaved.
In total, the first and second law derived in Sec. V A become for this setup To compare our results with Ref. [151], we setẆ S (t) = 0. In this reference, the change in the unit energy is identified with heat,Q U (t) ≡ d t E U (t). The first law is the same as ours, but the second law reads d t S S (t) + β Q U (t) ≥ 0. Interestingly this is the result obtained in Sec. V A 4, when the ensemble considered is not only that of the units which interacted but the entire set of units.
As we have seen, it overestimates our entropy production by a mixing term γD(J U ρ U ρ U ). Finally, this example also illustrates that -although the dynamics in the joint space of system and all units is unitary (and thus reversible) -the dynamics of the system is irreversible precisely because we impose a unidirectional movement of the units. If we time-reverse the global evolution, we would recover the initial system state. This can be also seen in the system-specific entropy production, which can be rewritten as [see also Eq. (9)] Σ S (t) = d t I S:U (t), i.e. for the entropy production rate of system and unit [compare with Eq. (47)] we haveΣ = 0.

Setup
In the last part of this section, we show that the stream of units can be engineered in a way that will effectively generate a time-dependent system Hamiltonian of the form where f (t) is an arbitrary real-valued and differentiable function and A an arbitrary hermitian system operator. We will further show that this stream of units acts as a work source thereby providing an alternative justification for treating time-dependent Hamiltonians as work sources as done in standard quantum thermodynamics [1,3,59]. We note that research in the direction of obtaining a time-dependent Hamiltonian out of a time-independent one has been carried out for different settings in Refs. [82,159,160]. The idea is that an arbitrary drive f (t) can be effectively generated by a stream of units with system-unit interactions of the form A ⊗ F , where F is so far an unspecified hermitian unit operator. As in the previous subsection, we consider short and repeated interactions: τ = τ ≡ δt. We also consider no reservoir at the moment. However, since f (t) can be arbitrary, one must relax the assumption that the units are prepared in the same initial state. Thus, only in this subsection, we allow that ρ Un (nδt) = ρ Um (mδt) for n = m (we set the initial time to be zero such that ρ Un (nδt) denotes the initial state of the unit just before the interaction). The incoming units are however still assumed to be decorrelated. The time evolution of the system is given by tr U e −i(H0+AF +H U )δt ρ S (nδt)ρ Un (nδt)e i(H0+AF +H U )δt .
By expanding Eq. (134) to first order in δt we arrive at We now choose the state of the unit such that Under these circumstances, we obtain from Eq. (135), after rearranging the terms in the limit δt → 0, which is the desired evolution according to the Hamiltonian (133). In fact, if δt is chosen small enough compared to any other time-scales, one could even include an additional reservoir in the description. In this case the Hamiltonian to be simulated becomes and the joint system-reservoir state evolves according to

Thermodynamics
In order to establish the thermodynamics of the present setup, we need to consider how the units change over time. Similarly as for Eqs. (134) and (135), we deduce that Since the unit state changes unitarily, the entropy change of the units is zero, d t S Un (t) = 0, and hence, according to the classification schemes from Sec. IV, the stream of units may behave as a work reservoir.
To confirm it, we now consider energy balances. First, the change in unit energy is given by For the last line, we used Eq. (140). Second, we need to consider the switching work steaming from the timedependent coupling of the system and unit. However, we have to remember that the units change for each interval. Naively applying the definition (44) for W sw , which is only valid for identical units, would yield a wrong result.
Considering the interval starting in nδt and lasting δt, we find that This quantity represents the work required to switch on the interaction for the next unit state ρ Un+1 (nδt+δt) minus the work required to switch off the interaction for the actual unit state ρ Un (nδt + δt) at the end of the interval.
To evaluate it, we use Eq. (140) and which follow from the Liouville-von Neumann equation for a time step δt. After a straightforward but tedious calculation, we arrive at (to first order in δt) Here, we introduced the discretized derivative of f (t) as which is well-behaved because we assumed f (t) to be differentiable. Since the units act as a pure work reservoir, the total rate of work done on the system can be defined asẆ Finally, let us compare this result with our general treatment from Sec. II A where we found out that for a time dependent Hamiltonian of the form (138), the rate of work done on the system is [compare with Eq. (6)] (148) This expression exactly coincides for t = nδt with Eq. (147). This confirms that there is a clean (but somewhat artificial) way to simulate a driven system by a stream of units and to justify that the driving corresponds to a pure work source.

VI. APPLICATIONS
In this section we demonstrate the use of the repeated interaction framework that we have developed in the previous sections by considering specific examples. We mostly emphasize the way in which the setups can be analyzed from our thermodynamic perspective and refer to the original literature for more details. Many more setups such as, e.g. the measurement and feedback scheme realized in Ref. [34], the squeezed reservoirs of Ref. [27], the coherent states of Ref. [25] or the entangled unit states of Ref. [23] 12 can be analyzed within our framework, but will not be considered here for brevity.

A. Information reservoir: the Mandal-Jarzynski engine
We start by providing a microscopic model describing the information-driven engine first proposed by Mandal and Jarzynski [35] and show that it falls within the class of information reservoirs considered in Sec. IV C.
The system is modeled as a three-level system with Hamiltonian and the unit by a two-level system ("bit") with Hamiltonian Thus, the bare system and unit Hamiltonians are completely degenerate.
The system-unit interaction is switched on and off at the beginning and end of the full interval of length τ , such that the time interval between the unit interactions is infinitely short (i.e. τ → τ ). During the interaction, the degeneracy of the system and unit states is lifted via such that the energy of the system-unit states |A1 , |B1 , |C1 becomes S + U + ∆w, and the energy of the system-unit states |A0 , |B0 , |C0 is S + U . The model is completed by adding a weakly coupled reservoir and by assuming that it induces thermally activated transitions between the following levels: A0 ↔ B0, B0 ↔ C0, C0 ↔ A1, A1 ↔ B1 and B1 ↔ C1. For other possible physical setups see Refs. [93,95].
Note that, although we have written down the model in a quantum mechanical way, the model in Ref. [35] is purely classical. In this spirit we neglect any subtleties arising from deriving a ME for degenerate quantum systems and use a classical rate equation where those levels are connected that interact with the reservoir as specified above. Then, the ME takes on the form d t p(t) = Rp with (in suitable units) [35] The parameter ∈ (−1, 1) is related to ∆w by local detailed balance [see Eq. (30)] via −β∆w = ln 1− 1+ . The initial state of the incoming units is given by ρ U (0) = 1+δ 2 |0 0| + 1−δ 2 |1 1| with δ ∈ [−1, 1]. The stationary solution for the system is obtained by solving this rate equation for a time τ with an initial condition ρ U (0) for the units and ρ S (0) = ρ S (τ ) for the system. As demonstrated in Ref. [35], it can be solved exactly.
Our thermodynamic analysis from Sec. III now tells us immediately that ∆E S = 0 and ∆E U = 0 due to the degeneracy of the bare system and unit Hamiltonian. Since ∆E U = 0 it also follows from Eq. (61) that the stream of bits constitutes an information reservoir unless ∆S U = 0, too. Furthermore, because we have no explicit driving, we also have W X = 0 [see Eq. (43)], and when the system has reached its steady state, we will also have ∆S S = 0. The first law (46) then tells us that In fact, Mandal and Jarzynski imagined a little load attached to the system such that the heat absorbed from the system can be identified as work. Within our setup we indeed see that this "attaching of the load", i.e. the switching on and off of the system-unit interaction, is responsible for providing that energy and has a clear microscopic interpretation in our framework. From Eq. (44) we can immediately compute This term exactly equals (minus) the work identified in Ref. [35]. Finally, in accordance with our second law (62) it was also shown in [35] that B. Work reservoir: the micromaser The micromaser is historically, experimentally, and theoretically important and its operation is based on repeated interactions. Beyond quantum optics it has also been used, e.g. as a model system for transport in superconducting single-electron transistors coupled to quantum resonators [161], where it displays an intriguing dynamics such as self-sustained oscillations and transitions to multistable behaviour. We now briefly elaborate on the fact that in its simplest version, the micromaser can be viewed as a system interacting with a stream of units which operate as a work reservoir. Our approach will be qualitative since the detailed calculations can be found, e.g. in Refs. [32,33,154].
The system S in this case consists of a high quality cavity supporting a microwave field with Hamiltonian H S = Ωa † a where a † and a are bosonic creation and annihilation operators and Ω denotes the frequency of the cavity. The microwave mode is coupled to an external reservoir of electromagnetic field modes at equilibrium with temperature β −1 and "high quality" means that the coupling is very weak, especially such that it is negligible on timescales when the system interacts with an atom flying through the cavity. This atom corresponds to a unit U and can be conveniently modeled as a two-level system (TLS) H U = ∆ 2 (|1 1| − |0 0|) with energy gap ∆ ≈ Ω (on resonance with the cavity). Depending on the experimental details the units can be prepared in different states and might arrive at the cavity at regular intervals or Poisson distributed, see Fig. 6 for a sketch of the setup and Ref. [34] for a recent experiment even involving measurement and feedback.
In the standard setup the TLSs are prepared in a statistical mixture of excited and ground states and interact with the cavity during a short time (compared to the cavity lifetime) via a Jaynes-Cummings interaction Hamiltonian V SU = g(|0 1|a † + |1 0|a) causing the atom to emit or absorb photons [33]. By tuning the interaction time (or the interaction strength g respectively) correctly, one can make sure that an atom initially in the excited (ground) state will always emit (absorb) a cavity photon. In essence, the effect of the cavity is therefore to swap the population of the TLSs.
This implies a difference in energy between incoming and outgoing TLSs (∆E U = 0), but not in entropy because entropy is invariant under exchange of state labels (∆S U = 0). Hence, the stream of atoms acts as a pure source of work which builds up a photon field inside the cavity. However, because the cavity is weakly coupled to an outside thermal reservoir, it constantly looses photons, too. To achieve a steady state occupation of the cavity above the thermal average, the incoming TLSs must be in a population-inverted state, i.e. have a higher probability to be excited then in the ground state. More details, such as the exact threshold condition for a buildup of the cavity field, are given in Refs. [32,33,154].
C. Quantum coherence as a resource: lasing without inversion As explained in the previous section, the thermodynamic working principle (but not the physical origin) of the micromaser can be understood within classical physics. However, it is also possible to populate a cavity above its thermal distribution by using a stream of atoms (units) without population inversion. This phenomenon is known as lasing without inversion [33] and results from a destructive interference of the photon absorption process due to a coherent superposition of the energy levels of the incoming unit. Thus, lasing without inversion is a pure quantum effect.
The idea to use quantum coherence via lasing without inversion in order to extract more work from a heat engine than classically possible was proposed by Scully et al. in Ref. [22], see also Refs. [163,164] for similar models and Ref. [76] for a resource theory formulation of the problem. We now briefly sketch how to treat lasing without inversion [33] and how to rederive the results from Ref. [22] from our results of Sec. V B.
The system we are considering is the same as for the micromaser (i.e. a single cavity with frequency Ω). The units are three-level systems described by We assume a so-called "Λ-configuration" [33] where the two states |b and |c are nearly degenerate (E b ≈ E c ) and well separated from the excited state |a , which is nearly resonant with the cavity (i.e.
The initial state of the units is modeled as a statistical mixture between the energy eigenstates with an additional coherence allowed between the near-degenerate levels |b and |c . Following the notation of Ref. [22], we use ρ U = P a |a a| + P b |b b| + P c |c c| + ρ bc |b c| + ρ cb |c b| , with P a + P b + P c = 1, P a,b,c ≥ 0 and ρ bc = ρ * cb ∈ C. Beyond that, the positive-definiteness of ρ U requires ρ bc ρ cb ≤ P b P c . Finally, the interaction between system and unit is modeled by a generalized Jaynes-Cummings Hamiltoniañ V = −g a(|a b| + |a c|) + a † (|b a| + |c a|) , (159) where we assumed that the direct transition between |b and |c is dipole-forbidden [33] and assumed an interaction scenario as in Sec. V B 1. We note that in the interaction picture with respect to H S + H U we havẽ due to the resonance condition. We now assume a cavity of very high quality neglecting any dissipation due to the electromagnetic reservoir such that the system interacts with many atoms coherently. This corresponds to the stage 1 → 2 in Fig. 2 of Ref. [22]. Using Eq. (158), it is easy to confirm that tr U {Ṽ ρ U } = 0. Then, following Sec. V B we see that Eq. (125) requires us to compute sixteen correlations functions B l B k U where we identify B 1 ≡ −g|a b|, B 2 ≡ −g|a c|, B 3 ≡ −g|b a| and B 4 ≡ −g|c a|. Only six are non-zero and the ME (125) in the interaction picture becomes with the dissipator D defined below Eq. (93) and some effective and for our purposes unimportant rate γ eff > 0. The Lindblad form is ensured by the non-negativity of the unit density matrix which implies (P b + P c + ρ bc + ρ cb ) ≥ 0. Note that D[a † ] describes the absorption and D[a] the emission of a cavity photon.
If the unit is initially in a thermal state with occupations P a = e −βΩ/2 /Z and P b = P c = e βΩ/2 /Z and without coherences, ρ bc = ρ cb = 0, the rates for emission and absorption satisfy local detailed balance and the equilibrium state ρ S β is the steady state of the ME.
In contrast, with coherences ρ bc +ρ cb = 2 (ρ bc ) (which can be positive as well as negative) the rate of absorption can be decreased or increased. If 2 (ρ bc ) < 0, the rate of photon absorption by the units is lowered and lasing without inversion becomes possible. Note that, typically, such coherences in three-level lambda systems are created by two coherent light fields via stimulated Raman processes, i.e. time-dependent external lasers which thus ultimately provide a resource of energy.
To show the equivalence of these results with those of Ref. [22], we compute the evolution of the mean photon occupation of the cavity N (t) ≡ tr S {a † aρ S (t)}. Using [a, a † ] = 1 and the property tr{ABC} = tr{CAB}, we obtain which is identical to Eq. (5) in Ref. [22] (after replacing N (t) with n φ and γ eff with α) from which the results in Ref. [22] are derived. The steady state occupation reads For zero coherence it corresponds to the (equilibrium) Bose distribution. But for finite coherence, the cavity population can be lowered or raised. This means that the non-equilibrium free energy of the incoming atoms has been converted into a non-equilibrium free energy for the cavity. This feature alone does not yet yield a positive work output, but a thermodynamic cycle which does so is presented in Ref. [22]. It basically relies on the fact that the population N (t) of the cavity is related to a radiation pressure P via P ∼ N (t), which can be used to drive a piston. Then, by putting the cavity first in contact with the stream of atoms populating it according to some effective temperature T eff > T [which can be inferred from Eq. (163)] and afterwards with a standard heat reservoir at temperature T , we can extract work proportional to N T eff − N T where N T denotes the Bose distribution.
The idea behind lasing without inversion thus provides an example of how our framework can account for coherences. Following Ref. [22], we have shown that these latter can be used as a thermodynamic resource. During the first part of the cycle as described above, the units do not correspond to any limiting classification scheme introduced in Sec. IV because the initial state of the units is not thermal and in general the energy as well as the entropy of the units will change, whereas during the rest of the cycle (where the systems expands back to an equilibrium distribution) there are no units interacting with the system.

D. Measurement and feedback: electronic Maxwell demon
In the traditional thought-experiment of Maxwell, the demon shuffles gas particles from a cold to a hot reservoir with negligible consumption of energy [18,19]. In an isothermal setup, a similar violation of the traditional second law appears if a feedback mechanism shuffles particles from a reservoir with low chemical potential to a reservoir with high chemical potential. This is the central idea of the electronic Maxwell demon, which has been theoretically well studied for a number of different models [95,140,144,[165][166][167][168][169][170]. The setup proposed in Ref. [144] was recently experimentally realized in Ref. [171]. Below, we revisit one particular electronic Maxwell demon.
The system to be controlled is a conventional singleelectron transistor (SET), which consists of a single-level quantum dot connected to two thermal reservoirs with chemical potential µ ν (ν ∈ {L, R}) at the same inverse temperature β. The quantum dot can either be filled with an electron of energy S or empty (corresponding to a zero energy state). A sketch of the setup (with the feedback mechanism described below) is shown in Fig. 7. The ME governing the time evolution of the system in absence of feedback is where the thermal generators are defined as Here, f ν = (e β( S −µν ) + 1) −1 is the Fermi function evaluated at the energy of the quantum dot, and Γ ν ≥ 0 is a bare rate which depends on the details of the microscopic coupling Hamiltonian. Furthermore, |E S (|F S ) denotes the empty (filled) state of the dot and the dissipator D is defined in the same way as below Eq. (93).
We now would like to engineer a demon mechanism operating a feedback control on the system which modulates the energy barriers of the dot (i.e. the bare rates Γ ν ) depending on the dot state as sketched in Fig. 7. The phenomenological description of this mechanism was done in Ref. [166] and its thermodynamical analysis was performed in Ref. [140]. A physical mechanism autonomously implementing this feedback was proposed Ref. [144]. It relies on a capacitive coupling to another single level quantum dot at a different temperature. This mechanism was further analyzed in Refs. [146,170] and will be also used below for comparison. We now propose a different mechanism implementing the same feedback on the system. As sketched in Fig. 7, this one is based on repeated interactions with a stream of units consisting of two-level systems prepared in the state ρ U = (1 − )Π 0 + Π 1 , where Π i = |i U i| is the projector on the state i ∈ {0, 1} and ∈ [0, 1] is a free parameter quantifying the measurement error. The system consists of a single-level quantum dot tunnel-coupled to two electronic reservoirs with chemical potentials µL ≥ µR and inverse temperature β. The demon mechanism is implemented by a stream of units which monitors the state of the dot and depending on its state, changes the tunneling barriers Γν to make electronic transport against the bias possible. In absence of the demon mechanism, the tunneling barriers would not depend on the state of the dot and electrons would flow from left to right. The picture of the demon was provided by courtesy of Ania Brzezinska.
At the beginning of the interaction interval, we assume that the interaction produces an instantaneous unitary operation U ms = Π E ⊗1 U +Π F ⊗σ x U where Π E = |E S E| and Π F = |F S F | and σ x U = |0 U 1|+|1 U 0|, which can be interpreted as a measurement. Indeed, considering an initial system state of the form ρ is the probability to find the system in the empty [filled] state, the post measurement state of the system and unit reads ρ ms Note that = 0 corresponds to a perfect measurement in which the state of the unit after the measurement is 0 (1) if and only if the state of the system is E (F ). The reduced state of the system is always given by ρ ms S (t) = tr U {ρ ms SU (t)} = ρ S (t), which means that the measurement does not disturb the system. This feature circumvents the difficulty mentioned in Sec. V B 1 and allows us to consider a continuously measured system in which δt (the waiting time between two units) can be arbitrarily small despite the fact that the system is still interacting with its reservoir.
Next, in spirit of Sec. IV E and Eq. (73), we postulate a Hamiltonian of the form SR +H R which acts during the remaining interaction time δt and changes the system reservoir coupling H (i) SR according to the state i of the unit. Assuming that we can treat H (i) SR as a weak perturbation, we are effectively changing the tunneling rates from Γ ν to Γ (i) ν and the time evolution of the system and unit is then given by Tracing over the unit space and expanding this equation to first order in δt (assuming that δt is sufficiently small) yields an effective evolution equation for the system of the form d t ρ S (t) = L eff ρ S (t) with This equation is identical to the ME obtained for the system when it is subjected to the capacitive demon mechanism considered in Ref. [144] which results from coarsegraining the demon dot and only retaining the SET degrees of freedom. In the error-free case ( = 0), it also reduces to the effective ME of Ref. [166], but the above procedure constitutes an elegant way to generalize arbitrary piecewise-constant feedback schemes [172] to finite detection errors. We now turn to the thermodynamic analysis of our new demon mechanism. First of all, we can assume that the unit Hamiltonian H U ∼ 1 U is fully degenerate. This implies d t E U = 0 at all times. Then, during the measurement step, the system and unit correlate such that [see Eq. (68)] I ms S:U = d t S ms U δt, where we used the fact that d t S ms S = 0 since the system density matrix is left unchanged by the measurement. This correlation can then be exploited during the feedback step. The second law for feedback (75) in our situation reads in a differential form aṡ where for simplicity we assumed that the system operates at steady state d t S fb S = 0 and where we used d t S fb U = 0 because the entropy of the unit does not change during the feedback step. Furthermore, the entropy flow reads −βQ (L) − βQ (R) = β(µ L − µ R )I L , where I L is the matter current which entered the system from the left reservoir. Finally, I fb S:U quantifies the remaining system-unit correlations after the feedback step.
In spirit of Eq. (47) it will turn out to be useful to include the final correlation I fb S:U in the second law and to definė Here, the newly defined quantity I is the rate with which we use up the correlations established during the measurement. I had not yet been considered in previous works on this system. In fact, the information current in Ref. [140] is purely phenomenological in nature, whereas the information flow in Ref. [146] describes the same quantity but in a bipartite setting. Note that while both terms  170)), the total one generated by the capacitive feedback mechanisṁ Σ cap (dashed green line, Refs. [144,146]), and the "effective" estimate obtained in these two cases if the demon mechanisms were not knownΣ eff S (dash-dotted red line, Eq. (172) and Ref. [140]). The top row shows these quantities as a function of the bias voltage V ≡ µL − µR for two different measurement errors . The bottom row shows them as a function of the measurement error ∈ [0, 1/2) for two different voltages V . The region in which we extract work is shaded in gray. Other parameters are Γ = 1, δ = ln 2, β = 0.1 and U = 0.1 and we choose a symmetric configuration of the bias, µL = S + V /2 and µR = S − V /2, effectively eliminating the dependence on S in the equations.
instead of Eq. (169). More specifically, we can compute For the last equality we used the steady state solution of p E and p F and parametrized the rates as Γ (0) R ≡ Γe δ , such that δ ∈ R characterizes a feedback strength. Note that I diverges for → 0. This makes sense because if we monitor the quantum dot in an error-free way, we can also extract an infinite amount of work by letting δ → ∞.
It is now interesting to compare the total entropy production generated by the two different electronic demon mechanisms, i.e. the one due to capacitive coupling with another quantum dot [144], denoted here asΣ cap , and the one generated by repeated interactions considered above, Σ. These two entropy productions can then be compared to the effective oneΣ eff S , obtained when the demon mechanism is not known and the only information at hand is that of the system's effective description. The best one can do in this case is to derive an "effective" second law in spirit of Eq. (108) or of Ref. [140] which at steady state can be written aṡ and is equivalent to Eq. (14) of Ref. [144]. Hereρ is the steady state fulfilling L effρ = 0 andρ ν is the steady state with respect to reservoir ν, i.e. L (ν) effρ ν = 0. Since this "effective" approach only quantifies the demon effect on the system and neglects the demon's dissipation, it will typically underestimate the true dissipation [89,144].
To make the comparison between the various dissipations meaningful, we must compare them in the regime where they all give rise to the same effective dynamics on the system, i.e. to the same ME (168). For the repeated interaction mechanism,Σ is given by (170) while the effective dissipationΣ eff S is given by (172). For the capacitive mechanism,Σ cap is given by Eq. (7) in Ref. [144] in the fast demon limit Γ D → ∞, which is required to derive the ME (168). In this limitΣ cap also coincides with Eq. (24) in Ref. [146] and therefore gives it an alternative interpretation in terms of the flow of mutual information. Note that we can link the measurement error to the parameters used in Ref. [146] via the relation β D U = 2 ln 1− . The comparison is done in Fig. 8. We observe that the effective second lawΣ eff S greatly underestimates the true entropy production as expected, but also that the total entropy production generated by the two different demon mechanisms,Σ andΣ cap , are remarkably close.

A. Connection to traditional thermodynamics
We have seen in Sec. IV A that if the units are initially thermal, our engine cannot surpass Carnot efficiency and deviations of the final unit state from the ideal thermal reservoir (i.e. nonequilibrium effects) always cause an even smaller efficiency. However, if the units are prepared in an arbitrary state, we found that one can continuously extract work from a single heat reservoir by lowering the nonequilibrium free energy of the units according to Eq. (49). We explained that this does not violate the second law of thermodynamics because the overall entropy does not decrease. One may nevertheless wonder if this contradicts the classical formulation of the second law according to Kelvin and Planck stating that: There is no cyclic process in nature whose sole result is the conversion of heat from a single reservoir into work.
To answer, let us close the "cycle of units" by feeding the outgoing units back into the system S after they have interacted with an additional system S in contact with the same overall heat reservoir at temperature T , as illustrated on Fig. 9. We assume to be at steady state and denote the outgoing units after the interaction with system S by U , which are in turn the incoming units for system S . The additional system S is required to reset the units U to the state U , which again correspond to the incoming units of S. Then, for S and S we find the two separate second laws (49) Hence, although W might be negative, the sum W + W must be non-negative in perfect agreement with the Kelvin-Planck statement of the second law of thermodynamics.

B. Quantum versus Classical Thermodynamics
At this point it is worth revisiting the debated question of whether quantum thermodynamics offers advantages (e.g. in terms of a higher power output or efficiency) in comparison to classical thermodynamics. There is ample evidence that states with quantum properties such as entanglement, coherence or squeezing can be used to extract more work than from thermal states, see e.g. Refs. [22-25, 27, 28, 76, 163, 164, 173, 174] (and also Sec. VI C). However, this by no means implies that quantum thermodynamics outperforms classical thermodynamics. Indeed, classical nonequilibrium properties are usually not considered, but if one only allows for nonequilibrium properties which are of a purely quantum ori-gin, this amounts to an unfair competition. In the repeated interaction framework the nonequilibrium free energy (23) captures both quantum and classical effects and we will now use it to analyze the thermodynamics of work extraction. Note that, despite its limitations, the framework fully captures quantum effects in the unit state and in the system-unit interaction.
In the ideal scenario where no final system-unit correlations are present (since they always degrade the amount of extractable work) 13 the second law (49) bounds the extractable work as The extractable work −W gets therefore maximized for a maximum initial and minimum final nonequilibrium free energy. The relevant question is therefore whether this procedure can be improved due to quantum effects? Let us consider an arbitrary unit which has N levels and a Hamiltonian H U = n E n |n n| with E 1 ≤ · · · ≤ E N . The state with maximum free energy corresponds to a state with maximum energy and minimum entropy as we can easily infer from Eq. (23). This state is given by ρ U (0) = |N N | and thus, is also an allowed classical state. 14 Finding the state with minimum free energy is more tricky and in general context dependent. 15 We can nevertheless easily show that the state with minimum free energy must be "classical". For this purpose lets define classical states as states which are diagonal in the energy eigenbasis, i.e. states which can be written as ρ cl = n p n |n n|. Let us denote by ρ QM quantum states (i.e. states for which there exists n = m such that n|ρ QM |m = 0) which minimize the nonequilibrium free energy. Its corresponding classical state (obtained by neglecting all coherences) is given by ρ cl = n n|ρ QM |n |n n|. If we now assume that the nonequilibrium free energy corresponding to ρ QM is strictly smaller than that of ρ cl , we get By construction we know that the left hand side is zero 13 We note that the maximum value of the quantum mutual information I S:U can be twice as large as its classical counterpart. Thus, quantum correlations in the outgoing state have the potential to degrade the amount of extractable work to a larger extend then classical ones. 14 If the highest energy belongs to a degenerate subspace, i.e. E N = E N −1 = . . . , then there is an additional freedom in the choice of ρ U (0) which, however, does not change the nonequilibrium free energy. 15 We remark that the argument presented here is even valid at finite times τ < ∞ and for time-dependent Hamiltonians, i.e. out of equilibrium. Realizing that a Gibbs state is a state of minimum free energy with respect to a reservoir at inverse temperature β is therefore of no help since the system might be driven and/or does not have the time to reach the Gibbs state.
(178) Since furthermore we have that S(ρ QM ) < S(ρ cl ) (Theorem 11.9 in [43]), Eq. (177) leads to a contradiction and the state of minimum free energy must necessarily be classical.
We thus proved that within our framework there is no benefit in using quantum over classical "resources" in terms of the bound dictated by the generalized second law. That is to say, for any scenario where quantum effects are used to extract work, an equivalent classical scenario can be conceived (using classical units with the same number N of basis states but a different interaction) which extracts at least the same amount of work. It should be noted, however, that we did not investigate the question how this bound can be reached and there is evidence that quanutum systems can offer advantages in terms of speed, i.e. if we want to extract work at finite power [175][176][177][178][179][180].

C. Summary and outlook
We start by summarizing the paper together with its key results. In Sec. II, we reviewed the exact identities describing the correlated dynamics of two interacting systems, one of which could be considered as a reservoir that is initially thermal. We also considered the weak-coupling limit which implicitly assumes macroscopic reservoirs. In Sec. III, we extended these concepts to describe a system which in addition of being continuously interacting with an initially thermal reservoir is subjected to repeated interactions with identical units prepared in arbitrary states. By establishing exact energy and entropy balances, we showed that the stream of units can be seen as a nonequilibrium reservoir or a resource of free energy. In Sec. IV, we identified the limits where these units operate as a pure work, heat or information reservoir and also formulated Landauer's principle. Most importantly, we showed that our setup can be used to formulate quantum feedback control, derived a new generalized bound for the extractable work and provided a clean connection to the theory of information reservoirs.
Up to that point, the discussion was based on exact identities which are conceptually powerful but of limited practical use. In Sec. V, we started focusing on limits where the system obeys a closed effective dynamics. We derived effective MEs for the system and established their corresponding thermodynamics: This has been done in Subsec. V A when the system weakly and continuously interacts with a thermal reservoir while rarely interacting with units arriving at Poisson distributed times, and in Subsec. V B when the system frequently interacts solely with the units. We also discussed in Subsec. V C the limit where a time dependent system Hamiltonian can be effectively mimicked by a stream of units behaving as a pure work source.
Finally, in Sec. VI we used our framework to analyze important models which were previously considered for their non-conventional thermodynamic features. In Subsec. VI A we proposed a microscopic model effectively implementing the Mandal-Jarzynski engine. We showed that the work extracted from the entropy of the tape originates from the switching on and off of the systemunit interaction. In Subsec. VI B we used our framework to study the thermodynamics of the micromaser which is probably the most popular setup making use of repeated interaction. Building on an extension of this model, we showed in Subsec. VI C that work can be extracted from purely quantum features based on the idea of "lasing without inversion". Finally, in Subsec. VI D we considered a Maxwell demon effect on an electronic current crossing a single level quantum dot which was theoretically studied in the past and also experimentally realized. We analyzed this effect thermodynamically when the demon mechanism is operated by repeated interactions with a stream of units and showed how it differs from the previously considered mechanisms.
The framework of repeated interactions presented in this paper is quite general and provides a unifying picture for many problems currently encountered in the literature. It nevertheless has limitations. For instance, our results crucially rely on the fact that the individual units in the incoming stream are decorrelated. This assumption is often justified, but recent works started to investigate the role of correlated units, classically [181][182][183][184][185] as well as quantum mechanically [186]. This leads in general to a refined second law with tighter bounds on the amount of extractable work [181,182,185]. The cost for creating these correlated units ("patterns") was considered in Ref. [183], and Ref. [184] proposed a simple device to exploit these based on techniques of predictive coding (which is a special coding technique, see, e.g. Sec. 4.7.2 in Ref. [87]). In turn, Ref. [186] investigated a model where work extraction and information erasure is simultaneously possible (and is even enhanced by quantum correlations). It would also be interesting to investigate the role of temporal correlations in the unit string due to non-exponential waiting time distribution.
Another limitation of our results when deriving effective master equations is that, although system-unit interactions can be arbitrary strong, the system-reservoir interaction must be weak and the resulting dynamics Markovian. Uzdin et al. [187] recently tried to tackle this issue via "heat exchangers" which could be strongly coupled to the system and which are equivalent to our units. Therefore, their work faces similar limitations as ours. Besides few exact identities, the correct thermodynamic description of a system in strong contact with a continuous (perhaps non-Markovian) reservoir is still an open and active field of research [47,[188][189][190][191][192][193][194][195][196][197][198][199][200][201].
As a final remark, let us note that connecting our present work to the recently developed quantum resource theories [38,39] is an interesting perspective, as already indicated in Sec. III E. The goal of these theories is to establish an axiomatic mathematical framework to study quantum thermodynamics based on the study of the interconvertibility of states under certain constraints. In fact, if we switch off the permanent coupling to the heat reservoir, assume initially thermal units and demand that ∆E S + ∆E U = 0, our framework becomes identical to the one used in the resource theory of thermal operations [39]. However, we have demonstrated that a consistent thermodynamic framework can be also established for a much larger class of situations which are also of experimental relevance. Applying the tools and results from resource theory to such problems could prove useful.