Download presentation
Presentation is loading. Please wait.
Published byPercival McDaniel Modified over 9 years ago
1
PSOD Lecture 2
3
Matrices and vectors in Chemical & Process Engineering Appear in calculations when process is described by the system of equations: Appear in calculations when process is described by the system of equations: –Piping system –Cascade of »Reactors »Heat exchangers »Mixers –System of apparatus and streams in chemical plant
4
concentrations give 4-elements vector c concentrations give 4-elements vector c To find solution we need system of 4 equations To find solution we need system of 4 equations Equation parameters creates square matrix Equation parameters creates square matrix Matrices in Chemical & Process Engineering L, c 1 L, c s L, c 2 L, c 3 L, c 4 V V V V
5
V,c1V,c1 V, csV, cs V,c2V,c2 V,c3V,c3 V,c4V,c4 Matrices in Chemical & Process Engineering
6
V,c1V,c1 V, csV, cs V,c2V,c2 V,c3V,c3 V,c4V,c4
7
MathCAD – vectors and matrix
8
Matrix operations Matrix operations –Multiply by constant –Matrix transpose [ctrl]+[1] –Inverse [^][-][1] –Matrix multiplying –Determinant
9
To read the matrix elements A r, k : key [[] r- row nr, k – column nr To read the matrix elements A r, k : key [[] r- row nr, k – column nr –e.g. element A 1,1 keystrokes: [A][[][1][,][1][=] To chose matrix column: M To chose matrix column: M –First column A( A ): keys [A][ctrl]+[6][0] Default first column&row number is 0, Default first column&row number is 0, –(to change : Math/Options/Array Origin) MathCAD – vectors and matrix
10
Calculations of dot product and cross product of vectors Calculations of dot product and cross product of vectors
11
Special definition of matrix elements as a function of row-column number M i,j =f(i,j) Special definition of matrix elements as a function of row-column number M i,j =f(i,j) –E.g. Value of element is equal to product of column and row number MathCAD – vectors and matrix Constrain: function arguments have to be integer
12
MathCAD 3D graphs 3D graphs of function on the base of matrix : [ctrl]+[2] [M] 3D graphs of function on the base of matrix : [ctrl]+[2] [M] –M – matrix defined earlier
13
3D Graphs of function of real type arguments 3D Graphs of function of real type arguments –Using procedure: CreateMesh(function, lb_v1, ub_v1, lb_v2, ub_v2, v1grid, v2grid) –Assign result to variable –Plot of the variable is similar to plot of matrix ([ctrl]+[2]) MathCAD 3D graphs Boundaries can be the real numbers. (def. –5,5) Grids have to be integer numbers (def. 20)
14
MathCAD 3D graphs
15
MathCAD 3D graphs - formating
16
MathCAD 3D graphs – formatting: fill options
17
Contours colour filled
18
MathCAD 3D graphs – formatting: line options
19
MathCAD 3D graphs – formatting: Lighting
20
MathCAD 3D graphs – formatting: Fog and perspective
21
MathCAD 3D graphs – formatting: Backplane and Grids
22
MathCAD 3D scatter graphs Data given as three vectors of each point coordinates Data given as three vectors of each point coordinates –Equal vector size –Button on Graph toolbar: 3D Scatter Plot –In the placeholder type in brackets the vectors names separated by comas
23
Predefined constants e = 2,718 – natural logarithm base e = 2,718 – natural logarithm base g = 9,81 m/s 2 – acceleration of gravity g = 9,81 m/s 2 – acceleration of gravity = 3,142 – circle perimeter/diameter ratio = 3,142 – circle perimeter/diameter ratio
24
Solving of algebraic equation When equation is implicit When equation is implicit When we don’t want to separate variables When we don’t want to separate variables
25
MathCAD equation solvers Single equation (one unknown value) Single equation (one unknown value) 1.Given-Find method »Input start point of variable »Type "Given" »Type equation with using [ = ] ([ctrl]+[=]) »Type Find(variable)=
26
MathCAD equation solving Given-Find – solving methods Given-Find – solving methods –Linear (function of type y=c 0 x + c 1 ) –starting point choice do not affects on results. –Nonlinear – according to nonlinear equation. Obtained result could depend on starting point. Available methods: »Conjugate Gradient »Quasi – Newton »Levenberg-Marquardt »Quadratic The choice of method is automatic by default. User can choose method from the pop-up menu over word Find. The choice of method is automatic by default. User can choose method from the pop-up menu over word Find.
27
Single equation (one unknown value) Single equation (one unknown value) 2.Root procedure: Root(function, variable, low_limit, up_limit)= –Values of function at the bounds must have different signs or MathCAD equation solving
28
Single equation (one unknown value) Single equation (one unknown value) 2.Root procedure methods: 1.Secant method 2.Mueller method (2 nd order polynomial) MathCAD equation solving x3x3 x2x2 y3y3 x1x1 y1y1 y2y2 x4x4 x5x5
29
Single equation (one unknown value) Single equation (one unknown value) 3.Special procedure: polyroots for the polynomials. Argument of procedure is a vector of polynomial coefficients (a 0, a 1...). The result is a vector too. MathCAD equation solving Methods: 1.Laguerre's method 2.companion matrix
30
Laguerre's method Polynomial p(x) of degree n. Starting from assumed x k.
31
The system of linear equations The system of linear equations –Solving on the base of matrix toolbar: »Prepare square matrix of equations coefficients (A) and vector of free terms (B) »Do the operation x:=A -1 B and show result: x= Or »Use the procedure LSOLVE: lsolve(A,B)= MathCAD, the system of equations solving
33
The system of nonlinear equation The system of nonlinear equation –Can be solved using given-find method »Assign starting values to variables »Type Given »Type the equations using = sign (bold) »Type Find(var1, var2,...)= MathCAD, the system of equations solving
35
Differential eq. Solvers in MathCAD
36
Ordinary differential equations solving Numerical methods: Numerical methods: –Gives only values not function –Engineer usually needs values –There is no need to make complicated transformations (e.g. variables separation) –Basic method implemented in MathCAD is Runge-Kutta 4 th order method.
37
Ordinary differential equations solving Numerical methods principle Numerical methods principle –Calculation involve bounded range of independent variable only –Every point is being calculated on the base of one or few points calculated before or given starting points. –Independent variable is calculated using step: x i+1 = x i + h = x i + x –Dependent value is calculated according to the method y i+1 = y i + y= y i +K i
38
Ordinary differential equations solving Runge-Kutta 4 th order method principles: Runge-Kutta 4 th order method principles: –New point of the integral is calculated on the base of one point (given/calculated earlier) and 4 intermediate values
39
MathCAD differential equations Single, first order differential equation Single, first order differential equation 1.Assign the initial value of dependent variable (optionally) 2.Define the derivative function 3.Assign to the new variable the integrating function rkfixed: R:=rkfixed(init_v, low_bound, up_bound, num_seg, function) Initial condition
40
4.Result is matrix (table) of two columns: first contain independent values second dependent ones 5.To show result as a plot: R @R 5.To show result as a plot: R @R MathCAD, differential equations
41
MathCAD differential equations
42
System of first order differential equations System of first order differential equations 1.Assign the vector of initial conditions of dependent variables (starting vector) 2.Define the vector function of derivatives (right-hand sides of equations) 3.Assign to the variable function rkfixed: R:=rkfixed(init_vect, low_bound, up_bound, num_seg, function) MathCAD differential equations
43
4.Result is matrix (table) of three columns: first contain independent values, 2 nd column contains first dependent variable values, third second ones : 5.Results as a plot: R,R @ R 5.Results as a plot: R,R @ R MathCAD differential equations
45
Single second order equation Single second order equation 1.Transform the second order equation to the system of two first order equations: Initial condition MathCAD differential equations
46
Example: Example: Solve the second order differential equation (calculate: values of function and its first derivatives) given by equation: While y=10 and y’=-1 for x=0 In the range of x= In the range of x=
47
MathCAD differential equations System of equations Starting vectorVectoral function
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.