External Forces / Interactions#

Description#

External force and environmental interaction are represented as force/torque boundary condition at different location.

Available Forcing

Numba implementation module for external forces applied to objects.

NoForces

This is the base class for external forcing boundary conditions applied to rod-like objects.

EndpointForces

This class applies constant forces on the endpoint nodes.

GravityForces

This class applies a constant gravitational force to the entire rod.

UniformForces

This class applies a uniform force to the entire rod.

UniformTorques

This class applies a uniform torque (defined in global frame) to the entire rod.

MuscleTorques

This class applies muscle torques along the body.

EndpointForcesSinusoidal

This class applies sinusoidally varying forces to the ends of a rod.

Available Interaction

Numba implementation module containing interactions between a rod and its environment.

SlenderBodyTheory

This slender body theory class is for flow-structure interaction problems.

Compatibility#

Forcing

Rod

Rigid Body

NoForces

EndpointForces

GravityForces

UniformForces

UniformTorques

MuscleTorques

EndpointForcesSinusoidal

Interaction

Rod

Rigid Body

SlenderBodyTheory

Built-in External Forces#

Numba implementation module for external forces applied to objects.

class elastica.external_forces.NoForces[source]#

This is the base class for external forcing boundary conditions applied to rod-like objects.

Notes

Every new external forcing class must be derived from NoForces class.

__init__()[source]#

NoForces class does not need any input parameters.

apply_forces(system, time=np.float64(0.0))[source]#

Apply forces to a rod-like object.

In NoForces class, this routine simply passes.

Return type:

None

Parameters:
systemSystemType

Rod or rigid-body object

timefloat

The time of simulation.

apply_torques(system, time=np.float64(0.0))[source]#

Apply torques to a rod-like object.

In NoForces class, this routine simply passes.

Return type:

None

Parameters:
systemSystemType

Rod or rigid-body object

timefloat

The time of simulation.

class elastica.external_forces.EndpointForces(start_force, end_force, ramp_up_time)[source]#

This class applies constant forces on the endpoint nodes.

Attributes:
start_force: numpy.ndarray

1D (dim) array containing data with ‘float’ type. Force applied to first node of the system.

end_force: numpy.ndarray

1D (dim) array containing data with ‘float’ type. Force applied to last node of the system.

ramp_up_time: float

Applied forces are ramped up until ramp up time.

__init__(start_force, end_force, ramp_up_time)[source]#
Parameters:
start_force: numpy.ndarray

1D (dim) array containing data with ‘float’ type. Force applied to first node of the system.

end_force: numpy.ndarray

1D (dim) array containing data with ‘float’ type. Force applied to last node of the system.

ramp_up_time: float

Applied forces are ramped up until ramp up time.

apply_forces(system, time=np.float64(0.0))[source]#

Apply forces to a rod-like object.

In NoForces class, this routine simply passes.

Parameters:
systemSystemType

Rod or rigid-body object

timefloat

The time of simulation.

apply_torques(system, time=np.float64(0.0))#

Apply torques to a rod-like object.

In NoForces class, this routine simply passes.

Return type:

None

Parameters:
systemSystemType

Rod or rigid-body object

timefloat

The time of simulation.

class elastica.external_forces.GravityForces(acc_gravity=None)[source]#

This class applies a constant gravitational force to the entire rod.

Attributes:
acc_gravitynumpy.ndarray

1D (dim) array containing data with ‘float’ type. Gravitational acceleration vector.

Examples

How to apply gravity to a rod:

>>> simulator.add_forcing_to(rod).using(
...     GravityForces,
...     acc_gravity=np.array([0.0, -9.80665, 0.0]),
... )
__init__(acc_gravity=None)[source]#
Parameters:
acc_gravity: numpy.ndarray

1D (dim) array containing data with ‘float’ type. Gravitational acceleration vector. Defaults to [0.0, -9.80665, 0.0] if not provided.

apply_forces(system, time=np.float64(0.0))[source]#

Apply forces to a rod-like object.

In NoForces class, this routine simply passes.

Parameters:
systemSystemType

Rod or rigid-body object

timefloat

The time of simulation.

apply_torques(system, time=np.float64(0.0))#

Apply torques to a rod-like object.

In NoForces class, this routine simply passes.

Return type:

None

Parameters:
systemSystemType

Rod or rigid-body object

timefloat

The time of simulation.

class elastica.external_forces.UniformForces(force, direction=None)[source]#

This class applies a uniform force to the entire rod.

Attributes:
forcenumpy.ndarray

2D (dim, 1) array containing data with ‘float’ type. Total force applied to a rod-like object.

__init__(force, direction=None)[source]#
Parameters:
force: float

Force magnitude applied to a rod-like object.

direction: numpy.ndarray

1D (dim) array containing data with ‘float’ type. Direction in which force applied. Defaults to [0.0, 0.0, 0.0] if not provided.

apply_forces(system, time=np.float64(0.0))[source]#

Apply forces to a rod-like object.

In NoForces class, this routine simply passes.

Parameters:
systemSystemType

Rod or rigid-body object

timefloat

The time of simulation.

apply_torques(system, time=np.float64(0.0))#

Apply torques to a rod-like object.

In NoForces class, this routine simply passes.

Return type:

None

Parameters:
systemSystemType

Rod or rigid-body object

timefloat

The time of simulation.

class elastica.external_forces.UniformTorques(torque, direction=None)[source]#

This class applies a uniform torque (defined in global frame) to the entire rod.

Attributes:
torquenumpy.ndarray

2D (dim, 1) array containing data with ‘float’ type. Total torque applied to a rod-like object.

__init__(torque, direction=None)[source]#
Parameters:
torque: float

