If $T dS = dq$ only for reversible processes, why can I use it for non-reversible processes? Assume some system with constant heat capacity $C_V$ at initial temperature $T_0$ is in thermal contact with a reservoir at temperature $T$. As is typically done, the net entropy increase in the universe when the system heats up, is calculated by using the identity in the title of this question, which gives
$$
\Delta S_{sys} = \int_{T_0}^T \frac{dq}{T'} = \int_{T_0}^T \frac{C_V dT'}{T'}   = C_V \ln \left ( \frac{T}{T_0} \right )
$$
$$
\Delta S_{res} = \int \frac{dq_{res}}{T}  = -\frac{1}{T} \int dq = -\frac{1}{T} C_V (T-T_0)
$$
And one can show that $\Delta S_{sys} + \Delta S_{res}>0$. However, this process is clearly irreversible to me. The total entropy in the universe has increased. So how can I have used an identity which is said to only be valid for reversible processes to show this?
 A: Deriving each of these two equations required devising an alternate reversible process for both the system and the surroundings separately, and evaluating the integral of dq/T for each of those alternate processes (which differ significantly from the actual irreversible process).  For the case of the system, for example, rather than using a single ideal constant temperature reservoir at T, it involved using an infinite continuous sequence of constant temperature reservoirs at all temperatures running between To and T, each separated from the previous one by just a differential difference in reservoir temperature. The change in entropy of the system for this alternate reversible process is the same as that for the irreversible process between the same two end states.
To get a better understanding on the methodology required to evaluate the change in entropy of a system (or surroundings) for an irreversible process, see the article I wrote in Physics Forums Insights:  https://www.physicsforums.com/insights/grandpa-chets-entropy-recipe/
A: This will elaborate a little bit on @Chet Miller already comprehensive answer.
When Chet stated "The change in entropy of the system for this alternate reversible process is the same as that for the irreversible process between the same two end states", that's because entropy, like internal energy, temperature, pressure, etc., is a system property having a unique single value for each equilibrium state. In other words, its value, and the change in its value between the same two equilibrium states, is independent on how you get there.
Hope this is additional help.
