You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This test shows that B-field computation is more stable than H-field computation.
Don't really understand why - probably something to do with the digits, but cant figure this out in floating point.
# Dipole <> Sphere
def test_core_physics_dipole_sphere():
"""
dipole and sphere field must be similar outside of sphere
moment = magnetization * volume
near field tests
"""
obs = np.array([(1, 2, 3), (-2, -2, -2), (3, 5, -4), (5, 4, 0.1)])
dia = np.array([2, 3, 0.1, 3.3])
pol = np.array([(1, 2, 3), (0, 0, 1), (-1, -2, 0), (1, -1, 0.1)])
mom = np.array([4 * (d / 2) ** 3 * np.pi / 3 * p / MU0 for d, p in zip(dia, pol)])
B1 = magpy.core.magnet_sphere_field(
field="B",
observers=obs,
diameter=dia,
polarization=pol,
)
B2 = magpy.core.dipole_field(
field="B",
observers=obs,
moment=mom,
)
np.testing.assert_allclose(B1, B2, rtol=0, atol=1e-16)
H1 = magpy.core.magnet_sphere_field(
field="H",
observers=obs,
diameter=dia,
polarization=pol,
)
H2 = magpy.core.dipole_field(
field="H",
observers=obs,
moment=mom,
)
np.testing.assert_allclose(H1, H2, rtol=0, atol=1e-11)
The text was updated successfully, but these errors were encountered:
This test shows that B-field computation is more stable than H-field computation.
Don't really understand why - probably something to do with the digits, but cant figure this out in floating point.
The text was updated successfully, but these errors were encountered: