-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from mumax/feature/bubbleshift
Feature/bubbleshift
- Loading branch information
Showing
7 changed files
with
217 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package engine | ||
|
||
import ( | ||
"github.com/mumax/3/data" | ||
"math" | ||
) | ||
|
||
func init() { | ||
DeclFunc("ext_centerBubble", CenterBubble, "centerBubble shifts m after each step to keep the bubble position close to the center of the window") | ||
} | ||
|
||
func centerBubble() { | ||
M := &M | ||
n := Mesh().Size() | ||
|
||
m := M.Buffer() | ||
mz := m.Comp(Z).HostCopy().Scalars()[0] | ||
|
||
posx, posy := 0., 0. | ||
sign := magsign(M.GetCell(0, n[Y]/2, n[Z]/2)[Z]) //TODO make more robust with temperature? | ||
|
||
{ | ||
var magsum float32 | ||
var weightedsum float32 | ||
|
||
for iy := range mz { | ||
for ix := range mz[0] { | ||
magsum += ((mz[iy][ix]*float32(-1*sign) + 1.) / 2.) | ||
weightedsum += ((mz[iy][ix]*float32(-1*sign) + 1.) / 2.) * float32(iy) | ||
} | ||
} | ||
posy = float64(weightedsum / magsum) | ||
} | ||
|
||
{ | ||
var magsum float32 | ||
var weightedsum float32 | ||
|
||
for ix := range mz[0] { | ||
for iy := range mz { | ||
magsum += ((mz[iy][ix]*float32(-1*sign) + 1.) / 2.) | ||
weightedsum += ((mz[iy][ix]*float32(-1*sign) + 1.) / 2.) * float32(ix) | ||
} | ||
} | ||
posx = float64(weightedsum / magsum) | ||
} | ||
|
||
zero := data.Vector{0, 0, 0} | ||
if ShiftMagL == zero || ShiftMagR == zero || ShiftMagD == zero || ShiftMagU == zero { | ||
ShiftMagL[Z] = float64(sign) | ||
ShiftMagR[Z] = float64(sign) | ||
ShiftMagD[Z] = float64(sign) | ||
ShiftMagU[Z] = float64(sign) | ||
} | ||
dx := int(math.Floor(float64(n[X]/2) - posx)) | ||
dy := int(math.Floor(float64(n[Y]/2) - posy)) | ||
|
||
//put bubble to center | ||
if dx != 0 { | ||
Shift(dx) | ||
} | ||
if dy != 0 { | ||
YShift(dy) | ||
} | ||
|
||
} | ||
|
||
// This post-step function centers the simulation window on a bubble | ||
func CenterBubble() { | ||
PostStep(func() { centerBubble() }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
SetMesh(128, 128, 1, 1e-9,1e-9,0.4e-9, 1, 1, 0) | ||
|
||
Msat =580e3 | ||
Aex = 15e-12 | ||
enabledemag=false | ||
alpha = 0.1 | ||
Ku1=0.59e6 | ||
anisU=vector(0,0,1) | ||
Dind=0.0034089785 | ||
|
||
shiftregions=true | ||
|
||
maxregion:=255 | ||
seed:=17 | ||
ext_makegrains(10e-9, maxregion, seed) | ||
|
||
for i:=0; i<maxRegion; i++{ | ||
for j:=i+1; j<maxRegion; j++{ | ||
ext_ScaleExchange(i, j, 0.5) | ||
} | ||
} | ||
|
||
|
||
m =neelskyrmion(1, -1) | ||
run(5e-11) | ||
t=0. | ||
minimize() | ||
|
||
setsolver(5) | ||
maxerr=0.001 | ||
|
||
ext_centerbubble() | ||
|
||
Xi=0.2 | ||
j=vector(5e12*cos(2*pi*1e9*t),5e12*sin(2*pi*1e9*t),0) | ||
|
||
run(2e-10) | ||
TOL:=1e-11 | ||
expectv("position", ext_bubblepos.average(), vector(-7.202214431762697e-08,-8.216819381713864e-08,0), TOL) | ||
|