SYSTEM OF ORDINARY DIFFERENTIAL EQUATIONS Example: Mathematical model of a mechanical system is defined as a system of differential equations as follows: x 1 20 x 1 15 x 2 1.5 f 0 x 2 12 x 1 5 x 2 2 f where f is input, x1 are x2 outputs. At t=0 x1=2 and x2=-1. a) Find the eigenvalues of the system. b) If f is a step input having magnitude of 3, find x1(t). c) If f is a step input having magnitude of 3, find x2(t). d) Find the response of x1 due to the initial conditions. e) Find the response of x2 due to the initial conditions. f) How do you obtain [sI-A]-1 with MATLAB? SYSTEM OF ORDINARY DIFFERENTIAL EQUATIONS Let us obtain the State Variables Form so as to 1st order derivative terms are left-hand side and non-derivative terms are on the right-hand side. x 1 20 x 1 15 x 2 1.5 f x 2 12 x 1 5 x 2 2 f x 1 20 15 x 1 1.5 x 2 f x 12 5 2 2 A State Variables Form B s 0 20 15 s 20 15 0 s 12 5 12 s 5 sI A det sI A (s 20) * (s 5) (12) * (15) s2 15 s 280 D(s) s 5 15 1 [sI A] 2 s 15 s 280 12 s 20 1 SYSTEM OF ORDINARY DIFFERENTIAL EQUATIONS a) Eigenvalues are roots of the polynomial D(s) or eigenvalues of the matrix A. or D(s) s2 15 s 280 0 15 152 4 * 1 * (280) s 1 ,2 2 *1 s1 25.8371 s2 10.8371 Initial Conditions b) x1(t) due to the forcing X 1 (s) 1 x 1 (0) 1 1.5 sI A sI A F(s) X 2 (s)G x 2 (0) 2 General Solution Solution due to the initial conditions Solution due to the input Particular Solution Homogeneous Solution 15 1.5 3 X1( s ) s 5 1 2 12 s 20 2 s X ( s ) s 15 s 280 2 P X1P ( s ) 1 s 2 15 s 280 [( s 5 )* 1.5 15* 2 ] 3 4.5 s 67.5 s s 3 15 s 2 280 s clc;clear; num=[4.5 67.5]; den=[1 15 -280 0]; [r,p,k]=residue(num,den) SYSTEM OF ORDINARY DIFFERENTIAL EQUATIONS X 1P ( s ) 0.0515 0.2925 0.2411 s 25.8371 s 10.8371 s 0 8 8 x 10 7 6 5 x1(t) 4 3 x1P ( t ) 0.0515 e 25 .8371 t 10 .8371 t 0.2925 e 0.2411 2 1 0 System is instable because of the positive root. -1 0 0.5 1 t(s) c) x2(t) due to input 6 s 174 1 3 X 2Ö (s) 2 [15 * 1.5 (s 20) * 2] 3 s 15 s 280 s s 15 s2 280 s 2 Laplace transform of x2p 0.02 0.6014 0.6214 X 2P( s ) s 25.8371 s 10.8371 s 0 x2 P ( t ) 0.02 e 25 .8371 t 0.6014 e10 .8371 t 0.6214 16 8 x 10 14 12 10 x2(t) clc;clear; num=[6 174]; den=[1 15 -280 0]; [r,p,k]=residue(num,den) 1.5 8 6 4 2 0 0 0.5 1 t(s) 1.5 2 SYSTEM OF ORDINARY DIFFERENTIAL EQUATIONS d) x1 due to the initial conditions. 15 2 X1 (s) s 5 1 2 12 s 20 1 X ( s ) s 15 s 280 2 h X1h (s) 2 s 25 (s 5) * 2 15 * (1) s2 15 s 280 s2 15 s 280 clc;clear; num=[2 -25]; den=[1 15 -280]; [r,p,k]=residue(num,den) x 1h (t) 2.0907e 25.8371t 0.0907e10.8371t e) x2 due to the initial conditions 12 * 2 (s 20) * (1) s4 X 2h (s) s2 15 s 280 s2 15 s 280 clc;clear; num=[-1 4]; den=[1 15 -280]; [r,p,k]= residue(num,den) x 2h (t) 0.8136e 25.8371t 0.1864e10.8371t f) [sI-A]-1 with Matlab. clc;clear; syms s; i1=eye(2) A=[-20 15;12 5]; a1=inv(s*i1-A) pretty(a1) SYSTEM OF ORDINARY DIFFERENTIAL EQUATIONS Example: Mathematical model of a system is given below. Where V(t) is input, q1(t) and q2(t) are outputs. 3(q1 q2 ) V 2q 1 a) Write the equations in the form of state variables. 0.8q2 3(q1 q2 ) 0 b) Write Matlab code to obtain eigenvalues of the system. c) Write Matlab code to obtain matrix [sI-A]-1. d) Results of (b) and (c) which are obtained by computer are as follows: 4 s2 15 6s 6 1 2 [sI A]1 15 4 s 6 s 4 s 6 2 s1,2 0.75 1.7854i, s3 s (4 s 6 s 15) 2 15 s 15 s 4 s 6 s q1 (0) 5 At t=0 q2 (0) 3 and V(t) is a step input having magnitude of 2. q 2 (0) 0.4 Find the Laplace transform of q 2 due to the initial conditions. e) Find the Laplace transform of q1 due to the input. 2 0 V2(t) t (s) SYSTEM OF ORDINARY DIFFERENTIAL EQUATIONS 3(q1 q2 ) V 2q 1 0.8q2 3(q1 q2 ) 0 a) State variables are q1, q2 and q 2 u. System of differential equations is arranged so as to 1st order derivative terms are lefthand side and non-derivative terms are on the right-hand side. q 1 1.5 q1 1.5 q2 0.5 V q 2 u u q2 3.75 q1 3.75 q2 State variables 0 q1 0.5 q 1 1.5 1.5 0 1 q2 0 V q 2 0 u 3.75 3.75 0 u 0 A b) Matlab code which gives the eigenvalues of the system. A=[-1.5 1.5 0;0 0 1;3.75 -3.75 0]; eig(A) c) Matlab code which produces [sI-A]-1 clc;clear A=[-1.5 1.5 0;0 0 1;3.75 -3.75 0]; syms s; i1=eye(3); sia=inv(s*i1-A); pretty(sia) B SYSTEM OF ORDINARY DIFFERENTIAL EQUATIONS d) Q 1 (s) q1 (0) 1 Q 2 (s) [sI A] q2 (0) U(s) u(0) h Q 2h (s) Uh (s) 4 s2 15 6s 6 5 Q 1 (s) 1 2 15 4 s 6 s 4 s 6 Q 2 (s) 2 3 s ( 4 s 6 s 15 ) 2 U(s) 15 s 15 s 4 s 6 s 0.4 h 1 2 5 * 15 s ( 3 * 15 s ) 0 . 4 * ( 4 s 6s) 2 s (4 s 6s 15) 2 2 1 . 6 s 75 s 45 s 2 . 4 s 1 . 6 s 122.4s 1.6s 122.4 Q 2h (s) Uh (s) 2 2 2 s (4 s 6s 15) s(4s 6s 15) 4s 6s 15 e) Q 1 (s) 0.5 2 1 Q ( s ) [ sI A ] 0 2 U(s) 0 s Ö 4 s2 15 6s 6 0.5 Q 1 (s) 1 2 2 Q ( s ) 15 4 s 6 s 4 s 6 2 2 0 s s ( 4 s 6 s 15 ) 2 U(s) 15 s 15 s 4 s 6 s 0 Ö 4 s2 15 1 2 2 Q 1Ö (s) 0.5 * (4s 15) * 4 s (4 s2 6s 15) s 4 s 6 s3 15s2 SYSTEM OF ORDINARY DIFFERENTIAL EQUATIONS Example: Write the equation of motion of the mechanical system given below in the State Variables Form. Force applied on the system is F(t)=100 u(t) (a step input having magnitude 100 Newtons) and at t=0 x0=0.05 m and dx/dt=0. Find x(t) and v(t). d2x dx m 2 c k x F(t) dt dt State variables are x and v=dx/dt . x v v x m=20 kg c k 1 v x F(t) m m m 1 x 0 x 0 F(t) v k / m c / m v 1 / m Matlab program to obtain eigenvalues: >>a=[0 1;-250 -2];eig(a) c=40 Ns/m k=5000 N/m 1 x 0 x 0 F(t) v 250 2 v 0.05 SYSTEM OF ORDINARY DIFFERENTIAL EQUATIONS 1 x 0 x 0 F(t) v 250 2 v 0.05 Applying Laplace transform and arranging, 1 X(s) 0 s X(s) x 0 0 V(s) 0.05 F(s) sV ( s ) v 250 2 0 1 X(s) x 0 0 X(s) 0 s F(s) V(s) 250 2 V(s) v 0 0.05 1 X(s) x 0 0 1 0 X(s) 0 s F(s) 0 1 V(s) 250 2 V(s) v 0 0.05 X(s) x 0 0 sI A F(s) V(s) v 0 0.05 X(s) 1 x 0 1 0 sI A sI A F(s) V ( s ) v 0 . 05 0 Solution due to the initial conditions Solution due to the input 1 s sI A 250 s 2 sI A 1 s 2 1 1 Det(sI A) 250 s Det(sI A) s2 2 s 250 SYSTEM OF ORDINARY DIFFERENTIAL EQUATIONS sI A 1 s 2 1 1 2 s 2 s 250 250 s X(s) 1 2 V(s) s 2 s 250 F(s) 100 s s 2 1 0.05 1 250 s 0 s2 2 s 250 0.05 s2 0.1 s 5 X(s) s (s2 2s 250) clc;clear; syms s; A=[0 1;-250 -2]; i1=eye(2); %unit matix with dimension 2x2 siA=s*i1-A; x0=[0.05;0]; %Initial conditions B=[0;0.05]; Fs=100/s; X=inv(siA)*x0+inv(siA)*B*Fs; pretty(X) V(s) s 2 1 0 100 250 s 0.05 s 7.5 s2 2s 250 For x(t) ; clc;clear; num=[0.05 0.1 5]; den=[1 2 250 0]; [r,p,k]=residue(num,den) X(s) 0.015 0.001i 0.015 0.001i 0.02 s (1 15.7797i) s (1 15.7797i) s SYSTEM OF ORDINARY DIFFERENTIAL EQUATIONS Steady-state value (Final value) 0.015 0.001i 0.015 0.001i 0.02 X(s) s (1 15.7797i) s (1 15.7797i) s t x(t) Ae cos(15.7797t ) 0.02 A 2 * abs(0.015 0.001i) 0.0301 angle(0.015 0.001i) 0.0666 rad x(t) 0.0301e t cos(15.7797t 0.0666) 0.02 0.06 Initial value, x0 0.05 0.04 x(t) 0.03 0.02 0.01 0 -0.01 0 1 2 3 t (s) 4 5 6 SYSTEM OF ORDINARY DIFFERENTIAL EQUATIONS V(s) For v(t) clc;clear; num=[-7.5]; den=[1 2 250]; [r,p,k]=residue(num,den) 0.2376i 0.2376i s (1 15.7797i) s (1 15.7797i) A 2 * abs(0.2376i) 0.4752 v(t) Ae t cos(15.7797t ) v(t) 0.4752e t cos(15.7797t 1.57) angle(0.2376i) / 2 rad 0.4 0.3 0.2 0.1 0 v(t) V(s) 7.5 s2 2s 250 -0.1 -0.2 -0.3 -0.4 -0.5 0 1 2 3 t (s) 4 5 6 SYSTEM OF ORDINARY DIFFERENTIAL EQUATIONS Example: Mathematical model of a mechanical system having two degrees of freedom is given below. If F(t) is a step input having magnitude 50 Newtons, find the Laplace transforms of x and θ. mx 2k x 2k R F(t) mR 2 c R2 2k R x 3k R2 0 10x 4000 x 800 F(t) R=0.2 m m=10 kg k=2000 N/m 0.4 0.8 800 x 240 0 c=20 Ns/m x State variables x v F(t) 10 2 2000 x 600 v x 400 x 80 x v 0 x 0 0 0 80 v 400 2000 600 0 x 0 0 1 0 F(t) 0 0 v 0.1 0 2 0 1 SYSTEM OF ORDINARY DIFFERENTIAL EQUATIONS X(s) x 0 (s) 0 1 1 [sI A] [sI A] F(s) V(s) v 0.1 (s) 0 0 clc;clear A=[0 0 1 0;0 0 0 1;-400 80 0 0;2000 -600 0 -2]; syms s; eig(A) i1=eye(4); sia=inv(s*i1-A); pretty(sia) D(s) s 4 2s 3 1000 s2 800 s 80000 If the initial conditions are zero, only the solution due to the input exists. For F(s) Eigenvalues: [sI A]1 System is stable since real parts of all eigenvalues are negative. 50 s SYSTEM OF ORDINARY DIFFERENTIAL EQUATIONS X(s) (s) V(s) (s) 0 0 50 0.1 s 0 0.1 * (s2 2 s 600) 5s2 10s 3000 50 X(s) 4 s 2 s3 1000 s2 800 s 80000 s s 5 2 s 4 1000 s3 800 s2 80000 s (s) 0.1 * 2000 50 10000 s 4 2 s 3 1000 s2 800 s 80000 s s 5 2 s 4 1000 s 3 800 s2 80000 s