Skip to content

Commit b7d5b5b

Browse files
committed
Add unit_length to demag atomistic tests so that the previously fixed but would be picked up in future
1 parent cdef1ac commit b7d5b5b

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

tests/test_demag.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
def test_demag_fft_exact():
9-
mesh = CuboidMesh(nx=5, ny=3, nz=4)
9+
mesh = CuboidMesh(nx=5, ny=3, nz=4, unit_length=1e-9)
1010
sim = Sim(mesh)
1111

1212
demag = Demag()
@@ -24,16 +24,15 @@ def init_m(pos):
2424
sim.set_m(init_m)
2525
fft = demag.compute_field()
2626
exact = demag.compute_exact()
27-
# print fft,exact
28-
print(np.max(np.abs(fft - exact)))
2927

30-
assert np.max(np.abs(fft - exact)) < 5e-22
28+
np.testing.assert_allclose(fft, exact, rtol=1e-10)
29+
30+
3131

3232

3333
def test_demag_fft_exact_oommf():
34-
mesh = CuboidMesh(nx=5, ny=3, nz=2)
34+
mesh = CuboidMesh(nx=5, ny=3, nz=2, unit_length=1e-9)
3535
sim = Sim(mesh)
36-
3736
demag = Demag()
3837
sim.add(demag)
3938

@@ -45,23 +44,18 @@ def init_m(pos):
4544
return (0, 0, 1)
4645
else:
4746
return (0, 1, 0)
48-
4947
sim.set_m(init_m)
5048
fft = demag.compute_field()
5149
exact = demag.compute_exact()
52-
# print fft,exact
53-
print(np.max(np.abs(fft - exact)))
50+
np.testing.assert_allclose(fft, exact, rtol=1e-10)
5451

55-
assert np.max(np.abs(fft - exact)) < 1e-15
5652

5753

5854
def test_demag_two_spin_xx():
5955
mesh = CuboidMesh(nx=2, ny=1, nz=1)
6056
sim = Sim(mesh)
61-
6257
demag = Demag()
6358
sim.add(demag)
64-
6559
sim.set_m((1, 0, 0))
6660
field = demag.compute_field()
6761
print(field)
@@ -71,8 +65,5 @@ def test_demag_two_spin_xx():
7165

7266
if __name__ == '__main__':
7367
test_demag_fft_exact()
74-
#test_demag_two_spin_xx()
75-
76-
# test_oommf_coefficient()
77-
# test_demag_fft_exact()
78-
#test_demag_fft_exact_oommf()
68+
test_demag_two_spin_xx()
69+
test_demag_fft_exact_oommf()

0 commit comments

Comments
 (0)