+ All Categories
Home > Documents > Lecturer 4 Mod&Sim

Lecturer 4 Mod&Sim

Date post: 14-Apr-2018
Category:
Upload: tarun-sachdeva
View: 221 times
Download: 0 times
Share this document with a friend

of 13

Transcript
  • 7/30/2019 Lecturer 4 Mod&Sim

    1/13

    MECHANICAL & INDUSTRIAL ENGINEERING DEPARTMENT

    INDIAN INSTITUTE OF TECHNOLOGY ROORKEE

    Numerical Solutions of Ordinary Differential Equations

    Dr. S. P. Harsha

  • 7/30/2019 Lecturer 4 Mod&Sim

    2/13

    MECHANICAL & INDUSTRIAL ENGINEERING DEPARTMENT

    INDIAN INSTITUTE OF TECHNOLOGY ROORKEE

    EULERS METHOD:

    First order system

    with an initial condition x(t0) = x0

    The method proposed by Euler was based on a

    finite-difference approximation of a continuous first

    derivative dx/dt.

    Taylors approximation of a first-order continuous

    derivative defined as

    Dr. S. P. Harsha

  • 7/30/2019 Lecturer 4 Mod&Sim

    3/13

    MECHANICAL & INDUSTRIAL ENGINEERING DEPARTMENT

    INDIAN INSTITUTE OF TECHNOLOGY ROORKEE

    Cont

    The Eulers solution procedure is marching from the initial

    time t0 to the final time tf = t0 + twith a constant time step t.

    The following equations are solved successively in the

    computational process:

    Use Eulers method to obtain a numerical solution of thedifferential equation

    Over a period of time from 0 to 12 s. The initial condition is

    x(0) = 10, and the system time constant is 4 s.

    Dr. S. P. Harsha

  • 7/30/2019 Lecturer 4 Mod&Sim

    4/13

    MECHANICAL & INDUSTRIAL ENGINEERING DEPARTMENT

    INDIAN INSTITUTE OF TECHNOLOGY ROORKEE

    Cont

    First rewrite the differential equation in the same form

    The first step in implementing the numerical solution is to

    choose a value of the integration interval t.

    For this system, the time constant is 4 s and to illustrate thisrelationship, the Euler method is implemented for ts of 0.5,

    1.0, 2.0, and 4.0 s.

    Dr. S. P. Harsha

  • 7/30/2019 Lecturer 4 Mod&Sim

    5/13

    MECHANICAL & INDUSTRIAL ENGINEERING DEPARTMENT

    INDIAN INSTITUTE OF TECHNOLOGY ROORKEE

    Cont

    Table 5.1. MATLAB script for the solution of Example use of the Euler

    method of integration

    % MATLAB script to integrate a first order

    % ODE using the Euler method.

    %

    dt = 0.5; % time step

    t(1) = 0.0; % initial time

    tf = 12.0; % final time

    %

    x(1) = 10.0; % Set initial condition

    %for i = 2: tf/dt + 1

    k1 = 1/4*x(i 1)+1;

    x(i) = x(i 1) + k1*dt;

    t(i) = t(i 1)+ dt; % increment time end

    endDr. S. P. Harsha

  • 7/30/2019 Lecturer 4 Mod&Sim

    6/13

    MECHANICAL & INDUSTRIAL ENGINEERING DEPARTMENT

    INDIAN INSTITUTE OF TECHNOLOGY ROORKEE

    Cont

    Table 5.2. Comparison of Euler method solution for various step sizes

    Dr. S. P. Harsha

  • 7/30/2019 Lecturer 4 Mod&Sim

    7/13

    MECHANICAL & INDUSTRIAL ENGINEERING DEPARTMENT

    INDIAN INSTITUTE OF TECHNOLOGY ROORKEE

    RungeKutta Method

    In the Runge Kutta method is that the higher derivatives are

    approximated by finite-difference expressions and thus do not

    have to be calculated from the original differential equation.

    The approximating expressions are calculated by use of data

    obtained from tentative steps taken from t0 toward t0 + t. The

    number of steps used to estimate x(t0 + t) determines the

    order of the RungeKutta method.

    In the most common version of the method, four tentative

    steps are made within each time step, and the successive value

    of the dependent variable is calculated as

    Dr. S. P. Harsha

  • 7/30/2019 Lecturer 4 Mod&Sim

    8/13

    MECHANICAL & INDUSTRIAL ENGINEERING DEPARTMENT

    INDIAN INSTITUTE OF TECHNOLOGY ROORKEE

    RungeKutta Method

    Table 5.4. MATLAB script for implementation of the fourth-order Runge

    Kutta numerical integration scheme

    Dr. S. P. Harsha

  • 7/30/2019 Lecturer 4 Mod&Sim

    9/13

    MECHANICAL & INDUSTRIAL ENGINEERING DEPARTMENT

    INDIAN INSTITUTE OF TECHNOLOGY ROORKEE

    RungeKutta Method Algorithm

    Dr. S. P. Harsha

  • 7/30/2019 Lecturer 4 Mod&Sim

    10/13

    MECHANICAL & INDUSTRIAL ENGINEERING DEPARTMENT

    INDIAN INSTITUTE OF TECHNOLOGY ROORKEE

    RungeKutta Method Algorithm

    Dr. S. P. Harsha

  • 7/30/2019 Lecturer 4 Mod&Sim

    11/13

    MECHANICAL & INDUSTRIAL ENGINEERING DEPARTMENT

    INDIAN INSTITUTE OF TECHNOLOGY ROORKEE

    Step Size

    Dr. S. P. Harsha

    Step 1. Starting at some time t0, integrate to t0 + t, using a default time

    step, t

    Step 2. Return to the original time, and integrate to t0 + t by using two

    time steps of t/2.Step 3. Compare the difference between the results of Steps 1 and 2 to a

    user defined tolerance.

    Step 4. If the tolerance is exceeded, decrease the step size and return to

    Step 1; if not, nominally increase the step size and move to the next time

    step.

  • 7/30/2019 Lecturer 4 Mod&Sim

    12/13

    MECHANICAL & INDUSTRIAL ENGINEERING DEPARTMENT

    INDIAN INSTITUTE OF TECHNOLOGY ROORKEE

    Example:

    Dr. S. P. Harsha

    Consider the following nonlinear differential equation:

  • 7/30/2019 Lecturer 4 Mod&Sim

    13/13

    MECHANICAL & INDUSTRIAL ENGINEERING DEPARTMENT

    INDIAN INSTITUTE OF TECHNOLOGY ROORKEE

    Dr. S. P. Harsha


Recommended