Accounting for work in an irreversible thermodynamic process I'd like to understand whether a work interaction occurs during the thermodynamic process described below, and why or why not. My analysis seems to suggest that some sort of work should be occurring, but my intuition says there's no work done. So specifically I want to know where my approach fails, or why my intuition is off base.
Consider two equal volumes of an ideal gas, $A$ and $B$, separated by a fixed adiabatic wall. Both halves contain the same number of molecules: The only difference between the two halves is that they're at different temperatures, say $T_A$ and $T_B$. This is the initial equilibrium state of the system.
Now, suppose the adiabatic wall is replaced by a thermally conductive wall, also rigid. This wall keeps the volume of each half the same, but allows energy transfer between the two halves. After some time, the two halves reach a common temperature $(T_A+T_B)/2$.
I can say a few things about this process. Let's just focus on one half of the system, say $A$. First, assuming that the movement towards equilibrium after initial thermal contact is sufficiently slow, the subsystem $A$ passes through a succession of states with roughly well-defined thermodynamic variables. So, at every infinitesimal step of the process, we have:
$$dU=TdS-PdV,$$
where $U$, $T$, $S$, $P$, and $V$ are thermodynamic properties of $A$ alone. Second, by the first law of thermodynamics:
$$dU=\delta Q + \delta W.$$
Here, I've used the convention that $\delta Q$ is the heat flow into $A$ during the infinitesimal step, and $\delta W$ is the work done on A. Taking the difference between these two equations yields:
$$TdS - \delta Q = PdV + \delta W.$$
Now, it seems to me that the process is irreversible: Returning the total system $A$ and $B$ to its original state would require some sort of permanent alteration of its environment. We can't just make the temperatures of the two halves unequal again without any external effects (right? This is one part where I'm a little confused, so I'm being somewhat imprecise). So by the second law of thermodynamics, we know that $dS > \delta Q/T$, and so:
$$TdS - \delta Q = PdV + \delta W > 0.$$
But the volume of $A$ remains fixed during the process, so $dV=0$, and therefore we have $\delta W > 0$. So it seems like at each infinitesimal step in the process, some work is done on $A$. But I can't see a mechanism by which this work is being performed. So am I wrong in my conclusion that a work interaction is occurring, or I am not thinking about something else in the right way?
Thanks.
 A: The issue is one of terminology, and this particular issue is an extremely common one. (In the context of classical thermodynamics, almost all of the issues that students run into are ones of terminology.)
In this case, you are confusing the notions of reversible/irreversible and quasi-static/non-quasi-static. Quasi-static is a term that applies to an individual system, and reversible is a term that applies to a collection of systems. A system undergoes a quasi-static (or quasi-equilibrium) process when it moves through a sequence of equilibrium states. A quasi-static process can be irreversible, if the irreversibility occurs in some sense outside the system; in the context of elementary thermodynamics, irreversibility is usually a consequence of heat flow across a finite temperature difference between a system and a reservoir (or, as in the OP's case, between one system and another).
Therefore, the short answer is that the OP went wrong when saying that $dS \neq \delta Q/T$ for the process. By assumption, the individual processes undergone by systems A and B are both quasi-static, and so
$$dS_A = \frac{\delta Q_A}{T_A},$$
and
$$dS_B = \frac{\delta Q_B}{T_B}.$$

So here is how I would analyze the problem, based on what the OP has done. Suppose we have the same setup, in which both systems A and B are at finitely different temperatures $T_A$ and $T_B$ to begin with, and they are then brought into contact via a rigid, impermeable, immovable, conducting boundary. In this case, the work done on either gas must be zero, as the OP notes, due to the membrane being rigid and immovable. In addition, since the processes undergone are quasi-static, we can write that the change in entropy of each subsystem during a small chunk of the process  is
$$dS = \frac{\delta Q}{T},$$
and that the change in internal energy during that small chunk of the process is
$$dU = \delta Q + \delta W = TdS.$$
By conservation of energy, the total change in energy of the combined system is given by
$$dU = dU_A +dU_B = \delta Q_A + \delta Q_B=0,$$
since the systems are in thermal contact but are otherwise isolated from the rest of the universe.
Now, we do know that this process must be irreversible, since there is heat flow across a finite temperature difference, so let's compute the total change in entropy of the combined system and see if it's strictly positive. Without loss of generality, let's take $T_A > T_B$, in which case
$$\delta Q_B = -\delta Q_A = |\delta Q_A|.$$
(That is, $\delta Q_B>0$ since heat must flow into system B, and $\delta Q_A<0$ since heat must flow out of system A.)
Then, the combined change in entropy during one tiny chunk of the process (so that the temperatures can be treated as constant) is
\begin{align*}
dS &= dS_A + dS_B = \frac{\delta Q_A}{T_A} + \frac{\delta Q_B}{T_B}\\
& = \frac{-|\delta Q_A|}{T_A} + \frac{|\delta Q_A|}{T_B}
= |\delta Q_A|\frac{T_A-T_B}{T_AT_B} >0,
\end{align*}
where the last inequality arises as a consequence of $T_A > T_B$. This shows that at every step along the way, the entropy increases until the systems have equilibrated.
To complete the calculation, we merely integrate each expression separately. Assuming that each system has the same mass and that the specific heats are temperature-independent, we have
\begin{align*}
\Delta S_A &= \int \frac{\delta Q_A}{T_A}\\
&=\int_{T_A}^{(T_A+T_B)/2} \frac{n C dT}{T_A}=
nC\ln\left(\frac{(T_A+T_B)/2}{T_A}\right),
\end{align*}
where $n$ is the number of moles and $C$ is the molar specific heat.
The same expression holds for B (with B switched with A), and when we add the two expressions, it simplifies to
$$\Delta S = \Delta S_A + \Delta S_B = 2 n C\ln\left(\frac{(T_A+T_B)/2}{\sqrt{T_AT_B}}\right).$$
A: The problem starts from the first equation $dU=TdS-PdV$. When you assume this equation, $dS > \delta Q/T$ isn't valid, i.e. at one point, you assume it is irreversible and at another point you treated it as reversible.
