Skip to content

Commit

Permalink
example with negative susceptibility
Browse files Browse the repository at this point in the history
  • Loading branch information
fslanovc committed Aug 28, 2024
1 parent aa1e8ce commit d1e788e
Show file tree
Hide file tree
Showing 2 changed files with 447 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_isotropic_anisotropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,23 @@ def test_anisotropic_susceptibility():
field_magpylib = magnet_meshed.getB(grid)

np.testing.assert_allclose(field_ansys, field_magpylib, rtol=0, atol=0.0012)


def test_negative_susceptibility():

cells = 1000 # should be >=1000, otherwise discretization error too large

magnet = magpy.magnet.Cuboid(dimension=(1e-3, 1e-3, 1e-3), polarization=(0, 0, -0.1))
grid = np.loadtxt("tests/testdata/grid_points.pts")
field_ansys = np.loadtxt("tests/testdata/negative_susceptibility_ansys.txt", skiprows=1)
field_ansys = field_ansys[:, 3:]

# isotropic
magnet.susceptibility = -1.1
magnet_meshed = meshing.mesh_Cuboid(magnet, cells)

demag.apply_demag(magnet_meshed, inplace=True)

field_magpylib = magnet_meshed.getB(grid)

np.testing.assert_allclose(field_ansys, field_magpylib, rtol=0, atol=0.0065)
Loading

0 comments on commit d1e788e

Please sign in to comment.