Simulator#

Base System#

Basic coordinating for multiple, smaller systems that have an independently integrable interface (i.e. works with symplectic or explicit routines timestepper.py.)

class elastica.modules.base_system.BaseSystemCollection[source]#

Base System for simulator classes. Every simulation class written by the user must be derived from the BaseSystemCollection class; otherwise the simulation will proceed.

Attributes:
allowed_sys_types: tuple[Type]

Tuple of allowed type rod-like objects. Here use a base class for objects, i.e. RodBase.

systems: Callable

Returns all system objects. Once finalize, block objects are also included.

blocks: Callable

Returns block objects. Should be called after finalize.

final get_system_index(system)[source]#

Get the index of the system object in the system list. System list is private, so this is the only way to get the index of the system object.

Parameters:
system: SystemType

System object to be found in the system list.

final systems()[source]#

Iterate over all systems in the system collection. If the system collection is finalized, block objects are also included.

Return type:

Generator[StaticSystemProtocol, None, None]

final block_systems()[source]#

Iterate over all block systems in the system collection.

Return type:

Generator[BlockSystemProtocol, None, None]

final finalize()[source]#

This method finalizes the simulator class. When it is called, it is assumed that the user has appended all rod-like objects to the simulator as well as all boundary conditions, callbacks, etc., acting on these rod-like objects. After the finalize method called, the user cannot add new features to the simulator class.

Return type:

None

final synchronize(time)[source]#

Call synchronize functions for all features. Features are registered in _feature_group_synchronize.

Return type:

None

final constrain_values(time)[source]#

Call constrain values functions for all features. Features are registered in _feature_group_constrain_values.

Return type:

None

final constrain_rates(time)[source]#

Call constrain rates functions for all features. Features are registered in _feature_group_constrain_rates.

Return type:

None

final apply_callbacks(time, current_step)[source]#

Call callback functions for all features. Features are registered in _feature_group_callback.

Return type:

None

CallBacks#

Provides the callBack interface to collect data over time (see callback_functions.py).

class elastica.modules.callbacks.CallBacks[source]#

CallBacks class is a module for calling callback functions, set by the user. If the user wants to collect data from the simulation, the simulator class has to be derived from the CallBacks class.

Attributes:
_callback_list: list

List of call back classes defined for rod-like objects.

collect_diagnostics(system)[source]#

This method calls user-defined call-back classes for a user-defined system or rod-like object. You need to input the system or rod-like object that you want to collect data from.

Return type:

ModuleProtocol

Parameters:
system: object

System is a rod-like object.

Returns:

Connect#

Provides the connections interface to connect entities (rods, rigid bodies) using joints (see joints.py).

class elastica.modules.connections.Connections[source]#

The Connections class is a module for connecting rod-like objects using joints selected by the user. To connect two rod-like objects, the simulator class must be derived from the Connections class.

Attributes:
_connections: list

List of joint classes defined for rod-like objects.

connect(first_rod, second_rod, first_connect_idx=(), second_connect_idx=())[source]#

This method connects two rod-like objects using the selected joint class. You need to input the two rod-like objects that are to be connected as well as set the element indexes of these rods where the connection occurs.

Parameters:
first_rodRodType | RigidBodyType

Rod-like object

second_rodRodType | RigidBodyType

Rod-like object

first_connect_idxConnectionIndex

Index of first rod for joint.

second_connect_idxConnectionIndex

Index of second rod for joint.

Returns:

Constraints#

Provides the constraints interface to enforce displacement boundary conditions (see boundary_conditions.py).

class elastica.modules.constraints.Constraints[source]#

The Constraints class is a module for enforcing displacement boundary conditions. To enforce boundary conditions on rod-like objects, the simulator class must be derived from Constraints class.

Attributes:
_constraints: list

List of boundary condition classes defined for rod-like objects.

constrain(system)[source]#

This method enforces a displacement boundary conditions to the relevant user-defined system or rod-like object. You must input the system or rod-like object that you want to enforce boundary condition on.

Parameters:
system: object

System is a rod-like object.

Returns:

Forcing#

Provides the forcing interface to apply forces and torques to rod-like objects (external point force, muscle torques, etc).

class elastica.modules.forcing.Forcing[source]#

The Forcing class is a module for applying boundary conditions that consist of applied external forces. To apply forcing on rod-like objects, the simulator class must be derived from the Forcing class.

Attributes:
_ext_forces_torques: list

List of forcing class defined for rod-like objects.

add_forcing_to(system)[source]#

This method applies external forces and torques on the relevant user-defined system or rod-like object. You must input the system or rod-like object that you want to apply external forces and torques on.

Return type:

ModuleProtocol

Parameters:
system: object

System is a rod-like object.

Returns:

Damping#

(added in version 0.3.0)

Provides the damper interface to apply damping on the rods. (see dissipation.py).

class elastica.modules.damping.Damping[source]#

The Damping class is a module for applying damping on rod-like objects, the simulator class must be derived from Damping class.

Attributes:
_dampers: list

List of damper classes defined for rod-like objects.

dampen(system)[source]#

This method applies damping on relevant user-defined system or rod-like object. You must input the system or rod-like object that you want to apply damping on.

Return type:

ModuleProtocol

Parameters:
system: object

System is a rod-like object.

Returns: