This is one of those parts of engineering thermodynamics courses which is never made clear enough. The first confusion I suffered from was the idea that entropy increase was always a sign of irreversibility. This is clearly not true, since we can (in theory) increase the entropy of a system just by transferring some heat to it reversibly. Perhaps the single most important thing to remember, however, is that, in the equation for dS, when you transfer heat (dQ) into a system, the local system temperature at the interface is what is meant by T.
Now it may be that the rest of the system is also at T, in which case there are no thermal gradients and no additional changes in system entropy. That would be the ideal case of reversible heat transfer (dS=dQ/T). In reality, once the dQ has entered the system, it is faced by some kind of temperature profile (ie the internal T distribution in the system is non-uniform). Any such non uniformities result in non equilibrium conditions. The subsequent passage of heat into the system is therefore irreversible (it’s very hard to keep track of which atoms hit which others and thus how the dissipation process plays out). The extra increase in system entropy which is created, after the effect of transfer of heat in (dQ/T), is summed up as dSgen (aka dSp). This is a term the detailed behaviour of which is hard to account for. It might include the effects of internal friction, pressure gradients etc…anything which represents a deviation from quasi-equilibrium in the system.
It’s quite important to keep a close eye on the language used. I found it easy to get terms like ‘entropy production’ (dSp = dSgen) and ‘entropy increase’ (dS) mixed up.
For a long time, I was also confused by textbooks which said things like “dSgen includes the effects of finite T differences.” So, when you put an object at say 2T in contact with a system at T, did that mean that, in dS=dQ/T +dSgen, the term dQ/T=0 (because the ht was finite-difference and thus irreversible and dSgen included all effects of irreversibility)? Also, what T value was I supposed to use?
I hope it’s clear now that dS=dQ/(interface contact temp) +dSp.