Professional Documents
Culture Documents
ODE
5.1 Euler Method
5.2 Runge-Kutta method
PDE
5.5 Examples
Initial Valuation Problem
Moâ hình thöïc teá Moâ hình vaät lí
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)
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, …
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
Đặ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 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
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.
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 y1 y1 y1 y1
d T T D V
Q2
dt y3 y3 y3 y3
d T T D V
Q3
dt
- Dạng ma trận
?
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 .
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
Matrix form
PHUONG PHAP GIAI TICH
0.06
0.04
-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
1.5
title('BIEU DO GIAI BANG PHUONG PHAP
1
RUNGEKUTTA');
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
Với
Beta- Newmark với Matlab code
cho
Tính
Với
element dof
1 (1,,2) 1 2
2 (2,3) 2 3
Stability condition
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
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
Ñ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 :
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 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 xL
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
(c)
(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)
a b
4
( y i2 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)
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 * => y1 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 yL*
0 0 0 0 1 2 1 0 y8 2h yL *
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
• 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
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
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) dxdx
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
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
Ba 0,a 0 det(B) 0
tan tanh
The characteristic equation
Solve numerically (fsolve) to obtain solution to
transcendental (characteristic) equation
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