Skip to content

AakaashfromIndia/2D-Ising-model-using-Metropolis-Algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

2D Ising Model using the Metropolis Algorithm

Ising model - Made with Clipchamp (3)

Overview

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.

Features

  • 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.

How It Works

  • 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.

Usage

  1. Clone the repository:

    git clone https://github.com/AakaashfromIndia/2D-Ising-model-using-Metropolis-Algorithm.git
  2. Install dependencies:

    pip install numpy matplotlib
  3. Run the simulation:

    python Ising-Model.py
  4. Use the Reset button in the GUI to start with a new random configuration.

Dependencies

  • Python 3.x
  • NumPy
  • Matplotlib

About

Simulation of the 2D Ising model using the Metropolis Monte Carlo algorithm which models a grid of spins that can point up or down, and updates them over time based on thermal fluctuations at a fixed temperature and visualises the spin configuration as it evolves, and tracks the system's energy, magnetization, and energy distribution.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages