CHEE319_tutorial1

Embed Size (px)

Citation preview

  • 8/11/2019 CHEE319_tutorial1

    1/4

    CHEE 319

    Introduction to the MATLAB SIMULINK Program

    Using Simulink to perform open-loop simulations

    MATLAB, which stands for MATrix LABoratory, is a technical computing environment for high-

    performance numeric computation and visualization. SIMULINK is a part of MATLAB that canbe used to simulate dynamic systems. To facilitate model definition, SIMULINK adds a new

    class of windows called block diagram windows. In these windows, models are created and edited

    primarily by mouse- driven commands. Part of mastering SIMULINK is to become familiar with

    manipulating model components within these windows. The purpose of this tutorial is to introduce

    you to SIMULINK and give you experience simulating dynamic systems.

    Launching SIMULINK

    In this tutorial, you will use SIMULINK to generate an open-loop set-point and load response fora linear process. In the second part of the tutorial, you will generate the closed-loop set-point and

    load responses.

    Open MATLAB. Start Simulink by typing simulinkin the Matlab command prompt >>.

    Once the simulink library window block opens, you will create a new Model.

    To create a model, click on File in the simulink block, followed by new and then Model. A

    blank page opens. You are now ready to build a Simulink model. Save the empty model

    by choosing Save from the File menu in the untitled window. Name the model, examplesim.

    From this point on, the model will be referred to as examplesim.

    This tutorial is part 1 of two tutorials. In the first part, you will build a model of the open-loop

    system for a nonlinear process and determine the response of the system to sinusoidal, step and

    ramp inputs. We make use of the Differential Equation Editor (DEE) to perform the simulations.

    1

  • 8/11/2019 CHEE319_tutorial1

    2/4

    Problem Statement

    In class, we developed a dynamic model of the gravity tank. A schematic diagram of the process

    is shown below.

    The dynamics of the process are given by:

    dh

    dt =

    Fo

    A

    Apv

    A (1)

    dv

    dt =

    hg

    L

    Kfv2

    ApL (2)

    where A and Ap are the cross-sectional areas of the tank and the outlet pipe, g (=9.8 m/sec2) is

    2

  • 8/11/2019 CHEE319_tutorial1

    3/4

    the gravitation constant, L is the length of the outlet pipe, h is the height of liquid in the tank,

    v is the average velocity of the fluid in the outlet pipe, Kf is the pipe friction constant, is the

    density of the fluid and Fo is the inlet flowrate of fluid to the tank. It is assumed that the tank

    and the outlet pipe are cylindrical.

    The tank has a radius Rof 2 m. The inner radius of the pipe, r, is 0.125 m. The outlet pipe is 10

    m in length. The density of the fluid is 1000 kg/m3. The friction constant is 4.0.

    We will now simulate the dynamic behavior of the nonlinear process using the SIMULINK differ-

    ential equation editor (DEE). You can input the differential equation as they are formulated using

    the DEE.

    To invoke the DEE editor, typeDEEat the MATLAB command prompt. This will open the

    DEE window.

    Click and drag the DEE icon to your untitled SIMULINK worksheet.

    Double Click on the DEE to invoke the entry window. You must enter the number of in-

    puts, the differential equations, the initial conditions and the output functions that you are

    interested in.

    For this case, there is 1 input, the inlet flow. To enter the system of equations, you must use

    the DDE syntax. The variables that you are solving for are given as entries in the array x.

    Leth=x(1) andv=x(2). The input variable, Fo, is given as the first entry in the array u, i.e.,

    u(1). All other variables of the system must be set to their numerical values.

    To solve the system, you must supply the initial conditions. Let h(0)=3 and v(0)=4.

    Finally, enter the output functions that you are interested in, i.e., x(1) and x(2). Once you

    close the DEE editor window you will see that the DEE block has one input Fo and two

    outputs h and v.

    Copy a Step Input block from the Sources menu, place the block to the left of DEE editor

    window and connect it to the input. The Step Input block generates a step function. The

    step time (time at which the step occurs), initial value, and final value of the function can be

    specified.

    Copy two (2) To Workspace blocks to the right of the DEE block and connect the outputs

    of the DEE block to the two (s) new To Workspace blocks. Double-click on the new blocks

    and set the Variable name to h and v, respectively. The model developed to this point is a

    model of the open-loop system. To facilitate the analysis, you can choose to change the Save

    format of the output variables by selecting the ARRAY in the save format item of the menu.

    Now we are ready to simulate the open-loop response of the system. To select the integration

    technique and parameters to be used during simulations, pull down the Simulation menu and

    3

  • 8/11/2019 CHEE319_tutorial1

    4/4

    choose Parameters. A dialog box is opened showing all the simulation parameters that can

    be modified. Set the Stop Time to 500 and the Max Step Size to 1. Because the system

    is easy to integrate numerically , SIMULINK can and will take integration step sizes equal

    to the default value. If this occurs, the appearance of the response will not be smooth. By

    setting Max Step Size to 1, the outputs u and v will be output to the workspace each timeinterval and the simulated response will be smoother. Start the simulation by selecting Start

    from Simulation menu. The resulting h, v and t variables in the workspace will be for the

    open-loop unit set-point response.

    Once a simulation has been completed, the resulting data can be manipulated and analyzed

    using MATLAB. Select the MATLAB command window and type

    >> plot(t,h)

    to view the response. Theplot command opens a MATLAB Figure window and generates a

    plot inside the window. To add x and y axis labels and a title type xlabel(Time) ylabel(h)

    title(Step Response (Open-Loop)). Repeat this for the variable v.

    Perform the following steps. i) Assuming an inlet flow of 0.45 m3/sec, find the steady-state values

    for the height of liquid in the tank and the outlet pipe fluid velocity. Report the steady-state

    value and show the resulting plots of h and v. ii) Starting for this steady-state, perform a 0.25

    m3/sec step increase and a 0.25 m3/sec step decrease in inlet flowrate. Report the two new sets of

    steady-state values. Generate a first plot showing both step responses for the level and a second

    showing the step responses for the velocity. Briefly comment on the extent of nonlinearity of this

    process.

    4