Tải bản đầy đủ (.pdf) (46 trang)

Bài giảng Phần 2: Mô phỏng máy tính

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (772.43 KB, 46 trang )

Phần 2: mô phỏng máy tính
Modeling, simulation and optimization for chemical process

Instructor: Hoang Ngoc Ha
Email:
Bộ môn QT&TB
CuuDuongThanCong.com

/>

Introduction

Numerical
Analysis

Computer
Programming
TION

SIMULA

CuuDuongThanCong.com

/>

Computer simulation
„

Some simulation techniques for solving some
of the systems of equations
‰


‰
‰

„

Solution of (nonlinear) algebraic equations
Ordinary differential equations (ODEs)
Partial differential equations (PDEs)

Numerical methods
‰
‰
‰

Iterative methods
Discrete difference methods
Femlab, Fortran, Ansys…

CuuDuongThanCong.com

Matlab/Simulink

/>

Computer simulation
„

Computer programming
‰


‰

Assume that you know some computer
programming language
We are not interested in generating the most
efficient and elegant code but in solving problems
(from point of view of engineers)
„
„

„
„

Including extensive comment statements
Use of symbols (the same ones in the equations
describing the systems)
Debugging (for mistakes in coding and/or in logic)


CuuDuongThanCong.com

/>

Computer simulation

Example:

CuuDuongThanCong.com

/>


Computer simulation

CuuDuongThanCong.com

/>

Computer simulation

CuuDuongThanCong.com

/>

Computer simulation
„

Interval halving (chia đôi khoảng)

CuuDuongThanCong.com

/>

Computer simulation
„

This problem can be formulated under the
following form:

f (x) = 0, x ∈ R
„

„

The goal is to find the solution of this
nonlinear equations (in ONE VARIABLE)
Tools (Iterative methods)
‰
‰

Bisection method (phương pháp phân đoạn)
Newton’s (or Newton-Raphson) method

CuuDuongThanCong.com

/>

Iterative method
„

Intermediate value theorem
‰

If f is a real-valued continuous function on the
interval [a, b], and u is a number between f(a) and
f(b), then there is a c ∈ [a, b] such that f(c) = u

If f(a) and f(b) are of opposite sign, there exist a number p in [a, b] with f(p)=0
CuuDuongThanCong.com

/>


Iterative method
„

Bisection method

Computer programming: Matlab
CuuDuongThanCong.com

/>

Iterative method
„

Newton’s method

Numerical solutions of nonlinear systems of equations (of
SEVERAL VARIABLES)Î (See Ref.)
CuuDuongThanCong.com

/>

Computer simulation
„

Interpolation and polynomial approximation
‰
‰
‰

„


Interpolation and the Lagrange polynomial
Cubic spline interpolation


Numerical differentiation and intergration
‰
‰
‰

Numerical differentiation
Richardson’s extrapolation


(See Ref.)
CuuDuongThanCong.com

/>

Numerical intergration of Ordinary
Differential Equations (ODEs)

CuuDuongThanCong.com

/>

Numerical intergration of Ordinary
Differential Equations (ODEs)

y(t) y(t0 )

y(t1 )
x
x

y(tN )
x

Interpolation

t0 t1
CuuDuongThanCong.com

tN t
/>

Numerical intergration of Ordinary
Differential Equations (ODEs)
„

Tools:
‰

Euler’s method

‰

Higher-Order Taylor methods

‰


Runge-Kutta methods

‰



CuuDuongThanCong.com

/>

Numerical intergration of Ordinary
Differential Equations (ODEs)
„

Euler’s method

CuuDuongThanCong.com

/>

Numerical intergration of Ordinary
Differential Equations (ODEs)
„

Euler’s method

CuuDuongThanCong.com

/>


Numerical intergration of Ordinary
Differential Equations (ODEs)
„

Example

y 0 = y − t2 + 1, t ∈ [0 2]
y(0) = 0.5
P/p Euler n=10?
Approximate solution?

Exact solution?

n = 10 ⇒ h =

b−a
n

= 0.2

y(t) = −0.5 exp(t) + (t + 1)2
Computer programming: Matlab
CuuDuongThanCong.com

/>

Numerical intergration of Ordinary
Differential Equations (ODEs)
„


Local truncation error
Definition

The local truncation error in Euler’s method is

CuuDuongThanCong.com

O(h)
/>

Numerical intergration of Ordinary
Differential Equations (ODEs)
„

Higher-Order Taylor methods

CuuDuongThanCong.com

/>

Numerical intergration of Ordinary
Differential Equations (ODEs)
„

Higher-Order Taylor methods

CuuDuongThanCong.com

/>


Numerical intergration of Ordinary
Differential Equations (ODEs)
„

Runge-Kutta methods

CuuDuongThanCong.com

/>

Numerical intergration of Ordinary
Differential Equations (ODEs)
„

Runge-Kutta methods
‰

Xây dựng công thức tính wi+1 theo wi mà không
phải đạo hàm « tay », cần xấp xỉ T (k) mà không
dùng đạo hàm với O(hk )
„

Minh họa qua k=2

T

(2)

(t, y) = f (t, y) +


h 0
f (t, y)
2
0

f 0 (t, y) = ft0 (t, y) + fy0 (t, y)y (t)

f (t, y)
CuuDuongThanCong.com

/>

Numerical intergration of Ordinary
Differential Equations (ODEs)
Như vậy

T

(2)

(t, y) = f (t, y) +

h 0
f (t, y)
2 t

+

h 0
f (t, y)f (t, y)

2 y

Cần tìm a1 , α1 , β1 với sai số O(h2 ) để

a1 f (t + α1 , y + β1 ) ' T (2) (t, y)
0
ft (t, y)α1

f (t + α1 , y + β1 ) ' f (t, y) +
+fy0 (t, y)β1
CuuDuongThanCong.com

/>

×