Maximum power and corresponding efficiency for two-level heat engines and refrigerators: optimality of fast cycles

We study how to achieve the ultimate power in the simplest, yet non trivial, model of a thermal machine, namely a two-level quantum system coupled to two thermal baths. Without making any prior assumption on the protocol, via optimal control we show that, regardless of the microscopic details and of the operating mode of the thermal machine, the maximum power is universally achieved by a fast Otto-cycle like structure in which the controls are rapidly switched between two extremal values. A closed formula for the maximum power is derived, and finite-speed effects are discussed. We also analyse the associated efficiency at maximum power (EMP) showing that, contrary to universal results derived in the slow-driving regime, it can approach Carnot's efficiency, no other universal bounds being allowed.


Introduction
Two thermal baths in contact through a working fluid that can be externally driven represent the prototypical setup that has been studied from the origin of thermodynamics up to our days. The energy balance can be described in terms of three quantities: the work extracted from the fluid and the heat exchanged with the hot/cold baths. The fundamental limitations to the inter-conversion of heat into work stem from the concept of irreversibility and are at the core of the second law of thermodynamics. A working medium in contact with two baths at different temperatures is also significant from a practical point of view, since it is the paradigm behind the following specific machines: the heat engine, the refrigerator [1][2][3][4], the thermal accelerator [5], and the heater [5].
Quantum thermodynamics [6][7][8] has emerged both as a field of fundamental interest, and as a potential candidate to improve the performance of thermal machines [9][10][11][12][13][14][15][16][17][18][19][20][21][22][23]. The optimal performance of these systems has been discussed within several frameworks and operational assumptions, ranging from low-dissipation and slow driving regimes [24][25][26][27][28], to shortcuts to adiabaticity approaches [29][30][31][32], to endoreversible engines [33,34]. Several techniques have been developed for the optimal control of two-level systems for achieving a variety of goals: from optimizing the speed [35][36][37], to generating efficient quantum gates [38,39], to controlling dissipation [40,41], and to optimizing thermodynamic performances [42][43][44][45][46][47]. The aim of the present paper is to find the optimal strategy to deliver maximum power in all four previously mentioned machines. We perform this optimization in the simplest, yet non trivial, model of a machine which, in the spirit of quantum thermodynamics, is based on a two-level quantum system as working fluid. As opposed to current literature, we explicitly carry out the power maximization without making any assumptions on the operational regime, nor on the speed of the control parameters, nor on the specific coupling between the working fluid and the bath. We find that, if the evolution of the working medium is governed by a Markovian master equation [48,49], the optimal driving takes a universal form: an infinitesimal Otto-cycle-like structure in which the control parameters must be varied between two extremal values as fast as possible. This is our first main results, described in Eq. (8). Surprisingly, the optimal solution is achieved in the "fast-driving" regime, i.e. when the driving frequency is faster than the typical dissipation rate induced by the baths, which has received little attention in literature [50][51][52].
By applying our optimal protocol to heat engines and refrigerators, we find new theoretical bounds on the efficiency at maximum power (EMP). Many upper limits to the EMP, strictly smaller than Carnot's efficiency, have been derived in literature, such as the Curzon-Ahlborn and Schmiedl-Seifert efficiencies. The Curzon-Ahlborn efficiency emerges in various specific models [53][54][55], and it has been derived by general arguments from linear irreversible thermodynamics [56]. The Schmiedl-Seifert efficiency has been proven to be universal in cyclic Brownian heat engines [57] and for any driven system operating in the slow-driving regime [24]. By studying the efficiency of our system at the ultimate power, i.e. in the fast-driving regime, we prove that there is no fundamental upper bound to the EMP. Indeed, we show that the Carnot efficiency is reachable at maximum power through a suitable engineering of the bath couplings. This is our second main results, illustrated in Figs. 2b, 2c and 3. In view of experimental implementations, we assess the impact of finite-time effects on our optimal protocol, finding that the maximum power does not decrease much if the external driving is not much slower than the typical dissipation rate induced by the baths [58,59]. Furthermore, we apply our optimal protocol to two experimentally accessible models, namely photonic baths coupled to a qubit [22,[60][61][62][63] and electronic leads coupled to a quantum dot [21,23,58,59,64,65].

