This is the grand canonical ensemble (μVT) run directly on a 2D square lattice: L×L sites, each either empty (n=0) or occupied by one particle (n=1), exchange both energy and particles with an implicit reservoir at fixed temperature T and chemical potential μ — unlike a canonical (NVT) simulation where particle number is fixed. Each site has exactly 4 nearest neighbours (up/down/left/right, periodic boundaries), instead of the 6 a cubic 3D lattice would give — a genuinely 2D lattice gas, not a flattened view of a 3D one.
Energy: E = -ε Σ<i,j> nᵢnⱼ (4 nearest-neighbour bonds/site)
Grand pot.: ΔΩ = ΔE - μΔN
Accept if: rand() < exp(-ΔΩ / kT)
Each Monte Carlo step picks a random site and proposes flipping its occupation (insert a particle if empty, remove if occupied — a Metropolis grand-canonical move). ΔN = +1 for insertion, -1 for removal; ΔE comes from the site's occupied neighbours. The grid below is drawn directly from the occupation array: every filled square is a rendered lattice site, so the canvas is the physics, not a camera view of it.
- Temperature — higher kT/ε accepts more energetically unfavourable moves, randomising the lattice.
- Chemical potential μ — raising μ favours insertion and increases average density; very negative μ empties the lattice.
- Interaction ε — the attractive coupling between occupied neighbours; large ε/kT drives clustering and, near μ ≈ -2ε (half filling with 4 neighbours), a liquid-gas-like phase separation into amber domains.
- ⟨(ΔN)²⟩ — the variance of the particle number over recent sweeps. The fluctuation-response relation κ = ⟨(ΔN)²⟩/(N·kT) links these fluctuations directly to the isothermal compressibility of the system.
Real-world relevance: grand canonical Monte Carlo on a 2D lattice is the standard model for gas adsorbed onto a single crystalline surface layer (2D adsorption), and — via the exact lattice-gas/Ising mapping — shares its critical exponents with the 2D Ising model, whose critical temperature is known analytically from the Onsager solution.