# Showing $\mu_1=\mu_2$ by minimization of thermodynamic potentials

A gas tank is divided into two parts by a stationary barrier. The tank is held at constant temperature and constant pressure. A small hole is pierced in the barrier, so that particles can move. Show that $\mu_1=\mu_2$.

Before looking at the solution, I used minimization of $F(T,V,N)$, Helmholtz Free Energy, since I know $T$ is constant and $V$ is constant for each side. I wrote $F_{tot}=F_1+F_2$ and diffrentiated with respect to $N_1$, the number of particles in the left side, which is the changing quantity in this case. I got the right result- $\mu_1=\mu_2$.

However, the solution used minimization of $G(T,P,N)$, Gibbs Free Energy, saying that both pressure and temperature are constant so this is the right thermodynamic potential to use.

I am insecure now- does my solution hold or is $G$ the only right thermodynamic potential for the problem? Did I miss anything? Did I get the right answer just by luck?

$F=F_1(T_1,V_1,N_1)+F_2(T_2,V_2,N_2)$. For constant temperature process,
$dF=dF_1+dF_2=-p_1 dV_1+\mu_1 dN_1-p_2 dV_2+\mu_2 dN_2=0$, at equilibrium.
Now $dN_1=-dN_2,p_1=p_2$, hence
$dF=-p_1 (dV_1+ dV_2)+(\mu_1 -\mu_2) dN_1=0$. Since $p_1(T_1,V_1,N_1)=$constant, in which $T_1$ is also constant, then $V_1$ must be a function of $N_1$. Therefore you cannot straight away equate the coefficient of $dN_1$ to zero to obtain $\mu_1=\mu_2$, because it is not an independent variation, i.e. variations $dV_1$ and $dV_2$ are not independent of $dN_1$. This dependence is a result of pressure being constant.
This problem is eliminated if you use $G$ instead, as you may verify yourself.