NONLINEAR MECHANICAL SYSTEMS CANONICAL TRANSFORMATION S AND NUMERICAL INTEGRATION Jacobi Canonical Transformations A Jacobi canonical transformations yields a Hamiltonian that depends on only one of the conjugate variable sets. Assume dependence on new momentum alone. H(p*,q*) = K(p*) ∂K(p*)/∂q* = 0 Thus dp*/dt = e* dq*/dt = ∂K(p*)/∂p* – f* The simple relation between effort and the rate of change of momentum is recovered in the new coordinates. Mod. Sim. Dyn. Sys. Transforms & Numerical Integration page 1 EXAMPLE: SIMPLE HARMONIC OSCILLATOR Hamiltonian 1 H(p,q) = 2(p2/I + q2/C) Hamilton's equations dq/dt = ∂H/∂p = p/I dp/dt = –∂H/∂q = q/C Change variables from old (q,p) to new (P,Q) Define Zo = IC and the generating function S(q,Q) = Zo(q2/2) cotQ The transformation equations are p = ∂S/∂q = Zoq cotQ P = –∂S/∂Q = Zo(q2/2)/sin2Q Mod. Sim. Dyn. Sys. Transforms & Numerical Integration page 2 Express the old variables in terms of the new p = 2P cosQ Zo q = 2P sinQ (1/ Zo ) Define ωo = 1/IC and the new Hamiltonian is H(P,Q) = ωo P = K(P) Hamilton’s equations in the new coordinates dQ/dt = ∂K/∂P = ωo dP/dt = –∂K/∂Q = 0 Their solution is Q(t) = ωo t + constant P(t) = constant Mod. Sim. Dyn. Sys. Transforms & Numerical Integration page 3 In essence this variable change has integrated the equations. As the product of P and Q has the units of action (energy by time) it is sometimes called a (simple harmonic) actional transformation. PHYSICAL INTERPRETATION: P is proportional to the total system energy. Its square root is proportional to oscillation amplitude. Q is the phase angle of the oscillations. Mod. Sim. Dyn. Sys. Transforms & Numerical Integration page 4 In general, finding Jacobi canonical transformations requires solving a non-trivial partial differential equation. A practical alternative is to separate the Hamiltonian into two parts, one with a known Jacobi canonical transform. H(p,q) = Hj(p,q) + Hn(p,q) Apply the known Jacobi canonical transformation H*(P,Q) = Hj*(P) + H*n(P,Q) Mod. Sim. Dyn. Sys. Transforms & Numerical Integration page 5 We may represent the second term as a set of canonical forces e*(P,Q) = –∂H*n/∂Q f*(P,Q) = –∂H*n/∂P The transformed equations become dP/dt = e*(P,Q) dQ/dt = ∂H*j/∂P – f*(P,Q) An advantage of this change of variables is that, in effect, it integrates the fundamental oscillatory mode of the solution. Mod. Sim. Dyn. Sys. Transforms & Numerical Integration page 6 EXAMPLE: SIMPLE PENDULUM For large amplitudes, the simple pendulum is a nonlinear oscillator. H(η,θ) = η2/2 + 1 – cos θ where θ angle with respect to the vertical η corresponding angular momentum Expand the cosine as a power series H(η,θ) = η2/2 + θ2/2 – θ4/4! + θ6/6! – ... The Hamiltonian is quadratic in momentum and displacement with additional terms in displacement of fourth power and higher. Mod. Sim. Dyn. Sys. Transforms & Numerical Integration page 7 Until the fourth power of the angle in radians becomes significant, the nonlinear pendulum may be treated as linear system with a Hamiltonian that is quadratic in momentum and displacement. For the quadratic terms have a knownJacobi canonical transformation: the simple harmonic actional. Split the Hamiltonian as follows H(η,θ) = η2/2 + θ2/2 + (1 – cosθ – θ2/2) H(η,θ) = K(η,θ) + N(η,θ) Mod. Sim. Dyn. Sys. Transforms & Numerical Integration page 8 Apply the simple harmonic actional θ = 2P sinQ η = 2P cosQ The Hamiltonian becomes H*(P,Q) = K*(P) + N*(P,Q) In the original variables, the system equations are dη/dt = –∂H/∂θ dθ/dt = ∂H/∂η In the new variables, the system equations become dP/dt = –∂N*/∂Q dQ/dt = 1 + ∂N*/∂P Mod. Sim. Dyn. Sys. Transforms & Numerical Integration page 9 Transformation does not change the value of either K or N. Use the chain rule on the original N which depends only on θ. ∂N*/∂Q = (∂N/∂θ) (∂θ/∂Q) ∂N*/∂P = (∂N/∂θ) (∂θ/∂P) ∂N/∂θ = sinθ – θ ∂θ/∂Q = 2P cosQ ∂θ/∂P = sinQ (1/ 2P ) The transformed equations become dP/dt = [ 2P sinQ – sin( 2P sinQ)][ 2P cosQ] dQ/dt = 1 + [sin( 2P sinQ) – 2P sinQ][sinQ (1/ 2P )] Mod. Sim. Dyn. Sys. Transforms & Numerical Integration page 10 Use the transformation equations to express the rates of change as a function of both old and new variables. dP/dt = (θ – sinθ)η dQ/dt = 1 + (sinθ – θ)θ/2P θ = 2P sinQ η = 2P cosQ What have we gained? The system equations are simpler in the old variables dη/dt = –sinθ dθ/dt = η In the new variables, the solution is far more stable numerically. Mod. Sim. Dyn. Sys. Transforms & Numerical Integration page 11 Simple Euler integration algorithm starting time 0 seconds, final time 50 seconds, time step 0.1 seconds. start from rest at an angle of 0.1 radians (≈6°) In old coordinates, simulation is unstable. Total system energy grows exponentially. Lagrangian formulation angle in radians 1 0.5 0 -0.5 -1 -1.5 0 5 10 15 20 25 30 time in seconds 35 40 45 50 35 40 45 50 Lagrangian formulation total energy 0.6 0.4 0.2 0 0 5 Mod. Sim. Dyn. Sys. 10 15 20 25 30 time in seconds Transforms & Numerical Integration page 12 In new coodinates, the simulation is stable. Total system energy variation: 5.6x10-7. Hamilton-Jacobi formulation angle in radians 0.1 0.05 0 -0.05 -0.1 0 5 10 15 total energy 35 40 45 50 35 40 45 50 Hamilton-Jacobi formulation -3 4.9962 20 25 30 time in seconds x 10 4.996 4.9958 4.9956 4.9954 0 5 Mod. Sim. Dyn. Sys. 10 15 20 25 30 time in seconds Transforms & Numerical Integration page 13 Perform the same integration using a third-order fixed-step Runge-Kutta algorithm. Lagrangian formulation angle in radians 0.1 0.05 0 -0.05 -0.1 0 5 10 15 35 40 45 50 35 40 45 50 Lagrangian formulation -3 5 20 25 30 time in seconds x 10 total energy 4.995 4.99 4.985 4.98 4.975 0 5 10 15 20 25 30 time in seconds Total energy, declines steadily by 2.1x10-5 over 50 seconds. Mod. Sim. Dyn. Sys. Transforms & Numerical Integration page 14 Hamilton-Jacobi formulation angle in radians 0.1 0.05 0 -0.05 -0.1 0 5 10 15 total energy 35 40 45 50 35 40 45 50 Hamilton-Jacobi formulation -3 4.9958 20 25 30 time in seconds x 10 4.9958 4.9958 4.9958 4.9958 0 5 10 15 20 25 30 time in seconds Total energy also decreases, but by 2.3x10-10 — a hundred thousand time less. Mod. Sim. Dyn. Sys. Transforms & Numerical Integration page 15 Start the pendulum from rest at 1 radian (≈57°) and use the same integration algorithm and parameters Lagrangian formulation angle in radians 1 0.5 0 -0.5 -1 0 5 10 15 20 25 30 time in seconds 35 40 45 50 35 40 45 50 35 40 45 50 35 40 45 50 total energy Lagrangian formulation 0.4595 0.459 0 5 10 15 20 25 30 time in seconds Hamilton-Jacobi formulation angle in radians 1 0.5 0 -0.5 -1 0 5 10 15 20 25 30 time in seconds Hamilton-Jacobi formulation total energy 0.4597 0.4597 0.4596 0.4596 0 5 10 15 20 25 30 time in seconds Again, the transformed equations produce a smaller decline in energy, though the difference is less pronounced — 8.8x10-4 vs. 1.5x10-4. Mod. Sim. Dyn. Sys. Transforms & Numerical Integration page 16 Start from rest at 5° off vertically upright (3.05 radians) and use the same integration algorithm and parameters Lagrangian formulation angle in radians 4 2 0 -2 -4 0 5 10 15 20 25 30 time in seconds 35 40 45 50 35 40 45 50 Lagrangian formulation total energy 1.9975 1.997 1.9965 1.996 1.9955 0 5 10 15 20 25 30 time in seconds Hamilton-Jacobi formulation angle in radians 4 2 0 -2 -4 0 5 10 15 20 25 30 time in seconds 35 40 45 50 35 40 45 50 Hamilton-Jacobi formulation total energy 1.996 1.995 1.994 1.993 1.992 0 5 10 15 20 25 30 time in seconds Now the original formulation is unstable — energy increases by 1.3x10-3 in 50 seconds. The transformed equations yield a decline of energy of 3.1x10-3. Mod. Sim. Dyn. Sys. Transforms & Numerical Integration page 17 Start from the same initial conditions but use MATLAB’s ode23, a 3rd-order adaptive Runge-Kutta algorithm with error tolerance of 1.0x10-3 Lagrangian formulation angle in radians 30 20 10 0 -10 0 5 10 15 20 25 30 time in seconds 35 40 45 50 35 40 45 50 total energy Lagrangian formulation 2.05 2 0 5 10 15 20 25 30 time in seconds Now the steady increase in computed total energy in the original formulation results in a major departure of the computed angle from what it should be — the simulation claims that after one oscillation the pendulum will spin continuously in one direction. Mod. Sim. Dyn. Sys. Transforms & Numerical Integration page 18 Hamilton-Jacobi formulation angle in radians 4 2 0 -2 -4 0 5 10 15 20 25 30 time in seconds 35 40 45 50 35 40 45 50 Hamilton-Jacobi formulation 2 total energy 1.98 1.96 1.94 1.92 1.9 0 5 10 15 20 25 30 time in seconds The transformed equations do not exhibit this behavior, though the computed energy declines substantially (9.3x10-2 in 50 seconds). Mod. Sim. Dyn. Sys. Transforms & Numerical Integration page 19 POINTS: • Never believe anything you get from a computer. Find some way of cross checking the results. One effective method is to compute a known invariant, in this case energy. • The equations in the original variables may look simpler, but that is deceptive. In fact the transformed equations have been partially integrated by the transformation and so present a less demanding task to the integration algorithm. • A little analysis up front can have a dramatic effect on the accuracy of numerical computations. Mod. Sim. Dyn. Sys. Transforms & Numerical Integration page 20