55class Zeeman (object ):
66
77 """
8- The time independent external field, can vary with space
8+
9+ A time independent external magnetic field that can be space dependent.
10+ The field energy is computed as:
11+
12+ __ -> ->
13+ E = - \ \mu_i \cdot B_i
14+ /__
15+ i
16+
17+ where mu_i = g \mu_B S_i is the magnetic moment vector at the i-th lattice
18+ site, g is the Lande factor, \mu_B the Bohr magneton, S_i the average total
19+ spin vector at the i-th site and B_i the bias field vector at the i-th
20+ site, given in Tesla units.
21+
22+ If the field is homogeneous, it can be specified in a simulation object
23+ *Sim* as
24+
25+ Sim.add(Zeeman((B_x, B_y, B_z)))
26+
27+ Otherwise, it can be specified as any Fidimag field, passing a function or
28+ an array. For example, a space dependent field function that changes
29+ linearly in the x-direction, and only has a x-component, can be defined as:
30+
31+ def my_Zeeman_field(pos):
32+ B = 0.01 # T
33+ return (B * pos[0], 0, 0)
34+
35+ # Add field to Simulation object
36+ Sim.add(Zeeman(my_Zeeman_field))
37+
38+
39+ For a hysteresis loop, the field can be updated using the *update_field*
40+ function. For an already defined simulation object *Sim*, it is updated as
41+
42+ Sim.get_interaction('Zeeman').update_field(new_field)
43+
44+ where new_field is a 3-tuple, and array or a function, as shown before.
45+ It is recommended to reset the integrator with *Sim.reset_integrator()*
46+ to start a new relaxation after updating the field.
47+
948 """
1049
11- def __init__ (self , H0 , name = 'Zeeman' ):
12- self .H0 = H0
50+ def __init__ (self , B0 , name = 'Zeeman' ):
51+ self .B0 = B0
1352 self .name = name
1453 self .jac = False
1554
@@ -28,7 +67,11 @@ def setup(self, mesh, spin, mu_s):
2867 self .mu_s_long .shape = (- 1 ,)
2968
3069 self .field = np .zeros (3 * self .n )
31- self .field [:] = helper .init_vector (self .H0 , self .mesh )
70+ self .field [:] = helper .init_vector (self .B0 , self .mesh )
71+
72+ def update_field (self , B0 ):
73+ self .B0 = B0
74+ self .field [:] = helper .init_vector (self .B0 , self .mesh )
3275
3376 def compute_field (self , t = 0 ):
3477 return self .field
@@ -56,8 +99,8 @@ class TimeZeeman(Zeeman):
5699 The time dependent external field, also can vary with space
57100 """
58101
59- def __init__ (self , H0 , time_fun , name = 'TimeZeeman' ):
60- self .H0 = H0
102+ def __init__ (self , B0 , time_fun , name = 'TimeZeeman' ):
103+ self .B0 = B0
61104 self .time_fun = time_fun
62105 self .name = name
63106 self .jac = False
0 commit comments