Non-linear Differential Equations of Motion for tutorial2x.py
Provided herein is the wxMaxima derivation of a discrete state representation in the form Y' = Ainv*G(y,y') for non-linear differential equations of motion of the double pendulum system described for problem 6.4 presented on page 276 of reference [1].
References:
[1] Greenwood, Donald T., "Principles of Dynamics". Englewood Cliffs, N.J.: Prentice-Hall, Inc., 1965.
The following two cells present the non-linear differential equations of motion given on page 505 of reference [1] as solution (a) to problem 6-4 presented on page 276 of same reference.
--> | m·l^2·((3+2·cos(φ))·'diff(θ,t,2)+(1+cos(φ))·'diff(φ,t,2)−sin(φ)·('diff(φ,t,1)^2+2·'diff(θ,t,1)·'diff(φ,t,1)))+m·g·l·(2·sin(θ)+sin(θ+φ))=0; |
--> | m·l^2·((1+cos(φ))·'diff(θ,t,2)+'diff(φ,t,2)+'diff(θ,t,1)^2·sin(φ))+m·g·l·sin(θ+φ)=0; |
This pair of differential equations are expanded to group terms containing 2nd derivatives of Theta and Phi in order to transform the above two equations into the form A*Y' = G(y,y').
--> | expand(m·l^2·((3+2·cos(φ))·'diff(θ,t,2)+(1+cos(φ))·'diff(φ,t,2)−sin(φ)·('diff(φ,t,1)^2+2·'diff(θ,t,1)·'diff(φ,t,1)))+m·g·l·(2·sin(θ)+sin(θ+φ))); |
--> | expand(m·l^2·((1+cos(φ))·'diff(θ,t,2)+'diff(φ,t,2)+'diff(θ,t,1)^2·sin(φ))+m·g·l·sin(θ+φ)); |
The elements of the A matrix are coefficients of terms containing 2nd derivatives of Theta and Phi as presented below.
--> |
A: matrix( [2·l^2·m·cos(φ)+3·l^2·m,l^2·m·cos(φ)+l^2·m], [l^2·m·cos(φ)+l^2·m,l^2·m] ); |
The Y' matrix contains 2nd derivative terms for the state variables Theta and Phi as such.
--> |
Yprime: matrix( [('diff(θ,t,2))], [('diff(φ,t,2))] ); |
The G matrix contains remaining terms of the differential equations of motion which do not contain 2nd derivatives of Theta and Phi; moved to the right side of the equality sign.
--> |
G: −1·matrix( [g·l·m·sin(φ+θ)−l^2·m·sin(φ)·('diff(φ,t,1))^2−2·l^2·m·('diff(θ,t,1))·sin(φ)·('diff(φ,t,1))+2·g·l·m·sin(θ)], [g·l·m·sin(φ+θ)+l^2·m·('diff(θ,t,1))^2·sin(φ)] ); |
The expression A*Y' = G(y,y') can be rearranged to solve for Y' by multiplying both sides by the inverse of matrix A to yield Y' = Ainv*G(y,y'). But first, matrix A can be simplified by factoring and dividing by the m*l^2 term present in each element. Note matrix G(y,y') must also be divided by the same m*l^2 term.
Factoring matrix A, dividing by m*l^2, inverting and expanding yields the following expression for Ainv.
--> | Ainv:expand(invert(factor(A)/(m·l^2))); |
--> | factor(Ainv); |
Note the expression for matrix Ainv can be further simplified by moving the common element denominator term outside the matrix.
Factoring matrix G and dividing by m*l^2 yields the following expression for G.
--> | factor(G)/(m·l^2); |
The above expressions for matrix Ainv and G are implemented for the non-linearized differential equations of motion in the dotS function of the PyODE double pendulum simulation modeled in the tutorial2x.py Python script.