Skip to content

Commit 6683963

Browse files
committed
Check that no infinities in inverse of magnetisation/spin length
1 parent a4843e1 commit 6683963

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/test_check_ms_inv_sensible.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import fidimag
2+
import numpy as np
3+
4+
def setup_fixture_micro(driver='llg'):
5+
mesh = fidimag.common.CuboidMesh(nx=3, ny=3, nz=3,
6+
dx=1, dy=1, dz=1,
7+
unit_length=1e-9)
8+
sim = fidimag.micro.Sim(mesh, driver=driver)
9+
return mesh, sim
10+
11+
12+
def setup_fixture_atomistic(driver='llg'):
13+
mesh = fidimag.common.CuboidMesh(nx=3, ny=3, nz=3,
14+
dx=1, dy=1, dz=1,
15+
unit_length=1e-9)
16+
sim = fidimag.atomistic.Sim(mesh, driver=driver)
17+
return mesh, sim
18+
19+
def set_Ms(pos):
20+
if pos[0] < 2:
21+
return 0
22+
else:
23+
return 5e8
24+
25+
def test_llg_Ms_inv():
26+
mesh, sim = setup_fixture_micro()
27+
sim.set_Ms(set_Ms)
28+
assert np.isnan(np.dot(sim._magnetisation_inv, sim._magnetisation_inv)) == False
29+
30+
def test_llg_atomistic_mu_s_inv():
31+
mesh, sim = setup_fixture_atomistic()
32+
sim.set_mu_s(set_Ms)
33+
assert np.isnan(np.dot(sim._magnetisation_inv, sim._magnetisation_inv)) == False

0 commit comments

Comments
 (0)