forked from mumax/3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmel-force-dmzdz-dmydz.mx3
94 lines (72 loc) · 1.56 KB
/
mel-force-dmzdz-dmydz.mx3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Nx := 16
Ny := 16
Nz := 1024
csX := 1e-9
csY := 2e-9
csZ := 0.5e-9
setgridsize(Nx, Ny, Nz)
setcellsize(csX, csY, csZ)
Msat = 1000e3
B1 = 1000e3
B2 = 1000e3
enabledemag = false
m = uniform(1.0, 1.0, 1.0)
mask := newVectorMask(Nx, Ny, Nz)
Period := 32e-9
kx := 2 * pi / Period
pre := 1.0 / (2.0 * B1.Average() * kx)
pre2 := 1.0 / (B2.Average() * kx)
for ii := 0; ii < Nx; ii++ {
for jj := 0; jj < Ny; jj++ {
for kk := 0; kk < Nz; kk++ {
r := index2coord(ii, jj, kk)
z := r.Z()
my := cos(kx * z)
mz := sin(kx * z)
mask.setVector(ii, jj, kk, vector(0.0, my, mz))
}
}
}
m.setarray(mask)
save(m)
save(F_mel)
Fmel := F_mel.HostCopy()
errx := -inf
errz := -inf
for ii := 0; ii < Nx; ii++ {
for jj := 0; jj < Ny; jj++ {
for kk := 0; kk < Nz; kk++ {
r := index2coord(ii, jj, kk)
z := r.Z()
ref := sin(kx*z) * cos(kx*z)
ref2 := (cos(kx*z)*cos(kx*z) - sin(kx*z)*sin(kx*z))
val := Fmel.get(2, ii, jj, kk)
val2 := Fmel.get(1, ii, jj, kk)
ez := abs(val*pre - ref)
ex := abs(val2*pre2 - ref2)
if ex > errx {
errx = ex
}
if ez > errz {
errz = ez
}
}
}
}
ii := Nx / 2
jj := Ny / 2
kk := Nz / 2
r := index2coord(ii, jj, kk)
z := r.Z()
ref := sin(kx*z) * cos(kx*z)
ref2 := (cos(kx*z)*cos(kx*z) - sin(kx*z)*sin(kx*z))
val := Fmel.get(2, ii, jj, kk)
val2 := Fmel.get(1, ii, jj, kk)
ez := abs(val*pre - ref)
ex := abs(val2*pre2 - ref2)
ERRMAX := 0.004
ERRMIN := 3e-6
expect("max(Fmel,x)", errx, 0., ERRMAX)
expect("max(Fmel,z)", errz, 0., ERRMAX)
expect("min(Fmel,x)", ex, 0., ERRMIN)
expect("min(Fmel,z)", ez, 0., ERRMIN)