From 9b47adaacf18b194eb02c9defb0b0d859b516620 Mon Sep 17 00:00:00 2001 From: jleliaer Date: Sat, 28 Jan 2023 21:49:18 +0100 Subject: [PATCH] add ext_backgroundtilt variabel (default=0 for backwards compatibility) which compensates in-plane tilted backgrounds for calculating the bubble position. Add test which fails for the previous implementation that did not account for this. Thanks M. Mangold for signaling this issue. --- engine/ext_bubblepos.go | 23 +++++++++++++++-------- test/bubblepos.mx3 | 28 ++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 test/bubblepos.mx3 diff --git a/engine/ext_bubblepos.go b/engine/ext_bubblepos.go index 20a9a831c..3f0ab9a52 100644 --- a/engine/ext_bubblepos.go +++ b/engine/ext_bubblepos.go @@ -9,10 +9,12 @@ var ( BubbleDist = NewScalarValue("ext_bubbledist", "m", "Bubble traveled distance", bubbleDist) BubbleSpeed = NewScalarValue("ext_bubblespeed", "m/s", "Bubble velocity", bubbleSpeed) BubbleMz = 1.0 + BackGroundTilt = 0.25 ) func init() { DeclVar("ext_BubbleMz", &BubbleMz, "Center magnetization 1.0 or -1.0 (default = 1.0)") + DeclVar("ext_BackGroundTilt", &BackGroundTilt, "Size of in-plane component of background magnetization. All values below this one are rounded down to perfectly out-pf-plane to improve position calculation (default = 0.25)") } func bubblePos() []float64 { @@ -28,26 +30,26 @@ func bubblePos() []float64 { } { - var magsum float32 - var weightedsum float32 + var magsum float64 + var weightedsum float64 for iy := range mz { for ix := range mz[0] { - magsum += ((mz[iy][ix]*float32(BubbleMz) + 1.) / 2.) - weightedsum += ((mz[iy][ix]*float32(BubbleMz) + 1.) / 2.) * float32(iy) + magsum += (backgroundAdjust(mz[iy][ix]*float32(BubbleMz) + 1.) / 2.) + weightedsum += (backgroundAdjust(mz[iy][ix]*float32(BubbleMz) + 1.) / 2.) * float64(iy) } } posy = float64(weightedsum / magsum) } { - var magsum float32 - var weightedsum float32 + var magsum float64 + var weightedsum float64 for ix := range mz[0] { for iy := range mz { - magsum += ((mz[iy][ix]*float32(BubbleMz) + 1.) / 2.) - weightedsum += ((mz[iy][ix]*float32(BubbleMz) + 1.) / 2.) * float32(ix) + magsum += (backgroundAdjust(mz[iy][ix]*float32(BubbleMz) + 1.) / 2.) + weightedsum += (backgroundAdjust(mz[iy][ix]*float32(BubbleMz) + 1.) / 2.) * float64(ix) } } posx = float64(weightedsum / magsum) @@ -112,3 +114,8 @@ func bubbleSpeed() float64 { return v } + +func backgroundAdjust(arg float32) float64{ +if float64(arg)< BackGroundTilt{ +return float64(0)} +return float64(arg)} diff --git a/test/bubblepos.mx3 b/test/bubblepos.mx3 new file mode 100644 index 000000000..66aef4ccd --- /dev/null +++ b/test/bubblepos.mx3 @@ -0,0 +1,28 @@ +SetMesh(128, 128, 1, 1e-9,1e-9,0.4e-9, 1, 0, 0) + +Msat =580e3 +Aex = 15e-12 +enabledemag=true +alpha = 0.1 +Ku1=0.59e6+4*pi*1e-7*0.5*580e3*580e3 +anisU=vector(0,0,1) +Dind=0.0034089785 + +shiftregions=false + +m =neelskyrmion(1, -1).transl(-30e-9,0e-9,0) +minimize() + + +ext_bubbleMz = -1.0 +//without compensating for in-plane tilts of the background this fails (corresponds to ext_backgroundtilt=0) +ext_backgroundtilt=0.25 //default value + +TOL:=1e-9 +expectv("position", ext_bubblepos.average(), vector(-3e-08,0,0), TOL) + + +SetMesh(128, 128, 1, 1e-9,1e-9,0.4e-9, 0, 1, 0) +m =neelskyrmion(1, -1).transl(0e-9,-30e-9,0) +minimize() +expectv("position", ext_bubblepos.average(), vector(0,-3e-08,0), TOL)