Magnetic field 2D

Consider magnetostatics — the stationary field of a rectangular permanent magnet, uniformly magnetized (M\mathbf{M}=const{} = \text{const}). There are no free currents, so the field is potential: ×H\nabla \times \mathbf{H}=0{} = 0, hence H\mathbf{H}=φ{} = -\nabla \varphi. Substituting this into B\nabla \cdot \mathbf{B}=0{} = 0 with B\mathbf{B}=μ0(H+M){} = \mu_0 (\mathbf{H} + \mathbf{M}), we obtain a single elliptic equation for the scalar potential (with the Laplace operator) and a Dirichlet condition on the outer boundary — the field decays far away

2φx2\displaystyle \frac{\displaystyle \partial^2 \varphi}{\displaystyle \partial x^2}+2φy2\displaystyle {} + \frac{\displaystyle \partial^2 \varphi}{\displaystyle \partial y^2}=σ(x,y),\displaystyle {} = \sigma(x, y),(x,y)\displaystyle (x, y) Ω,\displaystyle {} \in \Omega,φΩ\displaystyle \varphi\big|_{\partial \Omega} =0.\displaystyle {} = 0.
(7.3)

On the left is the Laplace operator (2\nabla^2=Δ{} = \Delta). The right-hand side is the source σ\sigma=M{} = \nabla \cdot \mathbf{M}: inside a uniform magnet it vanishes, while on the pole faces it gives a bound surface charge (essentially the normal “flux” of the magnetization Mn\mathbf{M} \cdot \mathbf{n}), which depends on which face we are on

σ\displaystyle \sigma =Mn\displaystyle {} = \mathbf{M} \cdot \mathbf{n}={+M,right face (N),M,left face (S),0,top and bottom faces.\displaystyle {} = \begin{cases} +M, & \text{right face (N)},\\ -M, & \text{left face (S)},\\ 0, & \text{top and bottom faces}. \end{cases}

Equation (7.3) is a Poisson equation, i.e. an elliptic boundary value problem; for elliptic equations and reducing transient problems to them see Appendix N. We solve it numerically by the finite element method on a triangular mesh: the weak form is ΩφvdΩ\int_\Omega \nabla \varphi \cdot \nabla v \, d\Omega=magnetMvdΩ{} = \int_{\text{magnet}} \mathbf{M} \cdot \nabla v \, d\Omega.

Fig. 7.3. Numerical (FEM) field of a rectangular magnet (N — red pole, S — blue). The colour shows the potential map φ\varphi; the ∇ button overlays the field vectors.