I want to study the thermodynamics of the 2D Nearest Neighbour Ising model (calculate the average energy, susceptibility, etc.). I have the Hamiltonian
$$\mathcal{H} = J\sum_{\langle i j \rangle} s_i s_j + h\sum_i s_i$$
where $s_i \in \{-1, 1\}$. I put these spins $s_i$ on a lattice of size $n\times n$. To calculate the partition function, I need to sum over all possible spin configurations (permutations) of the spins $s_i$.
However, I am not sure how I should go about summing over all possible permutations in Mathematica and implementing the 'nearest neighbour' interaction for a 2D grid.