Mechanics Mathematics

This page explains the mathematical model used by every mechanism in the simulator. Each system is described by generalized coordinates, its kinetic energy \(T\), its potential energy \(V\), and the Lagrangian \(L=T-V\).

1. The common method

A generalized coordinate \(q_i\) describes one independent way the system can move. Its velocity is \(\dot q_i=dq_i/dt\). The Euler-Lagrange equation for every coordinate is

\[ \frac{d}{dt}\left(\frac{\partial L}{\partial \dot q_i}\right) -\frac{\partial L}{\partial q_i}=0,\qquad L=T-V. \]

The symbolic engine differentiates \(L\), collects the coefficients of the accelerations \(\ddot q_i\), and produces a linear system

\[ A(q,\dot q,t)\,\ddot q=b(q,\dot q,t). \]

The solver evaluates \(A\) and \(b\) at the current state, solves for the accelerations, and advances the state with fourth-order Runge-Kutta integration.

2. Pendulums

Simple pendulum

With \(\mathbf r=(l\sin\theta,-l\cos\theta)\):

\[ T=\frac12ml^2\dot\theta^2,\qquad V=-mgl\cos\theta, \] \[ ml^2\ddot\theta+mgl\sin\theta=0,\qquad \ddot\theta=-\frac gl\sin\theta. \]

Double pendulum

The two angles are measured from the downward vertical. The bob positions are

\[ \mathbf r_1=(l_1\sin\theta_1,-l_1\cos\theta_1), \] \[ \mathbf r_2=\mathbf r_1+ (l_2\sin\theta_2,-l_2\cos\theta_2). \]
\[ T=\frac12(m_1+m_2)l_1^2\dot\theta_1^2+ \frac12m_2l_2^2\dot\theta_2^2+ m_2l_1l_2\dot\theta_1\dot\theta_2 \cos(\theta_1-\theta_2), \] \[ V=-(m_1+m_2)gl_1\cos\theta_1-m_2gl_2\cos\theta_2. \]

The equations are coupled because the kinetic energy contains both velocities. The solver solves the resulting \(2\times2\) system at every time step.

Swinging Atwood machine

With hanging coordinate \(r\) and swing angle \(\theta\):

\[ T=\frac12(M+m)\dot r^2+\frac12mr^2\dot\theta^2, \qquad V=Mgr-mgr\cos\theta, \] \[ (M+m)\ddot r-mr\dot\theta^2+ g(M-m\cos\theta)=0, \] \[ mr^2\ddot\theta+2mr\dot r\dot\theta+ mgr\sin\theta=0. \]

3. Springs

Elastic pendulum

Using radial extension \(r\) and angle \(\theta\), the bob is \(\mathbf r=(r\sin\theta,-r\cos\theta)\). Therefore

\[ T=\frac12m\left(\dot r^2+r^2\dot\theta^2\right), \qquad V=-mgr\cos\theta+\frac12k(r-l)^2. \]

4. Rolling systems

Disk on a slope

The slope direction is \(\hat p=(2,-1)/\sqrt5\), and the disk center is \(\mathbf c=r\hat n+x\hat p\). Rolling without slipping gives \(\omega=\dot x/r\), so

\[ T=\frac12\left(m+\frac Ir^2\right)\dot x^2,\qquad V=mg\frac{2r-x}{\sqrt5}, \] \[ \ddot x=\frac{mg}{\sqrt5(m+I/r^2)}. \]

Rolling disk pendulum

The rolling disk pendulum has coordinates \(x,\theta_1,\theta_2\). Its kinetic energy is the sum of translational and rotational energies of the ring, inner disk, and pendulum masses:

\[ T=\frac12M|\dot{\mathbf c}_M|^2+\frac12I_M\omega_M^2+ \frac12m_r|\dot{\mathbf c}_r|^2+\frac12I_r\omega_r^2+ \frac12m_p\left(|\dot{\mathbf c}_{p+}|^2+ |\dot{\mathbf c}_{p-}|^2\right). \]

Each spring contributes \(V_s=\frac12k(|\mathbf b-\mathbf a|-l_0)^2\), and gravity contributes \(mgy\). The simulator differentiates this complete expression symbolically rather than displaying its very long expanded equations.

5. Numerical integration and conservation

The simulation advances time in small substeps. For state \(z=(q,\dot q)\), it evaluates

\[ \dot z=f(z,t) \]

with classical fourth-order Runge-Kutta:

\[ z_{n+1}=z_n+\frac16(k_1+2k_2+2k_3+k_4), \] \[ k_1=hf(z_n,t_n),\quad k_2=hf(z_n+k_1/2,t_n+h/2), \] \[ k_3=hf(z_n+k_2/2,t_n+h/2),\quad k_4=hf(z_n+k_3,t_n+h). \]

For time-independent systems, total energy \(E=T+V\) should remain nearly constant; small changes come from numerical integration.

← Back to Mechanics