From 97141dcb9bd18c30644ef7df22ef47a412e183d9 Mon Sep 17 00:00:00 2001 From: Ali-7800 <47090295+Ali-7800@users.noreply.github.com> Date: Mon, 2 Oct 2023 16:51:26 -0500 Subject: [PATCH] Finished requested changes from Rod Sphere Contact PR --- elastica/contact_forces.py | 22 +++++++++++----------- elastica/contact_utils.py | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/elastica/contact_forces.py b/elastica/contact_forces.py index 7c8c5a17..274723b1 100644 --- a/elastica/contact_forces.py +++ b/elastica/contact_forces.py @@ -753,8 +753,8 @@ def apply_contact( system_one.lengths, system_two.position_collection, system_two.director_collection, - system_two.radius[0], - system_two.length[0], + system_two.radius, + system_two.length, ): return @@ -867,7 +867,7 @@ class RodSphereContact(NoContact): """ This class is for applying contact forces between rod-sphere. First system is always rod and second system is always sphere. - In addition to the contact forces, user can define apply friction forces between rod and cylinder that + In addition to the contact forces, user can define apply friction forces between rod and sphere that are in contact. For details on friction model refer to this [1]_. Notes ----- @@ -936,22 +936,22 @@ def _check_systems_validity( ) ) - def apply_contact(self, system_one: RodType, system_two: AllowedContactType): + def apply_contact(self, system_one: RodType, system_two: SystemType): # First, check for a global AABB bounding box, and see whether that # intersects if _prune_using_aabbs_rod_sphere( system_one.position_collection, system_one.radius, system_one.lengths, - system_two.position, - system_two.director, + system_two.position_collection, + system_two.director_collection, system_two.radius, ): return x_sph = ( - system_two.position[..., 0] - - system_two.radius * system_two.director[2, :, 0] + system_two.position_collection[..., 0] + - system_two.radius * system_two.director_collection[2, :, 0] ) rod_element_position = 0.5 * ( @@ -961,16 +961,16 @@ def apply_contact(self, system_one: RodType, system_two: AllowedContactType): _calculate_contact_forces_rod_sphere( rod_element_position, system_one.lengths * system_one.tangents, - system_two.position[..., 0], + system_two.position_collection[..., 0], x_sph, - system_two.radius * system_two.director[2, :, 0], + system_two.radius * system_two.director_collection[2, :, 0], system_one.radius + system_two.radius, system_one.lengths + 2 * system_two.radius, system_one.internal_forces, system_one.external_forces, system_two.external_forces, system_two.external_torques, - system_two.director[:, :, 0], + system_two.director_collection[:, :, 0], system_one.velocity_collection, system_two.velocity_collection, self.k, diff --git a/elastica/contact_utils.py b/elastica/contact_utils.py index 58e76829..027ae481 100644 --- a/elastica/contact_utils.py +++ b/elastica/contact_utils.py @@ -136,7 +136,7 @@ def _prune_using_aabbs_rod_cylinder( # d^T @ Q cylinder_dimensions_in_local_FOR = np.array( [cylinder_radius, cylinder_radius, 0.5 * cylinder_length] - ) + ).reshape(3) cylinder_dimensions_in_world_FOR = np.zeros_like(cylinder_dimensions_in_local_FOR) for i in range(3): for j in range(3): @@ -213,7 +213,7 @@ def _prune_using_aabbs_rod_sphere( sphere_dimensions_in_local_FOR = np.array( [sphere_radius, sphere_radius, sphere_radius] - ) + ).reshape(3) sphere_dimensions_in_world_FOR = np.zeros_like(sphere_dimensions_in_local_FOR) for i in range(3): for j in range(3):