# How are fundamental equations valid for both reversible and irreversible processes?

We know for an irreversible process, $$\mathrm dS\gt\mathrm dq/T$$.

And if the process is done at constant pressure we can take the equation as $$\mathrm dH-T\,\mathrm dS\lt0$$.

And we defined Gibbs energy, $$G=H-TS$$. At constant temperature and pressure $$\mathrm dG\le0$$.

But the fundamental equation of Gibbs energy $$\mathrm dG$$, in terms of temperature and pressure is given by $$\mathrm dG=V\,\mathrm dp-S\,\mathrm dT$$.

And as per our original conditions, i.e. at constant pressure and temperature for an irreversible process the value $$\mathrm dG$$ should be less than zero.

I cannot understand for the same condition the two equations give different answers.

So, let's look how much is the equation fundamental, using as the starting point the definition of the Gibbs free energy: $$\require{cancel}$$ \begin{align} G &= H - TS\\ G &= U + pV - TS\\ \mathrm{d}G &= (\delta Q + \delta W) + (p\mathrm{d}V +V\mathrm{d}p) - (T\mathrm{d}S + S\mathrm{d}T)\\ \mathrm{d}G &= (\delta Q -\cancel{p\mathrm{d}V} + (\delta W_\mathrm{nonV})) + (\cancel{p\mathrm{d}V} +V\mathrm{d}p) - (T\mathrm{d}S + S\mathrm{d}T)\\ \mathrm{d}G &= \cancel{\delta Q} + (\delta W_\mathrm{nonV}) + V\mathrm{d}p - \cancel{T\mathrm{d}S} - S\mathrm{d}T \end{align}

For reversible processes is $$\delta Q=T\mathrm{d}S$$, therefore $$\mathrm{d}G= V\mathrm{d}p - S\mathrm{d}T \ (+ \delta W_\mathrm{nonV})$$

For irreversible processes is $$\delta Q \lt T\mathrm{d}S$$, therefore

$$\mathrm{d}G < V\mathrm{d}p - S\mathrm{d}T \ (+ \delta W_\mathrm{nonV})$$

and for $$T$$,$$p$$ constant

$$\mathrm{d}G < 0 \ (+ \delta W_\mathrm{nonV})$$.

The starting equation should read $$dS>dq/T_B$$, not dS>dq/T, where $$T_B$$ is the temperature at the boundary between the system and surroundings (usually an a reservoir temperature) through which the heat flow dq occurs, and T is the average temperature of the system (which may not be spatially uniform). The open literature often fails to make this important distinction. With this correction, all the OP issues are resolved.