-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
89 lines (71 loc) · 1.46 KB
/
main.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
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
// +build ignore
package main
import (
"flag"
"fmt"
"math"
. "."
)
var (
flagProf = flag.Bool("prof", false, "turn on CPU profiling")
flagMemProf = flag.Bool("memprof", false, "turn on memory profiling")
)
func main() {
defer Cleanup()
flag.Parse()
if *flagProf {
InitCPUProfile()
}
if *flagMemProf {
InitMemProfile()
}
worldSize := Vector{1, 1, 1}
NLEVEL := 5
Proximity = 1.2
InitFMM(worldSize, NLEVEL)
r := 1e-9
msat := 1.
//place particles with m=0 as field probes
for i := -0.5; i < 0.5; i += 0.05 {
for j := -0.5; j < 0.5; j += 0.05 {
M := Vector{0, 0, 0}
AddParticle(NewParticle(Vector{i, j, 0}, r, M, msat))
}
}
r = 1e-9
msat = 1e6
// place one magneticed particle as source
M := Vector{1, 0, 0}
AddParticle(NewParticle(Vector{-0.0, -0.0, -0.}, r, M, msat))
InitFMM2()
//for _, c := range Level[1] {
// fmt.Println(c.Center(), c.Moment(), c.CenterOfMag())
//}
FMMOrder = 1
Log("Order:", FMMOrder, " Proxy:", Proximity)
for i := 0; i < 1; i++ {
println(i)
CalcDemagParallel()
}
Log("Demag error:", DemagError())
// output one layer
for _, p := range Particles {
r := p.Center()
b := p.Bdemag()
b = b.Div(b.Len()).Mul(1. / 16.) // normalize
// if r[Z] == -0.03125 {
fmt.Println(r[X], r[Y], r[Z], b[X], b[Y], b[Z])
// }
}
Log("#Dipole evaluations:", NEvals)
}
func checkNaNs(x Vector) {
checkNaN(x[X])
checkNaN(x[Y])
checkNaN(x[Z])
}
func checkNaN(x float64) {
if math.IsNaN(x) {
panic("NaN")
}
}