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(x,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:
# a generic first order equation with parameters param a,b,c,d ds/dt=1 dx/dt=x*(1-x) @ xp=s,yp=x,xlo=-5,xhi=20,ylo=-2,yhi=2 doneThe first line is a comment (all comments start with
#). A function of x 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
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 iconified windows. If you get a message:
* (r)ead or (c)reatethen you haven't gotten the file first.ode in your directory. Type
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
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 x=0 an OUT OF BOUNDS
error will be generated since x 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)
(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
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 x=.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.
x*(1-x^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?
dx/dt = -x + .5*sin(x)
dx/dt = -x + sin(x)
dx/dt = -x + 2*sin(x)
dx/dt = -x + exp(-x)
draw the direction fields and solve numerically. By looking at the asymptotic limit for large t estimate the equilibrium point.
Here is a really weird equation to fool with:
dx/dt = x*sin(1/x)
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!