diff --git a/elastica/rod/knot_theory.py b/elastica/rod/knot_theory.py index e9688423..e6d55bfe 100644 --- a/elastica/rod/knot_theory.py +++ b/elastica/rod/knot_theory.py @@ -102,7 +102,9 @@ def compute_twist(self: MIXIN_PROTOCOL): return total_twist[0] def compute_writhe( - self: MIXIN_PROTOCOL, type_of_additional_segment: str = "next_tangent" + self: MIXIN_PROTOCOL, + type_of_additional_segment: str = "next_tangent", + alpha: float = 1.0, ): """ See :ref:`api/rods:Knot Theory (Mixin)` for the detail. @@ -112,15 +114,20 @@ def compute_writhe( type_of_additional_segment : str Determines the method to compute new segments (elements) added to the rod. Valid inputs are "next_tangent", "end_to_end", "net_tangent", otherwise program uses the center line. + alpha : float + Empirical factor to scale the segment length, where segment length is the rest length of the rod. + Depending on the error between Lk-(Tw+Wr), alpha value can be increased to reduce the error. Default is 1.0. """ return compute_writhe( self.position_collection[None, ...], - self.rest_lengths.sum(), + alpha * self.rest_lengths.sum(), type_of_additional_segment, )[0] def compute_link( - self: MIXIN_PROTOCOL, type_of_additional_segment: str = "next_tangent" + self: MIXIN_PROTOCOL, + type_of_additional_segment: str = "next_tangent", + alpha: float = 1.0, ): """ See :ref:`api/rods:Knot Theory (Mixin)` for the detail. @@ -130,13 +137,16 @@ def compute_link( type_of_additional_segment : str Determines the method to compute new segments (elements) added to the rod. Valid inputs are "next_tangent", "end_to_end", "net_tangent", otherwise program uses the center line. + alpha : float + Empirical factor to scale the segment length, where segment length is the rest length of the rod. + Depending on the error between Lk-(Tw+Wr), alpha value can be increased to reduce the error. Default is 1.0. """ - print(self.rest_lengths.sum()) + return compute_link( self.position_collection[None, ...], self.director_collection[0][None, ...], self.radius[None, ...], - self.rest_lengths.sum(), + alpha * self.rest_lengths.sum(), type_of_additional_segment, )[0]