I was trying to find relation between Gibb's free energy change and equilibrium constant for the following homogeneous gaseous phase reaction at constant temperature $$\ce{aA +bB }\rightleftharpoons \ce{cC + dD}$$
Let the initial partial pressures are $P_{1,i}$ and final partial pressures are $P_{2,i}$ for $i=A,B,C,D$
Now Gibb's free energy change of reaction is given by
$$\Delta_rG=\Delta G_{reac} + \Delta G_{prod}$$
However when I tried to find Gibb's free energy change for $\ce{A}$, I got stuck at first step
Using the relation $dG=VdP-SdT$
$$\Delta G_{A}=\int_1^2VdP=\int_1^2\frac{n_ART}{P_A}dP$$
However I cannot perform this integration as $n_A$ is not constant.
I saw other answers relating to same question but cannot gather much from them
Is my method correct ? If yes, then how can I continue ?