Exercise 8.13 from "Entropy, Order Parameters, and Complexity (2a. edição), Oxford University Press (2021), James P. Sethna"
A piece of magnetic material exposed to an increasing external field ( H(t) ) will magnetize in a series of sharp jumps, or avalanches. These avalanches arise as magnetic domain walls in the material are pushed by the external field through a rugged potential energy landscape due to irregularities and impurities in the magnet. The magnetic signal resulting from these random avalanches is called Barkhausen noise.
In this exercise, we model this system with a nonequilibrium lattice model: the Random Field Ising Model.
The Hamiltonian (or energy function) for our system is given by:
where:
-
$\mathcal{H}$ is the Hamiltonian, - J is the interaction strength between spins,
- S_i represents the spin at site i,
- ⟨i,j⟩ denotes summation over nearest neighbors,
- H(t) is the external magnetic field,
- h_i is a random field at each site i.
Each spin
We are not interested in thermal equilibrium (where there would be no hysteresis). Instead, we set the temperature to zero. We start with all spins pointing down and adiabatically (infinitely slowly) increase
Each spin flips when doing so would decrease the energy. This occurs at site i when the local field at that site,
changes from negative to positive.
A spin can be flipped in two ways:
- It can be triggered when one of its neighbors flips (participating in a propagating avalanche).
- It can be triggered by the slow increase of the external field, starting a new avalanche.
- Set up the spin lattice
s[m][n]
and the random field latticeh[m][n]
. - In three dimensions, add an extra index to the arrays.
- Fill
s[m][n]
with down-spins ( S = -1 ) andh[m][n]
with random fields from the Gaussian distribution$P(h)$ .
-
FlipSpin(s, i, j)
: Given indices$i$ and$j$ and your spin lattice$s$ , flip the spin from ( S = -1 ) to ( S = +1 ). Return an error if the spin is already flipped. -
NeighborsUp(i, j)
: Calculate the number of up-neighbors for the spin, implementing periodic boundary conditions.
To start a new avalanche, search for the next unflipped spin ready to flip, increase ( H ) just enough to flip it, and propagate the avalanche as follows:
-
Find the Triggering Spin: Find the unflipped site with the largest local field due to neighbors and random field,
$J \sum_{j , \text{nbr to} , i} S_j + h_i$ . -
Increment
$H(t)$ to reach this internal field threshold.
- Place the triggering spin in a first-in–first-out queue.
- While the queue is not empty:
- Pop a spin from the queue.
- Flip it if it hasn’t already flipped.
- Push all unflipped neighbors with positive local fields onto the queue.
BruteForceNextAvalanche
: Check all unflipped spins and return the position of the next to flip based on its local field.PropagateAvalanche
: Given the triggering spin, implement steps to propagate the avalanche. For visualization, color the spins that flip.
- Simulate a
$300 \times 300$ system at different$R$ values: ( R = 1.4 ), ( R = 0.9 ), and ( R = 0.7 ). - If running in three dimensions, use a
$50^3$ lattice with ( R = 4 ), ( R = 2.16 ), and ( R = 2 ). - Display the resulting avalanche patterns.
There are various properties you might want to measure about this system:
- Avalanche sizes and correlation functions.
- Hysteresis loop shapes.
- Average pulse shapes during avalanches.
There are lots of properties that one might wish to measure about this system: avalanche sizes, avalanche correlation functions, hysteresis loop shapes, and average pulse shapes during avalanches. It can become complex to put all these measurements inside the inner loop of your code. Instead, we suggest that you try the subject–observer design pattern: each time a spin is flipped, and each time an avalanche is finished, the subject (our simulation) notifies the list of observers.
- MagnetizationObserver: This observer stores an internal magnetization starting at (-N), adding two to it whenever it is notified.
- AvalancheSizeObserver: This observer tracks the growing size of the current avalanche after each spin flip, adding the final size to a histogram of all previous avalanche sizes when the avalanche ends.
Set up NotifySpinFlip
and NotifyAvalancheEnd
routines for your simulation, and add the two observers appropriately.
Finally, plot the magnetization curve ( M(H) ) and the avalanche size distribution histogram ( D(S) ) for the three systems you ran in part (c).