@@ -93,90 +93,91 @@ cdef extern from "clib.h":
93
93
void llg_rhs_dw_c(double * m, double * h, double * dm, double * T, double * alpha, double * mu_s_inv, int * pins, double * eta, int n, double gamma, double dt)
94
94
95
95
96
+
96
97
# -----------------------------------------------------------------------------
97
98
# -----------------------------------------------------------------------------
98
99
99
100
100
- def compute_skyrmion_number (np.ndarray[ double , ndim = 1 , mode = " c " ] spin,
101
- np.ndarray[ double , ndim = 1 , mode = " c " ] charge,
101
+ def compute_skyrmion_number (double [: ] spin ,
102
+ double [: ] charge ,
102
103
nx , ny , nz ,
103
- np.ndarray[ int , ndim = 2 , mode = " c " ] ngbs,
104
+ int [:, : ] ngbs ,
104
105
n_ngbs
105
106
):
106
107
107
108
return skyrmion_number(& spin[0 ], & charge[0 ], nx, ny, nz, & ngbs[0 ,0 ], n_ngbs)
108
109
109
110
110
- def compute_skyrmion_number_BergLuscher (np.ndarray[ double , ndim = 1 , mode = " c " ] spin,
111
- np.ndarray[ double , ndim = 1 , mode = " c " ] charge,
112
- nx , ny , nz ,
113
- np.ndarray[ int , ndim = 2 , mode = " c " ] ngbs,
114
- n_ngbs
115
- ):
111
+ def compute_skyrmion_number_BergLuscher (double [: ] spin ,
112
+ double [: ] charge ,
113
+ nx , ny , nz ,
114
+ int [:, : ] ngbs ,
115
+ n_ngbs
116
+ ):
116
117
117
118
return skyrmion_number_BergLuscher(& spin[0 ], & charge[0 ], nx, ny, nz, & ngbs[0 ,0 ], n_ngbs)
118
119
119
- def compute_RxRy (np.ndarray[ double , ndim = 1 , mode = " c " ] spin,
120
- nx , ny , nz , nx_start = 0 , nx_stop = - 1 , ny_start = 0 , ny_stop = - 1 ):
120
+ def compute_RxRy (double [: ] spin ,
121
+ nx , ny , nz , nx_start = 0 , nx_stop = - 1 , ny_start = 0 , ny_stop = - 1 ):
121
122
122
123
res = numpy.array([0.0 ,0.0 ])
123
124
if nx_stop < 0 or nx_stop > nx:
124
125
nx_stop = nx
125
126
if ny_stop < 0 or ny_stop > ny:
126
127
ny_stop = ny
127
128
128
- cdef np.ndarray[ double , ndim = 1 , mode = " c " ] R = res
129
+ cdef double [: ] R = res
129
130
130
131
compute_guiding_center(& spin[0 ], nx, ny, nz, nx_start, nx_stop, ny_start, ny_stop, & R[0 ])
131
132
132
133
return res[0 ], res[1 ]
133
134
134
- def compute_px_py (np.ndarray[ double , ndim = 1 , mode = " c " ] spin,
135
+ def compute_px_py (double [: ] spin ,
135
136
nx ,ny ,nz ,
136
- np.ndarray[ double , ndim = 1 , mode = " c " ] px,
137
- np.ndarray[ double , ndim = 1 , mode = " c " ] py):
137
+ double[: ] px ,
138
+ double[: ] py ):
138
139
139
140
compute_px_py_c(& spin[0 ], nx, ny, nz, & px[0 ], & py[0 ])
140
141
141
142
# -------------------------------------------------------------------------
142
143
143
- def compute_exchange_field (np.ndarray[ double , ndim = 1 , mode = " c " ] spin,
144
- np.ndarray[ double , ndim = 1 , mode = " c " ] field,
145
- np.ndarray[ double , ndim = 1 , mode = " c " ] energy,
146
- Jx , Jy , Jz ,
147
- np.ndarray[ int , ndim = 2 , mode = " c " ] ngbs,
148
- n , n_ngbs
149
- ):
144
+ def compute_exchange_field (double [: ] spin ,
145
+ double [: ] field ,
146
+ double [: ] energy ,
147
+ Jx , Jy , Jz ,
148
+ int [:, : ] ngbs ,
149
+ n , n_ngbs
150
+ ):
150
151
151
152
compute_exch_field(& spin[0 ], & field[0 ], & energy[0 ], Jx, Jy, Jz,
152
153
& ngbs[0 , 0 ], n, n_ngbs)
153
154
154
- def compute_exchange_field_spatial (np.ndarray[ double , ndim = 1 , mode = " c " ] spin,
155
- np.ndarray[ double , ndim = 1 , mode = " c " ] field,
156
- np.ndarray[ double , ndim = 1 , mode = " c " ] energy,
157
- np.ndarray[ double , ndim = 2 , mode = " c " ] J,
158
- np.ndarray[ int , ndim = 2 , mode = " c " ] ngbs,
159
- n , n_ngbs ):
155
+ def compute_exchange_field_spatial (double [: ] spin ,
156
+ double [: ] field ,
157
+ double [: ] energy ,
158
+ double [:, : ] J ,
159
+ int [:, : ] ngbs ,
160
+ n , n_ngbs ):
160
161
161
162
compute_exch_field_spatial(& spin[0 ], & field[0 ], & energy[0 ],& J[0 ,0 ],& ngbs[0 , 0 ], n, n_ngbs)
162
163
163
164
164
- def compute_exchange_energy (np.ndarray[ double , ndim = 1 , mode = " c " ] spin,
165
+ def compute_exchange_energy (double [: ] spin ,
165
166
Jx , Jy , Jz , nx , ny , nz , xperiodic ,yperiodic ):
166
167
167
168
return compute_exch_energy(& spin[0 ], Jx, Jy, Jz,
168
169
nx, ny, nz,
169
170
xperiodic, yperiodic)
170
171
171
172
172
- def compute_full_exchange_field (np.ndarray[ double , ndim = 1 , mode = " c " ] spin,
173
- np.ndarray[ double , ndim = 1 , mode = " c " ] field,
174
- np.ndarray[ double , ndim = 1 , mode = " c " ] energy,
175
- np.ndarray[ double , ndim = 1 , mode = " c " ] J,
176
- np.ndarray[ int , ndim = 2 , mode = " c " ] ngbs,
173
+ def compute_full_exchange_field (double [: ] spin ,
174
+ double [: ] field ,
175
+ double [: ] energy ,
176
+ double [: ] J ,
177
+ int [:, : ] ngbs ,
177
178
n , n_ngbs , n_shells ,
178
- np.ndarray[ int , ndim = 1 , mode = " c " ] n_ngbs_shell,
179
- np.ndarray[ int , ndim = 1 , mode = " c " ] sum_ngbs_shell
179
+ int [: ] n_ngbs_shell ,
180
+ int [: ] sum_ngbs_shell
180
181
):
181
182
182
183
compute_full_exch_field(& spin[0 ], & field[0 ], & energy[0 ], & J[0 ],
@@ -195,22 +196,22 @@ def compute_anisotropy_cubic(double [:] spin, double [:] field, double [:] energ
195
196
196
197
# -----------------------------------------------------------------------------
197
198
198
- def compute_dmi_field (np.ndarray[ double , ndim = 1 , mode = " c " ] spin,
199
- np.ndarray[ double , ndim = 1 , mode = " c " ] field,
200
- np.ndarray[ double , ndim = 1 , mode = " c " ] energy,
201
- np.ndarray[ double , ndim = 2 , mode = " c " ] D,
202
- np.ndarray[ int , ndim = 2 , mode = " c " ] ngbs,
199
+ def compute_dmi_field (double [: ] spin ,
200
+ double [: ] field ,
201
+ double [: ] energy ,
202
+ double [:, : ] D ,
203
+ int [:, : ] ngbs ,
203
204
n , n_ngbs ):
204
205
dmi_field_bulk(& spin[0 ], & field[0 ], & energy[0 ], & D[0 ,0 ], & ngbs[0 , 0 ], n, n_ngbs)
205
206
206
207
207
- def compute_dmi_field_interfacial (np.ndarray[ double , ndim = 1 , mode = " c " ] spin,
208
- np.ndarray[ double , ndim = 1 , mode = " c " ] field,
209
- np.ndarray[ double , ndim = 1 , mode = " c " ] energy,
208
+ def compute_dmi_field_interfacial (double [: ] spin ,
209
+ double [: ] field ,
210
+ double [: ] energy ,
210
211
D ,
211
- np.ndarray[ int , ndim = 2 , mode = " c " ] ngbs,
212
+ int [:, : ] ngbs ,
212
213
n , n_ngbs , n_ngbs_dmi ,
213
- np.ndarray[ double , ndim = 1 , mode = " c " ] DMI_vec,
214
+ double [: ] DMI_vec ,
214
215
):
215
216
dmi_field_interfacial_atomistic(& spin[0 ], & field[0 ], & energy[0 ],
216
217
D, & ngbs[0 , 0 ], n,
@@ -225,12 +226,12 @@ def compute_dmi_energy(np.ndarray[double, ndim=1, mode="c"] spin,
225
226
226
227
# -------------------------------------------------------------------------
227
228
228
- def compute_demag_full (np.ndarray[ double , ndim = 1 , mode = " c " ] spin,
229
- np.ndarray[ double , ndim = 1 , mode = " c " ] field,
230
- np.ndarray[ double , ndim = 1 , mode = " c " ] energy,
231
- np.ndarray[ double , ndim = 2 , mode = " c " ] coords,
232
- np.ndarray[ double , ndim = 1 , mode = " c " ] mu_s,
233
- np.ndarray[ double , ndim = 1 , mode = " c " ] mu_s_scale,
229
+ def compute_demag_full (double [: ] spin ,
230
+ double [: ] field ,
231
+ double [: ] energy ,
232
+ double [:, : ] coords ,
233
+ double [: ] mu_s ,
234
+ double [: ] mu_s_scale ,
234
235
n
235
236
):
236
237
demag_full(& spin[0 ], & field[0 ], & energy[0 ],
@@ -242,14 +243,14 @@ def normalise_spin(np.ndarray[double, ndim=1, mode="c"] spin,
242
243
np.ndarray[int , ndim = 1 , mode = " c" ] pins, n ):
243
244
normalise(& spin[0 ], & pins[0 ], n)
244
245
245
- def compute_llg_rhs_dw (np.ndarray[ double , ndim = 1 , mode = " c " ] dm,
246
- np.ndarray[ double , ndim = 1 , mode = " c " ] spin,
247
- np.ndarray[ double , ndim = 1 , mode = " c " ] field,
248
- np.ndarray[ double , ndim = 1 , mode = " c " ] T,
249
- np.ndarray[ double , ndim = 1 , mode = " c " ] alpha,
250
- np.ndarray[ double , ndim = 1 , mode = " c " ] mu_s_inv,
251
- np.ndarray[ double , ndim = 1 , mode = " c " ] eta,
252
- np.ndarray[ int , ndim = 1 , mode = " c " ] pin, n , gamma , dt ):
246
+ def compute_llg_rhs_dw (double [: ] dm ,
247
+ double [: ] spin ,
248
+ double [: ] field ,
249
+ double [: ] T ,
250
+ double [: ] alpha ,
251
+ double [: ] mu_s_inv ,
252
+ double [: ] eta ,
253
+ int [: ] pin , n , gamma , dt ):
253
254
llg_rhs_dw_c(& spin[0 ], & field[0 ], & dm[0 ], & T[0 ], & alpha[0 ], & mu_s_inv[0 ], & pin[0 ], & eta[0 ], n, gamma, dt)
254
255
255
256
@@ -307,12 +308,15 @@ cdef class monte_carlo(object):
307
308
def set_seed (self , seed ):
308
309
initial_rng_mt19973(self ._c_state, seed)
309
310
310
- def run_step (self ,np.ndarray[double , ndim = 1 , mode = " c" ] spin,
311
- np.ndarray[double , ndim = 1 , mode = " c" ] new_spin,
312
- np.ndarray[int , ndim = 2 , mode = " c" ] ngbs,
313
- np.ndarray[int , ndim = 2 , mode = " c" ] nngbs,
311
+ def run_step (self ,
312
+ double [:] spin ,
313
+ double [:] new_spin ,
314
+ int [:, :] ngbs ,
315
+ int [:, :] nngbs ,
314
316
n_ngbs ,
315
317
J , J1 , D , D1 , np.ndarray[double , ndim = 1 , mode = " c" ] h,
316
318
Kc , n , T , hexagonal_mesh ):
317
319
318
- run_step_mc(self ._c_state, & spin[0 ], & new_spin[0 ], & ngbs[0 ,0 ], & nngbs[0 ,0 ], n_ngbs, J, J1, D, D1, & h[0 ], Kc, n, T, hexagonal_mesh)
320
+ run_step_mc(self ._c_state, & spin[0 ], & new_spin[0 ],
321
+ & ngbs[0 ,0 ], & nngbs[0 ,0 ], n_ngbs,
322
+ J, J1, D, D1, & h[0 ], Kc, n, T, hexagonal_mesh)
0 commit comments