No external field
Ising model on square lattice are $L \times L$ spin that can take 2 values, either $S_i=+1$ or $S_i=-1$. Each spin interact with neighbors and with external field. The Hamiltonian of the system is
\begin{equation}
H = -\sum_{<ij>} J_{ij}S_iS_j - \sum_i H_iS_i
\end{equation}
A particular solution for no external field are obtained by Lars Onsager where the second-order phase transition is happened at
$\dfrac{J}{k_BT_c} = \dfrac{ln(1+\sqrt{2})}{2}$. With this in mind, we can use Metropolis algorithm to simulate Ising model with good accuracy. Following four figures show different MC steps, the spin of a $100 \times 100$ system with blue represent spin up and red represent spin down. Since the temperature happened around the critical temperature, the magnetization taken very long time to come to equilibrium.
First of all we can measure the mean energy at different temperature after reaching equilibrium by using following formula.
\begin{equation}