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.
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.
| Physics | Magnetostatic, permanent magnet, no free current — OpenFOAM magneticFoam |
|---|---|
| Body | A sphere of radius a = 1 m, magnetised along +y, cut with sphereToCell |
| Material | Relative permeability exactly 1 — see the caveats |
| Meshes | Four levels: 60³, 90³ and 120³ cells in a box of half-width 5a; 96³ in 8a |
| Cells across the radius | 6, 9, 12 and 6 |
| Boundary | Zero-gradient on the magnetic potential — a flux-excluding wall |
| Reference | The uniformly magnetised sphere: a uniform interior field of −M/3, and an exact point dipole outside |
| Agreement | Demagnetising factor −0.326224 against an exact −1/3, 2.13 % out on the finest mesh |
| Last run | 2026-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^3The 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
| Level | h/a | L/a | H_in/M | vs −1/3 | Non-uniformity | Transverse |
|---|---|---|---|---|---|---|
| 60³ cells, box 5a | 0.1667 | 5 | −0.3159130 | −5.226 % | 0.527 % | 0.870 % |
| 90³ cells, box 5a | 0.1111 | 5 | −0.3231941 | −3.042 % | 0.172 % | 0.481 % |
| 120³ cells, box 5a | 0.0833 | 5 | −0.3262244 | −2.133 % | 0.278 % | 0.589 % |
| 96³ cells, box 8a | 0.1667 | 8 | −0.3131498 | −6.055 % | 0.532 % | 0.878 % |
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.
| Level | B/(H + M) recovered | vs μ₀ = 1.2566370614 × 10⁻⁶ |
|---|---|---|
| 60³ cells, box 5a | 1.2566370648 × 10⁻⁶ | 2.7 × 10⁻⁹ |
| 90³ cells, box 5a | 1.2566370615 × 10⁻⁶ | 4.9 × 10⁻¹¹ |
| 120³ cells, box 5a | 1.2566370596 × 10⁻⁶ | 1.5 × 10⁻⁹ |
| 96³ cells, box 8a | 1.2566370619 × 10⁻⁶ | 4.1 × 10⁻¹⁰ |
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.
| Level | Axis exponent | Equator exponent | r/a = 1.42 | r/a = 1.92 | r/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 |
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.
| Level | r/a = 1.42 | r/a = 1.92 | r/a = 2.42 |
|---|---|---|---|
| 60³ cells, box 5a | 18.80 % | 1.71 % | 12.11 % |
| 90³ cells, box 5a | 7.49 % | 3.45 % | 16.70 % |
| 120³ cells, box 5a | 4.78 % | 5.74 % | 16.73 % |
| 96³ cells, box 8a | 22.77 % | 9.96 % | 2.58 % |
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.
Other cases
- Straight conductor, against AmpèreAmpère’s law is exact and the geometry is trivial, which is what makes the residual difference worth reporting rather than explaining away.
- Eddy-current loss in an AC barA square bar in its own alternating field has no closed-form loss. The low-frequency asymptotic is exact for any shape, and the mesh cancels out of it.
- Electrostatic platesThe product’s own staged Electrostatics case, measured against the parallel-plate closed form — and the demonstration that the potential field cannot see the permittivity at all.
All validation cases · Written by the team building SHD Sim.