Maximum Power.
The setup we consider consists of a two-level quantum system S with energy gap (t) that can be externally modulated [66]. As schematically shown in Fig. 1a, the system is placed in thermal contact with two reservoirs, the hot bath H at inverse temperature β H and the cold bath C at inverse temperature β C , respectively characterized by coupling constants λ H (t) and λ C (t) that can be modulated in time. The system can operate in four different modes: i) the heat engine mode [E], where S is used to produce work by extracting heat from H while donating it to C; ii) the refrigerator mode [R], where S is used to extract heat from C; iii) the thermal accelerator mode [A], where S operates to move as much heat as possible to C; iv) the heater mode [H], where we simply use S to deliver as much heat as possible to both H and C. Assuming cyclic modulation of the controls (i.e. of (t), λ H (t) and λ C (t)) we are interested in maximizing the corresponding averaged output powers of each operating mode, i.e. the quantities where J H and J C are the instantaneous heat fluxes entering the hot and cold reservoirs respectively, and where the symbol · · · stands for temporal average over a modulation cycle of the controls. To tackle the problem we adopt a Markovian Master Equation (MME) approach [60], namely we write whereρ is the density matrix of the two-level system at time t,Ĥ := (t)σ +σ− its local Hamiltonian, and is the Gorini-Kossakowski-Sudarshan-Lindblad dissipator [48,49] associated with the bath α = H, C. We have denoted withσ + andσ − the raising and lowering operators of S and with the symbol [· · · , · · ·] ∓ the commutator (−) and anti-commutator (+) operations. D α is characterized by dissipation rates Γ (i=±) α ( ) and by the dimensionless coupling constant λ α (t) ∈ [0, 1] that plays the role of a "switch" control parameter. It is worth noticing that, since [Ĥ(t),Ĥ(t )] = 0, the MME we employ is valid also in the fast-driving regime, provided that the correlation time of the bath is the smallest timescale in our problem [67]. Therefore, the fast-driving regime is characterized by a control frequency which is faster than the typical dissipation rate, but slower than the inverse correlation time of the bath. Furthermore, we assume that the Hamiltonain H int , describing the system-bath interaction, is such that its expectation value on the Gibbs state of the baths is zero (this is true, for example, for tunnel-like Hamiltonians, where the number of creation/annihilation operators of the bath enteringĤ int is odd). Such assumption guarantees that no work is necessary to switch on and off the coupling between the system and the baths.
Without assigning any specific value to the dissipation rates, we only require them to obey the detailed balance equation Γ (+) α ( )/Γ (−) α ( ) = e −βα . This ensures that, at constant level spacing , the system S will evolve into a thermal Gibbs state characterized by an excitation probability when in contact only with heat bath α. For simplicity, we consider the system to be coupled to one heat bath at the time, i.e. we assume that λ H (t) + λ C (t) = 1, and that λ α (t) can take the values 0 or 1. As we shall see in the following, this constraint, as well as the possibility of controlling the coupling constants λ α (t), is not fundamental to derive our results, at least for those cases where the effective dissipation rate of each bath is sufficiently peaked around distinct values. The instantaneous heat flux leaving the thermal bath α can now be expressed as [62] is the probability of finding S in the excited state of H at time t which obeys the following differential equation according to the MME specified above. By explicit integration of (7) we can hence transform all the terms in Eq. (2) into functionals of the controls which can then be optimized with respect to all possible choices of the latter.
As shown in App. A, we find that the protocols which maximize the average power of a fixed physical setup, i.e. at fixed dissipation rates, are cycles performed in the fast-driving regime, i.e. when the driving frequency is faster than the typical dissipation rate. More precisely, the optimal cycle is such that (t) instantaneously jumps between two values H and C , see Fig. 1b, while being in contact, respectively, only with the hot and cold bath for infinitesimal times τ H and τ C fulfilling the condition τ H /τ C = Γ C ( C )/Γ H ( H ) [68]. As in Otto cycles considered in literature (see the extensive literature on this topic, e.g. [10,12,20,[69][70][71]), no heat is transferred during the jumps and no work is done while the system is in contact with the baths. The resulting maximum power averaged over one period can then be cast into the following compact expression (see App. B for details) where ν = E,R,A,H and the quantity [ν] is given by In Eq. (8) C is the range over which the energy gap (t) of S is allowed to be varied according to the possible technical limitations associated with the specific implementation of the setup. Equation (8), which stems from the optimality of the fast-driving regime, is the first main result of the present work. We emphasize that, as opposed to current literature, our closed expression for the maximum power holds for any dissipation rate function Γ H/C ( ). In the following we will apply our result to specific implementations which are relevant experimentally and compute their associated efficiencies at maximum power. In particular we shall consider the case of fermionic (F n ) and bosonic (B n ) baths with associated effective rates of the form with n ≥ 0 integer and with k α being a coupling strength constant. The fermionic rate (the first of Eq. (9)) for instance can describe two electronic leads, with density of states depending on n, tunnel coupled to a single-level quantum-dot [64,72,73]; the bosonic one instead is applied in the study of two-level atoms in a dispersive quantum electromagnetic cavity [74].

Heat engine mode [E].
It is common belief that the efficiency of a heat engine (work extracted over heat absorbed from the hot bath H), driven at maximum power (EMP), should exhibit a finite gap with respect to the Carnot efficiency η c := 1 − β H /β C . Indeed, this is corroborated by various results on EMP bounds: the Curzon-Ahlborn EMP η CA := 1 − √ 1 − η c emerges in various specific models [27,53,57], and it has been derived by general arguments from linear irreversible thermodynamics [56], while the Schmiedl-Seifert EMP η SS := η c /(2−η c ) has been proven to be universal for any driven system operating in the slow-driving regime [24]. However, the completely out-of-equilibrium and optimal cycles associated with the values of P (max) [E] reported in Eq. (8), do not fulfill such assumptions. As a matter of fact, by choosing particular "energy filtering" dissipation rates Γ α ( ) (instead of the regular ones given e.g. in Eq. (9)), we can produce configurations which approach Carnot's efficiency with arbitrary precision while delivering maximum power, proving the lack of any fundamental bound to the EMP. Before discussing this highly not trivial effect, it is worth analyzing the performances associated with the baths models of Eq. (9).
We remind that the efficiency of an Otto cycle heat engine working between the internal energies C and H is given by η = 1 − C / H . Accordingly, indicating with * H and * C the values of the gaps that lead to the maximum of the r.h.s term of Eq. (8), we write the EMP of our scheme as In Fig. 2a we report the value of η(P (max) [E] ) obtained from (10) for the rates of Eq. (9) for n = 0, 1. By a direct comparison with η CA and η SS , one notices that while the second is always respected by our optimal protocol, the first is outperformed at least for the baths F 0 and B 0 , confirming the findings of Refs. [45,65,73]. For small temperature differences between the baths, the EMP can be expanded as a power series in η c of the form a 1 η c + a 2 η 2 c + · · · . It has been shown that a 1 = 1/2 is a universal property of low dissipation heat engines [24] and, in this context, a 2 = 1/8 is associated with symmetric dissipation coefficients. As explicitly discussed in App. C, we find that also our protocol delivers an efficiency at maximum power with a first order expansion term a 1 = 1/2 and with a second order correction a 2 = 1/8 achieved if we assume that the two leads are symmetric, i.e. Γ H ( , β) = Γ C ( , β), or if the rates are constants.
We now turn to the possibility of having η(P ) arbitrarily close to η c . By a close inspection of the second identity of Eq. (10) we notice that one can have η(P (max) [E] ) η c for all those models where the maximum power (see Eq. (8)) is obtained for values of the gaps fulfilling the condition * C β C ≈ * H β H . Consider hence a scenario where the rates Γ α ( α ) are such that the power is vanishingly small for all values of α except for a windows of width σ around a given value¯ α , a configuration that can be used to eliminate the presence of the activation controls λ α (t) from the problem. Under the assumption of small enough σ, we expect the maximization in Eq. (8) to ) ≈ η c . This is indeed evident from Fig. 2b and 2c, where we report the value ) as a function of η c (which represents the temperature of the baths) for rates having a Lorentzian shape dependence: by decreasing σ, the EMP approaches Carnot's efficiency atη c := 1 −¯ C /¯ H = 1/2 ( Fig. 2b), while by tuning the position of the peak of the Lorentzian rates, the EMP can approach Carnot's efficiency at any given bath temperature configurationη c (Fig. 2c). We emphasize that even our system with Lorentzian shaped rates would exhibit an EMP bounded by η SS if operated in the slowdriving regime. The possibility of reaching Carnot's efficiency at maximum power is ) for the fermionic models (F 0 and F 1 ) and the bosonic models (B 0 and B 1 ) of Eq. (9) together with the upper bounds η SS [57] and η CA [53]. Notice that as η c → 0 (small baths temperature difference), we have η(P ) for the models F 1 and B 1 saturates to a finite fraction of η c , while the F 0 and B 0 models reach Carnot efficiency. The Fermionic model displays a slightly larger η(P (max) [E] ) than the corresponding bosonic model. In all models we consider symmetric leads, i.e. k H = k C . Note that η(P ) computed using Lorentzian filtering rates Γ α ( α ) = γσ 2 /(σ 2 + ( α −¯ α ) 2 ) with γ, σ and¯ α positive constants (systems with multiple quantum-dots in series [75] e.g. exhibit such dependence). In both panels we fix¯ C = 1. (b): we set¯ H = 2¯ C such that we expect to approach η c atη c = 1/2. Indeed, as σ decreases, η(P (max) [E] )/η c approaches one atη c = 1/2. Conversely, the corresponding maximum power decreases: in the inset, where P (max) [E] is plotted as a function of σ forη c = 1/2, we see that the maximum power becomes vanishingly small for σ → 0. The power is normalized to the its value for σ = 0.15, where P thus a characteristic which emerges thanks to the fast-driving regime. Conversely, as σ decreases and η(P ) → η c , the corresponding maximum power tends to zero (see the inset of Fig. 2b where the maximum power, atη c = 1/2, is plotted as a function of σ).

