Ising model
The Ising model is a mathematical model used to describe the behavior of interacting particles, such as atoms or molecules, in a magnetic field. In the Ising model, each particle is represented as a binary variable $s_i$ that can take on the values of either +1 or -1. The total energy of the system is given by the Hamiltonian:
\[H = \sum_{(i,j) \in \mathcal{E}} J_{ij} s_i s_j + \sum_{i} h_i s_i\]
where $J_{ij}$ is the coupling constant between particles $i$ and $j$, $h_i$ is the external magnetic field at particle $i$, and the sum is taken over all pairs of particles and all particles in the system $\mathcal{E}$, respectively.
In SpinGlassPEPS.jl
package, an Ising graph can be created using the command ising_graph
.
SpinGlassNetworks.ising_graph
— Functionising_graph(
::Type{T},
inst::Union{String, Dict};
scale,
rank_override
) -> LabelledGraphs.LabelledGraph{S} where S<:(MetaGraphs.MetaGraph{Int64})
Create an Ising graph from interaction data.
This function creates an Ising graph (LabelledGraph) from interaction data provided in the form of an inst
argument. The Ising graph represents a system of spins, where each spin is associated with a vertex, and interactions between spins are represented as edges with corresponding weights.
Arguments:
::Type{T}
: The type of the edge weights, typicallyFloat64
orFloat32
.inst::Instance
: Interaction data, which can be either a file path to a CSV file or a collection of triples(i, j, J)
representing interactions between spins, wherei
andj
are spin indices, andJ
is the interaction strength.scale::Real
: The scale factor establishes the convention in the Hamiltonian (default is 1).rank_override::Dict
: A dictionary specifying the rank (number of states) for each vertex. If not provided, a default rank of 2 is used for all vertices.
Returns:
ig::IsingGraph{T}
: The Ising graph (LabelledGraph) representing the spin system.
The function reads interaction data and constructs an Ising graph ig
. It assigns interaction strengths to edges between spins and optionally scales them by the scale
factor. 'Scale' option allows for the change of convention in the Hamiltonian. The rank_override
dictionary can be used to specify the rank (number of states) for individual vertices, allowing customization of the Ising model. Convention: H = scale * sum{i, j} (J{ij} * si * sj + J{ii} * si)
Simple example
In this simple example below we show how to create Ising graph of a instance given as txt file in a format (i, j, Jij). The resulting graph has vertices corresponding to positions of spins in the system and edges defining coupling strength between spins. Each vertex contains information about local field.
using SpinGlassNetworks
# Create Ising instance
instance = "$(@__DIR__)/../../src/instances/square_diagonal/5x5/diagonal.txt"
ig = ising_graph(instance)
# View graph properties
@show biases(ig), couplings(ig)
([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0 -0.935080082835686 … 0.0 0.0; 0.0 0.0 … 0.0 0.0; … ; 0.0 0.0 … 0.0 -0.6713059673107826; 0.0 0.0 … 0.0 0.0])