-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexchange.go
38 lines (34 loc) · 1.16 KB
/
exchange.go
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
package cuda
import (
"unsafe"
"github.com/mumax/3/data"
)
// Add exchange field to Beff.
// m: normalized magnetization
// B: effective field in Tesla
// Aex_red: Aex / (Msat * 1e18 m2)
// see exchange.cu
func AddExchange(B, m *data.Slice, Aex_red SymmLUT, regions *Bytes, mesh *data.Mesh) {
c := mesh.CellSize()
wx := float32(2 * 1e-18 / (c[X] * c[X]))
wy := float32(2 * 1e-18 / (c[Y] * c[Y]))
wz := float32(2 * 1e-18 / (c[Z] * c[Z]))
N := mesh.Size()
pbc := mesh.PBC_code()
cfg := make3DConf(N)
k_addexchange_async(B.DevPtr(X), B.DevPtr(Y), B.DevPtr(Z),
m.DevPtr(X), m.DevPtr(Y), m.DevPtr(Z),
unsafe.Pointer(Aex_red), regions.Ptr,
wx, wy, wz, N[X], N[Y], N[Z], pbc, cfg)
}
// Finds the average exchange strength around each cell, for debugging.
func ExchangeDecode(dst *data.Slice, Aex_red SymmLUT, regions *Bytes, mesh *data.Mesh) {
c := mesh.CellSize()
wx := float32(2 * 1e-18 / (c[X] * c[X]))
wy := float32(2 * 1e-18 / (c[Y] * c[Y]))
wz := float32(2 * 1e-18 / (c[Z] * c[Z]))
N := mesh.Size()
pbc := mesh.PBC_code()
cfg := make3DConf(N)
k_exchangedecode_async(dst.DevPtr(0), unsafe.Pointer(Aex_red), regions.Ptr, wx, wy, wz, N[X], N[Y], N[Z], pbc, cfg)
}