Refrigerator mode [R].
The efficiency of a refrigerator is quantified by the coefficient of performance (COP), i.e. the ratio between the heat extracted from the cold bath and the work done on the system. For an Otto-cylce the COP is given by of Eq. (8), yields an associated COP at maximum power (CMP) equal to is the maximum COP dictated by the second law. Remarkably, as in the heat engine case, we can produce configurations which approach C (c) op with arbitrary precision while delivering maximum power exploiting the same "energy filtering" dissipation rates. Before discussing this effect we present some universal properties of the CMP and we analyze the performance of the baths models of Eq. (9).
Assuming that the rates depend on the energy and on the temperature through the product β , i.e. Γ α ( α ) = Γ α (β α α ) (e.g. the models (9) satisfy this hypothesis for n = 0, while they do not for n > 0), we find that the COP at maximum power reduces to the universal family of curves where C (0) op represents the COP when β H = β C . It thus follows that for these models the knowledge of C op (P max [R] ) at a single bath temperature configuration identifies unambiguously the COP for all other temperature differences. This feature is in contrast with the heat engine mode since, under the same hypothesis, the EMP at arbitrary temperatures depends on the details of the system. Consider next the maximum power for the models described Eq. (9). We find that the maximization in Eq. (8) yields * H → +∞ (and a finite value of * C ), which implies P where c n is a dimensionless number which only depends on n for n > 0, while it is a function of k H /k C if n = 0 (see App. D for details). The fact that the corresponding COP is equal to zero is a direct consequence of the divergent value of * H : physically it means that the maximum cooling power [which is finite, see Eq. (13)] is obtained by performing an infinite work, thus by releasing an infinite amount of heat into the hot bath. In the more realistic scenario where there are limitations on our control of the gaps, say | α | ≤ ∆, the resulting value of P (max) [R] will be smaller than in Eq. (13) but the associated COP will be non-zero with a scaling that for large enough ∆ goes as . Equation (13) shows that in all models the maximum cooling power only depends on the temperature 1/β C of the cold lead as a simple power law, and it vanishes as 1/β C → 0. Intuitively this makes sense since it is harder to refrigerate a colder bath and at 1/β C = 0 there is no energy to extract from the bath. Furthermore, for n > 0 the properties of the hot bath (i.e. temperature and coupling constant) do not enter the P (max) [R] formula. We now return to the possibility of having the CMP arbitrarily close to C (c) op . As in the heat engine case, from the second equality of Eq. (11) we see that, if the maximization in Eq.
) as a function of C Indeed, as we can see in Fig. 3, we are able to have a CMP close to C (c) op at any desired temperature configurationC (c) op by considering appropriately tuned Lorentzian rates (described in Fig. 2).

