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:
where f(y,t) is a continuous scalar function of 2 variables. We want to be able to put initial conditions in with a mouse and XPP prvents this if one of the axes is time, so we will study a two-dimensional system that is identical to the above equation:
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 f(y,t)=y*(1-y) param a,b,c,d ds/dt=1 dy/dt=f(y,s) @ xp=s,yp=y,xlo=-5,xhi=20,ylo=-2,yhi=2,total=25 doneThe 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 -- ignore everything below. If you are
running this from within Netscape, click on the equations above and
XPP should load up. Netscape generates a bunch of stuff that you can
click OK on to dispose of. If you are running this externally from
Netscape, then you have to start XPP from the command line. You should
first copy the file to your directory. Type:
cp ~phase/class/first.ode .Don't forget the dot. Now type
~phase/xpp first.ode
If you have the Windows version, download the file to your PC and then click on the WinPP icon. Then use the directory gadget to load in the ODE. It is useful to make a seperate directory for all your files.
If all went well, you should have a window for XPP as well as a bunch of little other windows. If you get a message:
(r)un (c)d (l)istthen you haven't gotten the file first.ode in your directory. Type Ctrl C to get out and make sure you have the program.
ls first.odeto check if it is there. If not, try to get it again. Or just copy the file into your editor and save it as first.ode.
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. (In Windows click on Run
Mouse).
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 or click on STOP in Windows.
If you click below y=0 an OUT OF BOUNDS
error will be generated since y goes beyond a limit that you
can set. XPP forgets trajectories when new ones are created. To keep
them on the screen click on (Graphics) (Freeze) (Autofreeze). In
Windows Click on Graphics Keep Curve and check Autofreeze.
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. (Graphics Keep curve Delete
all in Windows). Freeze 3 or 4 trajectories
using different initial conditions. Now click on (Dir. field/Flow)
(Scaled Direct Field) and accept 10 for the grid. (Use Phaseplane Direction
field in Windows). A field of tangents is
drawn. Now save the whole thing in a postscript file by choosing
(Graphics) (Postscript) and choose a file name. (In Windows, click on
File Print) The default is
first.ode.ps
.
NOTE If you are running from within Netscape, do not accept the default. Instead backspace over the name and type whatever you want to call it -- otherwise it will not be put in your directory.
You can now print it out if you want.
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=.01 and you will get a nice trajectory. Another way to change the initial conditions is to click on the iconified window labeled IC and change the numbers in the windows corresponding to the two variables. Click (OK) to accept the changes. Use this way for Windows! Freeze the solution with the (Graphics) (Freeze) (Freeze), but this time change the color to 1 before clicking (Ok). (In Win95, click on Graphics Keep curve. Click on Add New to the dialog box and choose Red as the color; click OK.) Now click on (nUmerics) and a new menu appears. Change (Dt) by clicking on it and changing it from 0.05 to 2.0. Click on (Escape). In Win95, choose Numerics Int.par to get a dialog box and change Delta-T; then click OK.) and click (Initialconds) (Go) to reintegrate. Notice that the trajectory is pretty good. Freeze this in color 2. Now click on (nUmerics) again and change the (Method) from the default Runge-Kutta to the (Modified Euler) which is Heun's method. Click (Escape) to the main menu and click (Initialconds) (Go) to get another trajectory. This one is not so good. Freeze it in color 3. Finally change the method of integration to Euler by clicking (nUmerics) (Method) (Euler) and (Escape) to the main menu and reintegrate. It really sucks -- note the little zig-zags.
You can skip this and come back later. For some real fun enter the numerics menu and change the total amount of time (Total) to 400. Change (Dt) to 3. Change (Bounds) to 1000. (Escape) to the main menu. Click (Window) (Window) and make Xhi=400. and click (Ok) to make the big window. Solve the equations by clicking (Initialconds) (Go). This is a chaotic time series. Now change the window back by clicking (Window) (Window) and change Xhi to 20. Go back to the numerics menu and change (Total) to 20.
y*(1-y^2)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. What are the fixed points? Which are stable? Do all trajectories end up at fixed points?
dy/dt = -y + .5*sin(y)
dy/dt = -y + sin(y)
dy/dt = -y + 2*sin(y)
dy/dt = -y + exp(-y)
draw the direction fields and solve numerically. By looking at the asymptotic limit for large t estimate the equilibrium point.
Try problems 4,5,6 (page 15) in your book. Make sure you make the
window the same as you are told in the book. (Use the Window
Window
command. To run a range of initial
conditions (eg for problem 5), click on Initconds Range
and fill in the dialog as follows:
Here is a really weird equation to fool with:
dy/dt = y*sin(1/y)
Look at several trajectories. Draw direction fields. How many equilibria do you find? Now use the (Window) (Window) command of XPP to change (Yhi) to 0.1 and (Ylo) to -0.1. Draw more trajectories in this window and the direction fields. Did you find more fixed points? Can you compute them analytically? Window it so that the (Yhi) is 0.01 and (Ylo) is -0.01. Try to compute a trajectory. Whoa -- this doesn't look right does it? Why is it failing? Try changing (Dt) in the (nUmerics) menu to something smaller (say 0.01). Now integrate a bunch of trajectories. It looks like everything is a fixed point!