JS Ising
This is my first JavaScript project. The goal is to make an interactive implementation of the Ising model that can run in browser. It simulates the behavior of magnetic materials in various environments.
MCMC Sampling
The Ising model is a 2D grid of cells, each with a value of spin that can be either up or down. The energy in a specific cell is related to its spin, the spins of its nearest neighbors, and the external field. The entire system is immersed in a heat bath. Throughout the evolution, cells are chosen at random and allowed to flip spin probabilistically, according to the Metropolis-Hastings acceptance criterion. The total system energy will tend to minimize.
Features
- Reset to a randomized state
- Coloring
- If a cell is spin-down, then it is colored black.
- If colors are enabled and a cell is spin-up, then it is colored either red or blue. The cells are colored red and blue with chess board pattern. If colors are disabled, then all spin-up cells are white.
- Temperature
- At high temperature T > Tc, the spins have enough energy to overcome the influence of their neighbors and the external field, and randomly change state.
- At low temperature T < Tc, the spins have less energy and are more strongly influenced by their neighbors and the external field, and organize to find the minimum energy state.
- At the critical temperature T = Tc, the spins undergo a phase transition.
- External field
- When h = 0, then there is no external field.
- When h = 1, the spin-up cells are aligned with the external field.
- When h = -1, the spin-down cells are aligned with the external field.
- Interaction
- When J = 0, the spins do not influence their neighbors, and there is no simulated magnetism. The system looks like red, blue, and black noise.
- When J = 1, the spins tend to align parallel to their neighbors, simulating ferromagnetic behavior. Red cells favor blue neighbors, and vice versa, while black cells favor black neighbors. The system displays large regions of solid black and magenta (actually, red and blue pixels close together).
- When J = -1, the spins tend to align anti-parallel to their neighbors, simulating antiferromagnetic behavior. Red cells favor black neighbors, vice versa, and so on for the blue cells. The system displays large regions of red and blue (really, red and blue each with black).