This is a simulation of the 2D Ising model using the Metropolis algorithm, a Monte Carlo method for modeling the behavior of ferromagnetic materials and phase transitions in statistical physics. It displays the evolution of spin configurations on a 2D lattice, as well as the energy, magnetization, and energy histogram over time.
The simulation is interactive, featuring a reset button to reinitialize the model and observe different random configurations.
- 2D Ising spin lattice: Each site on an N*N grid contains a spin (+1 or -1).
- Metropolis algorithm for Monte Carlo updates:
- Randomly selects lattice points and probabilistically flips spins.
- Considers change in energy and temperature for acceptance of spin flips.
-
Lattice Initialization: The system starts with a random
$$N \times N$$ lattice of spins, each set to +1 or -1. - Energy Calculation: The energy considers nearest-neighbor spin interactions and periodic boundary conditions.
-
Metropolis Algorithm: For each Monte Carlo step:
- Randomly select a site.
- Compute the energy change if the spin is flipped.
- Flip the spin with a probability determined by the Boltzmann factor
$$\exp(-\Delta E / T)$$ .
-
Measurements:
- Energy: Calculated by summing over all pairs of neighbors.
- Magnetization: Sum of all spins in the lattice.
-
Clone the repository:
git clone https://github.com/AakaashfromIndia/2D-Ising-model-using-Metropolis-Algorithm.git
-
Install dependencies:
pip install numpy matplotlib
-
Run the simulation:
python Ising-Model.py
-
Use the Reset button in the GUI to start with a new random configuration.
- Python 3.x
- NumPy
- Matplotlib
