Skip to content
SHD Sim
Menu

Validation/Magnetostatics

Uniformly magnetised sphere

A uniform field inside and an exact point dipole outside, over four meshes and two box sizes — and two magnetic defects, neither of them fixed, that bound what the case can claim.

VerificationDemagnetising factor −0.326224 against an exact −1/3, 2.13 % out

Why this case

A sphere carrying a uniform magnetisation is the one magnetostatics problem whose answer is closed form everywhere — inside the body and outside it, with no near-field correction to allow for and no fitted constant anywhere in it. That is what makes it worth running against a permanent-magnet solver, and it is what separates it from the straight conductor, where the reference holds only at a distance.

Four of the numbers it produces are pure: the interior field is exactly −M/3, the interior flux density is exactly two thirds of μ₀M, the exterior field falls as r⁻³, and the field on the axis is exactly −2 times the field on the equator at the same radius. None of them contains a material property, a length or a field strength, so none of them can be brought into line by rescaling something.

Two product defects were found by running this case and neither has been fixed. Both bear directly on what the page can claim, and both are set out in full below rather than left in a footnote.

PhysicsMagnetostatic, permanent magnet, no free current — OpenFOAM magneticFoam
BodyA sphere of radius a = 1 m, magnetised along +y, cut with sphereToCell
MaterialRelative permeability exactly 1 — see the caveats
MeshesFour levels: 60³, 90³ and 120³ cells in a box of half-width 5a; 96³ in 8a
Cells across the radius6, 9, 12 and 6
BoundaryZero-gradient on the magnetic potential — a flux-excluding wall
ReferenceThe uniformly magnetised sphere: a uniform interior field of −M/3, and an exact point dipole outside
AgreementDemagnetising factor −0.326224 against an exact −1/3, 2.13 % out on the finest mesh
Last run2026-08-28

The exact solution

With no free current the field is a gradient, H = −∇ψ, and the magnetisation enters as a source: ∇²ψ = ∇·M. For a uniformly magnetised sphere that source lives entirely on the surface, as a magnetic surface charge M cos θ, which is exactly the l = 1 Legendre term. Everything follows in closed form:

    H_in  = -M/3                       uniform, exactly, right up to the surface
    B_in  = mu0 (H_in + M) = (2/3) mu0 M
    B_out = a point dipole of moment  m = M (4/3) pi a^3

The 1/3 is the sphere’s shape and nothing else — it is 0 for a long rod along its own axis and 1 for a thin plate across it — so a solver cannot land near it by accident, and it cannot drift off it for a small reason.

The exterior form is unusually strong for a benchmark. Outside a uniformly magnetised sphere the field is a point dipole exactly, from r = a outwards. There is no multipole tail to allow for, so any departure from r⁻³ at a sampled radius is the discretisation or the domain boundary, and cannot be the shape of the body.

The harness evaluates its own closed form and subtracts the numbers it must reduce to, before any solver output is compared against it. Two of the three come out bit for bit — −1/3 and −2 evaluate to exactly zero residue — and the third, B/(μ₀M) against 2/3, lands 1.11 × 10⁻¹⁶ away, which is one rounding of a double.

Two product defects, neither of them fixed

Result — inside the sphere

The demagnetising factor and the uniformity of the interior field, four levels
Levelh/aL/aH_in/Mvs −1/3Non-uniformityTransverse
60³ cells, box 5a0.16675−0.3159130−5.226 %0.527 %0.870 %
90³ cells, box 5a0.11115−0.3231941−3.042 %0.172 %0.481 %
120³ cells, box 5a0.08335−0.3262244−2.133 %0.278 %0.589 %
96³ cells, box 8a0.16678−0.3131498−6.055 %0.532 %0.878 %
H_in/M is the mean over the cells inside 0.6a. Non-uniformity is the standard deviation of that field over its mean; transverse is the part of it pointing somewhere other than along the magnetisation. The exact interior field is uniform to machine precision with no transverse component at all, so both columns are entirely discretisation.

The sharpest number in the case is not on that table, because it checks the solver against itself rather than against the page. B and H are written as two separate fields, and B/(H + M) has to come back as μ₀. It does, to eight significant figures on every healthy row — worst 2.7 × 10⁻⁹ relative. That is also what rejects a run whose relative permeability is not 1, because at μᵣ ≠ 1 the interior value is no longer −M/3 and the textbook two thirds is the wrong form entirely.

