Magpylib Material Response

Fields that know
the iron is there.

The field of magnets and coils next to steel, soft iron and other magnets: solved, and handed back to Magpylib.

Get started Skip to the docs ↓

A magnet, in empty space.

Magpylib computes its field in closed form, at any point. These are its field lines, cut through the middle.

Now set it on a steel plate.

To Magpylib the plate isn't there. Its magnets have a fixed polarization, and nothing else answers: the field stays as it was.

But steel answers.

The magnet's field magnetizes the plate, and the plate's field adds to the magnet's. Turn up its susceptibility, and the flux takes the short way back, through the steel.

+29 %

Half a millimetre above the magnet the field is 473 mT, not 367 mT. Magpylib alone misses that; this package computes it.

And the plate holds on.

Lift the magnet: the pull falls from 33 N at contact to 0.5 N at 8 mm. A solved model is a Magpylib source, so magpy.getFT reads the force off it.

Three solvers, one model

Face charge solves the surface.

A part that is linear and uniform inside carries its whole response as a charge on its faces: north red, south green. No volume mesh; … panels, 0.17 s.

Cells solve the volume.

One polarization per cell, for what face charge can't do: saturation on a B–H curve, anisotropy, B inside a part. 2,916 cells, 0.8 s.

Finite elements mesh the air too.

NGSolve, independent of the other two, to check them. 14,229 elements, 4.3 s.

Three solvers, one answer

Drawn three times, it's one line.

Bz on the axis above the magnet, on the plate and alone.

Each solve, at its real pace

Face charge 0.00 s within 0.08 % of finite elements
Cells 0.00 s within 0.6 %, 4 cells across the plate
Finite elements 0.00 s the reference, order 4

Face charge is done 26× sooner than finite elements.

Timed on an Apple M4 Pro.

In code

Give a part a susceptibility. Solve. Read.

import magpylib as magpy
from magpylib_material_response import solve_face_charge
 
magnet = magpy.magnet.Cuboid(
    dimension=(0.01, 0.01, 0.005), position=(0, 0, 0.0055), polarization=(0, 0, 1.2)
)
plate = magpy.magnet.Cuboid(dimension=(0.04, 0.04, 0.006), polarization=(0, 0, 0))
plate.susceptibility = 1000  # soft iron
 
solved = solve_face_charge(magpy.Collection(magnet, plate))
magpy.getB(solved, (0, 0, 0.0085))  # Bz: 0.473 T, and 0.367 without the plate

Get started Which solver for my model →