Constraints#

Built-in boundary condition implementationss

Description#

Constraints are equivalent to displacement boundary condition.

Available Constraint

ConstraintBase

Base class for constraint and displacement boundary condition implementation.

FreeBC

Boundary condition template.

OneEndFixedBC

This boundary condition class fixes one end of the rod.

GeneralConstraint

This boundary condition class allows the specified node/link to have a configurable constraint.

FixedConstraint

This boundary condition class fixes the specified node or orientations.

HelicalBucklingBC

This is the boundary condition class for Helical Buckling case in Gazzola et.

FreeRod

Deprecated 0.2.1: Same implementation as FreeBC

OneEndFixedRod

Deprecated 0.2.1: Same implementation as OneEndFixedBC

Compatibility#

Constraint / Boundary Condition

Rod

Rigid Body

FreeBC

OneEndFixedBC

GeneralConstraint

FixedConstraint

HelicalBucklingBC

Examples#

Note

PyElastica package provides basic built-in constraints, and we expect use to adapt their own boundary condition from our examples.

Customizing boundary condition examples:

Built-in Constraints#

class elastica.boundary_conditions.ConstraintBase(*args, **kwargs)[source]#

Bases: ABC

Base class for constraint and displacement boundary condition implementation.

Notes

Constraint class must inherit BaseConstraint class.

Attributes:
systemRodBase or RigidBodyBase

get system (rod or rigid body) reference

node_indicesNone or numpy.ndarray
element_indicesNone or numpy.ndarray
property system: Type[RodBase] | Type[RigidBodyBase]#

get system (rod or rigid body) reference

property constrained_position_idx: ndarray | None#

get position-indices passed to “using”

property constrained_director_idx: ndarray | None#

get director-indices passed to “using”

abstract constrain_values(system, time)[source]#

Constrain values (position and/or directors) of a rod object.

Return type:

None

Parameters:
systemSystemType

Rod or rigid-body object.

timefloat

The time of simulation.

abstract constrain_rates(system, time)[source]#

Constrain rates (velocity and/or omega) of a rod object.

Return type:

None

Parameters:
systemSystemType

Rod or rigid-body object.

timefloat

The time of simulation.

class elastica.boundary_conditions.FreeBC(**kwargs)[source]#

Boundary condition template.

class elastica.boundary_conditions.OneEndFixedBC(fixed_position, fixed_directors, **kwargs)[source]#

This boundary condition class fixes one end of the rod. Currently, this boundary condition fixes position and directors at the first node and first element of the rod.

Example case (timoshenko)

Examples

How to fix one ends of the rod:

>>> simulator.constrain(rod).using(
...    OneEndFixedBC,
...    constrained_position_idx=(0,),
...    constrained_director_idx=(0,)
... )
__init__(fixed_position, fixed_directors, **kwargs)[source]#

Initialization of the constraint. Any parameter passed to ‘using’ will be available in kwargs.

Parameters:
constrained_position_idxtuple

Tuple of position-indices that will be constrained

constrained_director_idxtuple

Tuple of director-indices that will be constrained

class elastica.boundary_conditions.GeneralConstraint(*fixed_data, translational_constraint_selector=None, rotational_constraint_selector=None, **kwargs)[source]#

This boundary condition class allows the specified node/link to have a configurable constraint. Index can be passed to fix either or both the position or the director. Constraining position is equivalent to setting 0 translational DOF. Constraining director is equivalent to setting 0 rotational DOF.

Examples

How to fix all translational and rotational dof except allowing twisting around the z-axis in an inertial frame:

>>> simulator.constrain(system).using(
...    GeneralConstraint,
...    constrained_position_idx=(0,),
...    constrained_director_idx=(0,),
...    translational_constraint_selector=np.array([True, True, True]),
...    rotational_constraint_selector=np.array([True, True, False]),
... )

How to allow the end of the rod to move in the XY plane and allow all rotational dof:

>>> simulator.constrain(rod).using(
...    GeneralConstraint,
...    constrained_position_idx=(-1,),
...    translational_constraint_selector=np.array([True, True, False]),
... )
__init__(*fixed_data, translational_constraint_selector=None, rotational_constraint_selector=None, **kwargs)[source]#