The constitutive relation read back out of the two written fields
LevelB/(H + M) recoveredvs μ₀ = 1.2566370614 × 10⁻⁶
60³ cells, box 5a1.2566370648 × 10⁻⁶2.7 × 10⁻⁹
90³ cells, box 5a1.2566370615 × 10⁻⁶4.9 × 10⁻¹¹
120³ cells, box 5a1.2566370596 × 10⁻⁶1.5 × 10⁻⁹
96³ cells, box 8a1.2566370619 × 10⁻⁶4.1 × 10⁻¹⁰
Relative differences, from the fixture. On the fixture run at the application's default relative permeability of 1.05, the same ratio comes back at exactly 1.05 times μ₀ — which is how the case detects that its own reference no longer applies.

Result — outside the sphere

Outside, two things are measured: the exponent that |B| falls at, fitted through three sampled radii, and the ratio of the field on the axis to the field on the equator at the same radius. The second is the one that cannot be rescaled — it holds for any dipole and contains no magnetisation, no permeability, no radius and no length.

Falloff exponent and axis-to-equator ratio, against a point dipole
LevelAxis exponentEquator exponentr/a = 1.42r/a = 1.92r/a = 2.42
60³ cells, box 5a−3.2037−2.6396−2.3760−2.0342−1.7579
90³ cells, box 5a−3.1980−2.6984−2.1498−1.9310−1.6659
120³ cells, box 5a−3.1692−2.7327−2.0956−1.8852−1.6654
96³ cells, box 8a−3.1271−2.7878−2.4554−2.1993−2.0515
Both exponents should be −3 and every ratio should be −2. The sampled radii are the nearest cell centres to targets of 1.5a, 2.0a and 2.5a; the fixture records where each sample actually landed.

The four cells that make up each exterior sample are related by a mirror symmetry the problem has exactly, so a spread between them would be the mesh or the reader rather than the field. The worst spread anywhere in the sweep is 6.2 × 10⁻⁸, relative.

Two residuals, pulling in opposite directions

There are exactly two error sources here, and they behave oppositely. That is why the sweep is four rows and not one.

The staircase. The magnet’s cells are selected by their centres, so its surface is a staircase and its magnetic charge is smeared over a cell. It is a discretisation error: it falls with the cell size at very close to first order — 5.226 %, 3.042 %, 2.133 % as h/a goes 1/6, 1/9, 1/12 — and it dominates the samples nearest the sphere. The discrete magnet’s volume is within 1.91 % of (4/3)πa³ on every level.

The box. Zero-gradient on the magnetic potential means the normal component of H vanishes at the wall, so the domain boundary is a perfect flux-excluding surface and the dipole is imaged in all six faces. It does not fall with the cell size: the 5a and 8a rows have the same cell size and different answers. It dominates the samples nearest the wall. It is not a defect — zero-gradient is the only condition this family offers for that field, so free space can only be approached by making the box bigger.

Both are asserted as trends rather than as tolerances, because a tolerance cannot tell a converging answer from one that happens to sit inside it. The demagnetisation error falls by a factor of 2.45 from the coarsest to the finest mesh in the box of 5a. At equal cell size, the outermost dipole ratio improves from 12.1 % away from −2 in a box of 5a to 2.6 % in a box of 8a — a factor of 4.7, and the evidence that the exterior residual is the boundary and not the solver.

Where each residual bites: departure of the axis/equator ratio from −2, per cent
Levelr/a = 1.42r/a = 1.92r/a = 2.42
60³ cells, box 5a18.80 %1.71 %12.11 %
90³ cells, box 5a7.49 %3.45 %16.70 %
120³ cells, box 5a4.78 %5.74 %16.73 %
96³ cells, box 8a22.77 %9.96 %2.58 %
The inner column falls with the cell size and worsens with box size; the outer column does the reverse. Every row is worst at a different radius, which is itself the evidence that these are two effects and not one.

What this page does not establish

  • The exterior agreement is loose and is reported as loose. The worst fitted exponent is −2.6396 against −3, and the worst axis-to-equator ratio is 22.77 % from −2. Those are large numbers. They are attributed to the two residuals above on the evidence of the trends, not on the grounds that they ought to be small.
  • Nothing here is a magnetisation reversal, a soft-magnetic material or a multi-magnet interaction. One sphere, one uniform magnetisation, one direction, free space approached by enlargement.
  • The flux density this case reports is 1.03 × 10⁻⁶ T, not 0.8 T. That is the second defect and not a solver result. Until the pane’s label and the unit it is written into agree, any absolute field strength a magnetic case reports should be checked against the factor of μ₀ before it is used.

Repeat this yourself

Every case here is set up from the worked examples in the product, with no hand-editing of solver files — so you can run it, and get the same numbers. The free tier runs real cases up to 250,000 cells of fluids, or 100,000 nodes of solid, with no account needed to download and no time limit.

All validation cases · Written by the team building SHD Sim.