Skip to content

Commit

Permalink
wip: documentation on knot theory
Browse files Browse the repository at this point in the history
  • Loading branch information
skim0119 committed Mar 16, 2022
1 parent 25ffb8a commit 2324574
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions elastica/rod/knot_theory.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__docs__ = """
This script is for computing the link-writhe-twist of a rod using the method 1a from Klenin & Langowski 2000 paper.
This script is for computing the link-writhe-twist of a rod using the method from Klenin & Langowski 2000 paper.
Following codes are adapted from section S2 of Charles et. al. PRL 2019 paper.
"""
Expand All @@ -24,6 +24,11 @@


class KnotTheoryCompatibleProtocol(Protocol):
""" KnotTheoryCompatibleProtocol
Required properties to use KnotTheory mixin
"""

@property
def position_collection(self) -> np.ndarray:
...
Expand All @@ -46,6 +51,8 @@ class KnotTheory:
MIXIN_PROTOCOL = Union[RodBase, KnotTheoryCompatibleProtocol]

def compute_twist(self: MIXIN_PROTOCOL):
"""compute_twist
"""
total_twist, local_twist = compute_twist(
self.position_collection[None, ...],
self.director_collection[0][None, ...],
Expand All @@ -55,6 +62,14 @@ def compute_twist(self: MIXIN_PROTOCOL):
def compute_writhe(
self: MIXIN_PROTOCOL, type_of_additional_segment: str = "next_tangent"
):
"""compute_writhe
Parameters
----------
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.
"""
return compute_writhe(
self.position_collection[None, ...],
self.rest_lengths.sum(),
Expand All @@ -64,6 +79,14 @@ def compute_writhe(
def compute_link(
self: MIXIN_PROTOCOL, type_of_additional_segment: str = "next_tangent"
):
"""compute_link
Parameters
----------
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.
"""
return compute_link(
self.position_collection[None, ...],
self.director_collection[0][None, ...],
Expand All @@ -88,7 +111,7 @@ def compute_twist(center_line, normal_collection):
Time history of rod elements normal direction.
Warnings
-------
--------
If center line is straight, although the normals of each element is pointing different direction computed twist
will be zero.
Expand Down

0 comments on commit 2324574

Please sign in to comment.