Is $S = k\ln(W)$ also in grand canonical ensemble?

In grand canonical ensemble, we consider two systems A' and A in thermal contact that allow the exchange of particles and energy. When we consider all possible microstates configurations with distinct pairs $$(N_i, E_j)$$ compatible with $$E_0 = E' + E$$, $$N_0 = N' + N$$ we end up with:

$$W = \frac{\mathcal{N}!}{\prod_{i,j}(n_{i,j}!)}$$

where $$\mathcal{N}$$ is the total number of possible microstates, and $$n_{i,j}$$ is the number of microstates configurations giving a fixed $$(N_i, E_j)$$.

With that definitions, we have:

$$\sum_{i,j}n_{i,j} = \mathcal{N}$$

$$\sum_{i,j}n_{i,j}N_i = \mathcal{N}\langle N\rangle_e$$

$$\sum_{i,j}n_{i,j}E_j = \mathcal{N}\langle E\rangle_e$$

We can treat the system $$A_0$$ as a microcanonical ensemble with the above constraints. Said that, my questions are:

1. Can I say that $$S \propto W$$ in the grand canonical ensemble, where $$S$$ is the entropy ?

If 1 is valid, for two isolated grand canonical systems we must have $$W = W_1W_2$$ and $$S(W) = S_1(W_1) + S_2(W_2)$$, which implies that $$S(W) = k\ln(W)$$ like in the microcanonical ensemble.

1. Is it because a grand canonical ensemble is a microcanonical ensemble with constraints?

2. When we seek for the maximal $$W$$, and we maximize $$\ln(W)$$, in the grand canonical ensemble with the Lagrange multipliers (due to the constraints), is that because in equilibrium $$S$$ should be maximal and $$S(W) = k\ln(W)$$?

1. In thermodynamics, $$S=k \ln W$$ is always the entropy. We assume that every microstate consistent with macroscopic constraints is equally likely. The part "consistent with macroscopic constraints" is what separates different ensembles. For the microcanonical ensemble, the particle number and energy of the system are fixed. For the canonical ensemble, the system can exchange energy but not particles with its environment. For the grand canonical ensemble, the system can exchange energy and particles with its environment.
3. I tend to think of the basic problem thermodynamics solves as finding the probability distribution over microstates that maximizes the entropy, subject to constraints (eg fixed particle number and energy for the microcanonical ensemble). Since by definition $$S=k\ln W$$ and $$\ln W$$ is a monotonic function, you could also define the problem as finding the probability distribution over microstates that maximizes $$W$$.
• Sorry, why do you say that $S=k_\mathrm B\ln W$ always holds? That is certainly not true. The general formula is given by a variant of Shannon's entropy and this equation follows as a special case where $p_i=p$ for all $i$. Am I misunderstanding something? Commented May 30, 2023 at 17:08
• @TobiasFünke By "in thermodynamics, $S=k\ln W$ always holds", in more detail I mean assuming the fundamental assumption of thermodynamics (ie, that $p_i=p$ for all $i$) holds. It might not have been the most precise phrasing. Commented May 30, 2023 at 18:25
• But $p_i=p$ does not hold for the canonical ensemble...sorry, I still don't get it. Commented May 30, 2023 at 18:26