Part G: Numerical Integration and Visualization
Exercises
The dynamics homework this week asks you to explore various two-dimensional
maps and ODEs and the behaviors they produce. Use the simulation and display
programs introduced in this part of the tutorial for these problems by
modifying them appropriately. For the ODE problems, use the Runge-Kutta
integrator that you are asked to write below.
-
Write a 3D fourth-order Runge-Kutta integrator. Make it a function
RK3DIntegrator() that you can call, passing in the ODE
functions to be integrated and other simulation parameters, such as
the number of time steps to integrate over and the size of the time step.
Hint: Start with the 2D Runge-Kutta integrator discussed in class
(and on the class website) and extend it to three variables. Recall the
Lecture Notes on numerical integration, which describe the 3D
Runge-Kutta method.
-
Modify the MayaVi program
LorenzODE.py so
that its Euler integrator is a function Euler3DIntegrator() that
is called with the ODEs and simulation parameters, as above.
Hint: If you are having trouble running MayaVi, then,
as an alternative, modify the matplotlib version of the Lorenz program
LorenzODE.2d.py.
-
Integrate the 3D fourth-order Runge-Kutta integrator RK3DIntegrator()
into the above program in such a way that you can easily
switch between the Euler and Runge-Kutta integrators. That is, have the
simulator program call one or the other integrator using a generic
ODEIntegrator() function that is set appropriately to one
or the other integrator function.
-
Graphically compare the accuracy of the Euler and Runge-Kutta methods for the
Lorenz simulation. That is, compare them at the same integration time-step
size. How do the solutions differ? How would you convince yourself (or others)
that one is more accurate than another?
Hint: Recall the similar comparison that we did in the programming
lab between using the Euler, improved Euler, and Runge-Kutta
methods for 1D ODEs.
-
Two-dimensional map orbit tool: Make a collection of two-dimensional map
functions (investigated last week) that can be used by a general 2D map orbit
display program. Do this by making a library that includes all of the
two-dimensional map functions. Store this in a separate *.py file.
Have the program load this library (like any module).
Modify the program so that where it called the Henon map
function, it instead calls a generic TwoDMap() function with the
appropriate number of parameters. Also, include the various
defaults (parameters, initial conditions, and plot labels).
Hint: Recall that we did an analogous task for 1D map bifurcation
diagram tool in the previous programming lab exercises. See the steps
outlined there for details of what to include.
-
Do this same generalization with the ODE programs, so that you can easily
switch between different sets of ODEs, including Lorenz and Rossler ODEs.
Table of Contents