I want to calculate the stray magnetic field from a ferromagnet using the scalar potential method (1). The problem consists of a ferromagnetic cuboid divided into small cuboidal cells in which the magnetization $\mathbf{M}$ is assumed to be constant. To do this, I have to evaluate a convolution integral, discretized to a 3D - convolution sum (assuming all magnetization vectors point along $z$-axis)

$$\phi(\mathbf{r}_i) = \sum_j S_z(\mathbf{r}_i - \mathbf{r}_j)M_z(\mathbf{r}_j)$$

where $\phi$ is the scalar potential and $\mathbf{r}_i$ is the position vector a cell and $S_z$ is a known function. The solution is via FFT

$$\phi = \mathrm{F}^{-1}\left(\mathrm{F(S_z)} \, \mathrm{F}(M_z) \right)\, .$$

I am struggling to understand, especially the matrix representation of $S_z$, and how to proceed to perform the convolution with FFT.


  1. Abert, Claas, et al. "A fast finite-difference method for micromagnetics using the magnetic scalar potential." IEEE Transactions on Magnetics 48.3 (2011): 1105-1109.

1 Answer 1


I think I see the confusion.

Equation 14 of the cited publication indicates that $S_z$ is a scalar field and not a matrix. The i,j, and k components that appear in $S_z$ definition at equation 17 are arguments that are passed to $F(x,y,z)$ defined in equation 16. That is, $F(x,y,z)$ returns a scalar.

To perform a 3D Fourier Transform on $S_z$ in python, see


But a better approach would be to use the scipy fft convolve on the 3D grid containing the numerical approximation for $S_z$ and $M_z$. See


Doing so would handle a lot of the tedious complexity of padding, centering, etc... associated with manual FFT convolution. The final result from this method is the final result you're looking for.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.