First question: Is this equation applicable for irreversible processes?
From the first law, we have:
$$
\mathrm{d} U = \mathrm{d}Q + \mathrm{d}W
$$
where $\mathrm{d} U$ is an exact differential, and $\mathrm{d}Q$ and $\mathrm{d}W$ are inexact differentials. It is thus remarkable to see that the sum of of two inexact differentials makes an exact differential! This suggests that it might be possible to turn the inexact differentials into exact differentials.
Indeed, for an hydrostatic system we can write:
$$
\mathrm{d} W = - p \mathrm{d} V
$$
Furthermore, for a reversible process:
$$
\mathrm{d}Q = T \mathrm{d} S
$$
Thus, for a reversible process we obtain the following expression for the first law:
$$
\mathrm{d} U = T \mathrm{d} S - p \mathrm{d} V
$$
Again, note that the above equation has been derived only for reversible processes. However, since $\mathrm{d} S$ and $\mathrm{d} V $ are exact differentials, and thus they are path-independent, the above equation is also valid for irreversible processes! Thus, if $\mathrm{d}Q < T \mathrm{d}S$, then this get compensated by the fact that $\mathrm{d} W$ is larger than for the reversible case.
Second question:If the system temperature $T_{sys}$ is smaller than the surrounding temperature $T_{sur}$, which temperature should we put in the equation?
Remember that heat flows from "warm" to "cold", thus $T$ denotes the temperature of the object which rejects the heat $\mathrm{d} Q$. This means that $T$ does not necessarily denote the temperature of the system. This is consistent with the well known result:
\begin{equation}
\oint \frac{\mathrm{d} Q}{T} \leq 0
\end{equation}
[
title](
example.com)
- that redundancy would allow us to fix the link. $\endgroup$