The Work Done by an Irreversible Carnot Cycle This is a question from the book, Understanding Non-Equilibrium Thermodynamics by Lebon and Jou.

Show that the work performed by an engine during an irreversible cycle operating between two thermal reservoirs at temperatures $T_{1}$ and $T_{2} < T_{1}$ is given by $W = W_{max} − T_{2} \Delta S$, where $\Delta S$ is the increase of entropy of the Universe, and $W_{max}$ is the corresponding work performed in a reversible Carnot cycle.

I read this but still have some problems. The first one is about the system. Is the system the working substance or the working substance and the reservoirs? I think the latter is a better choice, because it would make the problem unnecessarily complicated if there were a surrounding with two different temperatures. So, everything happens within this system including the three subsystems. Can I assume here that this system is isolated? I think it is not necessary to do so. My second question is that should I consider the irreversibility of the processes of the exchanges of heat, too or only when the work is done? I mean I have seen in the textbooks the sign $Q_{rev}$ which denotes the heat exchanged during a reversible process. So the exchange of heat is also irreversible. The main problem is when I want to write the equations. I can simply write that in a reversible process the production of entropy is zero and according to the first law of thermodynamics we have, $$W_{max}=Q_{1,rev}-Q_{2,rev}$$
and in an irreversible process, according to the second law of thermodynamics and because of the production of entropy we also have the term $T_{2}\Delta S$, so $$Q_{1,rev}-Q_{2,rev}=W_{irr} + T_{2}\Delta S$$
But I think I need to write more equations. I have to show that the equation holds.
Does this hold in an irreversible process? $$Q_{1,irr}-Q_{2,irr}=W_{irr}$$
How can I proceed from this point?
 A: The basis for the model you presented is that (1) the system under consideration is the working fluid and (2) the reservoirs are ideal so that there is no entropy generated within them (and all the entropy due to irreversibility is generated within the working fluid).  Since the engine is working in a cycle, the change in internal energy and the change in entropy of the working fluid in each cycle is zero.  From this, it follows from the first law of thermodynamics (applied over a cycle) that $$Q_1-Q_2=W$$where Q1 is the heat received from the hot reservoir and Q2 is the heat rejected to the cold reservoir.  From the second law of thermodynamics, it also follows that $$0=\frac{Q_1}{T_1}-\frac{Q_2}{T_2}+\sigma$$where $\sigma$ is the entropy generated within the working fluid per cycle (and also, by assumption (2), the entropy generated within the universe per cycle).  This entropy generation is positive for an irreversible process or zero for a reversible process.
If we eliminate Q2 from these equations, and solve for W, we obtain:  $$W=Q_1\frac{(T_1-T_2)}{T_1}-\sigma T_2$$Since the entropy generation is positive or zero, the maximum work is if the entropy generation is zero:  $$W_{max}=Q_1\frac{(T_1-T_2)}{T_1}$$Therefore, $$W=W_{max}-\sigma T_2$$
