---
title: "Exchange smooths the magnetization and sets how fine the mesh must be"
description: "Exchange makes neighbours agree. Derive its field on a grid, find the lengths it sets, and check a simulation by halving its cells and watching the error drop."
canonical_url: "https://sandboxphysics.com/stories/micromagnetics/exchange-and-the-mesh/"
language: "en"
page_type: "story"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/stories/micromagnetics/exchange-and-the-mesh/"
last_modified: "2026-10-29"
---

[Micromagnetics · A course with experiments](https://sandboxphysics.com/stories/micromagnetics/)

L2 · Chapter 3

# Exchange smooths the magnetization and sets how fine the mesh must be

Exchange makes neighbouring moments line up, and bending the magnetization costs energy. Balanced against the stray field or the anisotropy, it sets a few nanometres as the shortest length over which the direction can change: 4.59 nm and 5.60 nm for the Pt/Co film of this course. A finite-difference simulation replaces the smooth magnetization by cells, and its error falls with the square of the cell size. Halve the cells, and the error should drop by four.

Sandbox Physics · 2026-10-29

In this chapter

[All eight chapters](https://sandboxphysics.com/stories/micromagnetics/)

Before you start

Chapter 1: the Landau-Lifshitz-Gilbert equation. Taylor series to fourth order and partial derivatives.

## The exchange energy and its field

Neighbouring spins in a ferromagnet prefer to be parallel. In the continuum this becomes an energy density $A(\nabla\mathbf{m})^2$ (Abert 2019, Eq. 10), where the exchange stiffness $A$ is measured in joules per metre. A uniform magnetization costs nothing; a twist costs more the shorter it is.

The effective field that enters the Landau-Lifshitz-Gilbert equation is minus the derivative of the energy with respect to the magnetization, divided by $\mu_0M_s$. For exchange this gives $(2A/\mu_0M_s)\nabla^2\mathbf{m}$: a field that pulls each moment toward the average of its neighbours.

$$
E_{\mathrm{ex}}=A\int(\nabla\mathbf{m})^2\,\mathrm{d}V,\qquad \mathbf{H}_{\mathrm{eff}}=-\frac{1}{\mu_0M_s}\frac{\delta E}{\delta\mathbf{m}},\qquad \mathbf{H}_{\mathrm{ex}}=\frac{2A}{\mu_0M_s}\nabla^2\mathbf{m}
$$

Worked example

## The same field on a chain of cells

Cut a strip into cells of length $a$ along $x$, with one direction $\mathbf{m}_i$ per cell. Replace the gradient by the difference between neighbours. Per unit cross-section the energy is $E/S=(A/a)\sum_i|\mathbf{m}_{i+1}-\mathbf{m}_i|^2$, since each bond spans a length $a$ and the squared gradient is about $|\mathbf{m}_{i+1}-\mathbf{m}_i|^2/a^2$.

Cell $i$ appears in two bonds. Differentiating gives $\partial(E/S)/\partial\mathbf{m}_i=(2A/a)(2\mathbf{m}_i-\mathbf{m}_{i+1}-\mathbf{m}_{i-1})$. Dividing by $-\mu_0M_sa$, the volume factor of one cell, gives the field below. It is the continuum field with the second derivative replaced by a central difference.

The domain-wall Lab is built exactly this way, and its first check differentiates the discrete energy numerically: the field agrees with minus the gradient to 9 parts in a billion. The skyrmion Lab does the same on a two-dimensional grid.

$$
\mathbf{H}_{\mathrm{ex},i}=\frac{2A}{\mu_0M_s}\,\frac{\mathbf{m}_{i+1}+\mathbf{m}_{i-1}-2\mathbf{m}_i}{a^2}
$$

## Lengths that exchange sets

Exchange alone would make everything uniform. It competes with energies that prefer the magnetization to bend. Against the stray field the balance length is the exchange length $\ell_{\mathrm{ex}}=\sqrt{2A/(\mu_0M_s^2)}$; against a perpendicular anisotropy $K_0$ it is the wall-width parameter $\Delta=\sqrt{A/K_0}$.

For the standard-problem element, with $A=13\,\mathrm{pJ/m}$ and $M_s=800\,\mathrm{kA/m}$, the exchange length is 5.69 nm. For the Pt/Co film of the later chapters, with $A=16\,\mathrm{pJ/m}$, $M_s=1.1\,\mathrm{MA/m}$ and $K_0=510\,\mathrm{kJ/m^3}$, it is 4.59 nm, and $\Delta=5.60\,\mathrm{nm}$. Walls and skyrmions in these films turn over lengths of this order, which tells you how small the cells must be.

$$
\ell_{\mathrm{ex}}=\sqrt{\frac{2A}{\mu_0M_s^{2}}}=4.59\,\mathrm{nm},\qquad \Delta=\sqrt{\frac{A}{K_0}}=5.60\,\mathrm{nm}\quad(\text{Pt/Co})
$$

## What the cells get wrong, and by how much

Expand $\mathbf{m}(x\pm a)$ in a Taylor series. The odd powers cancel in the central difference, which leaves $(\mathbf{m}_{i+1}+\mathbf{m}_{i-1}-2\mathbf{m}_i)/a^2=\mathbf{m}''+a^2\mathbf{m}''''/12+\dots$. The leading error is proportional to $a^2$ and to the fourth derivative, which is large where the texture bends over a few nanometres. So the relative error scales roughly as $(a/\Delta)^2$.

Miltat and Donahue reached the same practical rule from a demanding test problem: cells well below the exchange length are needed for adequate convergence. This course quotes that conclusion from the chapter’s abstract, the only part we have read.

$$
\frac{\mathbf{m}_{i+1}+\mathbf{m}_{i-1}-2\mathbf{m}_i}{a^2}=\mathbf{m}''+\frac{a^2}{12}\,\mathbf{m}''''+O(a^4)
$$

Worked example

## Halve the cells and read the order

If the error is $e(a)\approx Ca^p$, then $e(a)/e(a/2)=2^p$, and the observed order is $p=\log_2[e(a)/e(a/2)]$. A second-order method gives ratios near 4.

The domain-wall Lab checks the energy of a static Bloch wall against the exact $4\sqrt{AK_0}=11.42\,\mathrm{mJ/m^2}$. With cells of 2, 1, 0.5 and 0.25 nm the energy is low by 0.54, 0.133, 0.033 and 0.0083 per cent. The ratios are 4.06, 4.01 and 4.00, so $p=2.02$, 2.01 and 2.00. The wall is resolved, and you know how large the mesh error is.

A gap that does not shrink is not a mesh error. In the skyrmion benchmark at $D=3.4\,\mathrm{mJ/m^2}$ the relaxed skyrmion is 10.0 per cent smaller than the isolated profile on 2 nm cells and 9.1 per cent smaller on 1 nm cells. Halving the cells moved it by 1 per cent. The rest comes from the model: the film repeats every 60 nm across the track, and a skyrmion with a free radius of 17.3 nm feels its own periodic copies.

$$
p=\log_2\frac{e(a)}{e(a/2)}:\qquad \frac{0.54\%}{0.133\%}=4.06,\quad\frac{0.133\%}{0.033\%}=4.01,\quad\frac{0.033\%}{0.0083\%}=4.00
$$

## Why the community shares test problems

A converged answer shows only that the discrete model approaches its own continuum. It does not show that two codes solve the same continuum problem, or that the continuum model describes a device. That is why NIST publishes micromagnetic standard problems and keeps a public reference code, OOMMF: different groups run the same specified problem and compare. This course’s Labs borrow the geometry and constants of one of those problems and check themselves against analytic limits.

An experiment to think through

## Predict, change, explain

1. In the skyrmion Lab the cells are 2 nm. At $D=3.0\,\mathrm{mJ/m^2}$ the isolated skyrmion has a 9.40 nm radius; at $2.8$ it has 7.34 nm. Predict at which value the 2 nm cells misrepresent the skyrmion more.
2. Set “Interfacial DMI” to $2.8$ and open “More numbers and the saved record”; compare “Core radius” with the radius of the isolated skyrmion in an unbounded continuum film. Then return to $3.0$.
3. Explain the difference using the scaling of the error with $(a/R)^2$, where $R$ is the skyrmion radius, and say why the Lab stops the DMI slider at 2.8.

[Push a domain wall and launch spin waves](https://sandboxphysics.com/labs/domain-wall-spin-waves/) [Drive a skyrmion along a track](https://sandboxphysics.com/labs/skyrmion-track-pinning/)

The macrospin Lab treats the strip of muMAG Standard Problem 4 as one moment. The wall and skyrmion Labs use the Pt/Co film of Thiaville et al. with local stray-field terms. All three run at zero temperature.

## Try explaining it yourself

### 1. Compute the exchange length for $A=16\,\mathrm{pJ/m}$ and $M_s=1.1\,\mathrm{MA/m}$.

Read an explained answer

$\mu_0M_s^2=1.52\times10^{6}\,\mathrm{J/m^3}$, so $\ell_{\mathrm{ex}}=\sqrt{3.2\times10^{-11}/1.52\times10^{6}}\,\mathrm{m}=4.59\,\mathrm{nm}$.

### 2. A free-edge tilt is computed with 1, 0.5 and 0.25 nm cells and differs from the continuum value by 0.133, 0.035 and 0.0090 per cent. What is the observed order, and what error would you expect at 0.125 nm?

Read an explained answer

The ratios are 3.8 and 3.9, so the order is close to 2. Dividing by 4 again predicts about 0.0022 per cent at 0.125 nm.

### 3. Halving the cells changes a result by 1 per cent, but the result differs from a reference by 9 per cent. What should you look for?

Read an explained answer

A difference between the model and the reference, not a mesh error: a boundary, a finite box, a neglected energy or a different quantity being compared. Only a change to the model closes that gap.

## Sources to read alongside

1. [Abert, Micromagnetics and spintronics: models and numerical methods, European Physical Journal B 92, 120 (2019), arXiv:1810.12365v2](https://arxiv.org/abs/1810.12365v2)

   Read: the exchange energy (Eq. 10), the demagnetizing field (Sec. 2.3), uniaxial anisotropy (Sec. 2.4), interfacial DMI (Eq. 33) and its boundary term (Sec. 3.5), the Landau-Lifshitz-Gilbert equation in Gilbert and explicit form (Eqs. 117 and 118), the conservation of the magnetization length and the energy dissipation (Eqs. 120 to 125), the Zhang-Li torque (Eq. 134) and the finite-difference method (Sec. 6.1). Other sections were not read.

2. [NIST, Computational Micromagnetics (program overview)](https://www.nist.gov/programs-projects/computational-micromagnetics)

   Full page: why the community publishes standard problems and the public OOMMF code. It gives no equations or reference values.

3. [Miltat & Donahue, Numerical Micromagnetics: Finite Difference Methods, Handbook of Magnetism and Advanced Magnetic Materials, Vol. 2 (2007), NIST publication record](https://www.nist.gov/publications/numerical-micromagnetics-finite-difference-methods)

   Abstract only. It reports that a demanding test needs mesh sizes well below the exchange length to converge. The chapter itself was not read, so the course quotes only that conclusion.

[Previous A nanomagnet’s shape sets its easy axis and how it switches](https://sandboxphysics.com/stories/micromagnetics/shape-anisotropy-and-switching/) [Next A field drives a domain wall only so fast](https://sandboxphysics.com/stories/micromagnetics/domain-walls-and-walker-breakdown/)
