@@ -547,6 +547,92 @@ def test_contact_rod_sphere_with_collision_with_k_without_nu_and_friction(
547547 atol = 1e-6 ,
548548 )
549549
550+ def test_contact_rod_sphere_without_collision (
551+ self ,
552+ ):
553+ "Testing Rod Sphere Contact wrapper without Collision"
554+
555+ mock_rod = MockRod ()
556+ mock_sphere = MockSphere ()
557+ rod_sphere_contact = RodSphereContact (k = 1.0 , nu = 0.0 )
558+
559+ # Setting sphere position such that there is no collision
560+ mock_sphere .position_collection = np .array ([[100 ], [200 ], [300 ]])
561+
562+ mock_rod_external_forces_before_execution = mock_rod .external_forces .copy ()
563+ mock_sphere_external_forces_before_execution = (
564+ mock_sphere .external_forces .copy ()
565+ )
566+ mock_sphere_external_torques_before_execution = (
567+ mock_sphere .external_torques .copy ()
568+ )
569+
570+ rod_sphere_contact .apply_contact (mock_rod , mock_sphere )
571+
572+ assert_allclose (
573+ mock_rod .external_forces , mock_rod_external_forces_before_execution
574+ )
575+ assert_allclose (
576+ mock_sphere .external_forces ,
577+ mock_sphere_external_forces_before_execution ,
578+ )
579+ assert_allclose (
580+ mock_sphere .external_torques ,
581+ mock_sphere_external_torques_before_execution ,
582+ )
583+
584+ def test_contact_rod_sphere_with_collision_with_nu_without_k (
585+ self ,
586+ ):
587+ "Testing Rod Sphere Contact wrapper with Collision with nu without k"
588+
589+ mock_rod = MockRod ()
590+ mock_rod .velocity_collection = np .array ([[- 1 , 0 , 0 ], [- 1 , 0 , 0 ], [- 1 , 0 , 0 ]])
591+
592+ mock_sphere = MockSphere ()
593+ mock_sphere .velocity_collection = np .array ([[1 ], [0 ], [0 ]])
594+
595+ rod_sphere_contact = RodSphereContact (k = 0.0 , nu = 1.0 )
596+ rod_sphere_contact .apply_contact (mock_rod , mock_sphere )
597+
598+ assert_allclose (
599+ mock_sphere .external_forces , np .array ([[- 1.5 ], [0 ], [0 ]]), atol = 1e-6
600+ )
601+ assert_allclose (
602+ mock_sphere .external_torques , np .array ([[0 ], [0 ], [0 ]]), atol = 1e-6
603+ )
604+ assert_allclose (
605+ mock_rod .external_forces ,
606+ np .array ([[0.5 , 1.0 , 0 ], [0 , 0 , 0 ], [0 , 0 , 0 ]]),
607+ atol = 1e-6 ,
608+ )
609+
610+ def test_contact_rod_sphere_with_collision_with_k_and_nu (
611+ self ,
612+ ):
613+ "Testing Rod Sphere Contact wrapper with Collision with k and nu"
614+
615+ mock_rod = MockRod ()
616+ mock_rod .velocity_collection = np .array ([[- 1 , 0 , 0 ], [- 1 , 0 , 0 ], [- 1 , 0 , 0 ]])
617+
618+ mock_sphere = MockSphere ()
619+ mock_sphere .velocity_collection = np .array ([[1 ], [0 ], [0 ]])
620+
621+ rod_sphere_contact = RodSphereContact (k = 1.0 , nu = 1.0 )
622+ rod_sphere_contact .apply_contact (mock_rod , mock_sphere )
623+
624+ assert_allclose (
625+ mock_sphere .external_forces , np .array ([[- 2.0 ], [0 ], [0 ]]), atol = 1e-6
626+ )
627+ assert_allclose (
628+ mock_sphere .external_torques , np .array ([[0 ], [0 ], [0 ]]), atol = 1e-6
629+ )
630+ assert_allclose (
631+ mock_rod .external_forces ,
632+ np .array ([[0.666666 , 1.333333 , 0 ], [0 , 0 , 0 ], [0 , 0 , 0 ]]),
633+ atol = 1e-6 ,
634+ )
635+
550636
551637class TestRodPlaneContact :
552638 def initializer (
0 commit comments