This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Texas A&M University Artie McFerrin Department of Chemical Engineering Using Mathcad to solve nonlinear equations CHEN 354: Fall 2009 Prof. Perla B. Balbuena Mathcad is a mathematical software easy to use. Among the capabilities of Mathcad are: Solving nonlinear equations, graphing functions in two or three dimensions, solving differential equations, performing symbolic calculations, etc. The objective of this quick guide is to provide you the basic knowledge to use Mathcad in order to solve systems of nonlinear equations. First, we go through the basic operations in Mathcad, such as defining variables and evaluating functions. Then, we solve a vaporliquid equilibrium problem involving a system of nonlinear equations. Mathcad basics The Mathcad window is shown in the following figure. All the expressions and objects are inserted in the workspace Prepared by Rafael Callejas Tovar T.A. Fuman Zhao  zhaofuman@tamu.edu Page  1 CHEN 354: Fall 2009 Prof. Perla B. Balbuena The "Math toolbar" is useful to get quick access to the different capabilities of Mathcad. Defining variables and functions To define a variable, just place the cursor in the workspace and type its name followed by the "Definition symbol", located in the "Evaluation toolbar" or typing the ":" key. For example, define P equal to 101.33. If you want to know the numerical value of a previously defined variable, place the cursor below its definition, type the name of the variable followed by the "Evaluate numerically symbol" whose shortcut is the "=" key. Defining functions is simple. Type the name of the function followed by the name of its independent variables enclosed in parenthesis. Then use the "Definition symbol" and create the correct expression aided by "Space bar". You can evaluate the functions for given values of their independent variables. Prepared by Rafael Callejas Tovar T.A. Fuman Zhao  zhaofuman@tamu.edu Page  2 CHEN 354: Fall 2009 Prof. Perla B. Balbuena Useful tips If you want to use Greek symbols to name the variables, use the "Greek symbol toolbar". If you know the equivalent letter in the Latin alphabet, type the letter then "CTRL+g". For example, to obtain gamma type "g" then "CTRL+g" To insert a textbox just type the "double quote key" and the region will become a text region. All the characters inside the textbox will be treated as text. When selecting a math region the cursor is blue, in a text region the cursor is red. The Given... Find solution block The "Given... Find block" is the tool that allows us to solve nonlinear equations. The following is an example of its implementation. It is required to provide initial approximations for the unknowns. The block starts with the word "Given" written as a math expression; below it we place all the equations we want to solve. These equations may contain previously defined functions, is important to use the "Boolean equal symbol" to write the equations ("Ctrl+="). Prepared by Rafael Callejas Tovar T.A. Fuman Zhao  zhaofuman@tamu.edu Page  3 CHEN 354: Fall 2009 Prof. Perla B. Balbuena The "Given... Find block" ends with the "Find" command. Its arguments are the unknowns that we want to calculate. The result of the "Find" command may be assigned to a variable or function. In the example shown above the results are stored in the function "Solution(y1)". This is useful when we want to solve the system for several values of y1. In the example shown above, we have a twoequations/twounknonws system. Therefore, the solution porvided by the "Find" command will be a tworows/onecolumn vector. We can split assign each vector element to separate functions as follows. To make reference to the elements of a vector use the subscript, "[" key. In Mathcad the array subscripts begin at zero. Making plots To make plots, first define a "range variable", in general, it will be in the xaxis of the 2D plot. A range variable takes an initial value and add it a constant increment until a final value. To define it, name the variable, use the definition symbol, put the initial value, type a comma ",", put the increment and type a semicolon ";", then type the final value Prepared by Rafael Callejas Tovar T.A. Fuman Zhao  zhaofuman@tamu.edu Page  4 CHEN 354: Fall 2009 Prof. Perla B. Balbuena Insert a 2Dplot template ("Shift+2"), fill the blanks accordingly to the functions you want to graph. You can format the plot by selecting it and right click > Format... Example: Create Txy and xy diagrams Solve the following problem using Mathcad. For the system methanol(1)/methyl acetate(2), the following equations provide a reasonable correlation for the activity coefficients: 2 1 exp Ax2 2 exp Ax12 where A 2.771 0.00523T In addition, the following Antoine equations provide vapor pressures: P Sat 3643.310 1 exp 16.59158 kPa T K 33.424 P2Sat 2665.54 exp 14.25326 kPa T K 53.424 Assuming the validity of yi P xi i Pi Sat Calculate T and xi , for P 101.33 kPa and y1 0.40 . Also, prepare Txy and xy diagrams at this pressure. i 1, 2,, N Prepared by Rafael Callejas Tovar T.A. Fuman Zhao  zhaofuman@tamu.edu Page  5 ...
View
Full
Document
 Spring '08
 BALBUENA

Click to edit the document details