Skip to content

Commit d1e788e

Browse files
committed
example with negative susceptibility
1 parent aa1e8ce commit d1e788e

File tree

2 files changed

+447
-0
lines changed

2 files changed

+447
-0
lines changed

tests/test_isotropic_anisotropic.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,23 @@ def test_anisotropic_susceptibility():
4242
field_magpylib = magnet_meshed.getB(grid)
4343

4444
np.testing.assert_allclose(field_ansys, field_magpylib, rtol=0, atol=0.0012)
45+
46+
47+
def test_negative_susceptibility():
48+
49+
cells = 1000 # should be >=1000, otherwise discretization error too large
50+
51+
magnet = magpy.magnet.Cuboid(dimension=(1e-3, 1e-3, 1e-3), polarization=(0, 0, -0.1))
52+
grid = np.loadtxt("tests/testdata/grid_points.pts")
53+
field_ansys = np.loadtxt("tests/testdata/negative_susceptibility_ansys.txt", skiprows=1)
54+
field_ansys = field_ansys[:, 3:]
55+
56+
# isotropic
57+
magnet.susceptibility = -1.1
58+
magnet_meshed = meshing.mesh_Cuboid(magnet, cells)
59+
60+
demag.apply_demag(magnet_meshed, inplace=True)
61+
62+
field_magpylib = magnet_meshed.getB(grid)
63+
64+
np.testing.assert_allclose(field_ansys, field_magpylib, rtol=0, atol=0.0065)

0 commit comments

Comments
 (0)