You are on page 1of 124

University of Technical Education HCM City, 2013

Chapter 4 – Numerical methods for ODE and PDE problems

ODE
5.1 Euler Method
5.2 Runge-Kutta method

5.3 Laplace’s Transform

5.4 Analytic solution

PDE

5.5 Examples
 Initial Valuation Problem
Moâ hình thöïc teá Moâ hình vaät lí

This image cannot currently be display ed.


dy
Phöông phaùp Euler  f (t , y ); y (0)  y0
dt
Cho h = t1 – t0 vaø ñieàu kieän ban ñaàu, y = y(t0), tính :

y1  y 0  hf (t 0 , y 0 )
y 2  y1  hf (t1 , y1 )
...
y j 1  y j  hf (t j , y j )
Hoaëc
y j  y j 1  hf (t j 1 , y j 1 )  O(h 2 )
Dùng pháp Euler Tính

dy
 t  2y y(0) = 1
dt
1
Keát quaû chính xaùc y  [ 2t  1  5e  2t ]
4
f (t j 1 , y j 1 ) Euler C.xaùc Sai soá
j tj yj=yj+hf(tj-1,yj-1) y(tj) yj-y(tj)

0 0.0 NaN (Ñk ban ñaàu) 1.000 1.000 0


1 0.2 0-(2)(1) = - 2.000 1.0 + (0.2)(-2.0) = 0.60 0.688 -0.0879
2 0.4 0.2 – (2)(0.6) = -1.000 0.6 + (0.2)(-1.0) = 0.40 0.512 -0.1117
3 0.6 0.4 – (2)(0.4) = -0.4 0.4 + (0.2)(- 0.4) = 0.32 0.427 -0.1065

So saùnh vôùi ñoà thò :

Ñoái vôùi h ñaõ bieát, sai soá lôùn


nhaát trong keát quaû soá ñoù laø sai
soá rôøi raïc toaøn cuïc

max (  ( y j  y (t j )) )
j
 Ñaùnh giaù sai soá :
Sai soá ñòa phöông taïi moãi böôùc laø:

ej = yj – y(tj)
vôùi y(tj) laø keát quaû chính xaùc taïi tj

GDE = max( ej ) j = 1, …

h max(ej ) Giaûi baèng Matlab:

0.200 0.1117 function [t,y] = odeEuler(diffeq,tn,h,y0)]


0.100 0.0502 t = (0:h:tn)’;
0.050 0.0240
0.025 0.0117
n = length(t);
y = y0 + zeros(n , 1);
for j = 2 : n
y(j) = y(j – 1) + h* feval(diffeq,t(j -1),y(j-1));
>> rhs = inline(‘cos(t)’,’t’,’y’) ; end
>> [t,Y] = odeEuler(rhs,2*pi,0.01, 0) ;
>> plot(t,Y,’o’) ;
Matlab code
2.4
% (i) Exact solution Exact
sol = dsolve('Dz = z^2 * cos(2*t)', ... 2.2 Euler
'z(0)=1', 't'); 2
pretty(sol)
t = linspace(0, 6, 601); 1.8
z = eval(vectorize(sol)); 1.6
% (ii) Euler's method
tn = 6; z0 = 1; h = 0.125; 1.4
[teul,zeul] =odeEuler(@f,tn,h,z0); 1.2
% Exact solution - Euler approximate solution
1
plot(t,z, teul,zeul,'r-.')
legend('Exact', 'Euler') 0.8
grid on
0.6
%
echo off; diary off 0.4
0 1 2 3 4 5 6
%--------------------------------------------------------
function [t,z]=odeEuler(f,tn,h,z0)
% Function M-file f.m t=(0:h:tn)';
function zp = f(t,z) n=length(t);
zp = z.^2 .* cos(2.*t); z=z0+zeros(n,1);
%----------------------------- for j=2:n
z(j)=z(j-1)+h*feval(f,t(j-1),z(j-1));
end
Example: Euler’s method
dy1
 y2
dt
y1 (t  0)  1; y2 (t  0)  1.5
dy2
  y2  sin y1  sin t
