Why is the chemical potential of a photon gas 0 (mathematical argument)? $$dU=TdS-PdV+\mu d\bar{N}$$
$$\mu=\left(\frac{\partial U}{\partial \bar{N}}\right)_{S,V}$$
The energy of each photon is given by $\hbar\omega$ (each photon obviously carries energy). Therefore the addition of a photon to a photon gas must increase the internal energy. Why then is $\mu=0$?
Furthermore, many argue that $\mu=0$ whenever the system's particle number is not conserved. How do we argue this mathematically?
Note: I have read the other answers on this site and unless I've missed some they all seem to deal with this qualitatively, so please do not mark this as a duplicate.
 A: The energy $\hbar \omega$ is the photon's kinetic energy. Thermodynamically, it contributes the same as the kinetic energy of a gas molecule. When you insert a particle into a thermodynamic system, two things happen, in effect: the particle is inserted, and then it is brought up to speed, i.e. its kinetic energy is added. That these are simultaneous in this case doesn't matter. It's the first part that contributes to the chemical potential - the energy required to insert, and that means in this case, create, a photon in, of, and by itself, regardless of how much kinetic energy is then put behind it after it is created.
And the energy to create any particle, relativistically, is easily seen as the mass-energy. And a photon has no mass. So its mass-energy is zero. Thus the chemical potential to add a photon is also zero.
A: I would say that this is an interpretation problem. For a photon gas you can compute the Gibbs free energy, $G=G(T,P,N)$, if you do so yo will find that $G=0$. That's because pressure is completely determined by temperature, which means that $G$ is ill defined for the present case ($T$ and $P$ are not independent variables). Then, if there are $N\neq 0$ photons, since $G=\mu N$, we obtain $\mu=0$. This can be understood by noticing that $\mu$ is only defined to a conserved particle number $N$, which is not the case for a photon gas (that usually means a blackbody system). So, we can say that neither $G$ nor $\mu$ are defined for a photon gas system. Hope this answer your question.
See, Thermodynamics of blackbody radiation by Robert E. Kelly, for more details.
A: Like @Ashmit Dutta says, the conclusion of zero chemical potential comes from Statistical Mechanics. The absence of a constraint on the average number of photons removes the chemical potential as a Lagrange multiplier, so you have $\mu=0$.
From statistical mechanics, the energy density can be calculated. You can see that the energy doesn't depend on the number of photons,
$$
U= \frac{24 \pi^5 V (kT)^4}{45 h^3 c^3},
$$
where $h$ is Planck's constant, $c$ the speed of light in vacuum , $k$ Boltzmann's constant, $T$ the temperature and $V$ a volume.
When the particle number is not conserved the variance in the particle number should be infinite. Then using the relation to the isothermal compressibility,
$$
\kappa_T = \frac{V \sigma^2_n}{TN^2},
$$
it can be seen that
$$
\Bigg( \frac{\partial N}{\partial \mu} \Bigg)_T = \frac{\sigma^2_N}{T} \rightarrow \infty,
$$
which is consistent with $\mu = 0$. But from the beginning the absence of a particle average gives no particle conservation.
A: Photons are bosons, so their modes and waves can be described by the Bose-Einstein distribution:
$$f(E) = \frac{1}{e^{\beta (E - \mu)} - 1}$$
where $\beta$ is the thermodynamic constant $\beta\equiv 1/k_B T$ and $E$ is the energy of each particle in a mode or $E = h\nu$. Let us also describe this from a quantum mechanical persective. A harmonic oscillator cannot just have any amount of energy but moves up in discrete steps such as
$$E_n = 0, h\nu, 2h\nu, \dots , nh\nu.$$
The partition function of this is given by
$$Z = \sum_{\alpha}e^{-\beta E_{\alpha}} = 1 + e^{-\beta h\nu} + e^{-2\beta h\nu} + \dots + e^{-n\beta h\nu} = \frac{1}{1 - e^{-\beta h\nu}}.$$
The average energy in this case is
$$\bar{E} = -\frac{1}{Z}\frac{\partial Z}{\partial \beta} = \frac{h\nu}{e^{\beta h\nu} - 1}.$$
Energy comes in these units of $h\nu$ as we have seen. Thus, the average number of these units of energy is given by the distribution of
$$f(E) = \frac{1}{e^{\beta h\nu} - 1}.$$
This is called the Planck distribution and is used to describe photons (note that the Bose-Einstein distribution is derived very similarly). If we compare the Bose-Einstein distribution and the Planck distribution that we have just derived, we see that the chemical potential is $\mu = 0$.
Now, regarding your second question, this is what gives us more intution of why the chemical potential of gases are zero. The number of photons in a system $N$ is not constrained but will rather take whatever number that will minimize the Hemoltz free energy $F$ (assuming that $T$ and $V$ are constant). If $N$ changes infinitessimally, then $F$ will change as well or:
$$\left(\frac{\partial F}{\partial N}\right)_{V, T} = 0$$
in the equilibrium state. But let's think for a second. We now that
$$\text{d}F = -p\text{d}V - S\text{d}T + \mu \text{d}N\implies \mu = \left(\frac{\partial F}{\partial N}\right)_{V, T}.$$
That means that the chemical potential is zero!
If you have any questions, please comment below and I'll try to answer.
