Vibration ODEs
1.6 Energy Considerations
solutions are just the real part of the expressions in polar form:
unDI.1C!2t2/n=2cos.ntan1.!t //; (1.44) vnD !I.1C!2t2/n=2sin.ntan1.!t // : (1.45) The expression .1C!2t2/n=2causes growth of the amplitude, since a number greater than one is raised to a positive exponentn=2. We can develop a series expression to better understand the formula for the amplitude. Introducingp D
!tas the key variable and usingsympygives
>>> from sympy import *
>>> p = symbols(’p’, real=True)
>>> n = symbols(’n’, integer=True, positive=True)
>>> amplitude = (1 + p**2)**(n/2)
>>> amplitude.series(p, 0, 4) 1 + n*p**2/2 + O(p**4)
The amplitude goes like1C1
2n!2t2, clearly growing linearly in time (withn).
We can also investigate the error in the angular frequency by a series expansion:
>>> n*atan(p).series(p, 0, 4) n*(p - p**3/3 + O(p**4))
This means that the solution foruncan be written as unD
1C1
2n!2t2CO.t4/
cos
!t1
3!tt2CO.t4/
: The error in the angular frequency is of the same order as in the scheme (1.7) for the second-order ODE, but the error in the amplitude is severe.
byu0and integrating from0toT: ZT 0
u00u0dtC ZT 0
!2uu0dtD0 :
Observing that
u00u0D d dt
1
2.u0/2; uu0D d dt
1 2u2; we get
ZT 0
d dt
1
2.u0/2C d dt
1 2!2u2
dtDE.T /E.0/D0;
where we have introduced
E.t /D 1
2.u0/2C1
2!2u2: (1.46)
The important result from this derivation is that the total energy is constant:
E.t /DE.0/ : E.t/is closely related to the system’s energy
The quantityE.t /derived above is physically not the mechanical energy of a vibrating mechanical system, but the energy per unit mass. To see this, we start with Newton’s second lawF Dma(F is the sum of forces,mis the mass of the system, anda is the acceleration). The displacementuis related toathrough aDu00. With a spring force as the only force we haveF D ku, wherekis a spring constant measuring the stiffness of the spring. Newton’s second law then implies the differential equation
kuDmu00 ) mu00CkuD0 :
This equation of motion can be turned into an energy balance equation by finding the work done by each term during a time intervalŒ0; T . To this end, we multiply the equation byduDu0dtand integrate:
ZT 0
muu0dtC ZT
0
kuu0dtD0 :
The result is
E.t /Q DEk.t /CEp.t /D0;
where
Ek.t /D 1
2mv2; vDu0; (1.47)
is thekinetic energyof the system, and Ep.t /D 1
2ku2 (1.48)
is thepotential energy. The sumE.t /Q is the total mechanical energy. The deriva- tion demonstrates the famous energy principle that, under the right physical circumstances, any change in the kinetic energy is due to a change in potential energy and vice versa. (This principle breaks down when we introduce damping in the system, as we do in Sect.1.10.)
The equationmu00CkuD0can be divided bymand written asu00C!2uD0 for!Dp
k=m. The energy expressionE.t /D12.u0/2C12!2u2derived earlier is thenE.t /=m, i.e., mechanical energy per unit mass.Q
Energy of the exact solution Analytically, we haveu.t /DIcos!t, ifu.0/DI andu0.0/D0, so we can easily check the energy evolution and confirm thatE.t / is constant:
E.t /D 1
2I2.!sin!t/2C1
2!2I2cos2!t D1
2!2.sin2!tCcos2!t/D1 2!2: Growth of energy in the Forward Euler scheme It is easy to show that the energy in the Forward Euler scheme increases when stepping from time levelntonC1.
EnC1D1
2.vnC1/2C1
2!2.unC1/2 D1
2.vn!2t un/2C1
2!2.unCt vn/2 D.1Ct2!2/En:
1.6.2 An Error Measure Based on Energy
The constant energy is well expressed by its initial valueE.0/, so that the error in mechanical energy can be computed as a mesh function by
enED 1 2
unC1un1 2t
2
C1
2!2.un/2E.0/; nD1; : : : ; Nt1; (1.49) where
E.0/D 1 2V2C1
2!2I2;
ifu.0/DI andu0.0/DV. Note that we have used a centered approximation to u0:u0.tn/ŒD2tun.
A useful norm of the mesh functioneEn for the discrete mechanical energy can be the maximum absolute value ofeEn:
jjeEnjj`1 D max
1n<NtjenEj:
Alternatively, we can compute other norms involving integration over all mesh points, but we are often interested in worst case deviation of the energy, and then the maximum value is of particular relevance.
A vectorized Python implementation ofeEn takes the form
# import numpy as np and compute u, t dt = t[1]-t[0]
E = 0.5*((u[2:] - u[:-2])/(2*dt))**2 + 0.5*w**2*u[1:-1]**2 E0 = 0.5*V**2 + 0.5**w**2*I**2
e_E = E - E0
e_E_norm = np.abs(e_E).max()
The convergence rates of the quantitye_E_normcan be used for verification.
The value ofe_E_normis also useful for comparing schemes through their ability to preserve energy. Below is a table demonstrating the relative error in total energy for various schemes (computed by thevib_undamped_odespy.pyprogram). The test problem isu00C42u D 0withu.0/ D 1andu0.0/ D 0, so the period is 1 andE.t /4:93. We clearly see that the Crank-Nicolson and the Runge-Kutta schemes are superior to the Forward and Backward Euler schemes already after one period.
Method T t maxˇˇeEnˇˇ=e0E
Forward Euler 1 0.025 1:678100
Backward Euler 1 0.025 6:235101
Crank-Nicolson 1 0.025 1:221102
Runge-Kutta 2nd-order 1 0.025 6:076103
Runge-Kutta 4th-order 1 0.025 8:214103
However, after 10 periods, the picture is much more dramatic:
Method T t maxˇˇeEnˇˇ=e0E
Forward Euler 10 0.025 1:788104
Backward Euler 10 0.025 1:000100
Crank-Nicolson 10 0.025 1:221102
Runge-Kutta 2nd-order 10 0.025 6:250102
Runge-Kutta 4th-order 10 0.025 8:288103
The Runge-Kutta and Crank-Nicolson methods hardly change their energy error withT, while the error in the Forward Euler method grows to huge levels and a relative error of 1 in the Backward Euler method points toE.t / ! 0ast grows large.
Running multiple values oft, we can get some insight into the convergence of the energy error:
Method T t maxˇˇenEˇˇ=e0E
Forward Euler 10 0.05 1:120108
Forward Euler 10 0.025 1:788104
Forward Euler 10 0.0125 1:374102
Backward Euler 10 0.05 1:000100
Backward Euler 10 0.025 1:000100
Backward Euler 10 0.0125 9:928101
Crank-Nicolson 10 0.05 4:756102
Crank-Nicolson 10 0.025 1:221102
Crank-Nicolson 10 0.0125 3:125103
Runge-Kutta 2nd-order 10 0.05 6:152101
Runge-Kutta 2nd-order 10 0.025 6:250102
Runge-Kutta 2nd-order 10 0.0125 7:631103
Runge-Kutta 4th-order 10 0.05 3:510102
Runge-Kutta 4th-order 10 0.025 8:288103
Runge-Kutta 4th-order 10 0.0125 2:058103
A striking fact from this table is that the error of the Forward Euler method is re- duced by the same factor astis reduced by, while the error in the Crank-Nicolson method has a reduction proportional tot2(we cannot say anything for the Back- ward Euler method). However, for the RK2 method, halvingtreduces the error by almost a factor of 10 (!), and for the RK4 method the reduction seems propor- tional tot2only (and the trend is confirmed by running smaller time steps, so for tD3:9104the relative error of RK2 is a factor 10 smaller than that of RK4!).