@@ -84,6 +84,7 @@ def func(field, observers):
84
84
85
85
# with anchor
86
86
F ,T = getFT (hom , cloop , anchor = cloop .position )
87
+ T *= - 1 #bad sign at initial test design
87
88
assert np .amax (abs (F )) < 1e-14
88
89
assert abs (T [0 ]) < 1e-14
89
90
assert abs (T [1 ] - np .pi ) < 1e-3
@@ -106,6 +107,7 @@ def func(field, observers):
106
107
107
108
# with anchor
108
109
F ,T = getFT (hom , rloop , anchor = rloop .position )
110
+ T *= - 1 #bad sign at initial test design
109
111
assert np .amax (abs (F )) < 1e-14
110
112
assert abs (T [0 ]) < 1e-14
111
113
assert abs (T [1 ] + 4 ) < 1e-3
@@ -262,3 +264,32 @@ def test_sphere_cube_at_distance():
262
264
263
265
assert max (abs (errF )) < 1e-5
264
266
assert max (abs (errT )) < 1e-5
267
+
268
+
269
+ def test_torque_sign ():
270
+ """ make sure that torque sign is in the right direction"""
271
+
272
+ # Cuboid -> Cuboid
273
+ mag1 = magpy .magnet .Cuboid (position = (2 ,0 ,0 ), polarization = (1 ,0 ,0 ), dimension = (2 ,1 ,1 ))
274
+ mag2 = magpy .magnet .Cuboid (position = (- 2 ,0 ,0 ), polarization = (1 ,0 ,0 ), dimension = (2 ,1 ,1 ))
275
+
276
+ mag1 .rotate_from_angax (15 , "y" )
277
+ mag1 .meshing = (3 ,3 ,3 )
278
+
279
+ _ ,T = getFT (mag2 , mag1 )
280
+
281
+ assert T [1 ] < 0
282
+
283
+ # Cuboid -> Polyline
284
+ mag = magpy .magnet .Cuboid (polarization = (0 ,0 ,1 ), dimension = (1 ,1 ,2 ))
285
+
286
+ ts = np .linspace (0 ,2 * np .pi ,10 )
287
+ verts = [(2 * np .cos (t ), 2 * np .sin (t ),0 ) for t in ts ]
288
+ loop = magpy .current .Polyline (vertices = verts , current = 1 )
289
+ loop .rotate_from_angax (15 , "y" )
290
+
291
+ loop .meshing = 2
292
+
293
+ _ ,T = getFT (mag , loop , anchor = (0 ,0 ,0 ))
294
+
295
+ assert T [1 ] < 0
0 commit comments