1 Tips for solving Project 1 Reactor SO 3 SO 2 +O 2.

Slides:



Advertisements
Similar presentations
Introduction to Programming using Matlab Session 2 P DuffourJan 2008.
Advertisements

Lecture 14 User-defined functions Function: concept, syntax, and examples © 2007 Daniel Valentine. All rights reserved. Published by Elsevier.
Lecture 5.
Ch 7.7: Fundamental Matrices
Intro to modeling April Part of the course: Introduction to biological modeling 1.Intro to modeling 2.Intro to biological modeling (Floor) 3.Modeling.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
M AT L AB Programming: scripts & functions. Scripts It is possible to achieve a lot simply by executing one command at a time on the command line (even.
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
Dynamics of a four-bar linkage
Differential Equations Math Review with Matlab: Finding Solutions to Differential Equations S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department.
Conversion and Reactor Sizing
1 Using ANN to solve the Navier Stoke Equations Motivation: Solving the complete Navier Stokes equations using direct numerical simulation is computationally.
By Hrishikesh Gadre Session II Department of Mechanical Engineering Louisiana State University Engineering Equation Solver Tutorials.
1 Suggestions for solving Project 3. 2 In this project you are asked to extend the pseudo- homogeneous model you made in Project 2 to a heterogeneous.
Transfer Functions Convenient representation of a linear, dynamic model. A transfer function (TF) relates one input and one output: The following terminology.
EGR 106 – Week 2 – Arrays & Scripts Brief review of last week Arrays: – Concept – Construction – Addressing Scripts and the editor Audio arrays Textbook.
Transfer Functions Convenient representation of a linear, dynamic model. A transfer function (TF) relates one input and one output: The following terminology.
HossamTalaat - MATLAB Course - KSU - 21/1/24 1 IEEE Student Branch - College of Engineering - KSU Getting started with Simulink By Prof. Hossam Talaat.
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers Daniel Baur ETH Zurich, Institut.
Solving ODEs UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Linearizing ODEs of a PID Controller Anchored by: Rob Chockley and Scott Dombrowski.
ME457 Mechatronic System Modeling MICHIGAN STATE UNIVERSITY Matlab® refresher Your objective: to dominate! My objective: to help you dominate!
Lecture 8 Chemical Reaction Engineering (CRE) is the field that studies the rates and mechanisms of chemical reactions and the design of the reactors.
Programming For Nuclear Engineers Lecture 12 MATLAB (3) 1.
EPSII 59:006 Spring Topics Using TextPad If Statements Relational Operators Nested If Statements Else and Elseif Clauses Logical Functions For Loops.
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
Analytical vs. Numerical Minimization Each experimental data point, l, has an error, ε l, associated with it ‣ Difference between the experimentally measured.
1 Functions 1 Parameter, 1 Return-Value 1. The problem 2. Recall the layout 3. Create the definition 4. "Flow" of data 5. Testing 6. Projects 1 and 2.
© 2014 Carl Lund, all rights reserved A First Course on Kinetics and Reaction Engineering Class 19.
A Brief Introduction to Matlab Laila Guessous Dept. of Mechanical Engineering Oakland University.
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
Matlab Workshop 1/10/07 Lesson 1: Matlab as a graphing calculator.
System Control Theory Lab
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
Introduction to Engineering MATLAB – 2 Introduction to MATLAB - 2 Agenda Defining Variables MATLAB Windows.
MATLAB Harri Saarnisaari, Part of Simulations and Tools for Telecommunication Course.
4.1 The Indefinite Integral. Antiderivative An antiderivative of a function f is a function F such that Ex.An antiderivative of since is.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Solution of a System of ODEs with POLYMATH and MATLAB, Boundary Value Iterations with MATLAB For a system of n simultaneous first-order ODEs: where x is.
© 2014 Carl Lund, all rights reserved A First Course on Kinetics and Reaction Engineering Class 23.
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
The elements of higher mathematics Differential Equations
Beginning Programming for Engineers
Mathematical Applications using MATLAB (Cont….)
Chapter 8: The Thermodynamics of Multicomponent Mixtures
SIMULINK-Tutorial 1 Class ECES-304 Presented by : Shubham Bhat.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
A simple classification problem Extract attributes Pattern Pattern recognition decision x C1 C2.
Files: By the end of this class you should be able to: Prepare for EXAM 1. create an ASCII file describe the nature of an ASCII text Use and describe string.
The Kinetic Theory of Gases
Recap Cubic Spline Interpolation Multidimensional Interpolation Curve Fitting Linear Regression Polynomial Regression The Polyval Function The Interactive.
Conversion and Reactor Sizing Lec 4 week 4. Definition of Conversion for the following reaction The reaction can be arranged as follows: how far the above.
Louisiana Tech University Ruston, LA Boundary Layer Theory Steven A. Jones BIEN 501 Friday, April
Simulink  ? 1 Simulink  ( Simu lation and Link ) is an extension of Matlab Offers modeling, simulation, and analysis of dynamical systems; i.e., a system.
ERT 210/4 Process Control & Dynamics DYNAMIC BEHAVIOR OF PROCESSES :
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Chapter 4 MATLAB Programming MATLAB Troubleshooting Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
ACSL, POSTECH1 MATLAB 입문 CHAPTER 8 Numerical Calculus and Differential Equations.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
1-2 What is the Matlab environment? How can you create vectors ? What does the colon : operator do? How does the use of the built-in linspace function.
Modified Bessel Equations 홍성민. General Bessel Equation of order n: (1) The general solution of Eq.(1) Let’s consider the solutions of the 4.
1 Variational and Weighted Residual Methods. 2 Introduction The Finite Element method can be used to solve various problems, including: Steady-state field.
1.1 Basic Concepts. Modeling
Transfer Functions Convenient representation of a linear, dynamic model. A transfer function (TF) relates one input and one output: The following terminology.
Prof. Mark Glauser Created by: David Marr
Skydiver.
Prepared by: Lakhtartiya Amit A. Guided by: Mr. P. L. Koradiya
Introduction to Matlab
Getting Started With Simulink
Presentation transcript:

1 Tips for solving Project 1 Reactor SO 3 SO 2 +O 2

2 Reactor In Project 1 you are asked to develop differential equations to solve for the total pressure, temperature, gas velocity and partial pressures at steady state on a reactor. Then you need to solve a set of differential equations. How can that be done in Matlab? v (z)=? P (z)=? T (z)=? P i (z)=? z

3 Let’s take a look at the following very simple, worked-out example:

4 Notice that we have a system of 2 ordinary differential equations with its boundary conditions. The solution is How’s the script in Matlab?

5 We start a script on the Matlab Editor and give a name to it We should save the file with the same name, for example: “project_1_example.m” If we want to have the results for “f” and “g” available on the workspace, we need to give them as the output on the same line

6 Next, to avoid problems and a lot of confusion, a good habit when programming in Matlab, is to clear the memory for all variables from previous simulations before we start a new one. So on the top of the program we can use the command “clear all” Also we can use “clc” to clear the Command Window; and “close all” to close any graphics we might have open

7 Then we define the parameters that are going to be globally available by declaring them global

8 Then, we set the values of those parameters A semicolon at the end of the line avoids displaying this line on the screen when the script is run

9 Next, we specify the integration interval over which Matlab should integrate. For that, we create a vector containing the initial and final values for the independent variable

10 We can always make comments about our code. This helps remember what we were doing when we see the code in the future. Matlab ignores all the text after a percentage sign (%). Next, we specify the integration interval over which Matlab should integrate. For that, we create a vector containing the initial and final values for the independent variable

11 Now we set the boundary conditions on a vector “x0”. First we give the value for “f” and then the one for “g” If we had, let’s say, 3 differential equations, we would simply give here a vector with 3 columns. We would proceed in a similar fashion if we had only one equation instead of a system

12 Here we use the function “odeset” which will allow us to specify options to the ODE solver. For instance “abstol” determines the maximum error for every component of the solution

13 Other options are available, for example to control the step size and so on.

14 Here we call the ODE solver “ode15s”

15 Here, “x” is a vector with the discretization in the independent variable. The number of points will be determined by Matlab, automatically. The number of points will increase as we demand smaller tolerances through the “odeset” function.

16 “y” is a solution array that contains the solutions, as columns. Each row in the solution array “y” corresponds to a value in the column vector “x”

17 Here we give the name of the.m file where we have written the equations. (We will see the script in a few slides!)

18 “xspan” is the vector with the integration interval that we defined previously

19 “x0” is how we called the initial values vector of our differential equations

20 “project_1_options” are the options that we defined regarding error tolerances

21 We have provided the ODE solver with all the information that it needs to deliver the solution to us! Next on the script we shall plot the results obtained

22 We have used here “ode15s”, but other solvers are available. Which one is best will depend upon the properties of the system that we are solving, for example, its stiffness

23 Next we define the vectors “f” and “g” equal to the first and second columns of the solution array “y”

24 Finally, we plot the functions “f” and “g” on the same figure using the function “subplot”

25 Now let’s take a look at the script “math_example.m” where we write the equations

26 Now let’s take a look at the script “math_example.m” where we write the equations “dydx” is the output (the solution array) that contains the columns with the values for “f” and “g”

27 Now let’s take a look at the script “math_example.m” where we write the equations “dydx” is the output (the solution array) that contains the columns with the values for “f” and “g” “x” is the independent variable and “y” is array that contains both “f” and “g”

28 Here we make visible the global parameters to the function “math_example”

29 Next, we identify our functions in the “y” array

30 Here we write the system of equations

31 And now we put the derivatives togheter in the array “dydx” It’s done!

32

33 The results with A=1 and B=2

34 Some more tips… In the problem you are asked to find the total pressure. Using the balance for component j we find that for steady-state and without dispersion, we have: Using the ideal gas law to replace c j :

35 Some more tips… Now we need to operate to get an expression for the derivative of p j with respect to z… Then solving for the derivative of pressure, we obtain

36 Some more tips… In the problem you are also asked to find the gas velocity. For plug-flow the total molar flux is: Using again the ideal gas law, where the total pressure is P, and differentiating:

37 Some more tips… Solving for the derivative of velocity, we obtain: So we have found what Matlab needs as input: an expression for the derivative of velocity. For the total pressure, we have from plug-flow theory:

38 Some more tips… But since the mass flux is constant, we know that So the Ergun equation can be written as

39 Some more tips… Now let’s look at the temperature. The energy equation is: Now taking we get:

40 Some more tips… Solving for the derivative of temperature, we obtain where and