Thermal accelerator [A] and heater [H] modes.
For the physical models described in Eq. (9) it turns out that in order to maximize the heat entering the cold bath, it is more convenient to release heat into both baths (J H , J C < 0), rather than extracting heat from the hot bath H and releasing it into the cold bath (J H > 0, J C < 0). The thermal accelerator mode [A] thus appears to be useless if we are just interested in maximizing the heat delivered to the cold bath. Accordingly, in the following we shall focus on the heater [H] mode only with a single bath (or equivalently with two baths at the same temperature). Assuming to have some physical limit | | ≤ ∆ on the way we can control the gap, from Eq. (8) we find where k is the coupling constant appearing in Eq. (9). Equation (14) shows that the maximum power diverges as ∆ → +∞, the exponent of ∆ depending on the density of states associated with the rates. Interestingly, the maximum power that can be delivered to the bath vanishes for high temperatures (β∆ 1) in the fermionic models, while it is finite and insensitive to temperature in the bosonic models. This is due to the peculiar rates of the bosonic models which diverge for β 1. On the contrary, for low temperatures (β∆ 1) both models yield the same value of P (max) [H] .

Finite-Time Corrections.
The derivation of our main equation (8) was obtained under the implicit assumption that one could implement infinitesimal control cycles. Yet this hypothesis is not as crucial as it may appear. Indeed the feasibility of an infinitesimal Otto cycle relies on the ability of performing a very fast driving with respect to the typical time scales of the dynamics, a regime that can be achieved in several experimental setups [58,59]. Furthermore by taking the square-wave protocol shown in Fig. 1b   can still be achieved also in this case (e.g. see Fig. 1c where we report the dt dependence of P (max) [H] (dt) in the heater mode). On the contrary deviations from Eq. (8) due to finite time corrections in the quenches turns out to be more relevant. These last are first order in the ration between the duration of the quench (now different from 0) and the period of the protocol dt (see App. B for details).

Conclusions.
We proved that a cycle switching between two extremal values in the fast-driving regime achieves universally the maximum power and the maximum cooling rate (respectively for a working medium operating as a heat engine or as a refrigerator), regardless of the specific dissipation rates, and we found a general expression for the external control during the cycle. The power advantage of modulating the control fields with rapid adiabatic transformations has been observed in the literature [51,70,76] for some specific model and this intuition is in agreement with our general results. We also found that the first coefficient of the expansion in power of η C of the EMP is universal while the second one is linked to the symmetry of the dissipation coefficients. This paper enlights that the features mentioned above are valid also strongly out of equilibrium, while already proven in low dissipation [64] and steady state [3] heat engines. If the bath spectral densities can be suitably tailored through energy filters (as for instance in [75]) our protocol allows to reach the Carnot bound at maximum power both operating as a heat engine or refrigerator, although at the cost of a vanishing power. This observation proves the lack of universal upper bounds to the efficiency at maximum power. Finally, a new scaling for the COP of a bath with flat spectral density is shown and a clear dependence of the EMP and the COP at maximum power on the spectral densities of the two thermal baths is established. The results are discussed in detail for some specific models, from flat bosonic and fermionic baths to environments with more complicated spectral densities, and finite driving speed effects are analyzed.

