Physical model¶
Magnetostatic assumptions¶
Microcubed describes an axis-aligned cuboid with constant magnetisation
Outside the magnet, free currents, time-dependent fields, and media differing from vacuum are excluded. Consequently,
hold in the exterior domain. The field follows from the scalar magnetic potential of the Coulomb model. The implemented closed-form expressions are based on Ravaud and Lemarquand, who give all three field components for a uniformly and arbitrarily polarised parallelepiped (Ravaud and Lemarquand, 2009).
Geometry and corner sum¶
Let the cuboid centre be \(\mathbf c\), its size be \(\mathbf s=(s_x,s_y,s_z)\), and the observation point be \(\mathbf r\). The eight corners are
The total field is an alternating sum of corner terms:
The components of \(\mathbf B_{ijk}\) consist of logarithms and atan2 terms.
Microcubed evaluates all eight corners in a vectorised pass. Paired logarithms
are combined stably so that removable expressions of the form
log(0) - log(0) on extended edge lines do not produce NaN.
More explicitly, let \((x,y,z)=\mathbf r-\mathbf e_{ijk}\), \(R=\sqrt{x^2+y^2+z^2}\), and \(\mathbf p=(p_x,p_y,p_z)^\mathsf T\) denote the internal polarisation. Before applying the alternating corner sign, the field kernel implemented by both the NumPy and Rust backends is
These expressions follow by differentiating the Coulombian scalar potential of the six uniformly charged faces. Integrating each face analytically leaves the logarithmic and inverse-tangent terms above; inclusion–exclusion of the opposite face limits produces the eight-corner alternating sum.
Magnetisation, polarisation, and sign¶
The public input is \(\mathbf M\) in A/m. Internally, Microcubed uses the factor
The returned Bfield is magnetic flux density in tesla. Hfield is computed
as \(\mathbf B/\mu_0\).
Field gradient¶
The gradient is returned as the Jacobian matrix ordered as
In NumPy, use
dB[derivative_axis, field_component, point]
For example, dB[0, 2] is \(\partial_xB_z\).
In the current-free exterior domain, \(\nabla\times\mathbf B=0\), so the gradient matrix is symmetric. In addition, \(\nabla\cdot\mathbf B=0\) implies a vanishing trace. These identities provide useful consistency checks, but they do not replace a convergence study near material boundaries.
For the differentiated kernels, the implementation introduces the reusable abbreviations
with cyclic permutations for the other axes. For example, one corner’s \(\partial_x B_x\) contribution is
The remaining diagonal components follow by cyclic permutation. The
off-diagonal entries are obtained by differentiating the same kernels and are
filled symmetrically, e.g. \(\partial_xB_y=\partial_yB_x\), in the current-free
exterior. This is why dBfield returns the analytical Jacobian rather than a
finite difference of sampled field values.
Scope and limitations¶
The model is exact within its assumptions:
axis-aligned cuboid,
spatially constant magnetisation in each cuboid,
linear exterior medium with \(\mu_r=1\),
magnetostatic state,
evaluation outside magnetic material.
The model does not include:
feedback of the stray field on \(\mathbf M\),
domains, exchange, or anisotropy,
hysteresis or magnetisation dynamics,
temperature-dependent material parameters,
finite relative permeability of the magnetic material,
interaction with soft-magnetic bodies.
These tasks require a micromagnetic or finite-element solver. Microcubed can subsequently evaluate the field of a prescribed, piecewise-constant magnetisation.