|
| 1 | +import numpy as np |
| 2 | +import magpylib as magpy |
1 | 3 | import magpylib_material_response
|
| 4 | +from magpylib_material_response.demag import apply_demag |
| 5 | +from magpylib_material_response.meshing import mesh_Cuboid |
2 | 6 |
|
3 | 7 |
|
4 | 8 | def test_version():
|
5 | 9 | assert isinstance(magpylib_material_response.__version__, str)
|
| 10 | + |
| 11 | + |
| 12 | +def test_susceptibility_inputs(): |
| 13 | + """ |
| 14 | + test if different xi inputs give the same result |
| 15 | + """ |
| 16 | + |
| 17 | + zone = magpy.magnet.Cuboid( |
| 18 | + dimension=(1,1,1), |
| 19 | + polarization=(0,0,1), |
| 20 | + ) |
| 21 | + mesh = mesh_Cuboid(zone, (2,2,2)) |
| 22 | + |
| 23 | + dm1 = apply_demag(mesh, susceptibility=4) |
| 24 | + dm2 = apply_demag(mesh, susceptibility=(4,4,4)) |
| 25 | + dm3 = apply_demag(mesh, susceptibility=[4]*8) |
| 26 | + dm4 = apply_demag(mesh, susceptibility=[(4,4,4)]*8) |
| 27 | + |
| 28 | + zone = magpy.magnet.Cuboid( |
| 29 | + dimension=(1,1,1), |
| 30 | + polarization=(0,0,1), |
| 31 | + ) |
| 32 | + zone.susceptibility = 4 |
| 33 | + mesh = mesh_Cuboid(zone, (2,2,2)) |
| 34 | + dm5 = apply_demag(mesh) |
| 35 | + |
| 36 | + zone = magpy.magnet.Cuboid( |
| 37 | + dimension=(1,1,1), |
| 38 | + polarization=(0,0,1), |
| 39 | + ) |
| 40 | + zone.susceptibility = (4,4,4) |
| 41 | + mesh = mesh_Cuboid(zone, (2,2,2)) |
| 42 | + dm6 = apply_demag(mesh) |
| 43 | + |
| 44 | + b1 = dm1.getB((1,2,3)) |
| 45 | + for dm in [dm2,dm3,dm4,dm5,dm6]: |
| 46 | + bb = dm.getB((1,2,3)) |
| 47 | + np.testing.assert_allclose(b1,bb) |
0 commit comments