Acknowledgments.
We thank G. M. Andolina for useful discussions. This work has been supported by SNS-WIS joint lab "QUANTRA", by the SNS internal projects "Thermoelectricity in nano-devices", and by the CNR-CONICET cooperation programme "Energy conversion in quantum, nanoscale, hybrid devices".

Appendix A. Optimality of infinitesimal Otto cycles
In this appendix we present explicit proof that infinitesimal Otto cycles are optimal for reaching maximum power performances for our two-level setting.
As a preliminary result we clarify that under periodic modulations of the control parameters, the master equation (Eq. (4) of the main text) produces solutions which asymptotically are also periodic. For this purpose let us write Eq. (4) of the main text asṗ(t) = A(t)p(t) + B(t) where, for ease of notation, we introduced the functions and consider periodical driving forces such that A(t + τ ) = A(t), B(t + τ ) = B(t) for all t. By explicitly integration we get In the asymptotic limit where the initial condition p(0) has been completely forgotten (since A(t) ≤ 0 at all times, the contribution of the initial condition decays exponentially), Eq. (A.2) gives where we neglected again the contribution coming from the initial condition. Equation (A.6) defines a recursive succession, with limit point equal to c(t)/(1−d), the periodicity of c(t) concludes the proof. This result can also be framed in the general context of Floquet theory [77]. The Floquet theorem states that a fundamental matrix solution of a first order differential equation with periodically driven coefficients is quasi-periodical, namely can be written as y(t) = P (t)e M t where P (t) is a periodic matrix function (with the same period of the coefficients) and e M t is the so called monodromy matrix. The real parts of the eigenvalues of M are responsible of the asymptotic behavior of the solutions and are known as Lyapunov exponents, a stable cyclic solution is characterized by their negativity. In the case of Eq. (4) of the main text, our calculations reveal that the monodromy matrix is given by the constant d, the sign of the Lyapunov exponent is given by log d < 0, confirming our predictions about the stability.
In the above paragraph we showed that the asymptotic solution of Eq. (4) of the main text is periodic with the same period of the external driving (t). Notice that in the equilibrium scenario the previous result is trivial, since the population instantly relaxes to the Gibbs state that is a monotonic function of the control parameter . In our case we can establish only that p(t) and (t) share the same period, although finding the proper functional relation between the two is absolutely non trivial (cfr. for example [43]). However we don't need any additional information to prove that any cycle that is not infinitesimal, namely a square wave protocol in which the controls jump at a time much faster that the typical dynamical scale Γ, cannot achieve the maximum power. The proof is outlined in the following: since (t) and p(t) share the same periodicity, a cycle can be represented in the (p, ) plane as a closed curve. Let us suppose that the optimal cycle T is not infinitesimal, for example as in Fig. A1. Thus, it is possible to perform an instantaneous quench, for example, in the middle (where the probability is halfway between the minimum and maximum value), and divide the transformation in two smaller sub-cycles T 1 and T 2 (cfr. Fig A1). Since the quenches are instantaneous, they don't contribute to the heat exchanged and to the time duration of the process. Furthermore, performing the two sub-cycles in series effectively builds a transformation with the same average power of the original cycle, a property that in symbols we can exemplify as P (T ) = P (T 1 • T 2 ). Simple calculations reveal that the power of the single sub-cycles cannot be both greater or smaller than the power of the original one, thus we are left with two possibilities, P (T 1 ) ≤ P (T 1 • T 2 ) ≤ P (T 2 ) or P (T 2 ) ≤ P (T 1 • T 2 ) ≤ P (T 1 ). In both cases the original cycle is sub-optimal, that is absurd, unless P (T 1 ) = P (T 1 • T 2 ) = P (T 2 ) but even in this case we can choose one of the two sub-cycles still preserving optimality.
The previous argument shows that the only candidates for power maximization are those cycles that cannot be divided with a quench as done in the above proof, thus being infinitesimal. Notice that the previous proof strongly relies on the possibility of performing effectively instantaneous quenches, a characteristic that is better analyzed in the next appendix. At last, by using Pontryagin's minimum principle, it can be shown that if coupling constants λ H (t) and λ C (t) fulfill a "trade-off relation" (i.e. if one increases, the other one decreases), then the optimal cycle will have λ C (t) = 0 and λ H (t) = 1, or λ C (t) = 0 and λ H (t) = 1 at all times [43]. This implies that the coupling to the baths must be switched during the quenches of the infinitesimal Otto-cycle.

