Skip to content

Mechatronics

Mechatronics: mechanisms joined to circuits, and suspensions.

The suspensions are made of masses, springs, and dampers.

DampingInteraction(label, *, target, b=1.0)

Bases: Interaction

Damping that relaxes the velocity of the target at the rate b, as v' = -b v.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the element whose velocity relaxes.

required
b Annotated[float, open(0, oo)]

The damping rate.

1.0

Examples:

>>> from skcomplex.systems.engineering.mechatronics import DampingInteraction
>>> DampingInteraction('damping', target='ball').b
1.0
Source code in src/skcomplex/systems/engineering/mechatronics/_magnetic_levitation.py
74
75
76
77
78
79
80
81
82
83
def __init__(
    self,
    label: str,
    *,
    target: Role,
    b: Annotated[float, RealSet.open(0, oo)] = 1.0,
) -> None:
    super().__init__(label)
    self.target = target
    self.b = b

DcMotorSystem(V=12.0, *, R=1.0, L=0.5, k=0.5, J=0.1, b=0.2, label='system', solver='auto', backend='auto')

Bases: BaseSystem

A DC motor whose armature circuit drives an inertia.

The armature circuit is made of components and the inertia is on a Lagrangian coordinate. A voltage source drives a resistor, an inductor, and the armature in series. The armature has the voltage k phi', and its current exerts the torque k i on the angle of an inertia with viscous friction, so the angular velocity settles at k V / (R b + k^2). The system has the angle rotor.phi, the angular velocity rotor.phi', and the current winding.i.

Parameters:

Name Type Description Default
V float

The voltage of the source.

12.0
R float

The resistance of the armature circuit.

1.0
L float

The inductance of the armature circuit.

0.5
k float

The motor constant.

0.5
J float

The moment of inertia of the rotor.

0.1
b float

The coefficient of viscous friction of the rotor.

