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?