Mechanics
Mechanics: pendulums, oscillators, friction, projectiles, collisions, rotating bodies, wells, and beam maps.
BallisticPendulumElement(label, visual=None, *, x=-1.0, x_d1=0.0, theta=0.0, theta_d1=0.0, m=0.01, M=1.0, l=1.0, g=9.81)
Bases: Element
Bullet of mass m at the position x flying towards the block of mass M of a pendulum with the angle theta.
The position and the angle have order 2. The bullet flies freely, the pendulum swings, and the impact transfers the momentum of the bullet to the pendulum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the bullet and pendulum. |
required |
visual
|
VisualSpec | None
|
How the bullet and pendulum are drawn, or |
None
|
x
|
Annotated[float, StateSpec(order=2)]
|
The initial position of the bullet, negative before the block. |
-1.0
|
x_d1
|
float
|
The initial velocity of the bullet. |
0.0
|
theta
|
Annotated[float, StateSpec(period=2 * pi, order=2)]
|
The initial angle of the pendulum. |
0.0
|
theta_d1
|
float
|
The initial angular velocity of the pendulum. |
0.0
|
m
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The mass of the bullet. |
0.01
|
M
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The mass of the block. |
1.0
|
l
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The length of the rod. |
1.0
|
g
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The gravitational acceleration. |
9.81
|
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
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
BeamElement(label, visual=None, *, x=0.5, y=0.0, nu=0.3, c=0.05)
Bases: Element
Transverse position and momentum of a particle of an accelerator beam, kicked by the opposite beam every turn.
Map interactions rotate the particle by the tune and kick its momentum with the field of the opposite beam, so the element holds the states and the parameters they read.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the particle. |
required |
visual
|
VisualSpec | None
|
How the particle is drawn, or |
None
|
x
|
Annotated[float, StateSpec()]
|
The initial transverse position. |
0.5
|
y
|
Annotated[float, StateSpec()]
|
The initial transverse momentum. |
0.0
|
nu
|
Annotated[float, ParameterSpec(domain=closed(0, 2))]
|
The tune, the rotation per turn in units of |
0.3
|
c
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The strength of the beam-beam kick. |
0.05
|
Attributes:
| Name | Type | Description |
|---|---|---|
default_visual_ |
The visual of the particle when it sets none. |
Examples:
>>> from skcomplex.systems.physics.mechanics import BeamElement
>>> BeamElement('particle').nu
0.3
Source code in src/skcomplex/systems/physics/mechanics/_accelerators.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
BouncingBallElement(label, visual=None, *, h=1.0, h_d1=0.0, g=9.81)
Bases: Element
Ball at the height h above a floor, falling under the gravitational acceleration g.
The height has order 2 and its first derivative h_d1 is the vertical velocity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the ball. |
required |
visual
|
VisualSpec | None
|
How the ball is drawn, or |
None
|
h
|
Annotated[float, StateSpec(order=2)]
|
The initial height. |
1.0
|
h_d1
|
float
|
The initial vertical velocity. |
0.0
|
g
|
Annotated[float, ParameterSpec()]
|
The gravitational acceleration. |
9.81
|
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
58 59 60 61 62 63 64 65 66 67 68 69 70 | |
CartPendulumElement(label, visual=None, *, y=0.0, y_d1=0.0, theta=0.5, theta_d1=0.0, m1=1.0, m2=1.0, l=1.0, g=9.81, F=0.0)
Bases: Element
Cart on a horizontal track at the position y, with a pendulum of angle theta hanging from it.
The position and the angle have order 2. The motion comes from CartPendulumInteraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the cart and pendulum. |
required |
visual
|
VisualSpec | None
|
How the cart and pendulum are drawn, or |
None
|
y
|
Annotated[float, StateSpec(order=2)]
|
The initial position of the cart. |
0.0
|
y_d1
|
float
|
The initial velocity of the cart. |
0.0
|
theta
|
Annotated[float, StateSpec(period=2 * pi, order=2)]
|
The initial angle of the pendulum. |
0.5
|
theta_d1
|
float
|
The initial angular velocity of the pendulum. |
0.0
|
m1
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The mass of the cart. |
1.0
|
m2
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The mass of the bob. |
1.0
|
l
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The length of the rod. |
1.0
|
g
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The gravitational acceleration. |
9.81
|
F
|
Annotated[float, ParameterSpec()]
|
A constant horizontal force on the cart. |
0.0
|
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
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
CartPendulumInteraction(label, *, target)
Bases: EulerLagrangeInteraction
Motion of a cart and the pendulum that hangs from it, 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 of the
target drives the position y of the cart.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the cart and pendulum. |
required |
Examples:
>>> from skcomplex.systems.physics.mechanics import CartPendulumInteraction
>>> CartPendulumInteraction('motion', target='cart').states
('y', 'theta')
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
423 424 | |
ClockPendulumElement(label, visual=None, *, theta=0.2, theta_d1=0.0, x=0.0, x_d1=0.0, m=1.0, l=1.0, M=1.0, g=9.8, rho=0.1, lam=0.1, theta_c=0.1)
Bases: Element
Pendulum clock, a pendulum of angle theta hanging from a support at the horizontal position x.
The angle and the position have order 2. The motion comes from ClockPendulumInteraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the clock. |
required |
visual
|
VisualSpec | None
|
How the clock is drawn, or |
None
|
theta
|
Annotated[float, StateSpec(order=2)]
|
The initial angle of the pendulum. |
0.2
|
theta_d1
|
float
|
The initial angular velocity of the pendulum. |
0.0
|
x
|
Annotated[float, StateSpec(order=2)]
|
The initial position of the support. |
0.0
|
x_d1
|
float
|
The initial velocity of the support. |
0.0
|
m
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The mass of the bob. |
1.0
|
l
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The length of the pendulum. |
1.0
|
M
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The mass of the support. |
1.0
|
g
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The gravitational acceleration. |
9.8
|
rho
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The damping of the support. |
0.1
|
lam
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The strength of the escapement. |
0.1
|
theta_c
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The angle below which the escapement pumps energy in. |
0.1
|
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
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
ClockPendulumInteraction(label, *, target)
Bases: EulerLagrangeInteraction
Motion of a pendulum clock on a moving support, 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
|
Annotated[str, RoleSpec()]
|
The path of the clock. |
required |
Examples:
>>> from skcomplex.systems.physics.mechanics import ClockPendulumInteraction
>>> ClockPendulumInteraction('motion', target='clock').states
('theta', 'x')
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
468 469 | |
DiscBilliardElement(label, visual=None, *, x=0.3, y=0.0, vx=0.4, vy=1.0, radius=1.0)
Bases: Element
Particle moving freely in the plane with the position (x, y) and the velocity (vx, vy), inside a disc.
The position changes at the velocity, which changes only at the reflections off the wall of the disc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the particle. |
required |
visual
|
VisualSpec | None
|
How the particle is drawn, or |
None
|
x
|
Annotated[float, StateSpec()]
|
The initial horizontal position. |
0.3
|
y
|
Annotated[float, StateSpec()]
|
The initial vertical position. |
0.0
|
vx
|
Annotated[float, StateSpec()]
|
The initial horizontal velocity. |
0.4
|
vy
|
Annotated[float, StateSpec()]
|
The initial vertical velocity. |
1.0
|
radius
|
Annotated[float, ParameterSpec(domain=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
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
DoublePendulumElement(label, visual=None, *, theta1=math.pi / 2, theta1_d1=0.0, theta2=math.pi / 2, theta2_d1=0.0, m1=1.0, m2=1.0, l1=1.0, l2=1.0, g=9.81)
Bases: Element
Double pendulum, a bob of mass m2 on a rod of length l2 hanging from a bob of mass m1 on a rod l1.
The angles theta1 and theta2 of the rods from the vertical have order 2. The motion comes from
DoublePendulumInteraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the double pendulum. |
required |
visual
|
VisualSpec | None
|
How the double pendulum is drawn, or |
None
|
theta1
|
Annotated[float, StateSpec(period=2 * pi, order=2)]
|
The initial angle of the upper rod. |
pi / 2
|
theta1_d1
|
float
|
The initial angular velocity of the upper rod. |
0.0
|
theta2
|
Annotated[float, StateSpec(period=2 * pi, order=2)]
|
The initial angle of the lower rod. |
pi / 2
|
theta2_d1
|
float
|
The initial angular velocity of the lower rod. |
0.0
|
m1
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The mass of the upper bob. |
1.0
|
m2
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The mass of the lower bob. |
1.0
|
l1
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The length of the upper rod. |
1.0
|
l2
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The length of the lower rod. |
1.0
|
g
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The gravitational acceleration. |
9.81
|
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
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
DoublePendulumInteraction(label, *, target)
Bases: EulerLagrangeInteraction
Motion of a double pendulum, 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
|
Annotated[str, RoleSpec()]
|
The path of the double pendulum. |
required |
Examples:
>>> from skcomplex.systems.physics.mechanics import DoublePendulumInteraction
>>> DoublePendulumInteraction('motion', target='pendulum').states
('theta1', 'theta2')
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
514 515 | |
ElasticCollisionInteraction(label, *, left, right, diameter=0.1)
Bases: Interaction
Elastic collision of two equal masses in a row, which 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
|
Annotated[str, RoleSpec()]
|
The path of the left ball, with a position |
required |
right
|
Annotated[str, RoleSpec()]
|
The path of the right ball, with a position |
required |
diameter
|
Annotated[float, ParameterSpec(domain=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
227 228 229 230 231 232 233 234 235 236 237 238 | |
ExponentialWellInteraction(label, *, target, k=2.0)
Bases: PotentialEnergyInteraction
Potential k x² e^-x on a particle in one dimension, a well at x = 0 behind a barrier at x = 2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the particle. |
required |
k
|
Annotated[float, ParameterSpec(domain=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
38 39 40 41 42 43 44 45 46 | |
FrictionOscillatorElement(label, visual=None, *, 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)
Bases: Element
Mass on a spring with static, Coulomb, and viscous friction, which sticks and slips.
The mass m at the position x with the velocity v feels the spring -k x and the viscous friction -c v.
While it slides it feels the Coulomb friction -mu_k m g sign(v), and at rest it stays at rest while the spring
force stays within the static friction mu_s m g. The friction is discontinuous in the velocity, so the mass
counts as at rest below the speed v_stick, which must exceed the change of speed of one solver step, and its
position stays still while it is at rest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the mass. |
required |
visual
|
VisualSpec | None
|
How the mass is drawn, or |
None
|
x
|
Annotated[float, StateSpec()]
|
The initial position. |
1.03
|
v
|
Annotated[float, StateSpec()]
|
The initial velocity. |
0.0
|
m
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The mass. |
1.0
|
k
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The stiffness of the spring. |
1.0
|
c
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The viscous friction coefficient. |
0.0
|
mu_s
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The static friction coefficient. |
0.06
|
mu_k
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The kinetic friction coefficient. |
0.05
|
g
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The gravitational acceleration. |
1.0
|
v_stick
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The speed below which the mass counts as at rest. |
0.01
|
Attributes:
| Name | Type | Description |
|---|---|---|
default_visual_ |
The visual of the mass when it sets none. |
Examples:
>>> from skcomplex.systems.physics.mechanics import FrictionOscillatorElement
>>> FrictionOscillatorElement('mass').mu_s
0.06
Source code in src/skcomplex/systems/physics/mechanics/_accelerators.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
GyroscopeElement(label, visual=None, *, alpha=0.0, alpha_d1=0.0, beta=0.3, beta_d1=0.0, gamma=0.0, gamma_d1=0.0, A=1.0, C=2.0, A1=0.5, B1=0.5, C1=0.5, A2=1.0, torque=1.0)
Bases: Element
Gyroscope in a gimbal: a rotor in an inner ring that 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 have order 2. The motion
comes from GyroscopeInteraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the gyroscope. |
required |
visual
|
VisualSpec | None
|
How the gyroscope is drawn, or |
None
|
alpha
|
Annotated[float, StateSpec(period=2 * pi, order=2)]
|
The initial angle of the outer ring. |
0.0
|
alpha_d1
|
float
|
The initial angular velocity of the outer ring. |
0.0
|
beta
|
Annotated[float, StateSpec(order=2)]
|
The initial angle of the inner ring. |
0.3
|
beta_d1
|
float
|
The initial angular velocity of the inner ring. |
0.0
|
gamma
|
Annotated[float, StateSpec(period=2 * pi, order=2)]
|
The initial angle of the rotor. |
0.0
|
gamma_d1
|
float
|
The initial angular velocity of the rotor. |
0.0
|
A
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The equatorial moment of inertia of the rotor. |
1.0
|
C
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The polar moment of inertia of the rotor. |
2.0
|
A1
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The first principal moment of inertia of the inner ring. |
0.5
|
B1
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The second principal moment of inertia of the inner ring. |
0.5
|
C1
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The third principal moment of inertia of the inner ring. |
0.5
|
A2
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The moment of inertia of the outer ring about its axis. |
1.0
|
torque
|
Annotated[float, ParameterSpec()]
|
The torque on the axis of the inner ring. |
1.0
|
Examples:
>>> from skcomplex.systems.physics.mechanics import GyroscopeElement
>>> GyroscopeElement('gyroscope', gamma_d1=10.0).gamma_d1
10.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 104 105 106 107 108 109 110 111 | |
GyroscopeInteraction(label, *, target)
Bases: EulerLagrangeInteraction
Motion of a gimballed gyroscope, 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 of the target acts on the axis of the inner ring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the gyroscope. |
required |
Examples:
>>> from skcomplex.systems.physics.mechanics import GyroscopeInteraction
>>> GyroscopeInteraction('motion', target='gyroscope').states
('alpha', 'beta', 'gamma')
Source code in src/skcomplex/systems/physics/mechanics/_rotations.py
274 275 | |
HangingBallElement(label, visual=None, *, x=0.0, x_d1=0.0, rest=0.0, g=9.81, length=1.0)
Bases: Element
Ball hanging on a string of length length, which swings with small amplitude about its rest position.
The horizontal position x has order 2, and its first derivative x_d1 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 |
visual
|
VisualSpec | None
|
How the ball is drawn, or |
None
|
x
|
Annotated[float, StateSpec(order=2)]
|
The initial horizontal position. |
0.0
|
x_d1
|
float
|
The initial horizontal velocity. |
0.0
|
rest
|
Annotated[float, ParameterSpec()]
|
The rest position. |
0.0
|
g
|
Annotated[float, ParameterSpec()]
|
The gravitational acceleration. |
9.81
|
length
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The length of the string. |
1.0
|
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
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
HarmonicForceInteraction(label, *, target, F=0.0, omega=1.0, state='x', divisor='m')
Bases: RateInteraction
Periodic force F cos(omega t) on a target, the second derivative F cos(omega t) / m of its position.
It is the rate F cos(omega t) with the mass as divisor, applied to every component of the position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the element or group the force acts on. |
required |
F
|
Annotated[float, ParameterSpec()]
|
The amplitude of the force. |
0.0
|
omega
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The angular frequency of the force. |
1.0
|
state
|
str
|
The name of the state of order 2 that holds the position of the target. |
'x'
|
divisor
|
str
|
The name of the state or parameter that holds the mass of the target. |
'm'
|
Examples:
>>> from skcomplex.systems.physics.common.particles import HarmonicForceInteraction
>>> HarmonicForceInteraction('drive', target='mass', F=0.5, omega=2.0).omega
2.0
Source code in src/skcomplex/systems/physics/common/particles/_harmonic_force.py
46 47 48 49 50 51 52 53 54 55 56 57 58 | |
MagnetInteraction(label, *, target, center=0.0, gamma=1.0, d=0.3)
Bases: PotentialEnergyInteraction
Magnet below the plane of a pendulum bob, which attracts it with energy -gamma / sqrt(|x - center|**2 + d**2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the bob. |
required |
center
|
Annotated[ArrayLike, ParameterSpec(vector=True)]
|
The position of the magnet in the plane. |
0.0
|
gamma
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The strength of the magnet. |
1.0
|
d
|
Annotated[float, ParameterSpec(domain=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', center=[1.0, 0.0]).gamma
1.0
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
560 561 562 563 564 565 566 567 568 569 570 571 572 | |
ParametricPendulumElement(label, visual=None, *, theta=0.1, theta_d1=0.0, g=9.81, l=1.0, epsilon=0.2, Omega=2 * math.sqrt(9.81), c=0.0)
Bases: Element
Pendulum whose suspension point oscillates vertically, with the angle theta of order 2.
The motion comes from ParametricPendulumInteraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the pendulum. |
required |
visual
|
VisualSpec | None
|
How the pendulum is drawn, or |
None
|
theta
|
Annotated[float, StateSpec(period=2 * pi, order=2)]
|
The initial angle. |
0.1
|
theta_d1
|
float
|
The initial angular velocity. |
0.0
|
g
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The gravitational acceleration. |
9.81
|
l
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The length of the rod. |
1.0
|
epsilon
|
Annotated[float, ParameterSpec()]
|
The amplitude of the acceleration of the suspension point, relative to |
0.2
|
Omega
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The angular frequency of the suspension point. |
2 * sqrt(9.81)
|
c
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The friction coefficient. |
0.0
|
Examples:
>>> from skcomplex.systems.physics.mechanics import ParametricPendulumElement
>>> ParametricPendulumElement('swing', epsilon=0.5).epsilon
0.5
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
ParametricPendulumInteraction(label, *, target, direction='vertical')
Bases: EulerLagrangeInteraction
Motion of a pendulum whose suspension point oscillates vertically or horizontally, 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
parameters of the target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the pendulum. |
required |
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').states
'theta'
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
622 623 624 | |
PendulumElement(label, visual=None, *, theta=0.5, theta_d1=0.0, m=1.0, g=9.81, l=1.0)
Bases: Element
Pendulum, a bob of mass m on a rigid rod of length l that swings by the angle theta under gravity g.
The angle has order 2 and its first derivative theta_d1 is the angular velocity. The motion comes from an
interaction such as PendulumInteraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the pendulum. |
required |
visual
|
VisualSpec | None
|
How the pendulum is drawn, or |
None
|
theta
|
Annotated[float, StateSpec(period=2 * pi, order=2)]
|
The initial angle from the vertical, in radians. |
0.5
|
theta_d1
|
float
|
The initial angular velocity. |
0.0
|
m
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The mass of the bob. |
1.0
|
g
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The gravitational acceleration. |
9.81
|
l
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The length of the rod. |
1.0
|
Examples:
>>> from skcomplex.systems.physics.common.mechanics import PendulumElement
>>> PendulumElement('bob', theta=0.2, l=2.0).l
2.0
Source code in src/skcomplex/systems/physics/common/mechanics/_pendulum.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
PendulumInteraction(label, *, target)
Bases: EulerLagrangeInteraction
Motion of a pendulum, the Euler-Lagrange equation of L = m l² θ'² / 2 + m g l cos θ.
The equation is Newton's law m l² θ'' = -m g l sin θ for the angle θ of the target, whose mass m, length
l, and gravity g are parameters of the target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the pendulum. |
required |
Examples:
>>> from skcomplex.systems.physics.common.mechanics import PendulumInteraction
>>> PendulumInteraction('swing', target='bob').states
'theta'
Source code in src/skcomplex/systems/physics/common/mechanics/_pendulum_interaction.py
35 36 | |
PendulumSpringInteraction(label, *, first, second, k=1.0)
Bases: EulerLagrangeInteraction
Spring between the bobs of two pendulums, which stretches with the horizontal distance of the bobs.
The spring of stiffness k adds the Lagrangian -k (l2 sin θ2 - l1 sin θ1)² / 2 to the Euler-Lagrange equations
of the two angles, so its torque on every pendulum divides by the moment of inertia m l² of the pendulum's own
Lagrangian.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
first
|
Annotated[str, RoleSpec()]
|
The path of the first pendulum, with the angle |
required |
second
|
Annotated[str, RoleSpec()]
|
The path of the second pendulum. |
required |
k
|
Annotated[float, ParameterSpec(domain=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
687 688 689 690 691 692 693 694 695 696 697 698 | |
RotatingBallElement(label, visual=None, *, 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, turning 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 |
visual
|
VisualSpec | None
|
How the ball is drawn, or |
None
|
theta
|
Annotated[float, StateSpec(period=2 * pi)]
|
The initial angle about the axis. |
0.0
|
m
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The mass of the ball. |
1.0
|
r
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The distance of the ball from the joint of the rod. |
1.0
|
beta
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The angle of the rod to the axis, in radians. |
pi / 2
|
H
|
Annotated[float, ParameterSpec()]
|
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
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
RotatingSwingElement(label, visual=None, *, phi=0.0, phi_d1=0.0, theta=0.1, theta_d1=0.0, J=10.0, m=1.0, n_chairs=8.0, a=1.0, l=1.0, g=9.81, torque=0.0, friction=0.0)
Bases: Element
Rotating swing: chairs on chains hanging 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 have order 2. The motion comes
from RotatingSwingInteraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the swing. |
required |
visual
|
VisualSpec | None
|
How the swing is drawn, or |
None
|
phi
|
Annotated[float, StateSpec(period=2 * pi, order=2)]
|
The initial angle of the stand. |
0.0
|
phi_d1
|
float
|
The initial angular velocity of the stand. |
0.0
|
theta
|
Annotated[float, StateSpec(order=2)]
|
The initial angle of the chains. |
0.1
|
theta_d1
|
float
|
The initial angular velocity of the chains. |
0.0
|
J
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The moment of inertia of the stand. |
10.0
|
m
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The mass of every chair. |
1.0
|
n_chairs
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The number of chairs. |
8.0
|
a
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The length of the rods. |
1.0
|
l
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The length of the chains. |
1.0
|
g
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The gravitational acceleration. |
9.81
|
torque
|
Annotated[float, ParameterSpec()]
|
The torque that drives the stand. |
0.0
|
friction
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The friction coefficient of the stand's axis. |
0.0
|
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
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
RotatingSwingInteraction(label, *, target)
Bases: EulerLagrangeInteraction
Motion of a rotating swing, 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
|
Annotated[str, RoleSpec()]
|
The path of the swing. |
required |
Examples:
>>> from skcomplex.systems.physics.mechanics import RotatingSwingInteraction
>>> RotatingSwingInteraction('motion', target='swing').states
('phi', 'theta')
Source code in src/skcomplex/systems/physics/mechanics/_rotations.py
318 319 320 321 322 323 324 325 | |
SupportSpringInteraction(label, *, first, second, k=1.0)
Bases: EulerLagrangeInteraction
Spring of stiffness k between the supports of two pendulum clocks.
The spring adds the Lagrangian -k (x2 - x1)² / 2 to the Euler-Lagrange equations of the supports, so every clock
answers with the accelerations of its support and its pendulum through the mass matrix of its own Lagrangian.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
first
|
Annotated[str, RoleSpec()]
|
The path of the first clock. |
required |
second
|
Annotated[str, RoleSpec()]
|
The path of the second clock. |
required |
k
|
Annotated[float, ParameterSpec(domain=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
741 742 743 744 745 746 747 748 749 750 751 752 | |
ballistic_pendulum(speed=200.0, distance=1.0, *, m=0.01, M=1.0, l=1.0, g=9.81)
Return a bullet that sticks in the block of a pendulum at rest, which 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the bullet position |
Examples:
>>> from skcomplex.systems.physics.mechanics import ballistic_pendulum
>>> ballistic_pendulum(distance=2.0).elements[0].x
-2.0
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 | |
beam_beam_map(x=0.5, y=0.0, *, nu=0.3, c=0.05)
Return the beam-beam map of a particle of an accelerator beam that 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the states |
Examples:
>>> from skcomplex.systems.physics.mechanics import beam_beam_map
>>> beam_beam_map(nu=0.5).elements[0].nu
0.5
Source code in src/skcomplex/systems/physics/mechanics/_accelerators.py
189 190 191 192 193 194 195 196 197 198 199 200 201 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 227 228 229 230 231 232 233 | |
bouncing_ball(h=1.0, v=0.0, *, g=9.81, e=0.8)
Return a ball that falls under gravity and bounces off the floor, losing 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the height |
Examples:
>>> from skcomplex.systems.physics.mechanics import bouncing_ball
>>> from skcomplex.core.engine.runtime import Simulation
>>> trajectory = Simulation(bouncing_ball(), dt=0.01).prepare().run(until=1.0).trajectory_
>>> round(trajectory.events[0].time, 6)
0.451524
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 | |
cart_pendulum(theta=0.5, y=0.0, *, m1=1.0, m2=1.0, l=1.0, g=9.81, F=0.0)
Return a pendulum hanging from a cart that 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the cart position |
Examples:
>>> from skcomplex.systems.physics.mechanics import cart_pendulum
>>> cart_pendulum(m1=5.0).elements[0].m1
5.0
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
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 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 | |
circular_billiard(x=0.3, y=0.0, vx=0.4, vy=1.0, *, radius=1.0)
Return 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the position |
Examples:
>>> from skcomplex.systems.physics.mechanics import circular_billiard
>>> circular_billiard(radius=2.0).elements[0].radius
2.0
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 | |
coupled_pendulums(theta1=0.2, theta2=0.0, *, k=0.5, m1=1.0, m2=1.0, l1=1.0, l2=1.0, g=9.81)
Return two pendulums whose bobs are joined by a spring, which 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the pendulums |
Examples:
>>> from skcomplex.systems.physics.mechanics import coupled_pendulums
>>> coupled_pendulums(k=2.0).interactions[0].k
2.0
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 | |
double_pendulum(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)
Return a double pendulum, a pendulum hanging from the bob of another, 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the angles |
Examples:
>>> from skcomplex.systems.physics.mechanics import double_pendulum
>>> double_pendulum(m2=2.0).elements[0].m2
2.0
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 | |
driven_damped_oscillator(x=1.0, v=0.0, *, m=1.0, k=1.0, c=0.1, F=0.0, omega=1.0)
Return a mass on a spring with damping and a periodic force, m x'' = -k x - c x' + F cos(ω t).
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the mass |
Examples:
>>> from skcomplex.systems.physics.mechanics import driven_damped_oscillator
>>> driven_damped_oscillator(F=0.5).interactions[2].F
0.5
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | |
friction_oscillator(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)
Return a mass on a linear spring with static, Coulomb, and viscous friction, 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the position |
Examples:
>>> from skcomplex.systems.physics.mechanics import friction_oscillator
>>> friction_oscillator(mu_k=0.1).elements[0].mu_k
0.1
Source code in src/skcomplex/systems/physics/mechanics/_accelerators.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | |
gimballed_gyroscope(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)
Return a gyroscope in a gimbal: a rotor in an inner ring that 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the angles |
Examples:
>>> from skcomplex.systems.physics.mechanics import gimballed_gyroscope
>>> gimballed_gyroscope(spin=10.0).elements[0].gamma_d1
10.0
Source code in src/skcomplex/systems/physics/mechanics/_rotations.py
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 | |
harmonic_oscillator(x=1.0, v=0.0, *, k=1.0, mass=1.0, damping=0.0)
Return a particle on a spring, optionally damped.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the particle |
Examples:
>>> from skcomplex.systems.physics.mechanics import harmonic_oscillator
>>> harmonic_oscillator(k=4.0).interactions[0].k
4.0
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
huygens_clocks(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)
Return pendulum clocks on supports joined by springs, which 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the angles |
Examples:
>>> from skcomplex.systems.physics.mechanics import huygens_clocks
>>> len(huygens_clocks(3).interactions)
5
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 | |
magnetic_pendulum(x=1.0, y=1.5, *, n_magnets=3, omega=1.0, q=0.2, gamma=1.0, d=0.3)
Return a magnetic bob on a string swinging above magnets on a circle, which comes to rest at one of them.
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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the bob |
Examples:
>>> from skcomplex.systems.physics.mechanics import magnetic_pendulum
>>> len(magnetic_pendulum(n_magnets=4).interactions)
6
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 | |
newtons_cradle(n_balls=5, *, speed=0.5, diameter=0.1, gap=0.001, length=1.0, g=9.81)
Return Newton's cradle: pendulum balls in a row that 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the horizontal positions |
Examples:
>>> from skcomplex.systems.physics.mechanics import newtons_cradle
>>> len(newtons_cradle(n_balls=3).interactions)
5
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 | |
parametric_pendulum(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')
Return a pendulum whose suspension point oscillates vertically or horizontally, with 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.
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'
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the angle |
Examples:
>>> from skcomplex.systems.physics.mechanics import parametric_pendulum
>>> parametric_pendulum(epsilon=0.5).elements[0].epsilon
0.5
Source code in src/skcomplex/systems/physics/mechanics/_pendulums.py
977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 | |
particle_in_a_well(x=1.0, v=0.5, *, k=2.0, m=1.0)
Return 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the particle |
Examples:
>>> from skcomplex.systems.physics.mechanics import particle_in_a_well
>>> particle_in_a_well(k=3.0).interactions[0].k
3.0
Source code in src/skcomplex/systems/physics/mechanics/_wells.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
pendulum(theta=0.5, omega=0.0, *, m=1.0, g=9.81, l=1.0)
Return a pendulum, whose angle follows Newton's second law m l θ'' = -m g sin θ.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the pendulum |
Examples:
>>> from skcomplex.systems.physics.mechanics import pendulum
>>> pendulum(theta=0.1).elements[0].theta_d1
0.0
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | |
projectile(speed=10.0, angle=45.0, *, mass=1.0, drag=0.0)
Return a particle launched under uniform gravity, optionally slowed by linear drag.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the particle |
Examples:
>>> from skcomplex.systems.physics.mechanics import projectile
>>> projectile(speed=5.0, angle=90.0).elements[0].x_d1[1]
5.0
Source code in src/skcomplex/systems/physics/mechanics/_mechanics.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
rotating_balls_on_rods(omega=1.0, *, r=1.0, beta=math.pi / 2, m=1.0)
Return two balls on rods that turn about a vertical axis and 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².
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the angles |
Examples:
>>> from skcomplex.systems.physics.mechanics import rotating_balls_on_rods
>>> rotating_balls_on_rods(omega=2.0).elements[0].H
2.0
Source code in src/skcomplex/systems/physics/mechanics/_rotations.py
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | |
rotating_swing(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)
Return a rotating swing: chairs on chains hanging 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the angle of the stand |
Examples:
>>> from skcomplex.systems.physics.mechanics import rotating_swing
>>> rotating_swing(omega=1.0).elements[0].phi_d1
1.0
Source code in src/skcomplex/systems/physics/mechanics/_rotations.py
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | |
two_mass_spring_damper(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)
Return two masses between two walls, tied to the walls and to each other by springs, with dampers and forces.
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).
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the masses |
Examples:
>>> from skcomplex.systems.physics.mechanics import two_mass_spring_damper
>>> two_mass_spring_damper(l1=2.0).interactions[0].center
2.0
Source code in src/skcomplex/systems/physics/mechanics/_springs.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |