Difference in partition function of classical and quantum Ideal gas First, I have read this question:What is meant by the term "single particle state"
There is an analysis going on in my book (Mandle F. Statistical Physics) that has brought me in a confusing point.
In chapter 7 of the book, there is an analysis of the classical ideal gas. It is proved that $$Z_{\text{total}}={1 \over N!}(Z_1)^N $$ and that
$$Z_1 =Z_{\text{tr}} \, Z_{\text{int}}$$
where $Z_{\text{total}}$ is the total partition function of the system and $Z_{\text{tr}}$ and $Z_{\text{int}}$ are the transactional and internal partition functions of a sub system in canonical ensemble respectively.
Also, we know from chapter 2 that the partition function is in general of the form:
$$Z_1 ^{general} =\sum_r g(\epsilon_r) \exp\left[-\epsilon_r \over kT \right] \,. \qquad (1)$$
When defining the classical ideal gas we have that there exist energies
$$\epsilon_1 \leq \epsilon_2 \leq \epsilon_3 \ldots \leq \epsilon_r$$
corresponding to a discrete set of quantum states noted with $1,2,3 \ldots r$ where only a unique molecule can exist. Then we determine the state of the whole gas by defining a catalog of the molecules of each particular state defining $n_r$ as the occupation number of the state $r$.
Question :
In chapter 9 one finds the expression of the partition function of an ideal quantum gas:
$$Z_{\text{tot}} = \sum_{n_1 , n_2 \ldots} \exp\left(-\sum_r{n_r \epsilon_r} \over kT\right)~~~~~~~~(2) $$
and it is:
$$E(n_1 ,n_2 ,...)=\sum_r n_r \epsilon_r$$
and
$$N=\sum_r n_r \, .$$
So, why this difference between (1) and (2) at the expontential? Why not use 
the sum of the occupation numbers in (1) too? Although, if I take the relations for granted I can prove some things, I don't understand the reason the partition functions are different in this analysis. I mean, to be clear, why is there a sum at the exponent of (2) and not (1) or vice-versa? If it is something about indistinguishable particles in QM, or that the $n_r$ number in the second relation isn't considered to be constant but in one for some reason it is, can someone elaborate?
Also, it seems to me I don't quite understand the meaning of unique molecule,maybe it's something that refers to the single-particle state which I understand is what one study in the quantum gas in difference with the classical where one study a particle to determine the statistical behaviour of the system.
Thank you.
 A: Okay, this is actually pretty straightforward, but I don't know where to start. 
Review: What's a partition function?
Let's step back and derive what we're talking about: what is a partition function? So we have a system which takes on a set of energy levels with degeneracies $\left \{(E_i, g_i) \right \}.$
We know that your system $s$ is in contact with a reservoir $r$, but together they are sealed up in a microcanonical ensemble with $S = S_s + S_r$, $U = U_s + U_r$. Now that reservoir is big and complicated so its internal degrees of freedom over the (to it) smallish changes in $U_r$ can be linearized as $S_r(U - U_s) = S_r(U) - U_s/T$, where $T$ is its (effectively constant) thermodynamic temperature $T^{-1} = \left(\frac{\partial S_r}{\partial U_r}\right)_{N_r,~V_r}$. Therefore the overall entropy of the reservoir system in state $i$ is $S_r(i) = S_0 - E_i/T$ for some $S_0$. But we know that the definition of entropy is $S = k_B \ln W$ where $W$ is a multiplicity of the state, so counting in the degeneracy, the total multiplicity of the state is simply:
$$W_i = g_i ~ W_r(i) = g_i ~ e^{S_0/k_B - E_i / (k_B T)} $$and the probability is therefore $$p_i = \frac{W_i}{\sum_k W_k} =\frac {g_i ~ e^{-E_i / (k_B T)}} Z$$ for some constant $Z$ independent of the state index $i$, incorporating both $\sum_k W_k$ and $e^{S_0/k_B}$. Since the probabilities sum to 1, we can say that:$$Z = \sum_i g_i ~ \exp\left(\frac{-E_i} {k_B T}\right). $$If the system is continuous then we need a density-of-states $g(E)$ so that the number of states with energies between $E$ and $E + dE$ is roughly $g(E) ~ dE$, then we convert the above to an integral.
From particles to complex systems
Okay, now that we're both on the same page about what it is, what happens if your system has a bunch of parts? Then each $i$ now labels a configuration of the parts. It potentially gets complicated! The first easy thing to do is to ditch the degeneracies $g_i$ and instead store all of their energies in a multiset: this is a set which can hold the same number multiple times. That might be confusing so let's procede formally a different way.
Let's talk now about a set $C = \left\{c_i\right\}$ where the $c_i$ is some mathematical object telling me the configuration of the state $i$, and we'll assume that this is distinct for each $i$, and now we have to transition from a set of $E_i$ to a function $E(c_i)$ which gives the energy of a configuration of the parts. As a side effect now $g_i = 1$ for each $i$ since each configuration is treated independently, but the same result holds:$$Z = \sum_i \exp\left(\frac{-E(c_i)} {k_B T}\right).$$
Non-interacting systems
If you're with me so far, there's just one more step! What is the form of $c_i$ and $E(c)$? 
Well for a system of $N$ identical noninteracting particles, we have the single-particle energies $E_i$ from before, and the total energy is the sum of the energies for which the states are occupied. That is, the ideal form for $c_i$ becomes an occupation function, $c_i = \left\{n_{i,k}\right\}$ which tells us, in configuration $i$, how many particles are in the state with energy $E_k$. Then the energy of the state is:$$E(c_i) = \sum_k n_{i,k} ~ E_k,$$hence,$$Z = \sum_i \exp\left(\frac{-\sum_k n_{i,k} ~ E_k} {k_B T}\right)$$So that is where the sum up-top comes from: we now have a complicated multi-particle state but as long as the particles themselves are noninteracting we can use the sum of single-particle energies to get the overall energy.
