A pythonic implementation of the Ising model.
Check the example for more.
This is the main place of the Ising model, we have to initialize it with a tuple of the lattice shape that can be of any dimension or size. The lattice can be initialized with a random state (you can choose the state ratio up) or all in a state 1 or -1.
type: tuple(int)
The shape of the lattice is tested for 1 to 4 dimension. Every values of shape must be > 0
type: int == 1 or -1
Set the state at all 1 or -1 it overpass the r parrameter.
type: float in [0, ..., 1]
Set a random state with a ratio r of 1 in the lattice (default r = 0.5).
type: numpy.array
A vector of vector: is the representation of the spin interaction.
0 J 0 J # J 0 J 0 Will be written as [[1,0],[-1,0],[0,1],[0,-1]]
As default it's the left right up down direct neighbor matrix will be genereted (whatever this mean in 4 or more dimensions).
type: numpy.array or float
Is the interraction between spins, if J is an array he as to be the same length than adj.
(you can choose to make anisotropic iteractions !!)
type: numpy.array or float
Is the magnetic field imposed on the lattice, if B is an array he as to have the same shape of the lattice
type: float
Beta is 1/(Kb * T) with T the absolute temp, and Kb is the Boltzmann constant.
Randomize th lattice state with a given ratio of up state.
type: float in [0, ..., 1]
The ratio of up state.
Set all the lattice to the same state.
type: int == -1 or 1
Value of the spin site.
Compute the Hamiltonian of the lattice.
type: float
Hamiltonian of the lattice.
Compute the Halmitonian of each spin.
type: numpy array
The Hamiltonian calculated for each spin.
Compute the mean value of the Hamiltonian.
type: float
Mean value of the Hamiltonian.
Compute the magnetization of the lattice.
type: float
Magnetization of the lattice.
Method to get the magnetic field.
type: numpy array
Return the magnetic field.
Method to get beta.
type: float
Return beta.
Method to get the shape of the lattice
type: tuple(float)
Return the shape of the lattice
Method to get the size of the lattice
type: float
Return the size of the lattice
Method to get the state of the lattice.
type: numpy array
Return the copy of the state.
Method to set the magnetic field.
type: numpy array
The new Magnetic field.
Method to set beta.
type: float
The new beta.
Method to set the state of the lattice.
type: numpy array
The new state.
Is the class who solve the Ising model with the Metropolis algorithm
Implementation of the Metropolis algorithm
- for the arguments look the lattice class.
step apply the metropolis algorithm on n spin once
type: int
n must be strictly positive is the size of the sample