Skip to content

Commit f563653

Browse files
committed
Expose mx, my, mz in C dipolar struct
1 parent 895f985 commit f563653

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

fidimag/common/dipolar/dipolar.pyx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ cimport numpy as np
55
np.import_array()
66

77
cdef extern from "dipolar.h":
8-
98
# used for demag
109
ctypedef struct fft_demag_plan:
1110
int nx, ny, nz
@@ -21,6 +20,9 @@ cdef extern from "dipolar.h":
2120
double *hx
2221
double *hy
2322
double *hz
23+
double *mx
24+
double *my
25+
double *mz
2426
complex *Nxx
2527
complex *Nxy
2628
complex *Nxz
@@ -50,12 +52,12 @@ cdef class FFTDemag(object):
5052
cdef fft_demag_plan *_c_plan
5153
cdef int total_length
5254
cdef np.float64_t[:] tensor_xx_p, tensor_xy_p, tensor_xz_p, tensor_yy_p, \
53-
tensor_yz_p, tensor_zz_p, hx_p, hy_p, hz_p
55+
tensor_yz_p, tensor_zz_p, hx_p, hy_p, hz_p, mx_p, my_p, mz_p
5456
cdef np.complex128_t[:] Nxx_p, Nxy_p, Nxz_p, Nyy_p, Nyz_p, Nzz_p, Hx_p, \
5557
Hy_p, Hz_p, Mx_p, My_p, Mz_p
5658
cdef public np.ndarray tensor_xx, tensor_xy, tensor_xz, tensor_yy, \
5759
tensor_yz, tensor_zz, Nxx, Nxy, Nxz, Nyy, Nyz, Nzz, \
58-
Mx, My, Mz, Hx, Hy, Hz, hx, hy, hz
60+
Mx, My, Mz, Hx, Hy, Hz, hx, hy, hz, mx, my, mz
5961
#tensor_type could be 'dipolar', 'demag' or '2d_pbc'
6062
def __cinit__(self, dx, dy, dz, nx, ny, nz, tensor_type='dipolar'):
6163
self._c_plan = create_plan()
@@ -113,6 +115,12 @@ cdef class FFTDemag(object):
113115
self.hz_p = <np.float64_t[:self.total_length]> self._c_plan.hz
114116
self.hz = np.asarray(self.hz_p)
115117

118+
self.mx_p = <np.float64_t[:self.total_length]> self._c_plan.mx
119+
self.mx = np.asarray(self.mx_p)
120+
self.my_p = <np.float64_t[:self.total_length]> self._c_plan.my
121+
self.my = np.asarray(self.my_p)
122+
self.mz_p = <np.float64_t[:self.total_length]> self._c_plan.mz
123+
self.mz = np.asarray(self.mz_p)
116124

117125
self.tensor_xy_p = <np.float64_t[:self.total_length]> self._c_plan.tensor_xy
118126
self.tensor_xy = np.asarray(self.tensor_xy_p)

0 commit comments

Comments
 (0)