Part 1 - Derivation of the Gibbs Free Energy Equation: [copied from this]
Using the fundamental equations for the state function (and its natural variables): \begin{align} \mathrm{d}G &= -S\mathrm{d}T + V\mathrm{d}P\\ V &= \left(\frac{\partial G}{\partial P}\right)_T\\ \bar{G}(T,P_2) &= \bar{G}(T,P_1) + \int_{P_1}^{P_2}\bar{V} \mathrm{d}p \end{align} Here $\bar{x}$ represents molar $x$, i.e. $x$ per mole \begin{align} \bar{V} &= \frac{RT}{P}\\ \bar{G}(T,P_2) &= \bar{G}(T,P_1) + RT \ln\frac{P_2}{P_1} \end{align} Defining standard state as $P = \pu{1 bar}$ and $\bar{G}=\mu$ $$\mu(T,P)=\mu^\circ (T) + RT\ln \frac{P}{P_o}$$ consider the general gaseous reaction $\ce{a A + b B -> c C + d D}$ $$\Delta G=(c\mu_\ce{C} + d\mu_\ce{D} - a\mu_\ce{A} - b\mu_\ce{B})$$ for "unit progress" in reaction. Using $\mu_i = \mu^\circ_i + RT\ln \frac{P_i}{\pu{1 bar}}$ \begin{align} \Delta G &= (c\mu^\circ_\ce{C} + d\mu^\circ_\ce{D} - a\mu^\circ_\ce{A} - b\mu^\circ_\ce{B}) + RT \ln\frac{P_\ce{C}^c P_\ce{D}^d}{P_\ce{A}^a P_\ce{B}^b}\\ \Delta G &= \Delta G^\circ + RT\ln Q \end{align}
Here, $Q=\ln\frac{P_\ce{C}^c P_\ce{D}^d}{P_\ce{A}^a P_\ce{B}^b}$
Part 2 - Derivation of the Nernst Equation [Copied from this]
Realise that (reversible ideal case) $\Delta G = W_\text{non-exp}$ (non-expansion). Therefore, in an ideal chemical cell, if the potential difference between the electrodes is $E$, to move one mole electrons across the external circuit will be $FE$, which must be equal to the decrease in gibbs free energy of the system. Hence for $n$ mole electrons transferred at the same potential, $W_\text{non-exp} = \Delta G = -nFE$. $$ $$The fact that $\Delta G = W_\text{non-exp}$ can be derived as under: \begin{align} \mathrm{d}S &= \frac{\delta q}{T} && \text{(reversible case)}\\ \mathrm{d}U &= \delta q + \delta W_\text{non-exp} + \delta W_\text{exp}\\ \delta W_\text{non-exp} &= \mathrm{d}U - \delta W_\text{exp} - \delta q \\ &= \mathrm{d}U + p\,\mathrm{d}V - T\,\mathrm{d}S && \text{(const. $p$ and $T$)} \\ &= \mathrm{d}H - T\,\mathrm{d}S \\ &= \mathrm{d}G \end{align}
Combining the above two, we get Nernst Equation: $$E_{cell}=E^{\circ}_{cell}-\frac{RT}{nF}lnQ$$
The Q for this remains same i.e. $Q_p=\ln\frac{P_\ce{C}^c P_\ce{D}^d}{P_\ce{A}^a P_\ce{B}^b}$
But we always use $Q_c=\frac{[C]^c[D]^d}{[A]^a[B]^b}$ in the Nernst Equation in terms of molarity instead of $Q_p$ (in terms of partial pressure). How is this justified?
Thnx :)