SimplePendulum
SimplePendulum(
var_name='simple_pendulum',
L=1.0,
g=9.81,
damping=0.0,
state_variables=None,
diagnostic_variables=None,
*args,
**kwargs,
)Nonlinear pendulum with optional linear damping.
Parameters
var_name : = 'simple_pendulum'-
Human-readable label.
L : = 1.0-
Pendulum length in metres. Must be > 0.
g : = 9.81-
Gravitational acceleration in m/s². Must be > 0.
damping : = 0.0-
Linear damping coefficient λ (s⁻¹).
damping=0gives undamped SHM. state_variables : = None-
Names for [angle, angular velocity].
diagnostic_variables : = None-
Names for post-integration diagnostics.
Notes
State variables are theta (angle, rad) and omega (angular velocity, rad/s) in that order. Diagnostic variables energy and omega_0 are computed after integration.
Examples
import matplotlib.pyplot as plt
from climatecritters.model_critters.pendulum import SimplePendulum
model = SimplePendulum(L=1.0, g=9.81, damping=0.1)
output = model.integrate(t_span=(0, 20), y0=[1.5, 0.0], method='RK45')
ts = output.to_pyleo(var_names=['theta'])
ts.plot()
plt.savefig('docs/reference/figures/SimplePendulum_example.png',
dpi=150, bbox_inches='tight')
Methods
| Name | Description |
|---|---|
| damping_ratio | Return ζ = λ / (2ω₀). ζ < 1 underdamped, ζ = 1 critical. |
| natural_frequency | Return ω₀ = √(g/L) in rad/s. |
| natural_period | Return T₀ = 2π/ω₀ in seconds (small-angle approximation). |
damping_ratio
SimplePendulum.damping_ratio()Return ζ = λ / (2ω₀). ζ < 1 underdamped, ζ = 1 critical.
natural_frequency
SimplePendulum.natural_frequency()Return ω₀ = √(g/L) in rad/s.
natural_period
SimplePendulum.natural_period()Return T₀ = 2π/ω₀ in seconds (small-angle approximation).