0% found this document useful (0 votes)
19 views4 pages

POLYMATH5 ODE and Algebraic Equation Guide

POLYMATH5 is a Windows-based software for solving ordinary differential equations (ODEs) and nonlinear algebraic equations, useful for data analysis and reactor problems. The tutorial outlines how to input and solve a system of ODEs and a system of nonlinear equations, detailing the steps for defining variables and interpreting results. It provides examples of both types of problems, including initial conditions and expected outputs from the software.

Uploaded by

tatuxtats
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views4 pages

POLYMATH5 ODE and Algebraic Equation Guide

POLYMATH5 is a Windows-based software for solving ordinary differential equations (ODEs) and nonlinear algebraic equations, useful for data analysis and reactor problems. The tutorial outlines how to input and solve a system of ODEs and a system of nonlinear equations, detailing the steps for defining variables and interpreting results. It provides examples of both types of problems, including initial conditions and expected outputs from the software.

Uploaded by

tatuxtats
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

Common questions

Powered by AI

Configuration data from POLYMATH outputs can be cut and pasted into Excel, which provides more flexibility in displaying and further analyzing results. This ability allows users to leverage Excel's extensive data analysis tools, including graphing, sorting, and statistical functions, facilitating better insights and presentations of the computational results .

The initial guesses are critical in influencing the convergence of solutions in POLYMATH. The algorithm iterates from these initial values to find solutions. If the initial guess is not suitable, the method may not converge, or converge to a local solution rather than the global one. Different initial guesses may need to be tried to ensure correct convergence, particularly for equations representing conversion or mole fraction which typically need values between 0 and 1 .

To ensure convergence of nonlinear algebraic equations in POLYMATH, parameters such as max iterations, tolerance for variables (X), function values (F), and minimum tolerance should be adjusted. Increasing the number of maximum iterations allows more attempts for solution finding, while smaller tolerance values increase precision. Adjustments are necessary especially in complex and sensitive systems where convergence might otherwise fail .

To solve nonlinear algebraic equations in POLYMATH, the user must first enter the equations using the NLE interface, ensuring the right number of equations matches the number of unknowns. Initial guesses for the solving variables are necessary, and if the initial values fail to converge, different guesses can be tried. The system iteratively adjusts the guesses using a numerical method until the functions equate approximately to zero, demonstrating solution convergence .

In POLYMATH, variables are case-sensitive, treating different cases as unique identifiers. For example, 'x' and 'X' would be considered different variables. This requires users to be consistent and precise in their variable naming to avoid logical errors or unintended results during computation, reinforcing the need for careful equation setup .

Explicit equations in POLYMATH are used to define constants that can be referred to within the system of equations instead of using literal numerical values. This is especially useful for sensitivity analysis and reusability, as changes to parameter values can simply be made via these explicit definitions without altering the main differential or algebraic equations .

POLYMATH ensures precision in solving ODEs through careful control of the step size (h) and using a small truncation error tolerance (eps). The RKF45 method estimates errors at each step, allowing adaptive step size adjustments to not exceed the tolerance, ensuring numerical precision without unnecessary computation .

Defining constants as auxiliary equations instead of static numerical coefficients allows them to be altered individually without modifying the entire differential equation. This flexibility is beneficial for investigating the influence of individual parameters like rate constants, making it easier to conduct sensitivity analysis and adjust model conditions without re-entering the entire equation .

The RKF45 solver in POLYMATH, which stands for Runge-Kutta-Fehlberg 4th-5th order, is typically used due to its balance of accuracy and computational efficiency for many differential equations. However, for 'stiff' differential equations—those that require extremely small step sizes for certain solvers due to rapidly changing solutions—a more specialized solver may be necessary to handle the varying scales effectively, maintaining stability and reducing computation time .

In POLYMATH's differential equation solving, the variable 't' typically represents time, serving as the independent variable across which the differential equations are integrated. This is crucial for modeling dynamic systems such as batch and plug flow reactors, where changes over time are fundamental to understanding system behavior and responses .

You might also like