Mechanics
Mechanics systems.
The package covers pendulums, oscillators, friction, projectiles, collisions, rotating bodies, wells, and beam maps.
BallisticPendulumElement(label, *, x=-1.0, theta=0.0, m=0.01, M=1.0, l=1.0, g=9.81, values=None)
Bases: Element
Bullet of mass m at the position x flying towards the block of a pendulum.
The block has the mass M, and the pendulum the angle theta.
The bullet flies freely, the pendulum swings, and the impact transfers the momentum of the bullet to the pendulum.
The velocities are x' and theta'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the bullet and pendulum. |
required |
x
|
float
|
The initial position of the bullet, negative before the block. |
-1.0
|
theta
|
Annotated[float, Period(2 * pi)]
|
The initial angle of the pendulum. |
0.0
|
m
|
Annotated[float, open(0, oo)]
|
The mass of the bullet. |
0.01
|
M
|
Annotated[float, open(0, oo)]
|
The mass of the block. |
1.0
|
l
|
Annotated[float, open(0, oo)]
|
The length of the rod. |
1.0
|
g
|
Annotated[float, open(0, oo)]
|
The gravitational acceleration. |
9.81
|
values
|
Mapping[str, object] | None
|
Further values by name, such as an initial velocity named with a prime, or |
None
|
Examples:
>>> from skcomplex.systems.physics.mechanics import BallisticPendulumElement
>>> BallisticPendulumElement('pendulum', M=2.0).M
2.0
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
BallisticPendulumSystem(speed=200.0, distance=1.0, *, m=0.01, M=1.0, l=1.0, g=9.81, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A bullet that sticks in the block of a pendulum at rest.
The pendulum then swings up.
The bullet flies horizontally towards the block, and the impact is an event. Momentum is conserved in the perfectly
inelastic collision, so the pendulum starts with the speed m v / (m + M) and rises to the height (m v / (m + M))²
/ (2 g). The bullet position stops at the block after the impact. The system has the bullet position pendulum.x
and the angle pendulum.theta, and their velocities pendulum.x' and pendulum.theta'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
speed
|
float
|
The speed of the bullet. |
200.0
|
distance
|
float
|
The initial distance of the bullet from the block. |
1.0
|
m
|
float
|
The mass of the bullet. |
0.01
|
M
|
float
|
The mass of the block. |
1.0
|
l
|
float
|
The length of the rod. |
1.0
|
g
|
float
|
The gravitational acceleration. |
9.81
|
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import BallisticPendulumSystem
>>> BallisticPendulumSystem(distance=2.0).prepare().system_.elements[0].x
-2.0
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 | |
BeamBeamInteraction(label, *, target, nu=0.3, c=0.05)
Bases: Interaction
One turn of the beam-beam map, a rotation by the angle pi nu followed by a kick of the opposite beam.
With a = cos(pi nu), b = sin(pi nu), and u = a x + b y, the position and momentum of the target become
x = u and y = -b x + a y - 8 pi c (1 - exp(-u² / 2)) / u.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the particle. |
required |
nu
|
Annotated[float, closed(0, 2)]
|
The tune, in |
0.3
|
c
|
Annotated[float, closed_open(0, oo)]
|
The strength of the beam-beam kick. |
0.05
|
Examples:
>>> from skcomplex.systems.physics.mechanics import BeamBeamInteraction
>>> BeamBeamInteraction('turn', target='particle', nu=0.5).nu
0.5
Source code in src/skcomplex/systems/physics/mechanics/_accelerators.py
54 55 56 57 58 59 60 61 62 63 64 65 | |
BeamBeamMapSystem(x=0.5, y=0.0, *, nu=0.3, c=0.05, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The beam-beam map of a particle of an accelerator beam.
The particle meets the opposite beam once every turn.
Every turn the transverse position and momentum rotate by the angle pi nu of the tune, u = a x + b y with a =
cos(pi nu) and b = sin(pi nu), and the round Gaussian charge of the opposite beam kicks the momentum: x' = u,
y' = -b x + a y - 8 pi c (1 - exp(-u² / 2)) / u. The map preserves area, as the composition of a rotation and a
kick. The origin is a fixed point, whose linearisation has the trace 2 a - 4 pi c b and is elliptic when the trace
lies in (-2, 2), and the phase space mixes invariant curves, island chains, and chaotic layers. The system has the
states particle.x and particle.y.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The initial transverse position. |
0.5
|
y
|
float
|
The initial transverse momentum. |
0.0
|
nu
|
float
|
The tune, in |
0.3
|
c
|
float
|
The strength of the beam-beam kick. |
0.05
|
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import BeamBeamMapSystem
>>> BeamBeamMapSystem(nu=0.5).prepare().system_.interactions[0].nu
0.5
Source code in src/skcomplex/systems/physics/mechanics/_accelerators.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
BlockSwingInteraction(label, *, target)
Bases: LagrangianInteraction
Swing of the block of a ballistic pendulum, the Euler-Lagrange equation of L = l θ'² / 2 + g cos θ.
The angle theta of the target follows l θ'' = -g sin θ, with the length l and the gravity g of the target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the bullet and pendulum. |
required |
Examples:
>>> from skcomplex.systems.physics.mechanics import BlockSwingInteraction
>>> BlockSwingInteraction('swing', target='pendulum').target
'pendulum'
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
1388 1389 1390 | |
BouncingBallElement(label, *, h=1.0, values=None)
Bases: Element
Ball at the height h above a floor.
The height h and its derivative h', the vertical velocity, change under the laws of gravity and of the
impacts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the ball. |
required |
h
|
float
|
The initial height. |
1.0
|
values
|
Mapping[str, object] | None
|
Further values by name, such as an initial velocity named with a prime, or |
None
|
Examples:
>>> from skcomplex.systems.physics.mechanics import BouncingBallElement
>>> BouncingBallElement('ball', h=2.0).h
2.0
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
54 55 56 | |
BouncingBallSystem(h=1.0, v=0.0, *, g=9.81, e=0.8, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A ball that falls under gravity and bounces off the floor.
The ball loses speed by a coefficient of restitution.
Every impact is an event that reverses the velocity and scales it by e. The impacts accumulate at the Zeno time
sqrt(2 h / g) (1 + e) / (1 - e) for a ball dropped from rest, so runs should end before it. The system has the
height ball.h and its velocity ball.h'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
h
|
float
|
The initial height. |
1.0
|
v
|
float
|
The initial vertical velocity. |
0.0
|
g
|
float
|
The gravitational acceleration. |
9.81
|
e
|
float
|
The coefficient of restitution. |
0.8
|
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import BouncingBallSystem
>>> trajectory = BouncingBallSystem().prepare().simulate(until=1.0, dt=0.01)
>>> round(trajectory.events[0].time, 6)
0.451524
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 | |
BulletImpactInteraction(label, *, target)
Bases: Interaction
Free flight of a bullet that sticks in the block of a pendulum.
The position x of the bullet follows x'' = 0 until it reaches the block at x = 0. The impact stops the bullet
and gives the pendulum the angular velocity m x' / ((m + M) l), which conserves momentum, with the masses m of
the bullet and M of the block and the length l of the target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the bullet and pendulum. |
required |
Examples:
>>> from skcomplex.systems.physics.mechanics import BulletImpactInteraction
>>> BulletImpactInteraction('impact', target='pendulum').target
'pendulum'
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
1443 1444 1445 | |
CartPendulumElement(label, *, y=0.0, theta=0.5, m1=1.0, m2=1.0, l=1.0, g=9.81)
Bases: Element
Cart on a horizontal track at the position y.
A pendulum of angle theta hangs from the cart.
The position y and the angle theta are the coordinates of CartPendulumInteraction, and their velocities are
y' and theta'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the cart and pendulum. |
required |
y
|
float
|
The initial position of the cart. |
0.0
|
theta
|
Annotated[float, Period(2 * pi)]
|
The initial angle of the pendulum. |
0.5
|
m1
|
Annotated[float, open(0, oo)]
|
The mass of the cart. |
1.0
|
m2
|
Annotated[float, open(0, oo)]
|
The mass of the bob. |
1.0
|
l
|
Annotated[float, open(0, oo)]
|
The length of the rod. |
1.0
|
g
|
Annotated[float, open(0, oo)]
|
The gravitational acceleration. |
9.81
|
Examples:
>>> from skcomplex.systems.physics.mechanics import CartPendulumElement
>>> CartPendulumElement('cart', m1=5.0).m1
5.0
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
CartPendulumInteraction(label, *, target, F=0.0)
Bases: LagrangianInteraction
Motion of a cart and the pendulum that hangs from it.
The motion is the Euler-Lagrange equations with a force on the cart.
The Lagrangian is (m1 + m2) y'² / 2 + m2 l y' θ' cos θ + m2 l² θ'² / 2 + m2 g l cos θ, and the force F drives
the position y of the cart.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the cart and pendulum. |
required |
F
|
float
|
A constant horizontal force on the cart. |
0.0
|
Examples:
>>> from skcomplex.systems.physics.mechanics import CartPendulumInteraction
>>> CartPendulumInteraction('motion', target='cart', F=1.0).F
1.0
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
374 375 376 377 | |
CartPendulumSystem(theta=0.5, y=0.0, *, m1=1.0, m2=1.0, l=1.0, g=9.81, F=0.0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A pendulum hanging from a cart.
The cart slides without friction along a horizontal track.
The Lagrange equations (m1 + m2) y'' + m2 l (θ'' cos θ - θ'² sin θ) = F and l θ'' + y'' cos θ + g sin θ = 0
couple the position y of the cart and the angle θ of the pendulum. Without a force the horizontal momentum is
conserved, so the cart swings against the pendulum. The system has the cart position cart.y and the angle
cart.theta, and their velocities cart.y' and cart.theta'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theta
|
float
|
The initial angle of the pendulum. |
0.5
|
y
|
float
|
The initial position of the cart. |
0.0
|
m1
|
float
|
The mass of the cart. |
1.0
|
m2
|
float
|
The mass of the bob. |
1.0
|
l
|
float
|
The length of the rod. |
1.0
|
g
|
float
|
The gravitational acceleration. |
9.81
|
F
|
float
|
A constant horizontal force on the cart. |
0.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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import CartPendulumSystem
>>> CartPendulumSystem(m1=5.0).prepare().system_.elements[0].m1
5.0
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 | |
CircularBilliardSystem(x=0.3, y=0.0, vx=0.4, vy=1.0, *, radius=1.0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A particle moving freely inside a circle and reflecting specularly off its wall.
The angle of incidence is the same at every bounce, so the circular billiard is integrable. The system has the
position particle.x, particle.y and the velocity particle.vx, particle.vy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The initial horizontal position. |
0.3
|
y
|
float
|
The initial vertical position. |
0.0
|
vx
|
float
|
The initial horizontal velocity. |
0.4
|
vy
|
float
|
The initial vertical velocity. |
1.0
|
radius
|
float
|
The radius of the table. |
1.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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import CircularBilliardSystem
>>> CircularBilliardSystem(radius=2.0).prepare().system_.elements[0].radius
2.0
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 | |
ClockPendulumElement(label, *, theta=0.2, x=0.0, m=1.0, l=1.0, M=1.0, g=9.8, rho=0.1, lam=0.1, theta_c=0.1, values=None)
Bases: Element
Pendulum clock, a pendulum of angle theta hanging from a support.
The support is at the horizontal position x. The motion comes from ClockPendulumInteraction, and the velocities
are theta' and x'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the clock. |
required |
theta
|
float
|
The initial angle of the pendulum. |
0.2
|
x
|
float
|
The initial position of the support. |
0.0
|
m
|
Annotated[float, open(0, oo)]
|
The mass of the bob. |
1.0
|
l
|
Annotated[float, open(0, oo)]
|
The length of the pendulum. |
1.0
|
M
|
Annotated[float, open(0, oo)]
|
The mass of the support. |
1.0
|
g
|
Annotated[float, open(0, oo)]
|
The gravitational acceleration. |
9.8
|
rho
|
Annotated[float, closed_open(0, oo)]
|
The damping of the support. |
0.1
|
lam
|
Annotated[float, closed_open(0, oo)]
|
The strength of the escapement. |
0.1
|
theta_c
|
Annotated[float, open(0, oo)]
|
The angle below which the escapement pumps energy in. |
0.1
|
values
|
Mapping[str, object] | None
|
Further values by name, such as an initial velocity named with a prime, or |
None
|
Examples:
>>> from skcomplex.systems.physics.mechanics import ClockPendulumElement
>>> ClockPendulumElement('clock', lam=0.2).lam
0.2
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
ClockPendulumInteraction(label, *, target)
Bases: LagrangianInteraction
Motion of a pendulum clock on a moving support.
The motion is the Euler-Lagrange equations with the escapement.
The Lagrangian is (M + m) x'² / 2 + m l x' θ' cos θ + m l² θ'² / 2 + m g l cos θ. The Rayleigh dissipation
λ l sgn(|θ| - θ_c) θ'² + rho x'² damps the support and gives the escapement 2 λ l sgn(|θ| - θ_c) θ', which pumps
energy into the pendulum below the angle θ_c and takes it out beyond.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the clock. |
required |
Examples:
>>> from skcomplex.systems.physics.mechanics import ClockPendulumInteraction
>>> ClockPendulumInteraction('motion', target='clock').target
'clock'
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
443 444 445 | |
CoupledPendulumsSystem(theta1=0.2, theta2=0.0, *, k=0.5, m1=1.0, m2=1.0, l1=1.0, l2=1.0, g=9.81, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Two pendulums whose bobs are joined by a spring.
The pendulums pass their energy back and forth.
The spring stretches with the horizontal distance l2 sin θ2 - l1 sin θ1 of the bobs and adds the torque k l1 (l2
sin θ2 - l1 sin θ1) cos θ1 to the first pendulum and the opposite one to the second. Identical pendulums have the
normal modes sqrt(g / l) in phase and sqrt(g / l + 2 k / m) in antiphase. The system has the pendulums left
and right, their angles left.theta and right.theta, and their angular velocities left.theta' and
right.theta'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theta1
|
float
|
The initial angle of the first pendulum. |
0.2
|
theta2
|
float
|
The initial angle of the second pendulum. |
0.0
|
k
|
float
|
The stiffness of the spring. |
0.5
|
m1
|
float
|
The mass of the first bob. |
1.0
|
m2
|
float
|
The mass of the second bob. |
1.0
|
l1
|
float
|
The length of the first pendulum. |
1.0
|
l2
|
float
|
The length of the second pendulum. |
1.0
|
g
|
float
|
The gravitational acceleration. |
9.81
|
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import CoupledPendulumsSystem
>>> CoupledPendulumsSystem(k=2.0).prepare().system_.interactions[0].k
2.0
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 | |
DiscBilliardElement(label, *, x=0.3, y=0.0, vx=0.4, vy=1.0, radius=1.0)
Bases: Element
Particle moving freely in the plane inside a disc.
The particle has the position (x, y) and the velocity (vx, vy), and the disc the radius radius.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the particle. |
required |
x
|
float
|
The initial horizontal position. |
0.3
|
y
|
float
|
The initial vertical position. |
0.0
|
vx
|
float
|
The initial horizontal velocity. |
0.4
|
vy
|
float
|
The initial vertical velocity. |
1.0
|
radius
|
Annotated[float, open(0, oo)]
|
The radius of the disc. |
1.0
|
Examples:
>>> from skcomplex.systems.physics.mechanics import DiscBilliardElement
>>> DiscBilliardElement('particle', radius=2.0).radius
2.0
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
DiscWallInteraction(label, *, target)
Bases: Interaction
Specular reflection of a particle off the wall of a disc of radius radius.
When the particle reaches the wall x² + y² = radius² from inside, its velocity v = (vx, vy) becomes
v - 2 (v . n) n / |n|² with the normal n = (2 x, 2 y), so the angle of incidence equals the angle of
reflection. It is a circular billiard table, a gas in a round container, or light in a circular mirror.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the particle, whose values are |
required |
Examples:
>>> from skcomplex.systems.physics.mechanics import DiscWallInteraction
>>> DiscWallInteraction('bounce', target='particle').target
'particle'
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
400 401 402 | |
DoublePendulumElement(label, *, theta1=math.pi / 2, theta2=math.pi / 2, m1=1.0, m2=1.0, l1=1.0, l2=1.0, g=9.81, values=None)
Bases: Element
Double pendulum.
A bob of mass m2 on a rod of length l2 hangs from a bob of mass m1 on a rod l1.
The angles theta1 and theta2 of the rods from the vertical wrap around the circle, and their angular velocities
are theta1' and theta2'. The motion comes from DoublePendulumInteraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the double pendulum. |
required |
theta1
|
Annotated[float, Period(2 * pi)]
|
The initial angle of the upper rod. |
pi / 2
|
theta2
|
Annotated[float, Period(2 * pi)]
|
The initial angle of the lower rod. |
pi / 2
|
m1
|
Annotated[float, open(0, oo)]
|
The mass of the upper bob. |
1.0
|
m2
|
Annotated[float, open(0, oo)]
|
The mass of the lower bob. |
1.0
|
l1
|
Annotated[float, open(0, oo)]
|
The length of the upper rod. |
1.0
|
l2
|
Annotated[float, open(0, oo)]
|
The length of the lower rod. |
1.0
|
g
|
Annotated[float, open(0, oo)]
|
The gravitational acceleration. |
9.81
|
values
|
Mapping[str, object] | None
|
Further values by name, such as the initial angular velocities |
None
|
Examples:
>>> from skcomplex.systems.physics.mechanics import DoublePendulumElement
>>> DoublePendulumElement('pendulum', m2=2.0).m2
2.0
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | |
DoublePendulumInteraction(label, *, target)
Bases: LagrangianInteraction
Motion of a double pendulum.
The motion is the Euler-Lagrange equations of its kinetic energy and gravity.
The Lagrangian is (m1 + m2) l1² θ1'² / 2 + m2 l2² θ2'² / 2 + m2 l1 l2 θ1' θ2' cos(θ1 - θ2) + (m1 + m2) g l1 cos θ1
+ m2 g l2 cos θ2, with the masses, lengths, and gravity of the target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the double pendulum. |
required |
Examples:
>>> from skcomplex.systems.physics.mechanics import DoublePendulumInteraction
>>> DoublePendulumInteraction('motion', target='pendulum').target
'pendulum'
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
513 514 515 | |
DoublePendulumSystem(theta1=math.pi / 2, theta2=math.pi / 2, omega1=0.0, omega2=0.0, *, m1=1.0, m2=1.0, l1=1.0, l2=1.0, g=9.81, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A double pendulum, a pendulum hanging from the bob of another.
The system is written as its two Lagrange equations.
The equations (m1 + m2) l1 θ1'' + m2 l2 θ2'' cos(θ1 - θ2) + m2 l2 θ2'² sin(θ1 - θ2) + (m1 + m2) g sin θ1 = 0 and
l2 θ2'' + l1 θ1'' cos(θ1 - θ2) - l1 θ1'² sin(θ1 - θ2) + g sin θ2 = 0 are solved jointly for the angular
accelerations. The motion is chaotic at large amplitudes. The system has the angles pendulum.theta1 and
pendulum.theta2, which wrap around the circle, and their angular velocities pendulum.theta1' and
pendulum.theta2'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theta1
|
float
|
The initial angle of the upper rod from the vertical, in radians. |
pi / 2
|
theta2
|
float
|
The initial angle of the lower rod from the vertical, in radians. |
pi / 2
|
omega1
|
float
|
The initial angular velocity of the upper rod. |
0.0
|
omega2
|
float
|
The initial angular velocity of the lower rod. |
0.0
|
m1
|
float
|
The mass of the upper bob. |
1.0
|
m2
|
float
|
The mass of the lower bob. |
1.0
|
l1
|
float
|
The length of the upper rod. |
1.0
|
l2
|
float
|
The length of the lower rod. |
1.0
|
g
|
float
|
The gravitational acceleration. |
9.81
|
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import DoublePendulumSystem
>>> DoublePendulumSystem(m2=2.0).prepare().system_.elements[0].m2
2.0
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 | |
DrivenDampedOscillatorSystem(x=1.0, v=0.0, *, m=1.0, k=1.0, c=0.1, F=0.0, omega=1.0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A mass on a spring with damping and a periodic force.
The mass follows m x'' = -k x - c x' + F cos(ω t).
The system has the mass mass in one dimension, with the displacement mass.x and the velocity mass.x'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The initial displacement. |
1.0
|
v
|
float
|
The initial velocity. |
0.0
|
m
|
float
|
The mass. |
1.0
|
k
|
float
|
The stiffness. |
1.0
|
c
|
float
|
The damping coefficient. |
0.1
|
F
|
float
|
The amplitude of the driving force. |
0.0
|
omega
|
float
|
The angular frequency of the driving force. |
1.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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import DrivenDampedOscillatorSystem
>>> DrivenDampedOscillatorSystem(F=0.5).prepare().system_.interactions[2].F
0.5
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 | |
ElasticCollisionInteraction(label, *, left, right, diameter=0.1)
Bases: Interaction
Elastic collision of two equal masses in a row.
The masses exchange their velocities when they touch.
The collision is the event at which the gap x_right - x_left - diameter between the balls falls to zero, and
equal masses swap their velocities in an elastic collision.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
left
|
Role
|
The path of the left ball, with a position |
required |
right
|
Role
|
The path of the right ball, with a position |
required |
diameter
|
Annotated[float, open(0, oo)]
|
The diameter of the balls. |
0.1
|
Examples:
>>> from skcomplex.systems.physics.mechanics import ElasticCollisionInteraction
>>> ElasticCollisionInteraction('collision', left='a', right='b', diameter=0.2).diameter
0.2
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
194 195 196 197 198 199 200 201 202 203 204 205 | |
ElasticLinkInteraction(label, *, first, second, k=1.0, length=0.0)
Bases: Interaction
Spring of stiffness k and rest length length between two masses on a line.
The energy is k (|x1 - x2| - length)² / 2, so the masses follow m1 x1'' = f and m2 x2'' = -f, with the force
f = -k (|x1 - x2| - length) (x1 - x2) / |x1 - x2|. It is the spring between two carts, the bond of a diatomic
molecule, or the coupling of two floors of a building.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
first
|
Role
|
The path of the first mass. |
required |
second
|
Role
|
The path of the second mass. |
required |
k
|
Annotated[float, open(0, oo)]
|
The stiffness. |
1.0
|
length
|
Annotated[float, closed_open(0, oo)]
|
The rest length. |
0.0
|
Examples:
>>> from skcomplex.core.components.elements import Element
>>> from skcomplex.core.systems import System
>>> from skcomplex.systems.physics.mechanics import ElasticLinkInteraction
>>> left, right = Element('left', values={'x': 0.0, 'm': 1.0}), Element('right', values={'x': 2.0, 'm': 1.0})
>>> link = ElasticLinkInteraction('bond', first='left', second='right', k=1.0, length=1.0)
>>> trajectory = System(elements=[left, right], interactions=[link]).prepare().simulate(until=1.0, dt=1.0)
>>> round(float(trajectory.get_values('left.x')[-1] + trajectory.get_values('right.x')[-1]), 6)
2.0
Source code in src/skcomplex/systems/physics/mechanics/_springs.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
ExponentialWellInteraction(label, *, target, k=2.0)
Bases: Interaction
Potential k x² e^-x on a particle in one dimension.
The potential has a well at x = 0 behind a barrier at x = 2. The particle of mass m follows
m x'' = -k (2 x - x²) e^-x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the particle. |
required |
k
|
Annotated[float, open(0, oo)]
|
The strength of the potential. |
2.0
|
Examples:
>>> from skcomplex.systems.physics.mechanics import ExponentialWellInteraction
>>> ExponentialWellInteraction('well', target='particle', k=2.0).k
2.0
Source code in src/skcomplex/systems/physics/mechanics/_wells.py
50 51 52 53 54 55 56 57 58 59 | |
FloorImpactInteraction(label, *, target, e=1.0)
Bases: Interaction
Impact of a ball on the floor h = 0, which reverses its vertical velocity and scales it by e.
When the height h of the target falls to zero, the velocity h' becomes -e h', with the coefficient of
restitution e. It is a bouncing ball, a dropped phone, or a hopping robot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the ball, whose height is |
required |
e
|
Annotated[float, closed(0, 1)]
|
The coefficient of restitution, the ratio of the speeds after and before the impact. |
1.0
|
Examples:
>>> from skcomplex.systems.physics.mechanics import FloorImpactInteraction
>>> FloorImpactInteraction('impact', target='ball', e=0.5).e
0.5
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
323 324 325 326 | |
FreeFlightInteraction(label, *, target)
Bases: Interaction
Free flight of a particle in the plane, x' = vx and y' = vy.
The velocity (vx, vy) changes only at the walls, so the particle moves along straight lines between them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the particle. |
required |
Examples:
>>> from skcomplex.systems.physics.mechanics import FreeFlightInteraction
>>> FreeFlightInteraction('flight', target='particle').target
'particle'
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
362 363 364 | |
FrictionOscillatorSystem(x=1.03, v=0.0, *, m=1.0, k=1.0, c=0.0, mu_s=0.06, mu_k=0.05, g=1.0, v_stick=0.01, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A mass on a linear spring with static, Coulomb, and viscous friction.
The mass follows m x'' + c x' + k x + f = 0.
While the mass slides, the friction f = mu_k m g sign(x') opposes its motion, so in each half of the phase plane
the motion is linear, around the shifted centres x = ∓ mu_k m g / k. At rest the static friction holds the mass
while |k x| <= mu_s m g, so the system has a whole segment of equilibria rather than isolated ones. Without
viscous friction, every half swing ends 2 mu_k m g / k closer to the origin, and the mass sticks at the first
turning point inside the segment, after finitely many swings. The friction is discontinuous, so the mass counts as
at rest below the speed v_stick. The system has the position mass.x and the velocity mass.v.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The initial position. |
1.03
|
v
|
float
|
The initial velocity. |
0.0
|
m
|
float
|
The mass. |
1.0
|
k
|
float
|
The stiffness of the spring. |
1.0
|
c
|
float
|
The viscous friction coefficient. |
0.0
|
mu_s
|
float
|
The static friction coefficient. |
0.06
|
mu_k
|
float
|
The kinetic friction coefficient. |
0.05
|
g
|
float
|
The gravitational acceleration. |
1.0
|
v_stick
|
float
|
The speed below which the mass counts as at rest. |
0.01
|
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import FrictionOscillatorSystem
>>> FrictionOscillatorSystem(mu_k=0.1).prepare().system_.interactions[0].mu_k
0.1
Source code in src/skcomplex/systems/physics/mechanics/_accelerators.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
GimballedGyroscopeSystem(spin=50.0, beta=0.3, *, A=1.0, C=2.0, A1=0.5, B1=0.5, C1=0.5, A2=1.0, torque=1.0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A gyroscope in a gimbal.
A rotor in an inner ring turns in an outer ring about a fixed axis.
The outer ring turns by alpha about the fixed axis, the inner ring by beta in the outer ring, and the rotor
spins by gamma in the inner ring. The equations are the Lagrange equations of the kinetic energy [A2 + (A + A1)
cos² beta + (C + C1) sin² beta] alpha'² / 2 + (A + B1) beta'² / 2 + C alpha' gamma' sin beta + C gamma'² / 2, with
a torque on the axis of the inner ring, which makes the fast rotor precess about the fixed axis. The momenta
conjugate to alpha and gamma are conserved. The system has the angles gyroscope.alpha, gyroscope.beta, and
gyroscope.gamma, and their angular velocities, such as gyroscope.gamma'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spin
|
float
|
The initial angular velocity of the rotor in the inner ring. |
50.0
|
beta
|
float
|
The initial angle of the inner ring. |
0.3
|
A
|
float
|
The equatorial moment of inertia of the rotor. |
1.0
|
C
|
float
|
The polar moment of inertia of the rotor. |
2.0
|
A1
|
float
|
The first principal moment of inertia of the inner ring. |
0.5
|
B1
|
float
|
The second principal moment of inertia of the inner ring. |
0.5
|
C1
|
float
|
The third principal moment of inertia of the inner ring. |
0.5
|
A2
|
float
|
The moment of inertia of the outer ring about its axis. |
1.0
|
torque
|
float
|
The torque on the axis of the inner ring. |
1.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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import GimballedGyroscopeSystem
>>> trajectory = GimballedGyroscopeSystem(spin=10.0).prepare().simulate(until=0.1)
>>> float(trajectory.get_values("gyroscope.gamma'")[0])
10.0
Source code in src/skcomplex/systems/physics/mechanics/_rotations.py
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 | |
GyroscopeElement(label, *, alpha=0.0, beta=0.3, gamma=0.0, A=1.0, C=2.0, A1=0.5, B1=0.5, C1=0.5, A2=1.0, values=None)
Bases: Element
Gyroscope in a gimbal.
A rotor in an inner ring turns in an outer ring about a fixed axis.
The angle alpha of the outer ring, beta of the inner ring, and gamma of the rotor are the coordinates of
GyroscopeInteraction, and their angular velocities are alpha', beta', and gamma'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the gyroscope. |
required |
alpha
|
Annotated[float, Period(2 * pi)]
|
The initial angle of the outer ring. |
0.0
|
beta
|
float
|
The initial angle of the inner ring. |
0.3
|
gamma
|
Annotated[float, Period(2 * pi)]
|
The initial angle of the rotor. |
0.0
|
A
|
Annotated[float, open(0, oo)]
|
The equatorial moment of inertia of the rotor. |
1.0
|
C
|
Annotated[float, open(0, oo)]
|
The polar moment of inertia of the rotor. |
2.0
|
A1
|
Annotated[float, closed_open(0, oo)]
|
The first principal moment of inertia of the inner ring. |
0.5
|
B1
|
Annotated[float, closed_open(0, oo)]
|
The second principal moment of inertia of the inner ring. |
0.5
|
C1
|
Annotated[float, closed_open(0, oo)]
|
The third principal moment of inertia of the inner ring. |
0.5
|
A2
|
Annotated[float, closed_open(0, oo)]
|
The moment of inertia of the outer ring about its axis. |
1.0
|
values
|
Mapping[str, object] | None
|
Further values by name, such as an initial velocity named with a prime, or |
None
|
Examples:
>>> from skcomplex.systems.physics.mechanics import GyroscopeElement
>>> GyroscopeElement('gyroscope', C=3.0).C
3.0
Source code in src/skcomplex/systems/physics/mechanics/_rotations.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
GyroscopeInteraction(label, *, target, torque=1.0)
Bases: LagrangianInteraction
Motion of a gimballed gyroscope.
The motion is the Euler-Lagrange equations of its kinetic energy with a torque on beta.
The Lagrangian is the kinetic energy [A2 + (A + A1) cos² β + (C + C1) sin² β] alpha'² / 2 + (A + B1) β'² / 2
+ C alpha' gamma' sin β + C gamma'² / 2, and the torque acts on the axis of the inner ring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the gyroscope. |
required |
torque
|
float
|
The torque on the axis of the inner ring. |
1.0
|
Examples:
>>> from skcomplex.systems.physics.mechanics import GyroscopeInteraction
>>> GyroscopeInteraction('motion', target='gyroscope', torque=2.0).torque
2.0
Source code in src/skcomplex/systems/physics/mechanics/_rotations.py
290 291 292 293 | |
HangingBallElement(label, *, x=0.0, rest=0.0, g=9.81, length=1.0, values=None)
Bases: Element
Ball hanging on a string of length length.
The ball swings with small amplitude about its rest position.
The horizontal position is x and its derivative x' is the velocity. For small amplitudes the ball moves in the
potential g (x - rest)² / (2 length).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the ball. |
required |
x
|
float
|
The initial horizontal position. |
0.0
|
rest
|
float
|
The rest position. |
0.0
|
g
|
float
|
The gravitational acceleration. |
9.81
|
length
|
Annotated[float, open(0, oo)]
|
The length of the string. |
1.0
|
values
|
Mapping[str, object] | None
|
Further values by name, such as an initial velocity named with a prime, or |
None
|
Examples:
>>> from skcomplex.systems.physics.mechanics import HangingBallElement
>>> HangingBallElement('ball', rest=0.5).rest
0.5
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
HangingSwingInteraction(label, *, target)
Bases: Interaction
Small swing of a hanging ball about its rest position.
The position x of the target follows x'' = -g (x - rest) / length, with the gravity g, the rest position
rest, and the length length of the string, all values of the target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the ball. |
required |
Examples:
>>> from skcomplex.systems.physics.mechanics import HangingSwingInteraction
>>> HangingSwingInteraction('swing', target='ball').target
'ball'
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
241 242 243 | |
HarmonicOscillatorSystem(x=1.0, v=0.0, *, k=1.0, mass=1.0, damping=0.0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A particle on a spring, optionally damped.
The system has the particle mass in one dimension, with the displacement mass.x and the velocity mass.x'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The initial displacement. |
1.0
|
v
|
float
|
The initial velocity. |
0.0
|
k
|
float
|
The stiffness. |
1.0
|
mass
|
float
|
The mass. |
1.0
|
damping
|
float
|
The linear damping coefficient. |
0.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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import HarmonicOscillatorSystem
>>> HarmonicOscillatorSystem(k=4.0).prepare().system_.interactions[0].k
4.0
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 | |
HuygensClocksSystem(n_clocks=2, *, theta=0.2, k=1.0, m=1.0, l=1.0, M=1.0, g=9.8, rho=0.1, lam=0.1, theta_c=0.1, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Pendulum clocks on supports joined by springs.
The clocks synchronize through the motion of the supports.
Every pendulum hangs from a support of mass M that moves horizontally with damping rho, and neighbouring
supports are joined by springs of stiffness k. A pendulum follows m l θ'' + f(θ) θ' + m g sin θ = -m x'' cos θ
and its support (M + m) x'' + 2 rho x' + m l θ'' cos θ = m l θ'² sin θ + spring forces. The escapement f(θ) = 2 λ
sgn(|θ| - θ_c) is -2 λ for |θ| < θ_c, pumping energy in, and 2 λ beyond, so every clock has a limit cycle.
With λ = 0 the clocks are plain pendulums. Two identical clocks synchronize in antiphase. The first clock starts
at theta, away from the switch of the escapement at θ_c, and the others at rest. The system has the angles
clock_<i>.theta and the support positions clock_<i>.x, with their velocities clock_<i>.theta' and
clock_<i>.x'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_clocks
|
int
|
The number of clocks in the row. |
2
|
theta
|
float
|
The initial angle of the first clock. The others start at rest. |
0.2
|
k
|
float
|
The stiffness of the springs between neighbouring supports. |
1.0
|
m
|
float
|
The mass of every bob. |
1.0
|
l
|
float
|
The length of every pendulum. |
1.0
|
M
|
float
|
The mass of every support. |
1.0
|
g
|
float
|
The gravitational acceleration. |
9.8
|
rho
|
float
|
The damping of the supports. |
0.1
|
lam
|
float
|
The strength of the escapement. |
0.1
|
theta_c
|
float
|
The angle below which the escapement pumps energy in. |
0.1
|
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import HuygensClocksSystem
>>> len(HuygensClocksSystem(3).prepare().system_.interactions)
5
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 | |
MagnetInteraction(label, *, target, x0=0.0, y0=0.0, gamma=1.0, d=0.3)
Bases: Interaction
Magnet below the plane of a pendulum bob.
The magnet at (x0, y0) attracts the bob of mass m with the energy -gamma / sqrt(r² + d²), where r is the
distance of the bob from the magnet in the plane, so the bob follows m x'' = -gamma (x - x0) / (r² + d²)^(3/2) and
m y'' = -gamma (y - y0) / (r² + d²)^(3/2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the bob. |
required |
x0
|
float
|
The horizontal position of the magnet in the plane. |
0.0
|
y0
|
float
|
The vertical position of the magnet in the plane. |
0.0
|
gamma
|
Annotated[float, closed_open(0, oo)]
|
The strength of the magnet. |
1.0
|
d
|
Annotated[float, open(0, oo)]
|
The height of the bob above the plane of the magnets. |
0.3
|
Examples:
>>> from skcomplex.systems.physics.mechanics import MagnetInteraction
>>> MagnetInteraction('magnet', target='bob', x0=1.0).gamma
1.0
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 | |
MagneticPendulumSystem(x=1.0, y=1.5, *, n_magnets=3, omega=1.0, q=0.2, gamma=1.0, d=0.3, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A magnetic bob on a string swinging above magnets on a circle.
The bob comes to rest at one of the magnets.
The bob follows x'' = -ω² x - q x' - Σ gamma (x - x_i) / d_i³ with d_i = sqrt(|x - x_i|² + d²). The basins of
the magnets have fractal boundaries. The system has the bob bob and its position (bob.x, bob.y).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The initial horizontal position of the bob. |
1.0
|
y
|
float
|
The initial vertical position of the bob. |
1.5
|
n_magnets
|
int
|
The number of magnets, evenly spaced on the unit circle. |
3
|
omega
|
float
|
The natural frequency of the pendulum. |
1.0
|
q
|
float
|
The friction coefficient. |
0.2
|
gamma
|
float
|
The strength of every magnet. |
1.0
|
d
|
float
|
The height of the bob above the plane of the magnets. |
0.3
|
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import MagneticPendulumSystem
>>> len(MagneticPendulumSystem(n_magnets=4).prepare().system_.interactions)
6
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 | |
NewtonsCradleSystem(n_balls=5, *, speed=0.5, diameter=0.1, gap=0.001, length=1.0, g=9.81, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Newton's cradle.
Pendulum balls in a row pass momentum along by elastic collisions.
The balls swing with small amplitude about rest positions that leave a small gap between neighbours, so collisions
are separate events. The first ball starts with a speed towards the others, and equal masses exchange velocities at
every collision. The system has the horizontal positions ball_<i>.x and velocities ball_<i>.x'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_balls
|
int
|
The number of balls. |
5
|
speed
|
float
|
The initial speed of the first ball. |
0.5
|
diameter
|
float
|
The diameter of the balls. |
0.1
|
gap
|
float
|
The gap between neighbouring balls at rest. |
0.001
|
length
|
float
|
The length of the pendulums. |
1.0
|
g
|
float
|
The gravitational acceleration. |
9.81
|
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import NewtonsCradleSystem
>>> len(NewtonsCradleSystem(n_balls=3).prepare().system_.interactions)
5
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 | |
ParametricPendulumElement(label, *, theta=0.1, g=9.81, l=1.0, values=None)
Bases: Element
Pendulum whose suspension point oscillates.
The angle theta is the coordinate of ParametricPendulumInteraction, and theta' is its angular velocity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the pendulum. |
required |
theta
|
Annotated[float, Period(2 * pi)]
|
The initial angle. |
0.1
|
g
|
Annotated[float, open(0, oo)]
|
The gravitational acceleration. |
9.81
|
l
|
Annotated[float, open(0, oo)]
|
The length of the rod. |
1.0
|
values
|
Mapping[str, object] | None
|
Further values by name, such as an initial velocity named with a prime, or |
None
|
Examples:
>>> from skcomplex.systems.physics.mechanics import ParametricPendulumElement
>>> ParametricPendulumElement('swing', l=0.5).l
0.5
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
335 336 337 338 339 340 341 342 343 344 345 346 347 | |
ParametricPendulumInteraction(label, *, target, epsilon=0.2, Omega=2 * math.sqrt(9.81), c=0.0, direction='vertical')
Bases: LagrangianInteraction
Motion of a pendulum whose suspension point oscillates.
The point oscillates vertically or horizontally, and the motion is an Euler-Lagrange equation.
The suspension point accelerates by ε g cos Ω t. Vertically, the Lagrangian per moment of inertia is
θ'² / 2 + (g / l)(1 + ε cos Ω t) cos θ, and the acceleration modulates gravity, a parametric forcing.
Horizontally, it is θ'² / 2 + (g / l)(cos θ - ε cos Ω t sin θ), and the acceleration pushes the bob sideways, an
external forcing. The Rayleigh dissipation c θ'² / 2 adds the friction, so the angle follows
θ'' + c θ' + (g / l)(1 + ε cos Ω t) sin θ = 0 or θ'' + c θ' + (g / l)(sin θ + ε cos Ω t cos θ) = 0, with the
gravity g and the length l of the target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the pendulum. |
required |
epsilon
|
float
|
The amplitude of the acceleration of the suspension point, relative to |
0.2
|
Omega
|
Annotated[float, closed_open(0, oo)]
|
The angular frequency of the suspension point. |
2 * sqrt(9.81)
|
c
|
Annotated[float, closed_open(0, oo)]
|
The friction coefficient. |
0.0
|
direction
|
str
|
The direction in which the suspension point oscillates, |
'vertical'
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
The direction is unknown. |
Examples:
>>> from skcomplex.systems.physics.mechanics import ParametricPendulumInteraction
>>> ParametricPendulumInteraction('swing', target='pendulum', epsilon=0.5).epsilon
0.5
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 | |
ParametricPendulumSystem(theta=0.1, omega=0.0, *, g=9.81, l=1.0, epsilon=0.2, Omega=2 * math.sqrt(9.81), c=0.0, direction='vertical', label='system', solver='auto', backend='auto')
Bases: BaseSystem
A pendulum whose suspension point oscillates vertically or horizontally.
The suspension point has the acceleration ε g cos Ω t.
Vertically, the acceleration of the suspension point modulates gravity, θ'' + c θ' + (g / l)(1 + ε cos Ω t) sin θ =
0. Small oscillations grow when Ω is close to twice the natural frequency sqrt(g / l), the parametric resonance
of a swing, while a pendulum at rest stays at rest. Horizontally, the acceleration pushes the bob sideways, θ'' + c
θ' + (g / l)(sin θ + ε cos Ω t cos θ) = 0, which for small angles is a harmonic oscillator under an external force.
Its amplitude grows linearly in time, as ε Ω t / 2, when Ω equals the natural frequency, the linear resonance,
and the pendulum starts to swing even from rest. The system has the angle swing.theta and the angular velocity
swing.theta'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theta
|
float
|
The initial angle. |
0.1
|
omega
|
float
|
The initial angular velocity. |
0.0
|
g
|
float
|
The gravitational acceleration. |
9.81
|
l
|
float
|
The length of the rod. |
1.0
|
epsilon
|
float
|
The amplitude of the acceleration of the suspension point, relative to |
0.2
|
Omega
|
float
|
The angular frequency of the suspension point. |
2 * sqrt(9.81)
|
c
|
float
|
The friction coefficient. |
0.0
|
direction
|
str
|
The direction in which the suspension point oscillates, |
'vertical'
|
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import ParametricPendulumSystem
>>> ParametricPendulumSystem(epsilon=0.5).prepare().system_.interactions[0].epsilon
0.5
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 | |
ParticleInAWellSystem(x=1.0, v=0.5, *, k=2.0, m=1.0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A particle moving without friction in the potential U(x) = k x² e^-x.
The potential has a stable equilibrium at x = 0 and an unstable one at x = 2, the top of a barrier of height 4
k e^-2. A particle in the well with less energy than the barrier oscillates, and one with more escapes to large
x. The system has the particle particle and its position particle.x in one dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The initial position. |
1.0
|
v
|
float
|
The initial velocity. |
0.5
|
k
|
float
|
The strength of the potential. |
2.0
|
m
|
float
|
The mass of the particle. |
1.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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import ParticleInAWellSystem
>>> ParticleInAWellSystem(k=3.0).prepare().system_.interactions[0].k
3.0
Source code in src/skcomplex/systems/physics/mechanics/_wells.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
PendulumSpringInteraction(label, *, first, second, k=1.0)
Bases: Interaction
Spring between the bobs of two pendulums.
The spring stretches with the horizontal distance of the bobs.
The spring of stiffness k has the energy k (l2 sin θ2 - l1 sin θ1)² / 2. Its torque on every pendulum divides by
the moment of inertia m l² of that pendulum, so the first follows θ1'' = k (l2 sin θ2 - l1 sin θ1) cos θ1 / (m1
l1) and the second θ2'' = -k (l2 sin θ2 - l1 sin θ1) cos θ2 / (m2 l2), besides their own swing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
first
|
Role
|
The path of the first pendulum, with the angle |
required |
second
|
Role
|
The path of the second pendulum. |
required |
k
|
Annotated[float, closed_open(0, oo)]
|
The stiffness of the spring. |
1.0
|
Examples:
>>> from skcomplex.systems.physics.mechanics import PendulumSpringInteraction
>>> PendulumSpringInteraction('spring', first='left', second='right', k=2.0).k
2.0
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
759 760 761 762 763 764 765 766 767 768 769 770 | |
PendulumSystem(theta=0.5, omega=0.0, *, m=1.0, g=9.81, l=1.0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A pendulum, whose angle follows Newton's second law m l θ'' = -m g sin θ.
The system has the pendulum bob, with the angle bob.theta and the angular velocity bob.theta'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theta
|
float
|
The initial angle, in radians. |
0.5
|
omega
|
float
|
The initial angular velocity. |
0.0
|
m
|
float
|
The mass of the bob. |
1.0
|
g
|
float
|
The gravitational acceleration. |
9.81
|
l
|
float
|
The length of the rod. |
1.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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import PendulumSystem
>>> trajectory = PendulumSystem(theta=0.1).prepare().simulate(until=1.0, dt=1.0)
>>> round(float(trajectory.get_values('bob.theta')[0]), 1)
0.1
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 | |
ProjectileSystem(speed=10.0, angle=45.0, *, mass=1.0, drag=0.0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A particle launched under uniform gravity, optionally slowed by linear drag.
The system has the particle ball at the position (ball.x, ball.y), with the height ball.y.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
speed
|
float
|
The launch speed. |
10.0
|
angle
|
float
|
The launch angle above the horizon, in degrees. |
45.0
|
mass
|
float
|
The mass. |
1.0
|
drag
|
float
|
The linear drag coefficient. |
0.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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import ProjectileSystem
>>> trajectory = ProjectileSystem(speed=5.0, angle=90.0).prepare().simulate(until=0.1)
>>> float(trajectory.get_values("ball.x'")[0]), float(trajectory.get_values("ball.y'")[0])
(0.0, 5.0)
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 | |
RotatingBallElement(label, *, theta=0.0, m=1.0, r=1.0, beta=math.pi / 2, H=1.0)
Bases: Element
Ball of mass m on a rod at the distance r from the joint.
The rod turns about a vertical axis by the angle theta.
The rod is fixed at the angle beta to the axis, so the ball is at the distance r sin β from it, and H is its
angular momentum about the axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the ball. |
required |
theta
|
Annotated[float, Period(2 * pi)]
|
The initial angle about the axis. |
0.0
|
m
|
Annotated[float, open(0, oo)]
|
The mass of the ball. |
1.0
|
r
|
Annotated[float, open(0, oo)]
|
The distance of the ball from the joint of the rod. |
1.0
|
beta
|
Annotated[float, open(0, oo)]
|
The angle of the rod to the axis, in radians. |
pi / 2
|
H
|
float
|
The angular momentum of the ball about the axis. |
1.0
|
Examples:
>>> from skcomplex.systems.physics.mechanics import RotatingBallElement
>>> RotatingBallElement('ball', H=2.0).H
2.0
Source code in src/skcomplex/systems/physics/mechanics/_rotations.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
RotatingBallsOnRodsSystem(omega=1.0, *, r=1.0, beta=math.pi / 2, m=1.0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Two balls on rods that turn about a vertical axis.
The balls conserve their angular momentum.
Each ball sits at the distance r along a rod fixed at the angle β to the axis, so its distance from the axis is
r sin β. Its angular momentum H = m ω r² sin² β is fixed by the initial angular velocity, and the balls turn at
θ' = H / (m r² sin² β), so changing r during a run changes the angular velocity by 1 / r². The system has the
angles right.theta and left.theta of the two balls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
omega
|
float
|
The initial angular velocity. |
1.0
|
r
|
float
|
The distance of the balls from the joint of the rods. |
1.0
|
beta
|
float
|
The angle of the rods to the vertical axis, in radians. |
pi / 2
|
m
|
float
|
The mass of every ball. |
1.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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import RotatingBallsOnRodsSystem
>>> RotatingBallsOnRodsSystem(omega=2.0).prepare().system_.elements[0].H
2.0
Source code in src/skcomplex/systems/physics/mechanics/_rotations.py
593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 | |
RotatingSwingElement(label, *, phi=0.0, theta=0.1, J=10.0, m=1.0, n_chairs=8.0, a=1.0, l=1.0, g=9.81, values=None)
Bases: Element
Rotating swing.
Chairs on chains hang from the rods of a stand that turns about a vertical axis.
The angle phi of the stand and the angle theta of the chains from the vertical are the coordinates of
RotatingSwingInteraction, and their angular velocities are phi' and theta'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the swing. |
required |
phi
|
Annotated[float, Period(2 * pi)]
|
The initial angle of the stand. |
0.0
|
theta
|
float
|
The initial angle of the chains. |
0.1
|
J
|
Annotated[float, open(0, oo)]
|
The moment of inertia of the stand. |
10.0
|
m
|
Annotated[float, open(0, oo)]
|
The mass of every chair. |
1.0
|
n_chairs
|
Annotated[float, open(0, oo)]
|
The number of chairs. |
8.0
|
a
|
Annotated[float, closed_open(0, oo)]
|
The length of the rods. |
1.0
|
l
|
Annotated[float, open(0, oo)]
|
The length of the chains. |
1.0
|
g
|
Annotated[float, open(0, oo)]
|
The gravitational acceleration. |
9.81
|
values
|
Mapping[str, object] | None
|
Further values by name, such as an initial velocity named with a prime, or |
None
|
Examples:
>>> from skcomplex.systems.physics.mechanics import RotatingSwingElement
>>> RotatingSwingElement('swing', n_chairs=4.0).n_chairs
4.0
Source code in src/skcomplex/systems/physics/mechanics/_rotations.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
RotatingSwingInteraction(label, *, target, torque=0.0, friction=0.0)
Bases: LagrangianInteraction
Motion of a rotating swing.
The motion is the Euler-Lagrange equations with a torque and friction on the stand.
The Lagrangian is [J + n m (a + l sin θ)²] φ'² / 2 + n m l² θ'² / 2 + n m g l cos θ, the torque drives the angle
φ of the stand, and the Rayleigh dissipation c φ'² / 2 adds the friction of its axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the swing. |
required |
torque
|
float
|
The torque that drives the stand. |
0.0
|
friction
|
Annotated[float, closed_open(0, oo)]
|
The friction coefficient of the stand's axis. |
0.0
|
Examples:
>>> from skcomplex.systems.physics.mechanics import RotatingSwingInteraction
>>> RotatingSwingInteraction('motion', target='swing', friction=0.5).friction
0.5
Source code in src/skcomplex/systems/physics/mechanics/_rotations.py
367 368 369 370 371 372 373 374 375 376 377 378 | |
RotatingSwingSystem(omega=2.0, theta=0.1, *, n_chairs=8, J=10.0, m=1.0, a=1.0, l=1.0, g=9.81, torque=0.0, friction=0.0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A rotating swing.
Chairs on chains hang from the rods of a stand that turns about a vertical axis.
The stand of inertia J turns by the angle φ, and the chairs, all deflected by the same angle θ, follow the
Lagrange equations [J + n m (a + l sin θ)²] φ'' + 2 n m l φ' θ' (a + l sin θ) cos θ = M - c φ' and l θ'' - φ'² (a
+ l sin θ) cos θ + g sin θ = 0. At a steady speed ω the chairs settle at the angle where g tan θ = ω² (a + l sin
θ). Without torque and friction the angular momentum of the swing is conserved. The system has the angle of the
stand swing.phi and of the chains swing.theta, and their angular velocities swing.phi' and swing.theta'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
omega
|
float
|
The initial angular velocity of the stand. |
2.0
|
theta
|
float
|
The initial angle of the chains from the vertical. |
0.1
|
n_chairs
|
int
|
The number of chairs. |
8
|
J
|
float
|
The moment of inertia of the stand. |
10.0
|
m
|
float
|
The mass of every chair. |
1.0
|
a
|
float
|
The length of the rods. |
1.0
|
l
|
float
|
The length of the chains. |
1.0
|
g
|
float
|
The gravitational acceleration. |
9.81
|
torque
|
float
|
The torque that drives the stand. |
0.0
|
friction
|
float
|
The friction coefficient of the stand's axis. |
0.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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import RotatingSwingSystem
>>> trajectory = RotatingSwingSystem(omega=1.0).prepare().simulate(until=1.0)
>>> float(trajectory.get_values("swing.phi'")[0])
1.0
Source code in src/skcomplex/systems/physics/mechanics/_rotations.py
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 | |
RotationInteraction(label, *, target)
Bases: Interaction
Rotation of a ball about an axis at the rate fixed by its angular momentum.
The angle theta of the target follows theta' = H / (m r² sin² β), with the angular momentum H, the mass m,
the distance r from the joint, and the angle β of the rod, all values of the target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the ball. |
required |
Examples:
>>> from skcomplex.systems.physics.mechanics import RotationInteraction
>>> RotationInteraction('turn', target='ball').target
'ball'
Source code in src/skcomplex/systems/physics/mechanics/_rotations.py
250 251 252 | |
StickSlipInteraction(label, *, target, k=1.0, c=0.0, mu_s=0.06, mu_k=0.05, g=1.0, v_stick=0.01)
Bases: Interaction
A linear spring with static, Coulomb, and viscous friction on a mass.
The mass follows m x'' + c x' + k x + f = 0, with the sliding friction f = mu_k m g sign(x'). While
|x'| <= v_stick and |k x| <= mu_s m g, the static friction holds the mass at rest. The position x and the
velocity v of the target are both states, since the position stops while the static friction holds it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the mass. |
required |
k
|
Annotated[float, closed_open(0, oo)]
|
The stiffness of the spring. |
1.0
|
c
|
Annotated[float, closed_open(0, oo)]
|
The viscous friction coefficient. |
0.0
|
mu_s
|
Annotated[float, closed_open(0, oo)]
|
The static friction coefficient. |
0.06
|
mu_k
|
Annotated[float, closed_open(0, oo)]
|
The kinetic friction coefficient. |
0.05
|
g
|
Annotated[float, open(0, oo)]
|
The gravitational acceleration. |
1.0
|
v_stick
|
Annotated[float, open(0, oo)]
|
The speed below which the mass counts as at rest. |
0.01
|
Examples:
>>> from skcomplex.systems.physics.mechanics import StickSlipInteraction
>>> StickSlipInteraction('friction', target='mass', mu_k=0.1).mu_k
0.1
Source code in src/skcomplex/systems/physics/mechanics/_accelerators.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
SupportSpringInteraction(label, *, first, second, k=1.0)
Bases: Interaction
Spring of stiffness k between the supports of two pendulum clocks.
The spring pulls the supports with the forces ±k (x2 - x1). Every clock answers with the accelerations of its
support and its pendulum through its mass matrix [[m l², m l cos θ], [m l cos θ, M + m]], so a force Q on the
support gives θ'' = -m l cos θ Q / D and x'' = m l² Q / D, with the determinant D = m l² (M + m) - (m l cos
θ)².
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
first
|
Role
|
The path of the first clock. |
required |
second
|
Role
|
The path of the second clock. |
required |
k
|
Annotated[float, closed_open(0, oo)]
|
The stiffness of the spring. |
1.0
|
Examples:
>>> from skcomplex.systems.physics.mechanics import SupportSpringInteraction
>>> SupportSpringInteraction('spring', first='clock_0', second='clock_1', k=2.0).k
2.0
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
823 824 825 826 827 828 829 830 831 832 833 834 | |
TwoMassSpringDamperSystem(x1=1.2, x2=2.0, *, m1=1.0, m2=1.0, k1=1.0, k2=1.0, k=1.0, b1=0.0, b2=0.0, l1=1.0, l2=1.0, F1=0.0, F2=0.0, omega1=1.0, omega2=1.0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Two masses between two walls, with dampers and forces.
Springs tie the masses to the walls and to each other.
The first mass rests at x01 = l1 and the second at x02 = l1 + l2. They follow m1 x1'' = -k1 (x1 - x01) + k ((x2
- x1) - (x02 - x01)) - b1 x1' + F1 cos(ω1 t) and m2 x2'' = -k ((x2 - x1) - (x02 - x01)) - k2 (x2 - x02) - b2 x2' +
F2 cos(ω2 t). The system has the masses first and second and their positions first.x and second.x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x1
|
float
|
The initial position of the first mass. |
1.2
|
x2
|
float
|
The initial position of the second mass. |
2.0
|
m1
|
float
|
The first mass. |
1.0
|
m2
|
float
|
The second mass. |
1.0
|
k1
|
float
|
The stiffness of the spring between the left wall and the first mass. |
1.0
|
k2
|
float
|
The stiffness of the spring between the second mass and the right wall. |
1.0
|
k
|
float
|
The stiffness of the spring between the masses. |
1.0
|
b1
|
float
|
The damping coefficient of the first mass. |
0.0
|
b2
|
float
|
The damping coefficient of the second mass. |
0.0
|
l1
|
float
|
The rest length of the first spring. |
1.0
|
l2
|
float
|
The rest length of the middle spring. |
1.0
|
F1
|
float
|
The amplitude of the periodic force on the first mass. |
0.0
|
F2
|
float
|
The amplitude of the periodic force on the second mass. |
0.0
|
omega1
|
float
|
The angular frequency of the force on the first mass. |
1.0
|
omega2
|
float
|
The angular frequency of the force on the second mass. |
1.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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import TwoMassSpringDamperSystem
>>> TwoMassSpringDamperSystem(l1=2.0).prepare().system_.interactions[0].center
2.0
Source code in src/skcomplex/systems/physics/mechanics/_springs.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
UniformGravityInteraction(label, *, target, g=GRAVITY, coordinate='y')
Bases: Interaction
Uniform gravity, the constant acceleration -g of the height of a target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the body. |
required |
g
|
float
|
The gravitational acceleration. |
GRAVITY
|
coordinate
|
str
|
The name of the height of the body, such as |
'y'
|
Examples:
>>> from skcomplex.systems.physics.mechanics import UniformGravityInteraction
>>> UniformGravityInteraction('gravity', target='ball', g=1.62).g
1.62
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
281 282 283 284 285 | |