A quick look at XPP

XPP/WinPP is a software program designed to solve systems of differential equations. Up to 3000 ODEs can be solved at one time. We will mainly consider systems with one and two dimensions. Here we will concentrate on nonautonomous systems with 1 variable.

The basic unit for XPP is a file called an ode file that tells XPP the parameter and variable names and other named things. These files are editable ascii files. Use your favorite editor! For class, however, I will give you most of the files so you won't have to learn an editor.

We will look at the differential equation:

dy/dt = f(t,y)

where f(t,y) is a continuous scalar function of 2 variables. We want to be able to put initial conditions in with a mouse and XPP prevents this if one of the axes is time, so we will study a two-dimensional system that is identical to the above equation:

ds/dt = 1
dy/dt = f(s,y)

Now s is a time-like variable whose solution is s = t+C , a shifted version of t. The ODE file for this is

# a generic first order equation with parameters 
param a,b,c,d
@ xp=s,yp=y,xlo=-5,xhi=20,ylo=-10,yhi=10,total=25
The first line is a comment (all comments start with # ). A function of y and t is defined. Some parameter names are given and since they are not set to any value assume the value of 0. The differential equations are then given. The line beginning with @ tells XPP some things about plotting etc. The last line tells XPP that this is it we are done loading.
Here is how to run this:
  1. If using Windows or Mac, start your X server
  2. Copy the above text into a file called first.ode or download it
  3. In Windows, drag the file first.ode and drop it into the xpp.bat
  4. In Mac and Linux, I just call xppaut from the command line: xppaut first.ode but you can also do drag and drop.

If this worked (a miracle ?), then you should have the good old ugly XPP interface on the screen.
The main window shows y along the vertical axis and s which is just t along the horizontal. Zero axes are drawn.

To Exit XPP, click on (File) (Quit) and answer (Yes). To turn off the *%#!!$$ Bell, click on (File) (Bell off).

Now the fun begins. The first equation is one from class:

dy/dt = t^2-y^2

XPP lets you use keyboard or mouse shortcuts. Click on (Initialconds) (Mouse) and then click the mouse somewhere in the upper right quadrant. A trajectory will be drawn. Do it again several times in different locations. Better yet choose Mice from the options and just keep clicking away. Type ESC to exit this mode You may get an OUT OF BOUNDS error; dont worry about it. XPP forgets trajectories when new ones are created. To keep them on the screen click on (Graphics) (Freeze) (Autofreeze). In Now when you reintegrate the equations, the old curve will be saved along with the new one. Up to 20 trajectories can be frozen. Click on (Graphics) (Freeze) (Remove all) to get rid of the frozen curves. Freeze 3 or 4 trajectories using different initial conditions. Now click on (Dir. field/Flow) (Scaled Direct Field) and accept 10 for the grid. A field of tangents is Now save the whole thing in a postscript file by choosing (Graphics) (Postscript) and choose a file name. The default is first.ode.ps . Note Apparently Windows doesn't do Postscript, so that instead, you can click on Ctrl PrtSc and grab the XPP window. Paste this into a word document and then print this.

Looking at the values

Click anywhere in the graphics window and hold down the mouse as you move it. The bottom of the window tells you the x-y coordinates. A better way to see the values of the variables is the Data Browser. Click on the label Data on the main window. This brings up a window that has columns of number corresponding to the values of the variable as different times. Click on the top bar of the Data Viewr and then use the mouse or the arrow keys to scroll through the numbers. Click on the button labeled (End) to go to the end. If the solution went to some asymptotic limit, this will be it and will be a fixed point. Click on (Home) to get the starting point. Click on the main XPP graphics window when you are finished looking at the numerical values.

If you have frozen a bunch of graphs, get rid of them now with the (Graphics) (Freeze) (Remove all) sequence. Turn off the Auto-freeze. Choose (Initial conds) (New) and make s=0 and y=0 and you will get a nice trajectory. Another way to change the initial conditions is to click on the button labeled IC and change the numbers in the windows corresponding to the two variables. Click (OK) to accept the changes. This looks like it is nearly y=t . Can you prove this? (It is not homework, it is a challenge.)

Changing the view

Click on (View) (2D) and change the min and max of the axes. Then click (Ok).

Changing the equation

Click on (File) (Edit) (Function). You should get a window with f(t,y) in it. Delete it and replace it with
Click on (Ok). Draw the direction fields for this model. (First erase the screen with (Erase). Use the (Initialconds) (Mouse) option to choose a bunch of initial conditions. Where do all roads lead to? Can you prove this?

Onion model from class

  1. Load first.ode into XPP.
  2. Click on (View) (2D) and make the window (-6,6) x (-6,6)
  3. (File) (Edit) (RHS) Change the ds/dt to 1-y^2
  4. Change the dy/dt to -s^2 and clik (OK).
  5. Click on (Dir Fld.) (Flow) and accept 10 by pressing (Enter). Many trajectories will be drawn.
  6. Click on (Kinescope) (Capture). This grabs the screen.
  7. Click on (Kinescope) (Save) and choose gif format. Accept the default file name.
  8. Somewhere on your computer (probably the same directory as first.ode) is a file called frame_0.gif This is a GIF file which you can import into any program.