284
8 Solving Ordinary Differential Equations
by the Odespy software. Let the problem parameters a and b be arguments to the
function specifying the derivative. Use 100 time intervals in [0, T ] and plot the
solution when a = 2, b = 1, T = 6/a.
Filename: odespy_demo.py.
Exercise 8.22: Set up a Backward Euler Scheme for Oscillations
Write the ODE u + ω 2 u = 0 as a system of two first-order ODEs and discretize
these with backward differences as illustrated in Fig. 8.22. The resulting method is
referred to as a Backward Euler scheme. Identify the matrix and right-hand side of
the linear system that has to be solved at each time level. Implement the method, either from scratch yourself or using Odespy (the name is odespy.BackwardEuler).
Demonstrate that contrary to a Forward Euler scheme, the Backward Euler scheme
leads to significant non-physical damping. The figure below shows that even with
60 time steps per period, the results after a few periods are useless:
Filename: osc_BE.py.
Exercise 8.23: Set up a Forward Euler Scheme for Nonlinear and Damped
Oscillations
Derive a Forward Euler method for the ODE system (8.68)–(8.69). Compare
the method with the Euler-Cromer scheme for the sliding friction problem from
Sect. 8.4.11:
1. Does the Forward Euler scheme give growing amplitudes?
2. Is the period of oscillation accurate?
3. What is the required time step size for the two methods to have visually
coinciding curves?
Précédent

- 304/350

Suivant