Heat loss by gas compression - reversible vs. irreversible I just solved a problem involving the following scenario:
A gas following the van der Waals equation of state (not an ideal gas) is placed in a cylinder and undergoes isothermal compression. The temperature is kept constant because the cylinder is in a heat bath. What is the heat loss by the gas, assuming the compression happens reversibly? 
After working out an expression for $\rm dS$, I am simply able to integrate from State 1 to State 2 via: $$\Delta S = \int_1^2{\frac{\rm \partial Q}{T}}$$ and then use $Q=T\Delta S\;.$
Easy. The assumption of reversibility, however, is bothering me. Here are my questions: 


*

*Could I use this same procedure to calculate $Q$ if the process happens irreversibly? 

*If not, then how do we calculate $Q$ for an irreversible isothermal compression (or expansion)? 

*I imagine an answer for 2) involves using the first law $Q = \Delta U + W \;.$ But then how do you calculate $W$ for an irreversible compression (or expansion)? Can we still use $W = \int_1^2{P\;\rm dV}\;?$
 A: For an irreversible expansion or compression, let $P_B(t)$ represent the gas pressure on the portion of its boundary where the work is being done, and let $T_B(t)$ represent represent the gas temperature on the portion of the boundary where heat transfer is taking place, with $t$ representing the time during the irreversible change.  If the change is occurring irreversibly, the gas pressure P away from the boundary and the temperature $T$ away from the boundary will vary with spatial position within the gas.  So we won't be able to use an equation of state, such as the ideal gas law, to calculate the pressure at the boundary because, for a given gas volume, the pressure and temperature are not even constant over the volume. In addition to this, there are extra contributions to the force per unit area at the boundary as a result of viscous stresses in the gas (that are important only in irreversible changes, where the gas is deforming rapidly). The force per unit area depends not just on the volume but also on the rate of change of volume.  
For a reversible change, all these difficulties go away. The pressure and temperature of the gas are uniform throughout and viscous stresses are negligible, so the boundary pressure $P_B$ is equal to the average gas pressure, and the equation of state can be used to describe the pressure, volume, and temperature.
So, what do we do in the case of an irreversible change.  Basically, for both irreversible and reversible changes, the equation for the work is the same:$$W=\int P_B\rm\; dV\;.$$ This is just the integral of the force the gas exerts on its surroundings over the distance the force is applied.  But, unlike a reversible change, we can not depend on the equation of state to control the value of the boundary pressure $P_B$.  So we need to control it manually from the outside, using either a pressure transducer at the boundary combined with a feedback control system on the piston movement, or, in simpler cases, by adding or removing a weight to the piston.  
In the case you were describing, the initial and final temperatures of the gas were the same, so there was no change in internal energy.  Therefore, the heat added in the irreversible process as equal to the work:$$Q=\int P_B\;\rm dV\;.$$  Also, because the part of the cylinder where heat transfer is occurring is in contact with a constant temperature bath, $T_B$ is equal to the bath temperature.  
It is not very widely known, but the Clausius inequality calls for the use of the boundary temperature in comparing $\Delta S$ to the integral of $\rm \partial Q/T.$  In particular, $$\Delta S \geq \int \frac{\rm \partial Q}{T_B}\;.$$  So, how do you get the change in entropy for an irreversible process if you can't use this equation.  You start out by forgetting all about the irreversible process and focusing only on the two end states.  You then devise a reversible process between these same two end states and calculate the entropy change for that process. This will give you the entropy change for your irreversible process.
