POLYMATH5 Tutorial
POLYMATH5 is a Windows-based computational package designed to solve systems of
ordinary differential equations (ODEs), systems of algebraic equations, and perform data
analysis using linear and nonlinear regression techniques. POLYMATH5 is available on
the computers in the Coady lab. Your textbook contains a CD-ROM, which also includes
POLYMATH which you can load on your own personal computer.
This tutorial describes how to use POLYMATH for two distinct problems:
(1) Systems of ordinary differential equations (ODE), integrating these equations are
required to solve the batch and plug flow reactor problems.
(2) Systems of nonlinear algebraic equations, which are common in both equilibrium
and CSTR problems.
(1) The ODE system we will solve is the following:
dx
= 2 x + 4 y − 5 xy
dt
dy
= x2 − 6y
dt
for the time domain: to = 0
tf = 1
and initial conditions: xo = 5
yo = 0
Start POLYMATH5 and click on the DEQ (Differential Equations) Button.
One important things to remember about POLYMATH is that it is case sensitive: It
regards x and X as two distinct variables.
The default independent variable is t. Enter the initial and final values for time in the
respective boxes. The default solver, RKF45, should be sufficient for most of the
problems encountered in class. The other options may be used for particularly “stiff” sets
of differential equations.
Click the “Add DE” button to add a differential equation:
The first differential equations above can be entered as follows:
d(x)/d(t)=k1*x+k2*y-k3*x*y
Also enter the initial value in the respective box.
Repeat the process to add the second differential equation as follows:
d(y)/d(t)=k4*x^2-k5*y
These are the differential equations. You will notice that after you enter these equations
the program tells you that k1, k2, k3, k4, & k5 are undefined variables. Define these
variables by clicking the “Add EE” button. These equations are called explicit or
auxiliary equations. For this problem the explicit equations are simply:
k1=2
k2=4
k3=5
k4=1
k5=6
Alternatively the differential equations could have been entered using the numerical
coefficients. In this case no auxiliary equations would have been required. The advantage
of using the constants is that they can be altered individually without the need to adjust
the differential equation. This can be useful to investigate the influence of individual
parameters such as rate constants.
After all your equations have been entered they will appear in the spreadsheet below.
You may click on individual lines and edit or delete them as you see fit. When all the
equations are entered correctly you will receive the Green light. At this point you may
solve the system of equations. There are 3 boxes with italicized titles: Table, Graph,
Report, which are the three types of output that you may generate. You need to select at
least one and may select all three. At this point hit the forward arrow box to solve the
problem. Windows will appear with the solution to your problem. The Report and Graph
outputs are displayed below. The Table is simply that. The values can easily be cut and
paste into Excel to allow more flexibility in displaying your results.
Report Window
POLYMATH 5.0 Results
05-15-2001
Calculated values of the DEQ variables
Variable initial value minimal value maximal value final value
t 0 0 1 1
x 5 1.7065667 5.0964961 1.9762745
y 0 0 1.7936432 0.6106665
k1 2 2 2 2
k2 4 4 4 4
k3 5 5 5 5
k4 1 1 1 1
k5 6 6 6 6
ODE Report (RKF45)
Differential equations as entered by the user
[1] d(x)/d(t) = k1*x+k2*y-k3*x*y
[2] d(y)/d(t) = k4*x^2-k5*y
Explicit equations as entered by the user
[1] k1 = 2
[2] k2 = 4
[3] k3 = 5
[4] k4 = 1
[5] k5 = 6
Independent variable
variable name : t
initial value : 0
final value : 1
Precision
Step size guess. h = 0.000001
Truncation error tolerance. eps = 0.000001
General
number of differential equations: 2
number of explicit equations: 5
Graph Window
The second example is a system of nonlinear algebraic equations (remember if you have
n unknowns, you better have n distinct equations to solve them):
x2 –xy = 5
y2+2xy = 7
Start POLYMATH5 and click on the NLE (Non-Linear algebraic Equations) Button.
Click the “Add NLE” button to add a differential equation:
The two algebraic equations above can be entered as follows:
f(x)= x^2-x*y-5
f(y)= y^2+2*x*y-7
Both equations need initial guesses, and I happened to choose x = y = 1. Remember that
the convergence depends on initial guess. If you don’t get a solution at first, simply try
another guess. For many of our problems the variables represent either conversion or
mole fraction, both of which must be 0 < X < 1, which makes initial guesses easier.
As above you may also enter explicit equations to define coefficients if you so choose.
After you have entered your equations hit the right arrow button to solve.
This will iterate the values of both x and y until f(x) = f(y) = 0. The POLYMATH report
follows. As you can see that final answers are x = 2.82 and y = 1.05, and these values
satisfy the equations to within ~ 10-12, which is pretty damn close to zero.
POLYMATH 5.0 Results
08-28-2001
NLES Solution
Variable Value f(x) Ini Guess
x 2.8199384 2.327E-12 1
y 1.04685 -1.167E-12 1
NLES Report (safenewt)
Nonlinear equations as entered by the user
[1] f(x) = x^2-x*y-5 = 0
[2] f(y) = y^2+2*x*y-7 = 0
Settings
Max iterations = 150
Tolerance F = 0.0000001
Tolerance X = 0.0000001
Tolerance min = 0.0000001
General
number of implicit equations: 2
number of explicit equations: 0