Skip to content

Commit cd74197

Browse files
committed
doc: fix typo and clarify constraining boundary conditions
1 parent ad279e1 commit cd74197

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

elastica/boundary_conditions.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ class ConstraintBase(ABC, Generic[S]):
2222
2323
Notes
2424
-----
25-
Constraint class must inherit BaseConstraint class.
25+
Constraint class must inherit ConstraintBase class.
2626
2727
2828
Attributes
2929
----------
30-
system : RodBase or RigidBodyBase
31-
node_indices : None or numpy.ndarray
32-
element_indices : None or numpy.ndarray
30+
_system : RodType or RigidBodyType
31+
_constrained_position_idx : NDArray[np.int32]
32+
_constrained_director_idx : NDArray[np.int32]
3333
3434
"""
3535

@@ -39,14 +39,15 @@ class ConstraintBase(ABC, Generic[S]):
3939

4040
def __init__(
4141
self,
42+
_system: "RodType | RigidBodyType",
4243
*args: Any,
4344
constrained_position_idx: ConstrainingIndex = (),
4445
constrained_director_idx: ConstrainingIndex = (),
4546
**kwargs: Any,
4647
) -> None:
4748
"""Initialize boundary condition"""
4849
try:
49-
self._system = kwargs["_system"]
50+
self._system = _system
5051
self._constrained_position_idx = np.array(
5152
constrained_position_idx, dtype=np.int32
5253
)
@@ -85,7 +86,6 @@ def constrain_values(self, system: S, time: np.float64) -> None:
8586
time : float
8687
The time of simulation.
8788
"""
88-
pass
8989

9090
@abstractmethod
9191
def constrain_rates(self, system: S, time: np.float64) -> None:
@@ -100,7 +100,6 @@ def constrain_rates(self, system: S, time: np.float64) -> None:
100100
The time of simulation.
101101
102102
"""
103-
pass
104103

105104

106105
class FreeBC(ConstraintBase):
@@ -115,13 +114,11 @@ def constrain_values(
115114
self, system: "RodType | RigidBodyType", time: np.float64
116115
) -> None:
117116
"""In FreeBC, this routine simply passes."""
118-
pass
119117

120118
def constrain_rates(
121119
self, system: "RodType | RigidBodyType", time: np.float64
122120
) -> None:
123121
"""In FreeBC, this routine simply passes."""
124-
pass
125122

126123

127124
class OneEndFixedBC(ConstraintBase):
@@ -138,9 +135,13 @@ class OneEndFixedBC(ConstraintBase):
138135
139136
>>> simulator.constrain(rod).using(
140137
... OneEndFixedBC,
141-
... constrained_position_idx=(0,),
142-
... constrained_director_idx=(0,)
138+
... constrained_position_idx=(0,), # Specify node to fix
139+
... constrained_director_idx=(0,), # Specify element to fix
143140
... )
141+
142+
See Also
143+
--------
144+
:class:`GeneralConstraint`: For fixing multiple node/element with specific degrees-of-freedom.
144145
"""
145146

146147
def __init__(

0 commit comments

Comments
 (0)