Initialization of the constraint. Any parameter passed to ‘using’ will be available in kwargs.

Parameters:
constrained_position_idxtuple

Tuple of position-indices that will be constrained

constrained_director_idxtuple

Tuple of director-indices that will be constrained

translational_constraint_selector: Optional[np.ndarray]

np.array of type bool indicating which translational degrees of freedom (dof) to constrain. If entry is True, the corresponding dof will be constrained. If None, we constrain all dofs.

rotational_constraint_selector: Optional[np.ndarray]

np.array of type bool indicating which translational degrees of freedom (dof) to constrain. If entry is True, the corresponding dof will be constrained.

class elastica.boundary_conditions.FixedConstraint(*args, **kwargs)[source]#

This boundary condition class fixes the specified node or orientations. Index can be passed to fix either or both the position or the director. Constraining position is equivalent to setting 0 translational DOF. Constraining director is equivalent to setting 0 rotational DOF.

See also

GeneralConstraint

Generalized constraint with configurable DOF.

Examples

How to fix two ends of the rod:

>>> simulator.constrain(rod).using(
...    FixedConstraint,
...    constrained_position_idx=(0,-1),
...    constrained_director_idx=(0,-1)
... )

How to pin the middle of the rod (10th node), without constraining the rotational DOF.

>>> simulator.constrain(rod).using(
...    FixedConstraint,
...    constrained_position_idx=(10,)
... )
__init__(*args, **kwargs)[source]#

Initialization of the constraint. Any parameter passed to ‘using’ will be available in kwargs.

Parameters:
constrained_position_idxtuple

Tuple of position-indices that will be constrained

constrained_director_idxtuple

Tuple of director-indices that will be constrained

class elastica.boundary_conditions.HelicalBucklingBC(position_start, position_end, director_start, director_end, twisting_time, slack, number_of_rotations, **kwargs)[source]#

This is the boundary condition class for Helical Buckling case in Gazzola et. al. RSoS (2018). The applied boundary condition is twist and slack on to the first and last nodes and elements of the rod.

Example case (helical buckling)

Attributes:
twisting_time: float

Time to complete twist.

final_start_position: numpy.ndarray

2D (dim, 1) array containing data with ‘float’ type. Position of first node of rod after twist completed.

final_end_position: numpy.ndarray

2D (dim, 1) array containing data with ‘float’ type. Position of last node of rod after twist completed.

ang_vel: numpy.ndarray

2D (dim, 1) array containing data with ‘float’ type. Angular velocity of rod during twisting time.

shrink_vel: numpy.ndarray

2D (dim, 1) array containing data with ‘float’ type. Shrink velocity of rod during twisting time.

final_start_directors: numpy.ndarray

3D (dim, dim, 1) array containing data with ‘float’ type. Directors of first element of rod after twist completed.

final_end_directors: numpy.ndarray

3D (dim, dim, 1) array containing data with ‘float’ type. Directors of last element of rod after twist completed.

__init__(position_start, position_end, director_start, director_end, twisting_time, slack, number_of_rotations, **kwargs)[source]#

Helical Buckling initializer

Parameters:
position_startnumpy.ndarray

2D (dim, 1) array containing data with ‘float’ type. Initial position of first node.

position_endnumpy.ndarray

2D (dim, 1) array containing data with ‘float’ type. Initial position of last node.

director_startnumpy.ndarray

3D (dim, dim, blocksize) array containing data with ‘float’ type. Initial director of first element.

director_endnumpy.ndarray

3D (dim, dim, blocksize) array containing data with ‘float’ type. Initial director of last element.

twisting_timefloat

Time to complete twist.

slackfloat

Slack applied to rod.

number_of_rotationsfloat

Number of rotations applied to rod.

class elastica.boundary_conditions.FreeRod(**kwargs)[source]#

Deprecated 0.2.1: Same implementation as FreeBC

class elastica.boundary_conditions.OneEndFixedRod(fixed_position, fixed_directors, **kwargs)[source]#

Deprecated 0.2.1: Same implementation as OneEndFixedBC