0.2
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.engineering.mechatronics import DcMotorSystem
>>> DcMotorSystem(k=0.3).prepare().system_.interactions[-1].k
0.3
Source code in src/skcomplex/systems/engineering/mechatronics/_mechatronics.py
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
def __init__(
    self,
    V: float = 12.0,
    *,
    R: float = 1.0,
    L: float = 0.5,
    k: float = 0.5,
    J: float = 0.1,
    b: float = 0.2,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.V = V
    self.R = R
    self.L = L
    self.k = k
    self.J = J
    self.b = b

InertiaElement(label, *, phi=0.0, J=1.0, b=1.0)

Bases: Element

Rotating inertia of the angle phi, a coordinate of a Lagrangian.

Parameters:

Name Type Description Default
label str

The label of the element, unique among the components of its system.

required
phi object

The initial angle, whose derivative phi' is the angular velocity.

0.0
J Annotated[object, POSITIVE]

The moment of inertia.

1.0
b Annotated[object, POSITIVE]

The coefficient of viscous friction.

1.0

Examples:

>>> from skcomplex.systems.engineering.mechatronics import InertiaElement
>>> InertiaElement('rotor', J=0.5).J
0.5
Source code in src/skcomplex/systems/engineering/mechatronics/_mechatronics.py
60
61
62
63
64
65
66
67
68
69
70
71
def __init__(
    self,
    label: str,
    *,
    phi: object = 0.0,
    J: Annotated[object, POSITIVE] = 1.0,
    b: Annotated[object, POSITIVE] = 1.0,
) -> None:
    super().__init__(label)
    self.phi = phi
    self.J = J
    self.b = b

LevitatedBallElement(label, *, v=0.0)

Bases: Element

Conductive ball levitated in a vacuum, with the velocity v.

The damping and the impulses of MagneticLevitationSystem change the velocity.

Parameters:

Name Type Description Default
label str

The label of the ball.

required
v float

The initial velocity.

0.0

Examples:

>>> from skcomplex.systems.engineering.mechatronics import LevitatedBallElement
>>> LevitatedBallElement('ball', v=0.1).v
0.1
Source code in src/skcomplex/systems/engineering/mechatronics/_magnetic_levitation.py
48
49
50
def __init__(self, label: str, *, v: float = 0.0) -> None:
    super().__init__(label)
    self.v = v

MagneticLevitationSystem(v=None, *, b=1.0, m=0.2, label='system', solver='auto', backend='auto')

Bases: BaseSystem

A conductive ball levitated in a vacuum by a field.

The field pushes and pulls it with alternating impulses. The velocity follows v' + b v = m Σ_k [δ(t + 1 - 4 k) - δ(t - 1 - 4 k)]: it relaxes freely, rises by m at the times 4 k - 1, and falls by m at the times 4 k + 1. Its periodic solution, with the triangular wave τ(t) = (2 / π) arcsin(sin(π t / 2)) and the rectangular wave e(t) = sign(cos(π t / 2)), is v = m / (2 cosh b) exp(-b τ(t) e(t)) e(t), which the ball follows from the start when it starts at m / (2 cosh b). The system has the velocity ball.v, raised by the impulses push and lowered by the impulses pull.

Parameters:

Name Type Description Default
v float | None

The initial velocity, or None for the value m / (2 cosh b) of the periodic solution at time 0.

None
b float

The damping rate.

1.0
m float

The strength of every impulse.

0.2
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.engineering.mechatronics import MagneticLevitationSystem
>>> round(MagneticLevitationSystem(b=1.0, m=0.2).prepare().system_.elements[0].v, 4)
0.0648
Source code in src/skcomplex/systems/engineering/mechatronics/_magnetic_levitation.py
139
140
141
142
143
144
145
146
147
148
149
150
151
152
def __init__(
    self,
    v: float | None = None,
    *,
    b: float = 1.0,
    m: float = 0.2,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.v = v
    self.b = b
    self.m = m

MotorCouplingInteraction(label, *, a, b, winding, rotor, k=1.0)

Bases: BranchInteraction

Winding of a motor between the nodes a and b that drives an inertia with the motor constant k.

The voltage of the winding is the back electromotive force k phi' of the angle phi of the rotor, and its current i, from a to b, exerts the torque k i on the angle, which adds to the Euler-Lagrange equation of the angle.

Parameters:

Name Type Description Default
label str

The label of the interaction, unique among the components of its system.

required
a Role

The path of the node the current leaves.

required
b Role

The path of the node the current enters.

required
winding Role

The path of the element that holds the current i of the winding.

required
rotor Role

The path of the inertia, whose angle is phi.

required
k Annotated[float, POSITIVE]

The motor constant.

1.0

Examples:

>>> from skcomplex.systems.engineering.mechatronics import MotorCouplingInteraction
>>> MotorCouplingInteraction('motor', a='terminal', b='neutral', winding='winding', rotor='rotor', k=0.5).k
0.5
Source code in src/skcomplex/systems/engineering/mechatronics/_mechatronics.py
172
173
174
175
176
177
178
179
180
181
182
183
184
185
def __init__(
    self,
    label: str,
    *,
    a: Role,
    b: Role,
    winding: Role,
    rotor: Role,
    k: Annotated[float, POSITIVE] = 1.0,
) -> None:
    super().__init__(label, a=a, b=b)
    self.winding = winding
    self.rotor = rotor
    self.k = k

QuarterCarSystem(height=0.05, *, at=0.5, m1=250.0, m2=30.0, k=16000.0, b=1000.0, kt=160000.0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

A quarter-car suspension driving over a road step.

A body of mass m1 rests on a spring and a damper above a wheel of mass m2, and a tire spring joins the wheel to the road, which steps to height at time at. Both displacements settle at the height of the step. The system has the displacements car.y1 of the body and car.y2 of the wheel.

Parameters:

Name Type Description Default
height float

The height of the road step.

0.05
at float

The time of the road step.

0.5
m1 float

The mass of the body.

250.0
m2 float

The mass of the wheel.

30.0
k float

The stiffness of the suspension.

16000.0
b float

The damping of the suspension.

1000.0
kt float

The stiffness of the tire.

160000.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.engineering.mechatronics import QuarterCarSystem
>>> QuarterCarSystem(height=0.1).prepare().system_.interactions[0].height
0.1
Source code in src/skcomplex/systems/engineering/mechatronics/_mechatronics.py
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
def __init__(
    self,
    height: float = 0.05,
    *,
    at: float = 0.5,
    m1: float = 250.0,
    m2: float = 30.0,
    k: float = 16000.0,
    b: float = 1000.0,
    kt: float = 160000.0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.height = height
    self.at = at
    self.m1 = m1
    self.m2 = m2
    self.k = k
    self.b = b
    self.kt = kt

TireInteraction(label, *, target, state='y2', mass='m2', kt=160000.0, height=0.05, at=0.5)

Bases: Interaction

Tire spring between a wheel and a road that steps up to height at the time at.

The tire pushes the wheel with the force kt (road - y), which accelerates the wheel divided by its mass.

Parameters:

Name Type Description Default
label str

The label of the interaction, unique among the components of its system.

required
target Role

The path of the element that holds the wheel.

required
state str

The name of the displacement of the wheel.

'y2'
mass str

The name of the mass of the wheel.

'm2'
kt Annotated[float, POSITIVE]

The stiffness of the tire.

160000.0
height float

The height of the road step.

0.05
at float

The time of the road step.

0.5

Examples:

>>> from skcomplex.systems.engineering.mechatronics import TireInteraction
>>> TireInteraction('tire', target='car', height=0.1).height
0.1
Source code in src/skcomplex/systems/engineering/mechatronics/_mechatronics.py
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
def __init__(
    self,
    label: str,
    *,
    target: Role,
    state: str = 'y2',
    mass: str = 'm2',
    kt: Annotated[float, POSITIVE] = 160000.0,
    height: float = 0.05,
    at: float = 0.5,
) -> None:
    super().__init__(label)
    self.target = target
    self.state = state
    self.mass = mass
    self.kt = kt
    self.height = height
    self.at = at

VibratingTableSystem(*, U=0.141, omega=1.5915, R=1.5, L=0.25, C=0.1, K=500.0, m=10.0, B=2.0, k1=0.5, k2=17.0, alpha=2.5, linear=False, label='system', solver='auto', backend='auto')

Bases: DynamicalSystem

An electromagnetic vibrating table, a shaker driven by a sinusoidal supply.

The supply drives it after its switch closes. The source u = U sin(omega t) feeds a resistor and a capacitor, whose voltage drives the current i2 of the coil of an electromagnet against the back electromotive force k1 v of the table. The electromagnet pulls the table, held by a spring and a damper, with the force g(i2) = k2 tan(alpha i2) / alpha, whose slope k2 at zero current is the one of Trzaska's linearized model. From rest, a transient of about 8 s dies out and the table vibrates steadily at the supply frequency, and the linearized model, g(i2) = k2 i2, gives nearly the same response since the current stays small.

The system has the current shaker.i2, the capacitor voltage shaker.uC, the displacement shaker.x, and the velocity shaker.v.

Parameters:

Name Type Description Default
U float

The amplitude of the supply voltage in V.

0.141
omega float

The angular frequency of the supply in rad/s.

1.5915
R float

The resistance in Ω.

1.5
L float

The inductance of the coil in H.

0.25
C float

The capacitance in F.

0.1
K float

The stiffness of the spring in N/m.

500.0
m float

The mass of the table in kg.

10.0
B float

The damping coefficient in Ns/m.

2.0
k1 float

The electromechanical constant in Wb/m.

0.5
k2 float

The mechanical-electrical constant, the slope of the force of the electromagnet at zero current.

17.0
alpha float

The scale of the current in the characteristic of the electromagnet in 1/A.

2.5
linear bool

Whether the force of the electromagnet is its linearization k2 i2.

False
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.engineering.mechatronics import VibratingTableSystem
>>> VibratingTableSystem(linear=True).get_params()['linear']
True
Source code in src/skcomplex/systems/engineering/mechatronics/_vibrating_table.py
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
def __init__(
    self,
    *,
    U: float = 0.141,
    omega: float = 1.5915,
    R: float = 1.5,
    L: float = 0.25,
    C: float = 0.1,
    K: float = 500.0,
    m: float = 10.0,
    B: float = 2.0,
    k1: float = 0.5,
    k2: float = 17.0,
    alpha: float = 2.5,
    linear: bool = False,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label=label, solver=solver, backend=backend)
    self.U = U
    self.omega = omega
    self.R = R
    self.L = L
    self.C = C
    self.K = K
    self.m = m
    self.B = B
    self.k1 = k1
    self.k2 = k2
    self.alpha = alpha
    self.linear = linear