Skip to content

Exact computations on 1D Ising models with open boundary conditions

License

Notifications You must be signed in to change notification settings

stecrotti/IsingChains.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IsingChains

Build Status Coverage

A 1D Ising model with open boundary conditions, described by a Boltzmann distribution

equation

is exactly solvable in polynomial time.

Quantity Cost
Normalization, Free energy equation
Sample a configuration equation
Average energy, Entropy equation
Single-site distributions equation
Joint distributions of pairs of neighbors equation

Example

using Pkg; Pkg.add("https://github.com/stecrotti/IsingChains.jl.git")

Construct a IsingChain instance

using IsingChains, Random

N = 100000
rng = MersenneTwister(0)
J = 2.0*randn(rng, N-1)
h = randn(rng, N)
β = 0.1
x = IsingChain(J, h, β)

Compute stuff

# normalization and free energy
Z = normalization(x)
F = free_energy(x)

# energy and probability of a configuration
σ = rand(rng, (-1,1), N) 
E = energy(x, σ)
prob = pdf(x, σ)

# a sample along with its log-probability 
σ, logp = sample(rng, x)

# single-site magnetizations <σᵢ>
m = site_magnetizations(x)

# nearest-neighbor magnetizations <σᵢσᵢ₊₁>
mneigs = neighbor_magnetizations(x)

# energy expected value
U = avg_energy(x)

# entropy
S = entropy(x)

About

Exact computations on 1D Ising models with open boundary conditions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages