Math 157: Assignment 6

Assigned Friday, Feb. 6, 2009, due Friday, Feb. 13, 2009


Written Work

[1] Create a class diagram for the graphics classes you will be constructing for computational problem (a).

[2] Do problem 5.2 on page 106 of Blaha and Rumbaugh. It is expected you will read Chapter 5 before attempting the problem.

Computational Work

[Discussion/Preliminaries] The goal of this computational problem is to create a program that solves a 2D system of ODE's and then displays a phase plane plot of this solution. In particular, the program will display a line plot of a set of (x,y) data $ (x_k , y_k) \,, \, k = 1 \ldots N\,$ where each $(x_k , y_k)$ corresponds to the approximate solution value of the system of ODE's at time $t_k$. The supporting codes to create graphical output are contained in the QtConsoleGraphics repository from https://www.math.ucla.edu/~anderson/157support/ . Since we are creating a console application that uses Qt graphics, a special procedure will have to be followed in order to build the executable for this assignment. See "Creating a Visual Studio Console Application That Uses Qt Graphics" for information.

(a) Create a PlotData class that contains member functions for plotting the x-y data $ (x_k , y_k) \,, \, k = 1 \ldots N $ corresponding to an approximate solution of a 2D systems of ODE's. This class should implement its graphics member functions using the member functions of an associated instance of the UCdriver class. See the UCdriver class documentation for a list of the member functions.

The UCdriver methods assume that the plotting data is specified in the normalized region $[0,1] \times [0,1]\,$, so a principle task of the PlotData class is to transform input data with a specified range $[x_{min}, \, x_{max}] \times [y_{min}, \, y_{max}]\,$ into appropriate data for the UCdriver methods. Your class should be able to

You will have to decide how the output data, $ (x_k , y_k) \,, \, k = 1 \ldots N\,$, from the ODEsolver class will be passed to your plotting routines. Your class will be written using UCdriver methods, but at runtime you will associate with your program an instance of the extended class Qdriver. This extended class overrides the UCdriver methods and causes output to go to a dialog window. See slide #17 of "Graphics" for a sample of code structure to do this.





(b)
Create a console program that computes and then displays a phase plane plot of the solution to a 2D system of equations. This program will be a modification of the test code you created for assignment #4 and problem (a) above.

To avoid having to retype all of the input information when you run your program: Create a file of input data, run your program from the console and specify input to be taken from the data file using the input redirection operator < . For example, cd to the directory containing the program executable, create a file myInput.dat containing the required program input, then use the following command to run the program without prompts

Assign6.exe < myInput.dat

(c) To verify that you have a working code, use your code to solve and create a phase-plane plot of the van der Pol equation

$\qquad \qquad \begin{array}{rrl}
\dfrac{dx}{dt} & = & y \,\,\, \quad \qquad \qquad \qquad \quad
\;\;\;\;\;\;\;\;\;x(0)={1/2}\\ \, \\
\dfrac{dy}{dt} & = & (1-x^{\,2})\,y-x\;\;\;\;\;\;\;\;\;\;\;
\;\;\;\;\;\;\;\;y(0)={1/2}
\end{array}$

for time $t \in [0, 10]$.


What You Should Turn In

Hardcopy to be turned in

In an Assign6 subdirectory of your submit directory, place