-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathB_eff.go
74 lines (61 loc) · 1.85 KB
/
B_eff.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
package vinamax2
import (
"math"
"math/rand"
)
var rng = rand.New(rand.NewSource(0))
//Sums the individual fields to the effective field working on the particle
func (p *Particle) b_eff(temp Vector) Vector {
return p.anis().Add(p.zeeman().Add(temp)).Add(p.b)
}
//Set the randomseed for the temperature
func Setrandomseed(a int64) {
randomseedcalled = true
rng = rand.New(rand.NewSource(a))
}
// factor 4/3pi in "number" because they are spherical
func (p *Particle) calculatetempnumber() {
p.tempnumber = math.Sqrt((2. * kb * Alpha * Temp) / (gamma0 * p.msat * 4. / 3. * math.Pi * p.r * p.r * p.r * Dt))
}
func calculatetempnumbers(lijst []*Particle) {
for i := range lijst {
lijst[i].calculatetempnumber()
}
}
//Calculates the the thermal field B_therm working on a Particle
func (p *Particle) temp() Vector {
B_therm := Vector{0., 0., 0.}
if Brown {
if Temp != 0. {
etax := rng.NormFloat64()
etay := rng.NormFloat64()
etaz := rng.NormFloat64()
B_therm = Vector{etax, etay, etaz}
B_therm = B_therm.Mul(p.tempnumber)
}
}
return B_therm
}
//Calculates the Zeeman field working on a Particle
func (p *Particle) zeeman() Vector {
x, y, z := B_ext(T)
x2, y2, z2 := B_ext_space(T, p.center[0], p.center[1], p.center[2])
return Vector{x + x2, y + y2, z + z2}
}
//Calculates the anisotropy field working on a Particle
func (p *Particle) anis() Vector {
//2*Ku1*(m.u)*u/p.msat
mdotu := p.M.Dot(p.u_anis)
uniax := p.u_anis.Mul(2. * Ku1 * mdotu / p.msat)
cubic := Vector{0., 0., 0.}
if Kc1 != 0 {
c1m := p.M.Dot(p.c1_anis)
c2m := p.M.Dot(p.c2_anis)
c3m := p.M.Dot(p.c3_anis)
firstterm := p.c1_anis.Mul(c1m * (c3m*c3m + c2m*c2m))
secondterm := p.c2_anis.Mul(c2m * (c3m*c3m + c1m*c1m))
thirdterm := p.c3_anis.Mul(c3m * (c2m*c2m + c1m*c1m))
cubic = firstterm.Add(secondterm.Add(thirdterm)).Mul(-2. * Kc1 / p.msat)
}
return uniax.Add(cubic)
}