dt
Khảo sát khoảng thời gian từ (t=0:0.2:20) giây.

 Main program f = inline('[y(2);-.1*y(2)-


sin(y(1))+sin(t)]','t','y')
[T Y] = myeuler(f,[0 20],[1;-1.5],100);
Y1=Y(:,1);
Y2=Y(:,2);
t=0:0.2:20;
plot(t,Y1,'b',t,Y2,'r')
title('phuong phap EULER')
xlabel('thoi gian t')
ylabel('chyen vi')
legend('Y1','Y2')
grid on
function [T , Y] = myeuler (f,tspan ,y0 ,n)
% function [T , Y] = myeuler (f,tspan ,y0 ,n)
% Solves dy/dt = f(t,y) with initial condition y(a) = y0
% on the interval [a,b] using n steps of Euler s method .
% Inputs : f -- a function f(t,y) that returns a column vector of the same
% length as y
% tspan -- a vector [a,b] with the start and end times
% y0 -- a column vector of the initial values , y(a) = y0
% n -- number of steps to use
% Outputs : T -- a n+1 column vector containing the times
% Y -- a (n +1) by d matrix where d is the length of y
% Y(j,i) gives the ith component of y at time T(j)
a = tspan (1); b = tspan (2); % parse starting and ending points
h = (b-a)/n; % step size
t = a; T = a; % t is the current time and T will record all times
y = y0; % y is the current variable values , as a column vector
Y = y0'; % Y will record the values at all steps , each in a row
for i = 1:n
y = y + h*f(t,y); % Euler update of y to next time
t = a + i*h; % The next time .
T = [T; t]; % Record t and y into T and Y.
Y = [Y; y'];
end
Phöông phaùp Runge-Kutta
Tính ñoä doác ôû 4 vò trí öùng vôùi moãi böôùc laëp:
k 1  f (t j , y j )
h h
k 2  f (t j  , y j  k1 )
2 2
h h
k 3  f (t j  , y j  k 2 )  k1 k2 k3 k4 
y j 1  y j  h       O(h5 )
2 2 6 3 3 6
k 4  f (t j  h, y j  hk 3 )

Söû duïng haøm thư viện Matlab:


Söû duïng ode45
Cuù phaùp :
[t,Y] = ode45(diffep,tn,y0)
[t,Y] = ode45(diffep,[t0 tn],y0)
[t,Y] = ode45(diffep,[t0 tn],y0,options)
[t,Y] = ode45(diffep,[t0 tn],y0,options,arg1,arg2,…)
Giaûi baèng Matlab
>> rhs = inline(‘cos(t)’,’t’,’y’) ;
>> [t,Y] = odeRK4(rhs,2*pi,0.01, 0) ;
function [t,y] = odeRK4(diffeq,tn,h,y0) >> plot(t,Y,’o’) ;
t = (0:h:tn)’;
n = length(t) ;
y = y0+ zeros(n , 1) ; Haøm thö vieän Matlab
h2= h /2 ; h3= h /3 ; h6= h /6 ;
for j = 2 : n [t,Y] = ode45(diffeq,tn,y0)
k1 = feval(diffeq, t(j -1), y(j-1)) ; >> rhs = inline(‘cos(t)’,’t’,’y’) ;
k2 = feval(diffeq , t(j -1)+h2, y(j-1)+h2*k1 ) ; >> [t,Y] = ode45(rhs,[0 2*pi], 0) ;
k3 = feval(diffeq , t(j -1)+h2, y(j-1)+h2*k2 ) ; >> plot(t,Y,’r’,’linewidth’,2) ;
k4 = feval(diffeq , t(j -1)+h , y(j-1)+h*k3) ;
y(j) = y(j – 1) + h6* (k1+k4) + h3*(k2+k3);
end
Ví duï dy
 cos( t ) y(0) = 0
dt
clear all 2
clc
1.8
rhs = inline('cos(t)','t','y') ;
[t,Y] = odeRK4(rhs,2*pi,0.01, 0) ; 1.6

plot(t,Y,'o') ; 1.4

hold on 1.2
rhs = inline('cos(t)','t','y') ;
1
[t,Y] = ode45(rhs,[0 2*pi], 0) ;
0.8
plot(t,Y,'r','linewidth',2) ;
0.6
function [t,y] = odeRK4(diffeq,tn,h,y0)
t = (0:h:tn)'; 0.4

n = length(t) ; 0.2

y = y0+ zeros(n , 1) ; 0
0 1 2 3 4 5 6 7
h2= h /2 ; h3= h /3 ; h6= h /6 ;
for j = 2 : n
k1 = feval(diffeq, t(j -1), y(j-1)) ;
k2 = feval(diffeq , t(j -1)+h2, y(j-1)+h2*k1 ) ;
k3 = feval(diffeq , t(j -1)+h2, y(j-1)+h2*k2 ) ;
k4 = feval(diffeq , t(j -1)+h , y(j-1)+h*k3) ;
y(j) = y(j-1) + h6* (k1+k4) + h3*(k2+k3);
end
dy
 x, y ( x  0)  y0
dx
Exact x2
y   y0
2
Code Matlab
 4th Order Runge-Kutta Couple
Code Matlab
 General Procedure for Higher Order ODEs
 Hệ cấu trúc với TMD
Hình 2 Hệ SDOF với một TMD

Hình 4. Tải động đất EL-Centro 1940

Hình 3 Mô hình vật lý


 Dạng ma trận cấu trúc và TLD

 Runge-Kutta với Matlab code

Đặt
Example: Runge-Kutta method (slide 25)

function dz = ham(t,z) 
 Main program ms =3;md= 5;  ks = 10; kd=8;cs=0.5, cd=0.3 ;  w = 2;ugg=0.1
dz = zeros(4,1);  
clear;  clc;  dz(1) = z(2); 
y0=[0.01 0 0 1]'; dz(2) =(10*sin(w*t)‐ms*ugg+cd*z(4)+kd*z(3))/ms‐
tmin=0; tmax=20; (cs/ms)*z(2)‐(ks/ms)*z(1);
[t,dz]=ode45('ham',[tmin tmax],y0) dz(3) = z(4); 
plot(t,dz(:,1),'color','b', 'linewidth',2.5);hold on dz(4) =(md*ugg‐md*z(2))/md‐(cd/md)*z(4)‐
plot(t,dz(:,3),'color','r', 'linewidth',2.5); (kd/md)*z(3);
title('BIEU DO GIAI BANG PHUONG PHAP 
RUNGEKUTTA');
xlabel('Thoi gian t')
ylabel('Dap ung dao dong')
legend('chuyen vi cau truc',' chuyen vi TLD')
grid on; 
%‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
clear; clc;
options = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4 1e-5 1e-5]);
[t,dz] = ode45(@RK,[0 20],[0.01 0 0 1],options);
figure;
plot(t,dz(:,1),'color','b', 'linewidth',2.5);hold on
plot(t,dz(:,3),'color',‘r', 'linewidth',2.5);
title('BIEU DO GIAI BANG PHUONG PHAP RUNGEKUTTA');
xlabel('Thoi gian t')
ylabel(‘Dap ung dao dong')
Legen(‘chuyen vi cau truc’,’ chuyen vi TLD’)
grid on;
%------------------------------------------------
function dz = RK(t,z)
ms =3;md= 5; ks = 10; kd=8;cs=0.5, cd=0.3 ; w = 2;ugg=0.1
dz = zeros(4,1);
dz(1) = z(2);
dz(2) =(10*sin(w*t)-ms*ugg+cd*z(4)+kd*z(3))/ms (cs/ms)*z(2)-(ks/ms)*z(1);
dz(3) = z(4);
dz(4) = =(md*ugg-md*z(2)/md-(cd/md)*z(4)-(kd/md)*z(3);
Scripts file

m file
 Mô hình 1 cấu trúc SDOF có kháng chấn

Hình 8: Hệ 1 cấu trúc SDOF với kháng chấn


 Mô hình kết nối 2 cấu trúc SDOF có kháng chấn

Hình 9. Mô hình kết nối 2 các cấu trúc SDOF với thiết bị kháng chấn
dưới tác dụng tải động đất
Hình 11. Gia tốc nền theo thời gian El-CENTRO
từ động đất California Hoa Kỳ 18-5-1940

Hình 10. Mô hình các cấu trúc khung phẳng MDOF


kết nối thiết bị kháng chấn đặt tầng 2 dưới tác dụng
tải động đất
Ví dụ
Cho moâ hình vaät lyù cuûa tôøi nhö hình veõ. Vaät naëng 1 vaø 3 coù khoái löôïng laàn löôït laø m1, m3 vaø

Puli 2 coù baùn kính r , khoái löôïng m2 vaø moâmen quaùn tính quanh truïc quay laø I 2 . Tính chất đđđ
ñaøn hoài cuûa daây 4 ñöôïc moâ hình laø xo coù ñoä cöùng k1 vaø k2 . Ñieåm A di chuyeån theo phöông y
theo qui luaät y  a cos t
Thieát laäp phöông trình vi phaân dao ñoäng cuûa heä döôùi daïng ma traän.

Giải
- Choïn goác thôøi gian taïi vò trí ban đầu ở trạng thái cân bằng động.
- Choïn toïa ñoä suy roäng laø  , y1 , y3 lần lượt là góc xoay của puli, độ dịch
chuyển theo phương thẳng đứng của các vật nặng m1 , m3.

- Ñoäng naêng cuûa heä: 1 1 1 1


T m1 y 12  m3 y 32  m2 y 32  I 2 2
2 2 2 2
 m1 y 12  m2  m3  y 32  I 2 2
1 1 1
2 2 2
- Theá naêng đàn hồi trên các lò xo

V  k 1 r  y 3  y1   k 2  y 3  r   k 3  y  y 3 
1 2 1 2 1 2

2 2 2
- Năng lượng tiêu tán trên các giảm chấn
1 1
D c1 y 12  c 3 y 32
2 2
- Phương trình Lagrange loại 2

d  T  T D V
     Q1
dt  y1  y1 y1 y1
d  T  T D V
     Q2
dt  y3  y3 y3 y3
 
d  T  T D V
      Q3
dt      
- Dạng ma trận

m1 0 0   y1  c1 0 0   y 1   k 1  k1  k 1 r   y1   0 


0 m 2  m3 0   y2    0 c3 0   y 3     k 1 k 1  k 2  k 3 k 1 r  k 2 r   y 3   k 3 a cos t 

 0 0 I 2      0 0 0      k 1 r k1 r  k 2 r k 1 r 2  k 2 r 2      0 

?
Ví dụ

Daàm tuyeät ñoái cöùng ñoàng chaát 1 coù khoái löôïng M, chiều dài L, momen quán tính IA được đỡ bởi lò xo
có độ cứng k và giảm chấn có hệ số c như hình vẽ. Xem dầm 2 có khối lượng không đáng kể, modun đàn
hồi E và mômen quán tính J. Dầm có một đầu ngàm và đầu tự do gắn một vật nặng có khối lượng m.
Thiết lập phương trình vi phân dao động hệ.
Giải

- Choïn goác thôøi gian taïi vò trí ban đầu ở trạng thái cân bằng động.
- Choïn toïa ñoä suy roäng laø lần , ylượt là góc xoay của dầm, độ dịch chuyển
theo phương thẳng đứng của các vật nặng m .

- Ñoäng naêng cuûa heä:


1 2 1 2 1 1 1
T I A  my  ML22  my 2
2 2 23 2
- Theá naêng đàn hồi trên lò xo và dầm

1 1 3EJ 2
k  y  L  
2
V y
2 2 L3
- Năng lượng tiêu tán trên các giảm chấn

D  c y  L 
1 2

2
- Lực suy rộng
Q  FL  F0 L cos t
- Phương trình Lagrange loại 2

d  T  T D V
      Q1
dt      
d  T  T D V
     Q2
dt  y  y y y

- Dạng ma trận

1     kL2  kL 
0     cL cL          F0 L cos t 
2 2
12 ML
      3EJ   y   
 y   cL c   y    kL  k 0 
 0 m  L3 
Car model 4 DOFs

FBD diagram of half car model


Math model 4 DOFs

Matrix form
PHUONG PHAP GIAI TICH
0.06

0.04

BIEN DO DAO DONG


0.02

-0.02

-0.04

-0.06
0 2 4 6 8 10 12 14 16 18 20
TRUC t(s)
PHUONG PHAP BIEN DOI LAPLACE
0.06

0.04

0.02

TRUC x
0

-0.02

-0.04

-0.06
0 2 4 6 8 10 12 14 16 18 20
TRUC t(s)
c. Phương pháp Runge-Kutta
%------------------------------------------------
clear; clc;
[t,x] = ode45(@RK,[0 20],[0 1]);
figure;
plot(t,x(:,1),'color','b', 'linewidth',2.5);
BIEU DO GIAI BANG PHUONG PHAP RUNGEKUTTA
title('BIEU DO GIAI BANG PHUONG PHAP 0.1
RUNGEKUTTA'); 0.08
xlabel('Thoi gian t')
ylabel('Bien do dao dong') 0.06

grid on; 0.04

%------------------------------------------------Bien do dao dong


0.02
function dx = RK(t,x)
0
m = 1; k = 16; b=8; F = 1; w = 1;
dx = zeros(2,1); -0.02

dx(1) = x(2); -0.04


dx(2) = -(k/m)*x(1) -(b/m)*dx(1)+ (1/m)*sin(w*t);
-0.06
0 2 4 6 8 10 12 14 16 18 20
Thoi gian t
Example
Solution
c. Phương pháp Runge-Kutta
%------------------------------------------------
clear; clc;
[t,du] = ode45(@RK,[0 20],[-1 0 2 0]);
figure; BIEU DO GIAI BANG PHUONG PHAP RUNGEKUTTA

plot(t,du(:,1),'color','b', 'linewidth',2.5);hold on 2.5 chuyen vi vat 1

plot(t,du(:,3),'color',‘r', 'linewidth',2.5); 2 chuyen vi vat 2

1.5
title('BIEU DO GIAI BANG PHUONG PHAP
1
RUNGEKUTTA');

Dap ung dao dong


0.5
xlabel('Thoi gian t')
0
ylabel(‘Đáp ứng dao dong')
-0.5
grid on;
-1
%------------------------------------------------
-1.5
function du = RK(t,u)
-2
m1 =3;m2= 5; k1 = 10; k2=8; ; w = 2;
-2.5
du = zeros(4,1); 0 2 4 6 8 10
Thoi gian t
12 14 16 18 20

du(1) = u(2);
du(2) = -(k1+k2)/m1*u(1) +(k2/m1)*u(3);
du(3) = u(4);
du(4) = (k2/m2)*u(1) -(k2/m2)*u(3)+(3/m2)*sin(w*t);
Matlab program
1-D Heat transfer element

1-D fin
1-D fin
Math model (Strong form)
This image cannot currently be display ed.

k : thermal conductivity
hc : convection coefficient
• Dirichlet boundary condition A : cross-sectional area of the fin
P : perimeter of the fin
This image cannot currently be display ed.

T : temperature,
• Convective heat loss at free
end
This image cannot currently be display ed.
Tf : ambient temperature in the fluid
 Hệ cấu trúc với TLD

Hình 1 Hệ SDOF với một TLD

 Với cấu trúc


 Với TLD

 Với cấu trúc và TLD


 Dạng ma trận cấu trúc và TLD

Với
 Beta- Newmark với Matlab code

cho

Tính
Với

Ổn định không điều kiện


( Find Displacement, Acceleration, Velocity)
Determine the displacement, Acceleration and Velocity at t=0.1:0.5s 1Psi  0.007 MPa, 1inch  2.54 cm, 1 Kg  2.2 lb
 Solution
F(t)
1 2
3
(1) (2) 2
x

1Psi  0.007 MPa, 1inch  2.54 cm, 1lb  2.2 kg


 Solution

element dof
1 (1,,2) 1 2
2 (2,3) 2 3

Stability condition

Node dof Giaù trò

1 1 0
 Forced vibrations of a two-degrees-of-freedom
system
Matlab code
- Main program
clear all
% Newmark method employed for the integration of
% a two-degree-of-freedom system –
% numerical values
m1=400; m2=300; k1=60000; k2=50000;
ome=5; p10=10; p20=15;
tmax=10; % maximum value of time
h=0.02; % time step
tt=0:h:tmax; % time range
xm=[m1 0; 0 m2]; % mass matrix
xk=[k1+k2 -k2; -k2 k2]; % stiffness matrix
% numerical solution
% Newmark method parameters
gama=0.5; beta=0.25;
a1=1/(beta*h*h);
a1d=gama/(beta*h);
ck=0; cm=0; % damping coefficients
xd=ck*xk+cm*xm; % damping matrix
p=[0 0]'; % initial forces
xk=xk+a1*xm+a1d*xd; % effective. stiff. matrix
acc=xm\p; % initial acceleration
dis=zeros(2,1); % initial displacements
vel=zeros(2,1); % initial velocities
t=0; % initial time
kk=0; % step counter
kmax=round(tmax/h); % how many steps for tmax
% dimensions of arrays to be plotted later
dis1=zeros(kmax,1);
dis2=zeros(kmax,1);
while t<=tmax, % integate while t <= tmax
[disn,veln,accn] =VTRnewmd(beta,gama,dis,vel,acc,xm,xd,xk,p,h);
kk=kk+1; % increment step counter
t=t+h; % increment time value
dis1(kk)=dis(1); dis2(kk)=dis(2); % save for plotting
dis=disn; vel=veln; acc=accn; % new values for next step
p1=p10*sin(ome*t); p2=p20*sin(ome*t); % excitation forces
p=[p1 p2]';
end;
% analytical solution
% amplitudes of steady-state motion according to Eq. (5.192)
jm=(k1+k2-m1*ome^2).*(k2-m2*ome^2)-k2^2;
am1=(p10*(k2-m2*ome^2)+p20*k2)/jm;
am2=(p20*(k1+k2-m1*ome^2)+p10*k2)/jm;
% calculate steady-state response
% displacements according to (5.182) are
x1=am1*sin(ome*tt);
x2=am2*sin(ome*tt);
dis1t=dis1'; dis2t=dis2';
% compare results - plot it
figure(1)
subplot(211); plot(tt(1:kmax),dis1t(1:kmax),'k:', ...
tt,x1,'k', 'linewidth', 2);
lab='Steady-state (solid) vs. transient + steady-state (dotted)';
title(lab)
ylabel('particle 1')
subplot(212); plot(tt(1:kmax),dis2t(1:kmax),'k:', ...
tt,x2,'k', 'linewidth', 2);
lab=['gamma for Newmark is ' num2str(gama)];
title(lab); xlabel('time'); ylabel('particle 2')
sgama = gama*100;
str_sgama = int2str(sgama);
file_name = ['V2Etwodof3a' str_sgama];
print('-deps', file_name); print('-dmeta',file_name);

- Function
function [disn,veln,accn] =VTRnewmd(beta,gama,dis,vel,acc,xm,xd,xk,p,h)
% Newmark integration method
%
% beta, gama coefficients
% dis,vel,acc displacements, velocities, accelerations at the begining of time step
% disn,veln,accn corresponding quantities at the end of time step
% xm,xd mass and damping matrices
% xk effective rigidity matrix
% p loading vector at the end of time step
% h time step
% constants
a1=1/(beta*h*h);
a2=1/(beta*h);
a3=1/(2*beta)-1;
a4=(1-gama)*h;
a5=gama*h;
a1d=gama/(beta*h);
a2d=gama/beta-1;
a3d=0.5*h*(gama/beta-2);
% effective loading vector
r = p + xm*(a1*dis+a2*vel+a3*acc)+xd*(a1d*dis+a2d*vel+a3d*acc);
% solve system of equations for displacements xk
disn=xk\r;
% new velocities and accelerations
accn=a1*(disn-dis)-a2*vel-a3*acc;
veln=vel+a4*acc+a5*accn;
% end of VTRnewmd
 Natural Frequencies of a One-Dimensional Bar
 Boundary Valuation Problem

Phöông trình vi phaân caáp 2 :


ÖÙng duïng cho caùc baøi toaùn veà thanh , truyeàn nhieät ,vv…
Daïng : ay’’(x)+by’(x)+cy(x)=f(x) 0<x<L

Ñieàu kieän bieân :


a/ y(x=0) = y0 *
y(x= L) = y L *
b/ y’(x=0) = yo' *
y(x= L) = yL *
c/ y(x=0) = y0 *

y’(x=L) = y 'L *
 Xaáp xæ baèng löôùi ñeàu sai phaân trung taâm: h =x
yi 1  yi 1 1
yi ’ =  0(h2) vôùi O(h2) = - h2fi’’’
2h 6
yi 1  2 yi  yi 1 1
yi’’ =  0(h2) vôùi 0(h2) = - h2fi’’’
h2 12
phöông trình sai phaân

 y  2 y i  y i 1   y i 1  y i 1 
a  i 1 2   b    cyi  f ( x)
 h   2 h 

(2a+ bh)yi+1+(2ch2 - 4a)yi + (2a - bh)yi-1 = 2h2f(x)


i=1 => (2a + bh)y2 + (2ch2 - 4a)y1 + (2a - bh)yo = 2h2f(x)

i=2 => (2a + bh)y3 + (2ch2 - 4a)y2 + (2a - bh)y1 = 2h2f(x)

i=3 => (2a + bh)y4 + (2ch2 - 4a)y3 + (2a - bh)y2 = 2h2f(x)

i=4 => (2a + bh)y5 + (2ch2 - 4a)y4 + (2a - bh)y3 = 2h2f(x)

i=5 => (2a + bh)y6 + (2ch2 - 4a)y5 + (2a - bh)y4 = 2h2f(x)

Ñaët :
A=2a + bh
B=2ch2 - 4a
C=2a – bh
Ñöa heä 5 phöông trình treân veà daïng ma traän :

a/ By1 +Ay2 = 2h2f(x)-Cy0*


Cy1+By2+Ay3 = 2h2f(x)
Cy2+By3+Ay4 = 2h2f(x)
Cy3+By4+Ay5 = 2h2f(x)
Cy4+By5 = 2h2f(x)-AyL*

dạng ma trận :

B A 0 0 0  y1  2h 2 f(x) - Cy 0 * 
C    2 
 B A 0 0  
y 2 2h f(x) 
0 C B A 0  y3  = 2h 2 f(x) 
     
 y4  2h f(x) 
0 0 C B A 2

 y5   2 
0 0 0 C B   2h f(x) - Ay L *
y2  y0
b/ y'1 
2h
 y'0 * (Biết)  y0=y2 -2hy0’*

B A  C 00 0  y1  2hCy 0 '*  2h 2 f(x)


C B    2 
 A 0 0   y2   2h f(x) 
 y3  2h 2 f(x) 
 0

C B A 0
  =  2 
0 0 C B A  y4  2h f(x) 
0 0 0 C B  y5   2 
   2h f(x) - Ay L * 
y6  y4
c/ y'5 
2h
 y L '*  y 6  y 4  2hy L '*

B A 0 0 0  y1  2h 2 f(x) - Cy 0 * 
C B    2 
 A 0 0   y2   2h f(x) 
0 C

B A 0

 y3 
  = 2h 2 f(x)



0 0 C B A  y4  2h f(x)
2 
0 0 0 A  C B   y5   2 
  2h f(x) - 2hAy L '*
Ví duï
Thanh chịu lực như hình 1.
- Thiết lập phương trình vi phân chuyển
f
động hệ.
- Áp dụng phương pháp sai phân trung tâm P
x
tính chuyển vị và nội lực trên các phần tử
L
(trong phân tích tĩnh).
Hình 1. Thanh chịu kéo
Biết: L=1m, E=2.1011 N/m2, A=0.001m2,
f=1kN/m, P=2kN

d  du 
 E A   f  0; 0  x  L
dx  dx 
du
u (0)  0 EA P
dx xL
Ví duï
Truyeàn nhieät qua caùc baûn moûng hình 2.
Trong thöïc teá, caùc baûn moûng thöôøng
ñöôïc söû duïng ñeå phaân taùn nhieät ñoä töø
moät vaät theå noùng sang moâi tröôøng xung
quanh coù nhieät ñoä thaáp hôn (bộ tản
nhieät). Baûn chaát cuûa söï tản nhieät nhôø
vaøo söï ñoái löu treân phaàn dieän tích lôùn
ñöôïc taïo ra töø caùc baûn moûng .
Vôùi loaïi baøi toaùn naøy, treân moãi caùnh
ta giaû söû raèng nhieät ñoä laø phaân boá ñeàu
treân chieàu daøy vaø thay ñoåi doïc theo
chieàu daøi caùnh (theo phöông doøng Hình 2. Truyeàn nhieät baûn moûng
nhieät).
T   dT 
cp   kx  ; x0  x  xL (a)
t x  dx 
T  2T
  2 ; x0  x  xL (b)
t x
k
 x
cp

Forward finite difference approximation

(c)

central finite difference approximation

(d)
Substituting eqs. © and (d) into eq. (b)

(e)

(f)
Matlab code
Phöông trình vi phaân caáp 4 caân baèng daàm, v. v.
Daïng toång quaùt: ayi  byi  cy i dyi  eyi  f (x) 0<x<L
(1)
Ñieàu kieän bieân :
a/ y ( x  0)  y o *
y ( x  0)  y 0 *

y ( x  L)  y L *
y ( x  L )  y L*
b/ y ( x  0)  y o *
y ( x  0)  y 0 *
y( x  L )  y L *
y ( x  L)  y L *
(1)

Xaáp xæ (1) baèng löôùi ñeàu sai phaân trung taâm : h = x


y i  ( y i  2  4 y i 1  6 y i  4 y i 1  y i  2 ) / h 4
y i  ( y i  2  2 y i 1  2 y i 1  y i  2 ) / 2h 3
y i  ( y i 1  2 y i  y i 1 ) / h 2 (2)
y  y i 1
y i  i 1
2h

Thay (2) vaøo (1)

a b
4
( y i2  4 y i 1  6 y i  4 y i 1  y i 2 )  3
( y i  2  2 y i 1  2 y i 1  y i  2 )
h 2h
c d
 2 ( y i 1  2 y i  y i 1 )  ( y i 1  y i 1 )  ey i  f ( x) (3)
h 2h
 a b   4a b c d   6 a 2c 
 4  3  y i  2   4  3  2   y i 1   4  2  e  y i
h 2h  h h h 2h  h h  (4)
 4a b c d   a b 
   4  3  2   y i 1   4  3  y i  2  f ( x)
 h h h 2h  h 2h 
a b
Ñaët A = 4  3
h 2h
 4a b c d 
B =     
h
4
h 3
h 2
2 h 
(5)
6 a 2c
C=  2 e
h 4
h

4a b c d
D=    
h 4 h 3 h 2 2h
a b
E= 
h 4 2h 3
(4) (6)

Daïng toång quaùt :  A yi  2  B yi 1  Cyi  D yi 1  Eyi  2  f ( x)

a/ y ( 0)  y 0 *
y (0)  y 0 *
y ( L)  y L *
y ( L)  y L*

y0  y0 *
y1  y 1
y 0   y 0 * => y1  y1  2hy0 *
2h
y N  y N 1  2 y N  y N 1  2h 2 y L *
y N  y N  2  2 y N 1  2 y N 1  y N  2  2h 3 y L*
Vôùi : N = 6 i= 1 6
Daïng ma traän: 0  y1   f (x)  2hEy0 * Dy0 *
C  E B A 0 0 0 0
 D    
 C B A 0 0 0 0  y2   f (x)  Ey0 * 
 E D C B A 0 0 0  y3   f ( x)

    
 0 E D C B A 0 0  y4   f (x) 
    
 0 0 E D C B A 0  y5   f (x)
  
 0 0 0 E D C B A y6   f (x) 
 0    
0 0 1 2 0  2 1  y7   2h3 yL* 
  
 0 0 0 0 1  2 1 0  y8   2h yL *
2 
b/ y0  y0 * 
y 0'' = y 0'' *

y ( x  L)  y L *
y " ( x  L)  y L" *
y 0"  y1  2 y 0  y 1  2h 2 y 0" *
yN  yL *
y "N  y N 1  2 y N  y N 1  2h 2 y L" *
N=6
i=1=> y 1  2h 2 y L" * 2 y 0  y1
(C  E ) y1  By2  Ay3  f ( x )  ( D  2 E ) y0  2h 2 Ey0" *

Dy1  Cy 2  By3  Ay 4  f ( x )  Ey 0
Ey1  Dy 2  Cy3  By 4  Ay5  f ( x )
Ey 2  Dy 3  Cy 4  By 5  Ay 6  f ( x)
Ey 3  Dy 4  Cy 5  By 6  Ay 7  f ( x)
Ey 4  Dy 5  Cy 6  By 7  Ay8  f ( x)
y6 = yL *
y5 – 2 y6 + y7 = 2h y L *
2 "
Daïng ma traän

C  E B A 0 0 y1   f (x)  (D  2E) y0  2h2 Ey0" *


0 0 0
 
 D
 C B A 0 y2  
0 0 0 f (x)  Ey0 
 E D C B 0 y3  
A 0 0 f (x) 
    
 0 E D C B A 0
0 y4  

f (x) 
 0 0 E D 0 y5  
C B A f (x) 
    
 0 0 0 E D C B A y6   f (x) 
 0 0 0 0 0 1 0 0 y7   yL * 
    
 0 0 0 0 1  2 1 0 y8   2 "
2h yL * 
Example
Consider the bending of a simply supported beam loaded with a uniform load.

Uniform distribution load: Q( )  Q( x )  q 0

E  2.1011 N / m 2 , I  0.01m 4 , L  1m, q0  1000 N / m


• HYPERBOLIC PDE

• PARABOLIC PDE

• ELLIPTIC PDE
VIBRATION OF RODS - BARS
x x +dx
Equilibrium
position dx
• Consider a small
element of the bar
F F+dF • Deflection is now
along x (called
x longitudinal
vibration)
w(x,t) • F= ma on small
element yields the
0 l following:
Newton’s Law:
 2 w( x, t )
F  dF  F   A( x)dx (6.53)
 t 2
Constitutive relation:
 w( x, t )    w( x, t ) 
F  EA( x)  dF   EA( x)  dx
 x  x  x 
   w( x, t )   2 w( x, t )
 EA( x)    A( x) (6.55)
 x  x   t 2

E  2 w( x, t )  2 w( x, t )
A( x)  constant   (6.56)
  x 2
 t 2

At the clamped end: w(0, t )  0, (6.57)


 w( x, t )
At the free end: EA 0 (6.58)
 x x 
Example 6.5 Compute the mode shapes and natural frequencies of a
cantilevered bar with uniform cross section.

w( x, t )  X ( x)T (t )  c 2 wxx ( x, t )  wtt ( x, t )


X ( x) T(t )
  2   2 (6.59)
X ( x) c T (t )
 X ( x)   2 X ( x)  0, X (0)  0, AEX ()  0 (i)

 T(t )  c  T (t )  0, initial conditions (ii)
2 2

From equation (i) the form of the spatial solution is


X ( x)  a sin  x  b cos  x
Next apply the boundary conditions in (i) to get the
characteristic equation and the form of the eigenfunction:
Apply the initial conditions (ii)

a sin(0)  b cos(0)  0
a cos( )  b sin( )  0
 0 1 
 b  0 and det   0
cos( )  sin( ) 
 2n  1
cos    0   n  2  , n  1, 2,3,

 X ( x)  a sin( (2n  1) x ), n  1, 2,3,
 n n
2
The time response equation 
2
 2  2n  1 
Tn (t )  c    T (t )  0
 2 
(2n  1)c (2n  1)c
 Tn (t )  An sin t  Bn cos t
2 2
Thus the solution implies oscillation with Frequencies

(2n  1)c (2n  1) E


n   , n  1, 2,3 (6.63)
2 2 
BENDING VIBRATIONS OF A BEAM
w (x,t)
f (x,t) M(x,t)+Mx(x,t)dx
f(x,t)
h1
M(x,t)

h2 V(x,t)+Vx(x,t)dx
x w(x,t)
ꞏQ
V(x,t)
dx A(x)= h1h2
x x +dx
bending stiffness  EI(x) Next sum forces in the y - direction (up, down)
E  Youngs modulus Sum moments about the point Q
I (x)  cross-sect. area moment of Use the moment given from
inertia about z stenght of materials
 2 w(x,t) Assume sides do not bend
M (x,t)  EI(x)
 x2 (no shear deformation)
Summing forces and moments

 V (x,t)   2 w(x,t)
V (x,t)  dx  V (x,t)  f (x,t)dx  A(x)dx
 x  t 2

 M(x,t)   V (x,t) 
M(x,t)  dx  M(x,t)  V (x,t)  dxdx
 x   x 
dx
 f (x,t)dx 0
2
M(x,t)  V (x,t) f (x,t)  2
   V (x,t)dx    (dx)  0

 x   x 2 
0
M(x,t)
 V (x,t)  
x
Substitute into force balance equation yields:
 2 M(x,t)  2 w(x,t)
 dx  f (x,t)dx  A(x)dx
x 2
t 2
Dividing by dx and substituting for M yields
 2 w(x,t)  2   2 w(x,t) 
A(x)  2 EI(x)  f (x,t)
t 2
x  x 
2

Assume constant stiffness to get:


 2 w(x,t) 2  4 w(x,t) EI
c  0, c 
t 2
x 4
A
The possible boundary conditions

Free end Clamped (or fixed) end


 2w deflection  w  0
bending moment  EI 2  0
x
w
   2 w  slope  0
shear force  EI 2  0 x
x  x 

Pinned (or simply supported) end Sliding end


deflection  w  0 w
slope  0
 2w x
bending moment=EI 2  0    2 w 
x shear force  EI 2  0
x  x 
Solution of the time equation yields the oscillatory nature

X ( x ) T(t )
c 2
  2 
X ( x) T (t )
T(t )   2T (t )  0 
T (t )  A sin t  B cos t
Two initial conditions:
w( x, 0)  w0 ( x), wt ( x, 0)  w 0 ( x)
Spatial equation results in a boundary value problem (BVP)
2
 
X (x)    X(x)  0.
c 
2

  A 2
Define     
4

c  EI
x
Let X(x)  Ae to get :
X(x)  a1 sin x  a2 cos x  a3 sinh x  a4 cosh x
Apply boundary conditions to get 3
constants and the characteristic equation
Example
compute the mode shapes and natural frequencies for a clamped-
pinned beam.
At fixed end x  0 and
X(0)  0  a2  a4  0
X (0)  0   (a1  a3 )  0
At the pinned end, x   and
X()  0 
a1 sin   a2 cos   a3 sinh   a4 cosh   0
EIX ()  0 

 (a1 sin   a2 cos   a3 sinh   a4 cosh )  0


 2
The 4 boundary conditions in the 4 constants can be
written as the matrix equation:
 0 1 0 1 a1  0
    
  0  0 a2  0
 sin  cos  sinh  cosh  a3  0
 2    
 sin   cos   sinh   cosh a4  0

2 2 2
  
 
 
  

  
 
 
   
 
B a

Ba  0,a  0  det(B)  0 
 tan   tanh 
The characteristic equation
Solve numerically (fsolve) to obtain solution to
transcendental (characteristic) equation

1  3.926602  2   7.068583 3  10.210176


 4   13.351768 5  16.493361 
n 5
(4n  1)
n 
4
Next solve Ba=0 for 3 of the constants:
With the eigenvalues known, now solve for the eigen-functions

Ba  0 yields 3 constants in terms of the 4th : Choose a


a1  a3 from the first equation
a2  a4 from the second equation
(sinh  n   sin  n )a3  (cosh  n   cos  n )a4  0
from the third (or fourth) equation
Solving yields :
cosh  n   cos  n 
a3   a4
sinh  n   sin  n 
cosh  n   cos  n  
 X n (x)  (a4 ) n  (sinh  n x  sin  n x)  cosh  n x  cos  n x
 sinh  n   sin  n  
Plot the mode shapes to the system response
cosh n cos n
X n, x . sinh n. x sin n. x cosh n. x cos n. x
sinh n sin n

1.5
Mode 2
Mode 3
1
Note zero slope
0.5

X 3.926602 , x
0 0.2 0.4 0.6 0.8 1
X 7.068583 , x
Non zero slope
X 10.210176 , x 0.5

1.5

2 Mode 1
x

You might also like