Skip to content

Commit 08dd608

Browse files
committed
Add Exchange referencing test
1 parent dd2f329 commit 08dd608

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/test_regression_referencing.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# The idea behind these tests is to prevent regression back to a bug which was
2+
# caused by incorrect referencing. This bug caused
3+
4+
import fidimag
5+
6+
def setup_fixture_micro():
7+
mesh = fidimag.common.CuboidMesh(nx=10, ny=10, nz=10,
8+
dx=1, dy=1, dz=1,
9+
unit_length=1e-9)
10+
sim = fidimag.micro.Sim(mesh)
11+
return mesh, sim
12+
13+
14+
def setup_fixture_atomistic():
15+
mesh = fidimag.common.CuboidMesh(nx=10, ny=10, nz=10,
16+
dx=1, dy=1, dz=1,
17+
unit_length=1e-9)
18+
sim = fidimag.atomistic.Sim(mesh)
19+
return mesh, sim
20+
21+
22+
def test_exchange_Ms_regression_micro():
23+
mesh, sim = setup_fixture_micro()
24+
A1 = 2e-11
25+
Ms1 = 8.5e5
26+
Ms2 = 9.0e5
27+
sim.set_m(Ms1)
28+
exch = fidimag.micro.UniformExchange(A1)
29+
sim.add(exch)
30+
sim.set_m(Ms2)
31+
assert exch.Ms is sim._magnetisation, "The Ms in the Exchange Micro class is not a reference to Ms in the Sim class"
32+
assert exch.Ms_inv is sim._magnetisation_inv, "The Ms_inv in the Exchange Micro class is not a reference to Ms_inv in the Sim Class"

0 commit comments

Comments
 (0)