77
88class LLBarFull (MicroDriver ):
99
10- def __init__ (self , mesh , spin , Ms , field , alpha , pins ,
10+ def __init__ (self , mesh , spin , Ms , field , pins ,
1111 interactions ,
1212 name ,
1313 data_saver ,
@@ -18,18 +18,36 @@ def __init__(self, mesh, spin, Ms, field, alpha, pins,
1818
1919 # Inherit from the driver class
2020 super (LLBarFull , self ).__init__ (mesh , spin , Ms , field ,
21- alpha , pins , interactions , name ,
21+ pins , interactions , name ,
2222 data_saver ,
2323 integrator = integrator ,
2424 use_jac = use_jac
2525 )
2626
27- self .chi = chi
27+ self ._chi = 1e-3
28+ add (Relaxation (self .chi , name = 'chi_relax' ),
29+ self .interactions , self .data_saver ,
30+ self .mesh , self .spin , self ._Ms )
31+
2832 self .lap = Laplace (mesh )
29- self .add (Relaxation (chi ))
33+ # OLD: self.add(Relaxation(chi))
3034
3135 self .beta = 0
3236
37+ def get_chi (self ):
38+ """
39+ """
40+ return self ._chi
41+
42+ def set_chi (self , chi ):
43+ """
44+ """
45+ for i in self .interactions :
46+ if i .name == 'chi_relax' :
47+ i .chi = chi
48+
49+ chi = property (get_chi , set_chi )
50+
3351 def sundials_rhs (self , t , y , ydot ):
3452
3553 self .t = t
@@ -58,7 +76,7 @@ def sundials_rhs(self, t, y, ydot):
5876
5977class LLBar (MicroDriver ):
6078
61- def __init__ (self , mesh , spin , Ms , field , alpha , pins ,
79+ def __init__ (self , mesh , spin , Ms , field , pins ,
6280 interactions ,
6381 name ,
6482 data_saver ,
@@ -68,7 +86,7 @@ def __init__(self, mesh, spin, Ms, field, alpha, pins,
6886
6987 # Inherit from the driver class
7088 super (LLBar , self ).__init__ (mesh , spin , Ms , field ,
71- alpha , pins , interactions , name ,
89+ pins , interactions , name ,
7290 data_saver ,
7391 integrator = 'sundials' ,
7492 use_jac = False
@@ -107,3 +125,54 @@ def sundials_rhs(self, t, y, ydot):
107125 #ydot[:] = self.dm_dt[:]
108126
109127 return 0
128+
129+
130+ def add (interaction , interactions_list , data_saver ,
131+ mesh , spin , magnetisation , save_field = False ):
132+
133+ """
134+
135+ Add an interaction to the interaction list.
136+ This function is based on the Sim class *add* method
137+ (it is likely that this function will be moved to the common
138+ helpers in the future)
139+
140+ OPTIONAL ARGUMENTS:
141+
142+ save_field :: Set True to save the average values of this
143+ interaction field when relaxing the system
144+
145+ """
146+
147+ # magnetisation is Ms for the micromagnetic Sim class, and it is
148+ # mu_s for the atomistic Sim class
149+ interaction .setup (mesh , spin , magnetisation )
150+
151+ # TODO: FIX --> ??
152+ # When adding an interaction that was previously added, using
153+ # the same name, append a '_2' to the new interaction name (?)
154+ for i in interactions_list :
155+ if i .name == interaction .name :
156+ interaction .name = i .name + '_2'
157+
158+ interactions_list .append (interaction )
159+
160+ # Specify a name for the energy of the interaction, which will
161+ # appear in a file with saved values
162+ # When saving the energy values, we call the compute_energy() method
163+ # from the (micromagnetic/atomistic) Energy class (overhead?)
164+ energy_name = 'E_{0}' .format (interaction .name )
165+ data_saver .entities [energy_name ] = {
166+ 'unit' : '<J>' ,
167+ 'get' : lambda sim : sim .get_interaction (interaction .name ).compute_energy (),
168+ 'header' : energy_name }
169+
170+ # Save the average values of the interaction vector field components
171+ if save_field :
172+ fn = '{0}' .format (interaction .name )
173+ data_saver .entities [fn ] = {
174+ 'unit' : '<>' ,
175+ 'get' : lambda sim : sim .get_interaction (interaction .name ).average_field (),
176+ 'header' : ('%s_x' % fn , '%s_y' % fn , '%s_z' % fn )}
177+
178+ data_saver .update_entity_order ()
0 commit comments