Che 327 mathcad tutorial I PDF

Title Che 327 mathcad tutorial I
Author Arif Badem
Course Heat and mass transfer
Institution Orta Doğu Teknik Üniversitesi
Pages 24
File Size 1.8 MB
File Type PDF
Total Downloads 26
Total Views 171

Summary

matlab application in heat and mass transfer...


Description

Middle East Technical University ChE 327 Heat and Mass Transfer Operations (1) Mathcad Tutorial

1. Mathcad Basics When you open the Mathcad software, a blank worksheet appears. For simple mathematical operations, you can directly type. i.

Type 1+3=. You should get the following:

ii.

Now type (1+3)*2= :

iii.

You may also give variable names to any equation. To do so, type the variable name and then

type

Now type x

the colon : key: =:

Now type y:9-4/5 : Type z:x*y

:

Type z= iv.

To create the exponent operator, type a number, 4, then press ^ to create the exponent. Then enter the new value 5

and press =:

1.1 Line Editing Imagine that you need to find the result of the expression

i.

Type 1/2 spacebar – 3/4 spacebar spacebar:

ii.

Type ^ to create the exponent then type 8 and

iii.

Press / and type 5 ^ 6. Then press spacebar twice:

(1⁄ 2−3⁄4)8 56

+ √7.

press spacebar :

iv.

Press + and \ (or the square root icon)then type 7 . Finally, press = :

2. Toolbars You can easily access to Mathcad toolbars by clicking Toolbars button from the View menu. From the Math toolbar, one can access Calculator, Graph, Vector and Matrix, Evaluation, Calculus, Boolean, Programming, Greek Symbol, and Symbolic Keyword.

2.1 Calculator The Calculator can be understood literally as a calculator. One can inserts the numbers, functions or operators into Mathcad by clicking the buttons on the toolbar.

2.2 Functions Mathcad has hundreds of built-in functions, which one can call from the Insert Function dialog box opened by selecting Functions from the Insert menu.

One can also define functions and use them when necessary:

2.3 Vector and Matrix Notations in MATHCAD One can add a matrix by selecting the matrix icon (a three-by-three matrix) on the Matrix toolbar.

First, write Matrix . A : and click on the matrix icon. Once the dialog box is opened, one can define the dimensions of the matrix.

Now you can add the elements of the matrix. You can use the tab key to move from one element to another. You can also write expressions into the matrix elements.

You can also make matrix calculations easily by using matrix toolbox. Example: Find the discriminant and the transpose of the matrix given above. Also multiply matrix A with itself (dot product).

Element-By-Element Multiplication In order to do an element-by-element multiplication, you need to use the vectorize operator. This will tell Mathcad to ignore the normal matrix rules and perform the operation on each element. To vectorize the multiplication operation, type – while pressing the Ctrl key and write down the expression to be calculated:

Ranged Variables In various applications, one may need to use a ranged variable. The range of values is set to have a beginning value, an ending value and uniform incremental values. They are commonly used as subscripts for matrix operations. To create a ranged variable, first give a name to variable and type :. Then give initial value, type , and give the second value. Next press semicolon ; and enter the final value.

Array Functions Min, Max, Mean, Median

Truncation and Rounding Functions The function floor(x) returns the greatest integer less than z. The function ceil(x) returns the smallest integer greater than z. The function trunc(x) returns the integer part of x by removing the fractional part. If x is greater than zero, this function is identical to floor(x). If x is less than zero, this function is identical to ceil(x). The function round(x,n) returns z rounded to n decimal places. The argument n must be an integer. If n is omitted (or equal to zero), it returns x rounded to the nearest integer.

Summation Operations Vector Sum This operator adds all the elements in a vector. This operator is useful when you want to add a variable series of numbers. To insert the Vector Sum operator, type CTRL and 4 or use the summation icon on the Matrix toolbar.

Summation It allows you to sum an expression or a function over a range of values. The operator has four placeholders. To insert, type CTRL Shift and 4 or add from calculus toolbar.

Range Sum The Range Sum operator is similar to the Summation operator, except you need to have a range variable defined before using the Range Sum operator. To insert, type $ or use calculus toolbar.

2.4 Graphing Toolbar Using the Graphing toolbar, one can easily insert two-dimensional X-Y plots, polar plots, surface plots, and different three-dimensional plots. Easiest way to add a 2D plot is to type @.

The selected horizontal point is the place where independent variable is written. Note that it has to be predefined above.

If the independent variable is set as x : -1 ; 10 ;

As seen, dependent variable can be entered as a function or as a variable. To plot more than one function, one can click next to the dependent variable and type , and enter other functions of x or variable names;

