Mechanics
Mechanical realizations shared by the engineering packages: the spring and damper between two coordinates.
SpringDamperInteraction(label, *, target, states=('x1', 'x2'), stiffness='k', damping='b', divisor=None)
Bases: GradientInteraction
Linear spring and damper between two coordinates x1 and x2 of order 2 of one element.
The spring is the gradient of the energy k (x1 - x2)^2 / 2, and the damper adds -b (x1' - x2') to the first
coordinate and its opposite to the second, both divided by the divisor of every coordinate, such as its own mass.
The stiffness and the damping are named parameters of the element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the element with the two coordinates. |
required |
states
|
Sequence[str]
|
The names of the two coordinates. |
('x1', 'x2')
|
stiffness
|
str
|
The name of the parameter of the stiffness |
'k'
|
damping
|
str
|
The name of the parameter of the damping |
'b'
|
divisor
|
str | Callable[[SimpleNamespace], object] | Mapping[str, str] | None
|
The divisor of both coordinates, or a mapping from every coordinate to its own divisor. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
The states are not two names, the stiffness or the damping is not a name, or a divisor is invalid. |
Examples:
>>> from skcomplex.models.engineering.common.mechanics import SpringDamperInteraction
>>> SpringDamperInteraction('suspension', target='car', states=('y1', 'y2')).stiffness
'k'
Source code in src/skcomplex/models/engineering/common/mechanics/_spring_damper.py
58 59 60 61 62 63 64 65 66 67 68 69 70 | |