Appendix B. Maximum Power Formula and Finite-Time Corrections
In this appendix we prove Eq. (5) of the main text and discuss the finite-time corrections.
As as shown in the previous appendix, the optimal cycle must be an infinitesimal Otto cycle, so we consider a protocol (depicted in Fig. 1b of the main text) where (t) = H , λ H = 1 and λ C = 0 for t ∈ [0, τ H ], and (t) = C , λ H = 0 and λ C = 1 for t ∈ [τ H , τ H + τ C ]. The optimal cycle and corresponding power will then be found by taking the limit dt = τ H + τ C → 0 and maximizing over the free parameters H , C and τ H /τ C .
We proceed the following way: first we perform an exact calculation, for arbitrary τ H and τ C , of the heat rates J H , J C , averaged over one period, flowing out of the hot and cold bath respectively. Then, in the limit dt → 0, we find the ratio τ H /τ C that maximizes the power and we find the corresponding expression of the maximum power, proving Eq. (5) of the main text and the optimal ratio condition The instantaneous heat currents can be written in terms of the probability p(t) by plugging the solution of Eq. (4) of the main text into Eq. (3) of the main text. We (t), λ H (t) and λ C (t)) are constant in each interval, we have that where H and C are two constants and where, for ease of notation, we introduced the symbols Γ α := Γ α ( α ) and p (α) eq := p (α) eq ( α ) (for α = H, C). We determine the two constants H and C by imposing that the probability p(t) is continuous in t = τ H , i.e.
and that p(t) is periodic with period τ H + τ C , i.e.
We impose periodic boundary conditions because, as discussed in the previous appendix, a periodic protocol produces a periodic p(t) after an initial transient time, and we are indeed interested in the "asymptotic" regime. Equations (B.3) and (B.4) reduce to the following linear-algebra problem for the constants H and C: with solution which, via Eq. (B.2), completely determine p(t). By substituting Eq. (B.2) into Eq. (3) of the main text, we can write the averaged heat rates J H and J C as where we use the fact that (t) is constant in each I α and the fact that, since the twolevel system is coupled to one bath at a time,ṗ α =ṗ with p(t) = p H (t) during I H and p(t) = p C (t) during I C . Using the expressions for H and C given in Eq. (B.6), we can rewrite Eq. (B.7) as We now impose that dt = τ H + τ C by setting τ H = θdt and τ C = (1 − θ)dt, for θ ∈ [0, 1], in Eq. (B.8). Taking hence the infinitesimal cycle limit dt → 0 we get The maximization over θ of the above expression yields the condition which replaced into Eq. (1) of the main text, and maximizing with respect to the only two free parameters left, i.e. H and C , allows us to derive Eq. (5) of the main text for all four thermal machine modes. An additional comment has to be made for the accelerator mode [A], that aims at maximizing the heat released into the cold bath while extracting heat from the hot bath. By definition, we must restrict the maximization in Eq. (5) of the main text to guarantee J H ≥ 0, e.g. by forcing C to be ( On the other hand, the heater mode consists of heating a single reservoir whose interaction with the two-level system is described by a rate Γ( ) and equilibrium probability p eq ( ). So in this case the maximization must be performed taking Γ α ( ) = Γ( ) and p (α) eq ( ) = p eq ( ) (for α = H, C). If we also require that Γ( ) = Γ(− ), which physically means that the rates do not distinguish which one of the two energy levels is the ground and excited state, we find that Eq. (5) can be simplified to 12) and the corresponding optimal cycle is given by an Otto cycle where τ H = τ C and the value that maximizes Eq. (B.12) determines H = − C = . Thus the optimal cycle in the heater case corresponds to attempting continuous population inversions.

Appendix B.1. Finite-Time Corrections part one
Setting τ H = θdt and τ C = (1 − θ)dt in Eq. (B.8), and plugging in the expression of θ that satisfies Eq. (B.10), we find that the average heat rate for an arbitrary period dt is given by Plugging this results into Eq. (1) of the main text and maximizing over H and C yields the expression , (B.14) which provides the finite time version of Eq. (5) of the main text. On one hand, as anticipated in the main text, by expanding Eq. (B.14) for small dt, we find the following quadratic correction .

(B.15)
On the other hand for Γ H dt, Γ C dt 1, we get , (B. 16) implying that a considerable fraction of P can be achieved even if the driving frequency is slower than the typical rate. Notice that Eq. (B.14) is a strictly decreasing function of dt; this is consistent with the fact that an infinitesimal cycle is indeed the optimal solution.
We conclude by observing that we can simplify Eq. (B.14) for the heater mode where a single reservoir is coupled to the two-level system. Under the hypothesis leading to Eq. (B.12), we find that where Γ is computed in the value of that maximizes Eq. (B.12). Figure 1c of  (dt) is only decreased of a factor two.

Appendix B.2. Finite-Time Corrections part two: the Quenches
Finite-time corrections to the power may not only arise from the finite duration of the isothermal transformations (i.e. from a finite value of τ C and τ H ), but also from a finite duration τ of the quenches, i.e. of the transformations during which changes between the two extremal values C and H . We will thus assume that each quench is carried out in a time τ . The aim of this appendix is to show how these effects could be accounted for, and to estimate the leading order corrections to the maximum power delivered by the heat engine due to this effect; analogous considerations hold also for the other machines. We will thus restrict ourself to the regime τ dt γ −1 , where dt = τ C + τ H and γ is the characteristic rate of the system during the protocol. The first inequality states that the duration of the quenches is much smaller than the duration of the isothermal transformations. The second inequality implies that the finite-time corrections discussed in the previous subsection are neglected, since they have been previously discussed.
Using the results of App. A, we know that p(t) has a limit cycle with the same period of (t). If we further assume that the protocol is much faster than γ, the probability tends to a fixed valuep given bȳ By using again the hypothesis that the protocol is much faster than γ, we can write the power of the heat engine, averaged over one period, as where (. . .) stands for ds (s)Γ(s) [p eq (s) −p]. In the regime we consider the power, up to leading order corrections in τ /dt, can be written as where the first addend is obtained by means of a first order expansion in τ /dt of the denominator in the r. achieved in the ideal protocol, so we will estimate the four terms W H , W C , W H→C and W C→H . First, we notice thatp depends on the whole protocol, see Eq. (B.18). We can thus writē wherep (0) is the value ofp in the ideal protocol, and δp (1) the corrections due to the finite-time quenches. These two terms can be calculated simply by dividing the integrals in the definition ofp as we did for P [E] (τ ). It is easy to see that δp (1) is of the order τ /dt. Since W H and W C are linear functions ofp, andp =p (0) + δp (1) , we have that, for α = H, C, where W (0) α is the work extracted in the ideal protocol during the isothermal transformation, while W (1) α represents the corrections due to the variation in population p induced by the finite-time quenches. We have that where the last term means that W (1) α is of the order γτ . Next, we need to estimate W H→C and W C→H . By inspecting the definition, we see that where is a characteristic value of the energy gap during the quench. , we find that all the corrections previously discussed are of the order γ/dt. We thus conclude that where the corrections must be negative by virtue of the theorem proved in App. A. The impact of finite time quenches is thus first order τ /dt.

