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
The results are displayed in the folders "2D noDiag," "2D withDiag," and "1D."