Torque magnitude applied to a rod-like object.

direction: numpy.ndarray

1D (dim) array containing data with ‘float’ type. Direction in which torque applied. Defaults to [0.0, 0.0, 0.0] if not provided.

apply_torques(system, time=np.float64(0.0))[source]#

Apply torques to a rod-like object.

In NoForces class, this routine simply passes.

Parameters:
systemSystemType

Rod or rigid-body object

timefloat

The time of simulation.

apply_forces(system, time=np.float64(0.0))#

Apply forces to a rod-like object.

In NoForces class, this routine simply passes.

Return type:

None

Parameters:
systemSystemType

Rod or rigid-body object

timefloat

The time of simulation.

class elastica.external_forces.MuscleTorques(base_length, b_coeff, period, wave_number, phase_shift, direction, rest_lengths, ramp_up_time, with_spline=False)[source]#

This class applies muscle torques along the body. The applied muscle torques are treated as applied external forces. This class can apply muscle torques as a traveling wave with a beta spline or only as a traveling wave. For implementation details refer to Gazzola et. al. RSoS. (2018).

Attributes:
direction: numpy.ndarray

2D (dim, 1) array containing data with ‘float’ type. Muscle torque direction.

angular_frequency: float

Angular frequency of traveling wave.

wave_number: float

Wave number of traveling wave.

phase_shift: float

Phase shift of traveling wave.

ramp_up_time: float

Applied muscle torques are ramped up until ramp up time.

my_spline: numpy.ndarray

1D (blocksize) array containing data with ‘float’ type. Generated spline.

__init__(base_length, b_coeff, period, wave_number, phase_shift, direction, rest_lengths, ramp_up_time, with_spline=False)[source]#
Parameters:
base_length: float

Rest length of the rod-like object. This parameter is used to normalize the spatial coordinate along the rod for the traveling wave calculation.

b_coeff: numpy.ndarray

1D array containing data with ‘float’ type. Beta coefficients for beta-spline.

period: float

Period of traveling wave.

wave_number: float

Wave number of traveling wave.

phase_shift: float

Phase shift of traveling wave.

direction: numpy.ndarray

1D (dim) array containing data with ‘float’ type. Muscle torque direction.

rest_lengths: numpy.ndarray

1D (n_elems) array containing data with ‘float’ type. Rod element lengths at rest configuration.

ramp_up_time: float

Applied muscle torques are ramped up until ramp up time.

with_spline: boolean

Option to use beta-spline.

apply_torques(system, time=np.float64(0.0))[source]#

Apply torques to a rod-like object.

In NoForces class, this routine simply passes.

Parameters:
systemSystemType

Rod or rigid-body object

timefloat

The time of simulation.

apply_forces(system, time=np.float64(0.0))#

Apply forces to a rod-like object.

In NoForces class, this routine simply passes.

Return type:

None

Parameters:
systemSystemType

Rod or rigid-body object

timefloat

The time of simulation.

class elastica.external_forces.EndpointForcesSinusoidal(start_force_mag, end_force_mag, ramp_up_time=0.0, tangent_direction=None, normal_direction=None)[source]#

This class applies sinusoidally varying forces to the ends of a rod. Forces are applied in a plane, which is defined by the tangent_direction and normal_direction.

Attributes:
start_force_mag: float

Magnitude of the force that is applied to the start of the rod (node 0).

end_force_mag: float

Magnitude of the force that is applied to the end of the rod (node -1).

ramp_up_time: float

Applied forces are applied in the normal direction until time reaches ramp_up_time.

normal_direction: numpy.ndarray

1D (3,) array containing data with ‘float’ type. This is the normal direction of the rod.

roll_direction: numpy.ndarray

1D (3,) array containing data with ‘float’ type. This is the direction perpendicular to rod tangent, and rod normal.

Notes

In order to see example how to use this class, see joint examples.

__init__(start_force_mag, end_force_mag, ramp_up_time=0.0, tangent_direction=None, normal_direction=None)[source]#
Parameters:
start_force_mag: float

Magnitude of the force that is applied to the start of the system (node 0).

end_force_mag: float

Magnitude of the force that is applied to the end of the system (node -1).

ramp_up_time: float

Applied forces are ramped up until ramp up time.

tangent_direction: numpy.ndarray

1D (3,) array containing data with ‘float’ type. This is the tangent direction of the system, or normal of the plane that forces applied. Defaults to [0.0, 0.0, 1.0] if not provided.

normal_direction: numpy.ndarray

1D (3,) array containing data with ‘float’ type. This is the normal direction of the system. Defaults to [0.0, 1.0, 0.0] if not provided.

apply_forces(system, time=np.float64(0.0))[source]#

Apply forces to a rod-like object.

In NoForces class, this routine simply passes.

Parameters:
systemSystemType

Rod or rigid-body object

timefloat

The time of simulation.

apply_torques(system, time=np.float64(0.0))#

Apply torques to a rod-like object.

In NoForces class, this routine simply passes.

Return type:

None

Parameters:
systemSystemType

Rod or rigid-body object

timefloat

The time of simulation.

Built-in Environment Interactions#

Numba implementation module containing interactions between a rod and its environment.

class elastica.interaction.SlenderBodyTheory(dynamic_viscosity)[source]#

This slender body theory class is for flow-structure interaction problems. This class applies hydrodynamic forces on the body using the slender body theory given in Eq. 4.13 of Gazzola et al. RSoS (2018).

Attributes:
dynamic_viscosity: float

Dynamic viscosity of the fluid.

__init__(dynamic_viscosity)[source]#
Parameters:
dynamic_viscosityfloat

Dynamic viscosity of the fluid.