Polymath Tutorial

34
Polymath Tutorial

description

Polymath

Transcript of Polymath Tutorial

Page 1: Polymath Tutorial

Polymath Tutorial

Page 2: Polymath Tutorial

Polymath Capabilities• Linear Equations Solver

• Nonlinear Equations Solver

• Differential Equations Solver

• Regression – Linear & Polynomial

– Data Table

– Multiple Linear or Multiple Nonlinear Regression

• Additional Capabilities– Export to Excel

– Calculator and unit conversion tools

– Polymath Export to Matlab (see help Menu for more information)

Page 3: Polymath Tutorial

Today’s Class

• Provide information on Polymath– How to open and use the software

• Learn how to input and solve nonlinear and differential equations– Provide step-by-step instructions so you can practice

and compare results

• Address the question: Why learn another software program?

Page 4: Polymath Tutorial

Starting Polymath1. Open Polymath Fogler from the start menu.

Page 5: Polymath Tutorial

Navigating the Menu

1. New program2. Open file3. Open recent file4. Save file5. Cut6. Copy7. Paste8. Delete9. Find10. Find and replace11. Solve system of linear equations12. Solve system of nonlinear equations

13. Solve system of ODEs14. Regress and analyze data15. Calculator16. Unit converter17. Scientific constants18. Setup preferences19. Help

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

Page 6: Polymath Tutorial

For more information: Help Menu

Page 7: Polymath Tutorial

Help Menu

Page 8: Polymath Tutorial

Example 1: Nonlinear Equation SolverConsider the following set of equations:

k·CA12 = v·(CA0-CA1)/Vk·CA22 = v·(CA1-CA2)/V

where k = 0.075, v = 30, CA0 = 1.6, and CA2 = 0.2 CA0.

Therefore, we have two remaining variables: variables CA1 and V.

We will use initial estimates: CA1=1 and V=300.

How do we do this in Polymath?

Page 9: Polymath Tutorial

Nonlinear Equation Solver

Rearrange:

0 = k·CA12 – v(CA0 - CA1)/V 0 = k·CA22 – v(CA1-CA2)/V

In Polymath, the appropriate forms for these equations are:

f(CA1) = k·CA12 – v(CA0 - CA1)/V = 0f(V) = k·CA22 – v(CA1-CA2)/V = 0

Can f(CA1) and f(V) be switched?

Page 10: Polymath Tutorial

1. Open a new sheet by clicking on the blank sheet in the upper corner.2. Open Nonlinear Equations

Page 11: Polymath Tutorial

3. In the upper left corner, click the f(x)+ button. This will allow you to enter one of the two equations.4. A new window will open. 5. Type in the first equation as shown before.

Page 12: Polymath Tutorial

3. In the upper left corner, click the f(x)+ button. This will allow you to enter one of the two equations.4. A new window will open. 5. Type in the first equation as shown before. 6. Press Done.

Page 13: Polymath Tutorial

7. You should see the new equation in the worksheet, as well as the comments.8. Enter the second equation by repeating the same steps.

Page 14: Polymath Tutorial

9. You will see the two equations and two initial value guesses in the worksheet.10. The red X displays the undefined variables.11. Enter the undefined variables by either 1) clicking on the x(=)+ button in the menu or 2) entering directly into the worksheet.

Page 15: Polymath Tutorial

9. You will see the two equations and two initial value guesses in the worksheet.10. The red X displays the undefined variables.11. Enter the undefined variables by either 1) clicking on the x(=)+ button in the menu or 2) entering directly into the worksheet.12. Now you should see a blue check mark indicating this system of equations can be solved. 13. To solve, click the purple arrow.

Page 16: Polymath Tutorial

Results:

CA1 initial guess: 1V initial guess: 300

CA1 = 0.602V= 1102

Page 17: Polymath Tutorial

Example 2: Solving a System of Ordinary Differential Equations (ODEs)This system may contain two types of equations: 1) first order ordinary differential equations and 2) explicit algebraic equations.

The differential equations must be entered in the following form: d(x)/d(t)= ……….

Here t is the independent variable and x is a dependent variable.

Auxiliary algebraic equations must be entered in the form: x = …….

For differential equations, an initial value is needed for all variables. A final value is needed for the independent variable.

Page 18: Polymath Tutorial

1. Open a new program (blank sheet)2. Select Differential Equations

Page 19: Polymath Tutorial

3. Select the d(x)+ button to add a new differential equation.

Page 20: Polymath Tutorial

What should we solve?

Series Reaction: A B C

Using Polymath, we can monitor the conversion of A, the formation (and disappearance) of B, and the formation of C.

Species Balances:

Let’s solve this series of differential equations.

k1 k2

Aktd

Ad*1

)(

)( BkAk

td

Bd*2*1

)(

)( Bk

td

Cd*2

)(

)(

Page 21: Polymath Tutorial

4. Select the d(x)+ button to add a new differential equation.

Page 22: Polymath Tutorial

5. Add the three equations with the following initial parameters: A(0)=1, B(0)=0, C(0)=06. We still have two undefined variables: k2 and k17. Enter k1 as 1 and k2 as 2.

Page 23: Polymath Tutorial

5. Add the three equations with the following initial parameters: A(0)=1, B(0)=0, C(0)=06. We still have two undefined variables: k2 and k17. Enter k1 as 1 and k2 as 2.

We have an error. We need to enter the initial and final values for our independent variable (t).

Page 24: Polymath Tutorial

8. To add the final values for t, select Edit followed by Define Initial and Final values…9. Then enter the initial and final values for t: 0 and 3.

Page 25: Polymath Tutorial

8. To add the final values for t, select Edit followed by Define Initial and Final values…9. Then enter the initial and final values for t: 0 and 3.10. Select Problem and Arrange Equations to sort the list.

Page 26: Polymath Tutorial

8. To add the final values for t, select Edit followed by Define Initial and Final values…9. Then enter the initial and final values for t: 0 and 3.10. Select Problem and Arrange Equations to sort the list.

Page 27: Polymath Tutorial

Before we solve, let’s add a title.11. Select Edit and Enter Problem Title…

Page 28: Polymath Tutorial

12. Click the Graph box to add graphing options.

Graph

Page 29: Polymath Tutorial

13. To run the program, click the purple arrow.

Run Program

Page 30: Polymath Tutorial

Final values:A = 0.050B = 0.047C = 0.903

Page 31: Polymath Tutorial

Concentration ProfilesGraph generated to show disappearance of reactant A.

Page 32: Polymath Tutorial

Concentration ProfilesGraph generated to show disappearance of reactant A.

Click Graph to modify

Page 33: Polymath Tutorial

Concentration Profiles

Click brush to edit

Page 34: Polymath Tutorial

How can B maximized?• A B C• If k1>>k2, what happens?• Change k2 to 0.5 and k1 to 2

With k1 = 1 and k2 =2,Bmax = 0.25

With k1 = 2 and k2 =0.5,Bmax = 0.63

k1 k2