Skip to content

Commit

Permalink
Merge pull request #334 from mumax/bugfix/MFM_Nz
Browse files Browse the repository at this point in the history
Allow Nz=2,3,4,5 for MFM images
  • Loading branch information
JonathanMaes authored Oct 21, 2024
2 parents fd6b57b + 0a4a23e commit 7f79c95
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
13 changes: 7 additions & 6 deletions mag/mfmkernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package mag
import (
"bufio"
"fmt"
"math"
"os"

d "github.com/mumax/3/data"
"github.com/mumax/3/oommf"
"github.com/mumax/3/util"
"math"
"os"
)

func MFMKernel(mesh *d.Mesh, lift, tipsize float64, cacheDir string) (kernel [3]*d.Slice) {
Expand Down Expand Up @@ -105,10 +106,10 @@ func CalcMFMKernel(mesh *d.Mesh, lift, tipsize float64) (kernel [3]*d.Slice) {
{
util.Assert(size[Z] >= 1 && size[Y] >= 2 && size[X] >= 2)
util.Assert(cellsize[X] > 0 && cellsize[Y] > 0 && cellsize[Z] > 0)
util.AssertMsg(size[X]%2 == 0 && size[Y]%2 == 0, "Even kernel size needed")
if size[Z] > 1 {
util.AssertMsg(size[Z]%2 == 0, "Even kernel size needed")
}
// util.AssertMsg(size[X]%2 == 0 && size[Y]%2 == 0, "Even kernel size needed")
// if size[Z] > 1 {
// util.AssertMsg(size[Z]%2 == 0, "Even kernel size needed")
// }
}

// Allocate only upper diagonal part. The rest is symmetric due to reciprocity.
Expand Down
27 changes: 27 additions & 0 deletions test/mfm_sizes.mx3
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
Checks if MFM images can be saved for all thicknesses with and without PBC.
There was once a bug (#93) where Nz=2,3,4,5 could not generate an MFM image.
*/

Nx := 63
Ny := 64
c := 4e-9

Msat = 1 / mu0
Aex = 10e-12

for Nz := 1; Nz < 12; Nz++ {
SetGridSize(Nx, Ny, Nz)
SetCellSize(c, c, c)
SetGeom(Zrange(-NZ*c/2, c/2).Intersect(Circle(Nx * c).Add(Xrange(-c*Nx/4, c*Nx/4))))
m = vortex(1, 1)
SetPBC(0, 0, 0)

SaveAs(m, sprintf("m_%d.ovf", Nz))

MFMLift = 40e-9 // forces the calculation of the MFM kernel.
SnapshotAs(MFM, sprintf("MFM_%d.jpg", Nz))
SetPBC(2, 2, 0)
MFMLift = 40e-9 // forces the calculation of the MFM kernel.
SnapshotAs(MFM, sprintf("MFM_%d_PBC.jpg", Nz))
}

0 comments on commit 7f79c95

Please sign in to comment.