Skip to content

Commit a5971d6

Browse files
committed
Make Atomistic Demag Energy class a subclass of Energy
1 parent 40eb470 commit a5971d6

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

fidimag/atomistic/demag.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import fidimag.extensions.dipolar as clib
22
import numpy as np
3+
from .energy import Energy
34

45

5-
class Demag(object):
6+
class Demag(Energy):
67
"""
78
89
Energy class for the demagnetising field (a.k.a. dipolar interactions,
@@ -38,22 +39,8 @@ def __init__(self, name='Demag'):
3839
self.jac = True
3940

4041
def setup(self, mesh, spin, mu_s, mu_s_inv):
41-
self.mesh = mesh
42-
self.dx = mesh.dx
43-
self.dy = mesh.dy
44-
self.dz = mesh.dz
45-
self.nx = mesh.nx
46-
self.ny = mesh.ny
47-
self.nz = mesh.nz
48-
self.spin = spin
49-
self.mu_s = mu_s
50-
self.n = mesh.n
51-
self.field = np.zeros(3 * self.n, dtype=np.float)
52-
unit_length = mesh.unit_length
53-
self.mu_s_scale = np.zeros(mesh.n, dtype=np.float)
54-
55-
# note that the 1e-7 comes from \frac{\mu_0}{4\pi}
56-
self.scale = 1e-7 / unit_length**3
42+
super(Demag, self).setup(mesh, spin, mu_s, mu_s_inv)
43+
self.scale = 1e-7 / mesh.unit_length**3
5744

5845
# could be wrong, needs carefully tests!!!
5946
# David Tue 19 Jun 2018: This variable is updated in the SIM class in

0 commit comments

Comments
 (0)