Plotting Ranges: One can also plot a predefined function without giving values to independent variable at first. Illustrate, type p(t) : and insert arc coth from the functions as described above.

Press @ and write t on the midpoint of the horizontal axis and p(t) on the midpoint of the vertical axis. As you may have noticed, MATHCAD gives values up to 10 as default option for t. You can click on the upper and lower limits of the x axis and change those according to desired range.

Importing Data: One can use a different software and the output of that work might be needed to be further processed via MATHCAD. Imagine that you have written a code in FORTRAN language to find a temperature distribution on a heat exchanger wall and you need a 3D representation of your data.

i.

To do so, first click on Data Import Wizard.

ii.

Choose your program output file written in txt format, then click on finish.

iii.

You will obtain the data. Name it as T.

iv.

Insert a 2D surface plot via graph tool bar and name it as T.

v.

You can format your plot by double clicking on it.

vi.

You can also add more than one plot here as well. For instance, add first contour plot and add the data, T two times. Then you can format it by double clicking on the plot.

2.5 Symbolic calculations One of the most useful aspects of the MATHCAD is the ability to solve expressions algebraically.

Example: Second Order Polynomials i.

Type a * x ^ 2 spacebar + b * x + c. Then click on solve from the above toolbox. Type , x :

ii.

If a,b,c are defined, it can directly find the roots:

iii.

You can also defined an expression as a function and then use it:

Expand You can expand expressions easily via MATHCAD if needed. To do so, write an expression and then click on the expand button in the toolbox:

Simplify If equations have a simpler form, one can obtained them easily for many cases via Simplify tool. Write the expression and click on simplify :

Factor Factor operation works as the opposite of “Expand”. Write an expression and click on Factor :

3. Equation Solvers 3.1 “Polyroots” Function To use the polyroot fuction, coefficients of the polynomial is needed to be defined as a matrix. Then roots are to be found.

3.2 Given and Find Block i. ii. iii. iv.

Give an initial guess for each variable to be solved. Type Given . Type the constraint equations if there are any by using Boolean operators. Type Find(x) and list the desired solution variables (in the place of x).

Example: A system of nonlinear equations Initial guess values

Boolean Toolbox

4. Calculus and Differential Equation Solvers

4.1 Differentiation To differentiate, open calculus toolbar and add derivative operator, write down the expression and use symbolic evaluation:

One can evaluate a derivative for a specified point as well:

It is also possible to calculate for a range:

4.2 Integration The symbolic processor will perform both definite integrals and indefinite integrals while numeric processor will perform only definite integrals. To add integral operation, calculus toolbar is used.

4.3 Differential Equation Solvers Mathcad has multiple functions to solve various differential equation systems. These solvers are numeric solutions and approximate the exact solutions. The two easiest-to-use functions, Odesolve and Pdesolve, are used within Solve Blocks.

Ordinary Differential Equations The function Odesolve is used in a Solve Block to solve a single differential equation or a system of differential equations. It returns the solution as a function of the independent variable. The function has the form Odesolve([vector], x, b, [npoints]). The arguments are as follows:    

Vector is used only for systems of ODEs and is a vector of function names (with no variable names included) as they appear within the Solve Block. x is the name of the variable of integration. b is the final point of the solution interval. npoints is optional and is the integer number of equally spaced points used to interpolate the solution function. The default value of npoints is 1000.

The default solver for Odesolve is the Adams/BDF method. If you right-click the Odesolve function, you can select another solver for the Odesolve function.

Derivative symbol can be added by Ctrl and F7.

Partial Differential Equations The most common function for solving partial differential equations is the Pdesolve function. This function returns a function or vector of functions that solve a one dimensional nonlinear PDE or system of PDEs. The Pdesovle function has the form Pdesolve(u,x,xrange, t, trange, [xpts], [tpts]). The arguments are as follows:       

u is the scalar function name, or vector of function names with no variable names included; that is, f instead of f(x,t). x is the spatial variable name. xrange is a two-element column vector containing the real boundary values for x. t is the time variable name. trange is a two-element column vector containing the real boundary values for t. xpts (optional) is the integer number of spatial discretization points. Tpts (optional) is the integer number of temporal discretization points.

PDE equations must be defined using Boolean equals. Second partial derivatives are not allowed on the left-hand side of equations; you must convert your equation to a system of equations in first derivates only. It is a PDE solver for hyperbolic and parabolic systems of 1-D PDEs, including coupled ODEs and algebraic constraints. There must be an initial condition u(x,0), and n boundary conditions, where n is the order of the PDE, for each unknown function. Algebraic constraints are allowed but inequality constraints are not allowed....


Similar Free PDFs