Skip to content

Commit

Permalink
Merge branch 'update-0.3.3' into 359_dev_mesh_rigid_body
Browse files Browse the repository at this point in the history
  • Loading branch information
skim0119 authored Apr 26, 2024
2 parents 69b7811 + cb87a67 commit 2d1de07
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions elastica/rod/knot_theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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]

Expand Down

0 comments on commit 2d1de07

Please sign in to comment.