Appendix C. Efficiency at Maximum Power
For small temperature differences, i.e. for small values of η c , we can consider an expansion of the efficiency at maximum power of the kind In this appendix we prove that a 1 = 1/2, while for symmetric or constant rates we further have a 2 = 1/8. The maximum power of a heat engine (without constraints on the control parameters) can be written as [see Eq. (5) of the main text] where 3) x α = α β α (for α = H, C), f (x) := [1 + exp (x)] −1 and, expressing the Γ α as a function of the gap and of the inverse temperature β α of lead α, In  ) as a power series in η c , we find that Thus, the knowledge of b 1 and b 2 implies also the knowledge of a 1 and a 2 . Also the maximum power P [E] (x * H , x * C ) can be written as a power series in η c by plugging the expansion Eq. (C.5) into Eq. (C.3). This yields where the coefficients P (n) [E] are functions of m i , n i (for i = 0, 1, 2, . . .) and of β H . We now wish to determine b 1 and b 2 by maximizing P (n) [E] , starting from the lowest orders. We find that P (0) [E] = 0 and where we expressed n 1 in terms of b 1 . The last fraction in Eq. (C.9) is positive, so P is maximized by choosing b 1 that maximizes the term in square brackets, and m 0 that maximizes the last fraction. The maximization of the first term yields b 1 = −1/2, which readily implies [see Eq. (C.7)] a 1 = 1/2, as we wanted to prove. The maximization of the second term allows us to find the following implicit expression for m 0 where ∂ xα g(m 0 , m 0 ; 0) denotes the partial derivative of g(x H , x C ; η c ), respect to x α , calculated in x H = x C = m 0 and η c = 0. In order to compute b 2 , we must maximize also higher order terms of the power. It turns out that P [E] only depends on m 0 if we impose that b 1 = −1/2 and that m 0 satisfies Eq. (C.10). Thus, there is nothing to optimize, so we must analyze the next order. P (4) [E] is a function of m 0 , m 1 , n 1 , m 2 , n 2 and β C . We write m 1 in terms of b 2 , which is the only coefficient that determines a 2 . We further express n 1 in terms of b 1 , and impose b 1 = −1/2. At last, we write g(m 0 , m 0 ; 0) in terms of its partial derivatives using Eq. (C.10). This leads to an expression of P (4) [E] as a function of m 0 (which is implicitly known), b 2 , m 2 , n 2 and β H . We maximize P (4) [E] by setting to zero both partial derivatives of P (4) [E] respect to b 2 and m 2 . We thus find the following expression for b 2 : where all partial derivatives of g are computed in x H = x C = m 0 and η c = 0. This is, in principle, a closed expression for b 2 , thus for a 2 , since m 0 is defined in Eq. (C.10), and Eq. (C.11) only depends on m 0 . Eq. (C.11) shows that in general b 2 , thus a 2 , will depend on the specific rates. However, if ∂ x H g = ∂ x C g, the first term in Eq. (C.11) vanishes, while the second one reduces to a number, yielding b 2 = −3/4. Indeed, plugging this value of b 2 into Eq. (C.7) yields precisely a 2 = 1/8. We conclude the proof by noticing that if the rates are symmetric, i.e. Γ H ( , β) = Γ C ( , β), g(x H , x C ; 0) is a symmetric function upon exchange of x H and x C . This implies that ∂ x H g(m 0 , m 0 ; 0) = ∂ x C g(m 0 , m 0 ; 0), so a 2 = 1/8. At last, if the rates are constants, also g( In this appendix we prove Eqs. (9) and (10) We first prove that the COP at maximum power takes the universal form of Eq. (9) of the main text if the rates depend on the energy and on the temperature only through β , i.e. Γ α ( ) = Γ α (β α α ). We rewrite Eq. (D.1) as a function of x * α = β α * α (for α = H, C): where C (c) op is the Carnot COP for a refrigerator (see main text). We can determine x * α by maximizing Crucially, given our hypothesis on the rates, there is no explicit dependence on the temperatures in Eq. (D.5) (except for the prefactor 1/β C ), so the maximization of P [R] (x H , x C ) will simply yield two values of x * H and x * C that do not depend on the temperatures. Thus, for all bath temperatures the COP at maximum power will be given by Eq. (D.4), where x * H and x * C are two fixed values. The ratio x * H /x * C will depend on the specific rates we consider. By imposing in Eq. (D.4) that the COP at maximum power of the system for β H = β C (i.e. for C (c) op → ∞) is C (0) op , we can eliminate the ratio x * H /x * C in favor of C (0) op , concluding the proof of Eq. (9) of the main text. We now prove Eq. (10) of the main text. Since Eq. (D.2) remains unchanged by sending both H → − H and C → − C , we can assume without loss of generality that C ≥ 0 (this is a general property which applies independently of the specific choice of bath models). Furthermore, we must ensure that the system is acting as a refrigerator by imposing P [R] ( H , C ) ≥ 0. This implies that f (β H H ) ≤ f (β C C ), thus We now show that in the models described by Eq. (6) of the main text, the partial derivative of P [R] ( H , C ) respect to H is non negative for all values of H and C satisfying Eq. (D.6), which implies that * H → +∞. Using Eq. (D.6), the condition ∂P [R] ( H , C )/∂ H ≥ 0 can be written as We now know that * H → +∞ in the F n and B n models. Since both Γ Equation (D.9) is non-negarive for all values of x C and it vanishes in x C = 0 and x C → +∞ thanks to the exponential decrease of f (x C ) for large values of x C . Therefore, Eq. (D.9) will be maximum for the finite value x * C that maximizes x n+1 C h(x C )f (x C ), and plugging x * C into Eq. (D.9) yields the first relation in Eq. (10) of the main text, where c n = (x * C ) n+1 h(x * C )f (x * C ). For n = 0, we separately analyze the F 0 and B 0 models. In the F 0 model, g( H , C ) = k H k C /( √ k H + √ k C ) 2 , so P [R] (+∞, C ) can be written as where r := k H /k C . Using the same argument as before, Eq. (D.10) implies a finite value of x * C which arises from the maximization of x C f (x C ). We thus proved the first relation in Eq. (10) of the main text for the F 0 model, where c 0 = r/( √ r + 1) 2 x * C f (x * C ). At last, in the B 0 model g( H → +∞, C ) = k H k C coth (x C /2)/[ √ k H + k C coth (x C /2)] 2 . Thus, P [R] (+∞, C ) can be written as Again, x * C is a finite value which can be found by maximizing r coth (x C /2)/( √ r + coth (x C /2)) 2 x C f (x C ). Only in this case, x * C depends on the ratio r. We thus proved the first relation in Eq. (10) of the main text for the B 0 model, where c 0 = r coth (x * C /2)/( √ r + coth (x * C /2)) 2 x * C f (x * C ). The second relation in Eq. (10) of the main text stems from the fact that in all models * H → +∞ while * C is finite. Thus, Eq. (D.1) implies that the C op (P max [R] ) vanishes. At last we want to roughly estimate the behavior of C op (P max [R] ) in the presence of a large yet finite constraint on the maximum gap: | (t)| ≤ ∆. Since H would diverge if there was no constraint, we can assume that, in the presence of ∆, * H = ∆. On the other hand, * C is a finite quantity (which is given by * C = x * C /β C in the unconstrained case), so if we assume that ∆ * C , from Eq. (D.1) we have that