This Python code simulates the two-dimensional Ising model using the Metropolis algorithm on a square lattice at a given temperature.
It begins by initializing the spin grid, in which each magnetic spin is assigned a random initial state of -1 or +1. The Metropolis algorithm then evolves the spin system by randomly flipping spins based on changes in the system's energy, parametrized by
After a set number of warm-up sweeps, the magnetization is averaged over further sweeps, and the resulting spin configuration is visualized using a colour map. The average magnetization is also plotted against
The results are displayed in the folders "2D noDiag," "2D withDiag," and "1D."
