Ch 05 state variabe modes and simulation methods

28 152 0
Ch 05 state variabe modes and simulation methods

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

11/17/2012 System Dynamics 5.01 State Variable Models and Simulation Methods State Variable Models and Simulation Methods HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.01 Nguyen Tan Tien State Variable Models and Simulation Methods §1 State Variable Models - Consider the second-order equation 5𝑦 + 7𝑦 + 4𝑦 = 𝑓(𝑡) - Define 𝑥1 ≡ 𝑦 𝑥1 = 𝑦 𝑥2 ≡ 𝑦 ⟹ 𝑥2 = 𝑦 then 𝑥1 = 𝑥2 𝑥2 = − 𝑥1 − 𝑥2 + 𝑓(𝑡) 5 - These two equations, called the state equations, are the statevariable form of the model, and the variables 𝑥1 and 𝑥2 are called the state variables - The choice of state variables is not unique, but the choice must result in a set of first order differential equations HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 11/17/2012 System Dynamics 5.03 State Variable Models and Simulation Methods §1 State Variable Models - Example 5.1.1 State-Variable Model of a Two-Mass System Consider the two-mass system with the equations of motion 5𝑥1 + 12𝑥1 + 5𝑥1 − 8𝑥2 − 4𝑥2 = 3𝑥2 + 8𝑥2 + 4𝑥2 − 8𝑥1 − 4𝑥1 = 𝑓(𝑡) Put these equations into state-variable form Solution Define 𝑧1 ≡ 𝑥1 , 𝑧2 ≡ 𝑥1 , 𝑧3 ≡ 𝑥2 , 𝑧4 ≡ 𝑥2 Then 𝑧1 = 𝑧2 12 𝑧2 = −𝑧1 − 𝑧2 + 𝑧3 + 𝑧4 5 𝑧3 = 𝑧4 8 𝑧4 = 𝑧1 + 𝑧2 − 𝑧3 − 𝑧4 + 𝑓(𝑡) 3 3 HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.04 Nguyen Tan Tien State Variable Models and Simulation Methods §1 State Variable Models 1.Vector-Matrix Model of State-Variable Models - Vector-matrix notation enables us to represent multiple equations as a single matrix equation - Example 2𝑥1 + 9𝑥2 = 3𝑥1 − 4𝑥2 = can be represented in the form 𝑥1 = 𝑥 −4 or 𝑨𝒙 = 𝒃 𝑥1 𝑨= ,𝒙= 𝑥 ,𝒃= −4 HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 11/17/2012 System Dynamics 5.05 State Variable Models and Simulation Methods §1 State Variable Models - Example 5.1.2 Vector-Matrix Form of a Single-Mass Model Express the mass-spring-damper model 𝑥1 = 𝑥2 𝑘 𝑐 𝑥2 = 𝑓 𝑡 − 𝑥1 − 𝑥2 𝑚 𝑚 𝑚 as a single vector-matrix equation Solution The equations can be written as one equation as follows 𝑥1 𝑥1 𝑓(𝑡) 𝑘 𝑐 = + 𝑥2 𝑥2 − − 𝑚 𝑚 𝑚 In compact form this is 𝒙 = 𝑨𝒙 + 𝒃𝑓(𝑡) 𝑥1 𝑘 𝑐 ,𝒃 = 𝒙 = 𝑥 ,𝑨 = − − 𝑚 𝑚 𝑚 HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.06 Nguyen Tan Tien State Variable Models and Simulation Methods §1 State Variable Models - Example 5.1.3 Vector-Matrix Form of the Two-Mass Model Express the model 𝑧1 = 𝑧2 , 𝑧2 = −𝑧1 − 𝑧3 = 𝑧4 , 𝑧4 = 𝑧1 + 12 𝑧2 + 𝑧3 + 𝑧4 5 8 𝑧 − 𝑧3 − 𝑧4 + 𝑓(𝑡) in vector-matrix form Solution In vector-matrix form these equations are 𝒛 = 𝑨𝒛 + 𝒃𝑓 0 𝑧1 12 −1 − 𝑧2 5 𝒛= 𝑧 ,𝑨= ,𝒃= 0 0 8 𝑧4 − − 3 3 HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 11/17/2012 System Dynamics 5.07 State Variable Models and Simulation Methods §1 State Variable Models 2.Standard Form of the State Equation 𝒙 = 𝑨𝒙 + 𝑩𝒖 𝒙: 𝑛 × state vector 𝑨: 𝑛 × 𝑛 system matrix 𝑩: 𝑛 × 𝑚 control or input matrix 𝒖: 𝑚 × input vector 3.The Output Equation - The output vector contains the variables that are of interest for the particular problem at hand 𝒚 = 𝑪𝒙 + 𝑫𝒖 𝒚: 𝑝 × output vector 𝑪: 𝑝 × 𝑛 state output matrix 𝑫: 𝑝 × 𝑚 control output matrix HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.08 Nguyen Tan Tien State Variable Models and Simulation Methods §1 State Variable Models - Example 5.1.4 The Output Equation for a Two-Mass Model Consider the two-mass model 5𝑥1 + 12𝑥1 + 5𝑥1 − 8𝑥2 − 4𝑥2 = 3𝑥2 + 8𝑥2 + 4𝑥2 − 8𝑥1 − 4𝑥1 = 𝑓(𝑡) a Suppose the outputs are 𝑥1 and 𝑥2 Determine the output matrices 𝑪 and 𝑫 b Suppose the outputs are 𝑥2 − 𝑥1 , 𝑥2 , and 𝑓 Determine the output matrices 𝑪 and 𝑫 Solution 0 𝑧1 12 −1 − 𝑧2 5 𝒛 = 𝑨𝒛 + 𝒃𝑓, 𝒛 = 𝑧 , 𝑨 = ,𝒃= 0 0 8 𝑧4 − − 3 3 HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 11/17/2012 System Dynamics 5.09 State Variable Models and Simulation Methods §1 State Variable Models a.The outputs are 𝑥1 and 𝑥2 𝑥1 𝑧1 𝒚= 𝑥 = 𝑧 = ⟹ 𝒚 = 𝑪𝒙 + 𝑫𝑓 where 0 𝑪= 0 𝑫= 𝑧1 0 𝑧2 + 𝑓 𝑧3 𝑧4 0 HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.10 Nguyen Tan Tien State Variable Models and Simulation Methods §1 State Variable Models b.The outputs are 𝑥2 − 𝑥1 , 𝑥2 , and 𝑓 𝑧1 −𝑥1 + 𝑥2 −𝑧1 + 𝑧3 −1 𝑧 𝑧4 𝑥2 𝒚= = = 0 𝑧 + 𝑓 𝑓 𝑓 0 0 𝑧 ⟹ 𝒚 = 𝑪𝒙 + 𝑫𝑓 where −1 𝑪= 0 0 0 𝑫= HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 11/17/2012 System Dynamics 5.11 State Variable Models and Simulation Methods §1 State Variable Models 3.Model Forms having Numerator Dynamics Consider the model with numerator dynamics or input derivatives 𝑑3𝑦 𝑑2 𝑦 𝑑𝑦 𝑑𝑓 +3 +7 + 6𝑦 = + 9𝑓(𝑡) 𝑑𝑡 𝑑𝑡 𝑑𝑡 𝑑𝑡 With the existence of 𝑑𝑓 𝑑𝑡 the state variables are not so easy to identify to put the model in the standard form 𝒙 = 𝑨𝒙 + 𝒃𝑢 𝒚 = 𝑪𝒙 + 𝑫𝑢 HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.12 Nguyen Tan Tien State Variable Models and Simulation Methods §1 State Variable Models - Example 5.1.5 Numerator Dynamics in a First-Order System Consider the transfer function and its corresponding equation 𝑍(𝑠) 5𝑠 + = , 𝑧 + 2𝑧 = 5𝑢 + 3𝑢 𝑈(𝑠) 𝑠+2 Demonstrate two ways of converting this model to a statevariable model in standard form Solution a.Divide the numerator and denominator of the 𝑇𝐹 by 𝑠 𝑍(𝑠) 5𝑠 + + 3/𝑠 = = 𝑈(𝑠) 𝑠+2 + 2/𝑠 The objective is to obtain a in the denominator, which is then used to isolate 𝑍(𝑠) as follows 𝑍 𝑠 = − 𝑍 𝑠 + 5𝑈 𝑠 + 𝑈 𝑠 = 3𝑈 𝑠 − 2𝑍 𝑠 + 5𝑈(𝑠) 𝑠 𝑠 𝑠 HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 11/17/2012 System Dynamics 5.13 State Variable Models and Simulation Methods §1 State Variable Models The term within square brackets multiplying 1/𝑠 is the input to an integrator, and the integrator’s output can be selected as a state-variable 𝑥 𝑍 𝑠 = 𝑋(𝑠) + 5𝑈(𝑠) 𝑋 𝑠 ≡ 𝑠 3𝑈 𝑠 − 2𝑍 𝑠 = 3𝑈 𝑠 − 𝑋 𝑠 + 5𝑈 𝑠 𝑠 = [−2𝑋 𝑠 − 7𝑈(𝑠)] 𝑠 This gives 𝑥 = −2𝑥 − 7𝑢, with output equation 𝑧 = 𝑥 + 5𝑢 This fits the standard form 𝒙 = 𝑨𝒙 + 𝒃𝑢 𝒚 = 𝑪𝒙 + 𝑫𝑢 with 𝑨 = −2, 𝑩 = −7, 𝒚 = 𝑧, 𝑪 = 1, and 𝑫 = where HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.14 Nguyen Tan Tien State Variable Models and Simulation Methods §1 State Variable Models b.Rewrite the transfer function in the form 𝑈(𝑠) 𝑍 𝑠 = (5𝑠 + 3) 𝑠+2 Define the state-variable 𝑥 as follows 𝑈(𝑠) 𝑋 𝑠 ≡ ⟹ 𝑠𝑋 𝑠 = −2𝑋 𝑠 + 𝑈(𝑠) 𝑠+2 The state equation 𝑥 = −2𝑥 + 𝑢 To find the output equation, note that 𝑈 𝑠 𝑍 𝑠 = 5𝑠 + = 5𝑠 + 𝑋 𝑠 = 5𝑠𝑋 𝑠 + 3𝑋(𝑠) 𝑠+2 ⟹ 𝑍 𝑠 = −2𝑋 𝑠 + 𝑈 𝑠 + 3𝑋 𝑠 = −7𝑋 𝑠 + 5𝑈(𝑠) and the output equation 𝑧 = −7𝑥 + 5𝑢 HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 11/17/2012 System Dynamics 5.15 State Variable Models and Simulation Methods §1 State Variable Models - Example 5.1.6 Numerator Dynamics in a Second-Order System Obtain a state-variable model for 𝑋 𝑠 4𝑠 + = 𝑈 𝑠 5𝑠 + 4𝑠 + Relate the initial conditions for the state variables to the given initial conditions 𝑥(0) and 𝑥(0) Solution Divide by 5𝑠 to obtain a in the denominator −1 −2 𝑠 + 𝑠 𝑋 𝑠 = −1 −2 𝑈 𝑠 1+ 𝑠 + 𝑠 5 Use the in the denominator to solve for 𝑋(𝑠) 7 𝑋 𝑠 = 𝑠 −1 + 𝑠 −2 𝑈 𝑠 − 𝑠 −1 + 𝑠 −2 𝑋(𝑠) 5 5 HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.16 Nguyen Tan Tien State Variable Models and Simulation Methods §1 State Variable Models 4 7 ⟹𝑋 𝑠 = − 𝑋 𝑠 + 𝑈 𝑠 + 𝑈 𝑠 − 𝑋(𝑠) 𝑠 5 𝑠 5 This equation shows that 𝑋(𝑠) is the output of an integration Thus 𝑥 can be chosen as a state variable 𝑥1 𝑋1 𝑠 = 𝑋(𝑠) The term within square brackets is the input to an integration, and thus the second state variable can be chosen as 7 7 𝑋2 𝑠 = 𝑈 𝑠 − 𝑋(𝑠) = 𝑈 𝑠 − 𝑋1 (𝑠) 𝑠 5 𝑠 5 then 4 𝑋1 𝑠 = − 𝑋 𝑠 + 𝑈 𝑠 + 𝑋2 (𝑠) 𝑠 5 HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 11/17/2012 System Dynamics 5.17 State Variable Models and Simulation Methods §1 State Variable Models The state equations 4 𝑥1 = − 𝑥1 + 𝑥2 + 𝑢 5 7 𝑥2 = − 𝑥1 + 𝑥2 + 𝑢 5 The output equation 𝑥 = 𝑥1 The standard form 𝒙 = 𝑨𝒙 + 𝒃𝑢 𝒚 = 𝑪𝒙 + 𝑫𝑢 where 4 − 𝑨= ,𝑩 = ,𝑪 = ,𝑫 = 7 − 5 HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.18 Nguyen Tan Tien State Variable Models and Simulation Methods §1 State Variable Models HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 11/17/2012 System Dynamics 5.19 State Variable Models and Simulation Methods §1 State Variable Models 4.Transfer Function Versus State-Variable Models - Both models are equally effective and equally easy to use - The decision whether to use a transfer function model or a state-variable model depends on many factors, including personal preference - Application of basic physical principles sometimes directly results in a state-variable model - If you need to obtain the step response as a function, it might be easier to convert the model to transfer function form and then use the Laplace transform to obtain the desired function HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.20 Nguyen Tan Tien State Variable Models and Simulation Methods §2 State Variable Methods with Matlab 1.Creation of transfer functions or conversion to transfer function Function: tf(num,den) Example Model 5𝑥 + 7𝑥 + 4𝑥 = 𝑓(𝑡), or 𝑋(𝑠) = 𝐹(𝑠) 5𝑠 + 7𝑠 + Matlab sys1 = tf(1, [5, 7, 4]) 𝑑3 𝑥 𝑑2 𝑥 𝑑𝑥 𝑑2 𝑓 𝑑𝑓 Model 𝑑𝑡 − 𝑑𝑡 + 𝑑𝑡 + 6𝑥 = 𝑑𝑡 + 𝑑𝑡 + 5𝑓(𝑡) Matlab sys2 = tf([4, 3, 5], [8, -3, 5, 6]) HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 10 11/17/2012 System Dynamics 5.27 State Variable Models and Simulation Methods §2 State Variable Methods with Matlab - Solution The initial condition in term of variable 𝑧 𝑧1 (0) 𝑥1 (0) 𝑧2 (0) 𝑥1 (0) −3 𝒛(0) = = = 𝑧3 (0) 𝑥2 (0) 𝑧4 (0) 𝑥2 (0) The output equation 𝒚 = 𝑪𝒛 + 𝑫𝑓 with 𝑪 = 0 , 𝑫 = Matlab A = [0,1,0,0;-1,-12/5,4/5,8/5;0,0,0,1;4/3,8/3,-4/3,-8/3]; B = [0; 0; 0; 1/3]; C = [1, 0, 0, 0]; D = [0]; sys5 = ss(A, B, C, D); initial(sys5, [5, -3, 4, 2]) HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.28 Nguyen Tan Tien State Variable Models and Simulation Methods §2 State Variable Methods with Matlab 6.Impulse response of LTI models Function: impulse(sys) Example Matlab impulse(sys1) 7.Step response of LTI models Function: step(sys) Example Matlab step(sys1) 8.Simulate time response of LTI models to arbitrary inputs Function: lsim(sys) Example Matlab t=0:0.01:2*pi; u=cos(t); lsim(sys1, u, t) HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 14 11/17/2012 System Dynamics 5.29 State Variable Models and Simulation Methods §2 State Variable Methods with Matlab 9.Convert roots to polynomial Function: poly(A) Example Matlab A = [0, 1; -6, -5]; poly(A) HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.30 Nguyen Tan Tien State Variable Models and Simulation Methods §3 The Matlab ode Functions Numerical methods for solving differential equations - Example 5.3.1 MATLAB Solution of 𝑦 = 𝑠𝑖𝑛𝑡 Use the ode45 solver for the problem 𝑦 = 𝑠𝑖𝑛𝑡, 𝑦 = for ≤ 𝑡 ≤ 4𝜋 The exact solution is 𝑦(𝑡) = − 𝑐𝑜𝑠𝑡 Solution • Create and save the function file, named sinefn.m function ydot = sinefn(t,y) ydot = sin(t); • Matlab [t, y] = ode45(@sinefn, [0, 4*pi], 0); y_exact = - cos(t); plot(t,y,'o',t,y_exact),xlabel('t'),ylabel('y(t)'), axis([0 4*pi -0.5 2.5]) HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 15 11/17/2012 System Dynamics 5.31 State Variable Models and Simulation Methods §3 The Matlab ode Functions - Example 5.3.2 A Rocket-Propelled Sled A rocket-propelled sled on a track is represented in the figure as a mass 𝑚 with an applied force 𝑓 that represents the rocket thrust The rocket thrust initially is horizontal, but the engine accidentally pivots during firing and rotates with an angular acceleration of 𝜃 = 𝜋/50𝑟𝑎𝑑/𝑠 Compute the sled’s velocity 𝑣 for ≤ 𝑡 ≤ if 𝑣(0) = Rocket thrust is 4000𝑁 and the sled mass is 450𝑘𝑔 Solution The sled’s equation of motion 450𝑣 = 4000𝑐𝑜𝑠𝜃(𝑡) 80 ⟹𝑣= 𝑐𝑜𝑠𝜃(𝑡) HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.32 Nguyen Tan Tien State Variable Models and Simulation Methods §3 The Matlab ode Functions To obtain 𝜃(𝑡), note that 𝑡 𝑡 𝑡 𝜋 𝜋 𝜋 𝜃 = 𝜃 𝑑𝑡 = 𝑡 ⟹ 𝜃 = 𝜃 𝑑𝑡 = 𝑡𝑑𝑡 = 𝑡 50 100 0 50 The equation of motion becomes 80 𝜋 80 𝑡 𝜋 𝑣= 𝑐𝑜𝑠 𝑡 ⟹𝑣 𝑡 = 𝑐𝑜𝑠 𝑡 𝑑𝑡 100 100 • Create and save the function file, named sled.m function vdot = sled(t,v) vdot = 80*cos(pi*t^2/100)/9; • Matlab [t,v] = ode45(@sled,[0 6],0); plot(t,v,t,(80*t/9)),xlabel('t (s)'), ylabel('v (m/s)'), gtext('\theta = 0'),gtext('\theta \neq 0') HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 16 11/17/2012 System Dynamics 5.33 State Variable Models and Simulation Methods §3 The Matlab ode Functions Using the ODE solvers to solve an equation of order or greater Consider the second-order equation 5𝑦 + 7𝑦 + 4𝑦 = 𝑓 𝑡 Define the state variable 𝑥1 ≡ 𝑥2 𝑥2 ≡ − 𝑥1 − 𝑥2 + 𝑓(𝑡) 5 • Create and save the function file, named example1.m function xdot = example1(t,x) xdot = [x(2); (1/5)*(sin(t)-4*x(1)-7*x(2))]; • Matlab [t, x] = ode45(@example1, [0, 6], [3, 9]); plot(t,x) HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.34 Nguyen Tan Tien State Variable Models and Simulation Methods §3 The Matlab ode Functions - Example 5.3.3 A Nonlinear Pendulum Model The pendulum shown in the figure consists of a concentrated mass 𝑚 attached to a rod whose mass is small compared to 𝑚 The rod’s length is 𝐿 The equation of motion for this pendulum 𝑔 𝜃 + 𝑠𝑖𝑛𝜃 = 𝐿 Suppose that 𝐿 = 1𝑚 and 𝑔 = 9.81𝑚/𝑠 Use Matlab to solve this equation for 𝜃(𝑡) for two cases • Case 𝜃(0) = 0.5𝑟𝑎𝑑, 𝜃(0) = • Case 𝜃(0) = 0.8𝜋𝑟𝑎𝑑, 𝜃(0) = HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 17 11/17/2012 System Dynamics 5.35 State Variable Models and Simulation Methods §3 The Matlab ode Functions Solution Rewrite the pendulum equation 𝑥1 ≡ 𝜃 = 𝑥2 𝑔 𝑥2 ≡ 𝜃 = − 𝑠𝑖𝑛𝑥1 = −9.81𝑠𝑖𝑛𝑥1 𝐿 • Create and save the function file, named pendulum.m function xdot = pendulum(t,x) xdot = [x(2); -9.81*sin(x(1))]; • Matlab [ta, xa] = ode45(@pendulum, [0, 5], [0.5, 0]); [tb, xb] = ode45(@pendulum, [0, 5], [0.8*pi, 0]); plot(ta,xa(:,1),tb,xb(:,1)),xlabel('Time (s)'), ylabel('Angle (rad)'),gtext('Case 1'),gtext('Case 2') HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.36 Nguyen Tan Tien State Variable Models and Simulation Methods §3 The Matlab ode Functions Matrix method Matrix operations can be used to reduce the number of lines to be typed in the derivative function file Consider the mass-spring-damper model 𝑚𝑦 + 𝑐𝑦 + 𝑘𝑦 = 𝑓(𝑡) Define 𝑥1 ≡ 𝑦, 𝑥2 ≡ 𝑦, the equation can be rewritten 𝑥1 = 𝑥2 𝑘 𝑐 𝑥2 = − 𝑥1 − 𝑥2 + 𝑓(𝑡) 𝑚 𝑚 𝑚 This can be written as one matrix equation as follows 𝑥1 𝑥1 𝑓(𝑡) 𝑘 𝑐 = 𝑥2 + 𝑥2 − − 𝑚 𝑐 𝑚 In compact form this is𝒙 = 𝑨𝒙 + 𝑩𝑓(𝑡), where 𝑥1 𝑨 = −𝑘 − 𝑐 , 𝑩 = , 𝑥 = 𝑥 𝑐 𝑚 𝑚 HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 18 11/17/2012 System Dynamics 5.37 State Variable Models and Simulation Methods Đ3 The Matlab ode Functions Create and save the function file, named msd.m function xdot = msd(t,x) m = 1; c = 2; k = 5; f = 10; A = [0, 1;-k/m, -c/m]; B = [0; 1/m]; xdot = A*x+B*f; • Matlab [t, x] = ode45(@msd, [0, 5], [0, 0]); plot(t,x),xlabel('Time (s)'), ylabel('Displacement (m) and Velocity (m/s)'), gtext('Displacement'), gtext('Velocity') HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.38 Nguyen Tan Tien State Variable Models and Simulation Methods §3 The Matlab ode Functions HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 19 11/17/2012 System Dynamics 5.39 State Variable Models and Simulation Methods §4 Simulink and Linear Models - Type simulink in the Matlab Command window to start Simulink - Create a new model - Start to use … HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.40 Nguyen Tan Tien State Variable Models and Simulation Methods §4 Simulink and Linear Models 1.Simulation Diagrams - Simulink models is constructed using a diagram that shows the elements of the problem to be solved Such diagrams are called simulation diagrams - Consider the equation 𝑦 = 10𝑓(𝑡) ⟹ 𝑦 𝑡 = 10𝑓 𝑡 𝑑𝑡 which can be thought of as two steps, using an intermediate variable 𝑥 𝑥 𝑡 = 10𝑓 𝑡 , 𝑦 𝑡 = HCM City Univ of Technology, Faculty of Mechanical Engineering 𝑥 𝑡 𝑑𝑡 Nguyen Tan Tien 20 11/17/2012 System Dynamics 5.41 State Variable Models and Simulation Methods §4 Simulink and Linear Models The summer is used to subtract as well as to sum variables 𝑧 =𝑥−𝑦 The summer symbol can be used to represent the equation 𝑦 = 𝑓 𝑡 − 10𝑦, which can be expressed as 𝑦 𝑡 = or as [𝑓 𝑡 − 10𝑦]𝑑𝑡 𝑦 = (𝑓 − 10𝑦) 𝑠 HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.42 Nguyen Tan Tien State Variable Models and Simulation Methods §4 Simulink and Linear Models - Example 5.4.1 Simulink Solution of 𝑦 = 10𝑠𝑖𝑛𝑡 Use Simulink to solve the following problem for ≤ 𝑡 ≤ 13 𝑑𝑦 10𝑠𝑖𝑛𝑡, 𝑦 =0 𝑑𝑡 The exact solution is 𝑦 𝑡 = 10 − 𝑐𝑜𝑠𝑡 Solution 1.Start Simulink and open a new model window 2.Select and place the Sine Wave block from Sources category (amplitude = 1, bias = 0, frequency = 1, phase = 0, sample time = 0) 3.Select and place the Gain block from the Math category (gain value = 10) 4.Select and place the Integrator block from the Continuous category (initial condition = 0) HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 21 11/17/2012 System Dynamics 5.43 State Variable Models and Simulation Methods §4 Simulink and Linear Models 5.Select and place the Scope block from the Sinks category 6.Connect the input port on each block to the outport port on the preceding block 7.Click on the Simulation menu, and click the Configuration Parameters item Click on the Solver tab, and enter 13 for the Stop time 8.Run the simulation by clicking on the Simulation menu, and then clicking the Start item 9.There is a bell sound when the simulation is finished HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.44 Nguyen Tan Tien State Variable Models and Simulation Methods §4 Simulink and Linear Models - Example 5.4.2 Exporting to the MATLAB Workspace Demonstrate how to export the results of the simulation to the Matlab workspace, where they can be plotted or analyzed with any of the Matlab functions Solution Modify the Simulink model constructed in Example 5.4.1 with refer to the figure HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 22 11/17/2012 System Dynamics 5.45 State Variable Models and Simulation Methods §4 Simulink and Linear Models 1.Delete the Scope block and the arrow connecting the Scope block 2.Select and place the To Workspace block from the Sinks category and the Clock block from the Sources category 3.Select and place the Mux block from the Signal Routing category (number of inputs = 2) 4.Connect the top input port of the Mux block to the output port of the Integrator block, connect the bottom input port of the Mux block to the outport port of the Clock block 5.Specify variable name 𝑦 as the output Specify the Save Format as Array 6.After running the simulation, to plot 𝑦(𝑡), type in the MATLAB Command window plot(y(:,2),y(:,1)),xlabel('t'),ylabel('y') HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.46 Nguyen Tan Tien State Variable Models and Simulation Methods §4 Simulink and Linear Models - Example 5.4.3 Simulink Model for 𝑦 = −10𝑦 + 𝑓(𝑡) Construct a Simulink model to solve 𝑦 = −10𝑦 + 𝑓 𝑡 , 𝑦 =1 where 𝑓 𝑡 = 2𝑠𝑖𝑛4𝑡, for ≤ 𝑡 ≤ Solution Simulink model for the problem HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 23 11/17/2012 System Dynamics 5.47 State Variable Models and Simulation Methods §4 Simulink and Linear Models 1.Modify the previous example by rearranging the blocks as shown in the figure, need to add a Sum block 2.Select the place the Sum block from the Math operations library, changing the sign of sum block to ± 3.To reverse the direction of the gain block, right-click on the block, select Format from the pop-up menu, and select Flip Block 4.Connect the negative input port of the Sum block to the output port of the Gain block Connect the input of the Gain to the arrow connecting the Integrator and the Scope 5.Select Configuration Parameters from the Simulation menu, and set the Stop time to 6.Run the simulation as before and observe the results in the Scope HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.48 Nguyen Tan Tien State Variable Models and Simulation Methods §4 Simulink and Linear Models 2.Simulating State Variable Models - Example 5.4.4 Simulink Model of a Two-Mass System Consider the state-variable model of a two-mass system 𝒛 = 𝑨𝒛 + 𝒃𝑓, with 0 𝑥1 𝑧1 12 −1 − 𝑧2 𝑥1 5 𝒛= 𝑧 = 𝑥 ,𝑨= ,𝒃= 0 0 8 𝑧4 𝑥2 − − 3 3 Develop a Simulink model to plot the unit-step response of the variables 𝑥1 and 𝑥2 with the initial conditions 𝑥1 = 0.2, 𝑥1 = 0, 𝑥2 = 0.5, 𝑥2 = HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 24 11/17/2012 System Dynamics 5.49 State Variable Models and Simulation Methods §4 Simulink and Linear Models - Solution The matrices in the output equation 𝒚 = 𝑪𝒛 + 𝑫𝑓(𝑡) 0 0 𝑪= , 𝑫= 0 0 1.Select and place Step block from the sources category (step time = 0, initial value = 0, final value = 1, sample time = 0) 2.Select and place the State-Space block (A = [0,1,0,0; -1,-12/5,4/5,8/5; 0,0,0,1; 4/3,8/3,-4/3,-8/3], B = [0;0;0;1/3], C = [1,0,0,0; 0,0,1,0], D = [0; 0], initial conditions = [0.2; 0; 0.5; 0]) 3.Select and place the Scope block 4.Connect all blocks 5.Set stop time = 25 The plots of both 𝑥1 and 𝑥2 will appear in the Scope HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.50 Nguyen Tan Tien State Variable Models and Simulation Methods §5 Simulink and Non-Linear Models - Example 5.5.1 Simulink Model of a Rocket-Propelled Sled A rocket-propelled sled on a track is represented in the figure as a mass 𝑚 with an applied force 𝑓 that represents the rocket thrust The rocket thrust initially is horizontal, but the engine accidentally pivots during firing and rotates with an angular acceleration of 𝜃 = 𝜋/50𝑟𝑎𝑑/𝑠 Compute the sled’s velocity 𝑣 for ≤ 𝑡 ≤ if 𝑣(0) = Rocket thrust is 4000𝑁 and the sled mass is 450𝑘𝑔 Use Simulink to obtain the solution a.Create a Simulink model to solve this problem, ≤ 𝑡 ≤ 10𝑠 b.Now suppose that the engine angle is limited by a mechanical stop to 600 Create a Simulink model to solve the problem HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 25 11/17/2012 System Dynamics 5.51 State Variable Models and Simulation Methods §5 Simulink and Non-Linear Models Solution Equations of motion 𝜋 80 𝜃= , 𝑣= 𝑐𝑜𝑠𝜃(𝑡) 50 ⟹ Simulation model a Simulink model without mechanical stop b Simulink model with mechanical stop HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.52 Nguyen Tan Tien State Variable Models and Simulation Methods §4 Simulink and Linear Models 3.Simulating the Transfer Function Models - Example 5.5.2 A Simulink Model of Response with a Dead Zone Create and run a Simulink simulation of a mass-springdamper system 𝑚𝑦 + 𝑐𝑦 + 𝑘𝑦 = 𝑓(𝑡) using the parameter values 𝑚 = 1, 𝑐 = 2, and 𝑘 = The forcing function is the function 𝑓(𝑡) = sin1.4𝑡 The system has the dead-zone nonlinearity shown in the figure HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 26 11/17/2012 System Dynamics 5.53 State Variable Models and Simulation Methods §4 Simulink and Linear Models Solution 1.Start Simulink and open a new model window 2.Select and place the Sine Wave block from the Sources category (amplitude = 1, bias = 0, frequency = 1.4, phase = 0, sample time = 0) 3.Select and place the Dead Zone block from the Discontinuities category (start = −0.5, end = 0.5) 4.Select and place the Transfer Function block from the Continuous category (numerator = [1], denominator = [1,2,4]) 5.Select and place the Scope block from the Sinks category 6.Connect all block ports 7.Run the simulation HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.54 Nguyen Tan Tien State Variable Models and Simulation Methods §4 Simulink and Linear Models To plot both the input and the output of the Transfer Function block versus time on the same graph 1.Delete the arrow connecting the Scope block to the Transfer Fcn block 2.Select and place the Mux block from the Signal Routing category 3.Connect all block ports 4.Run the simulation HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 27 11/17/2012 System Dynamics 5.55 State Variable Models and Simulation Methods §4 Simulink and Linear Models - Example 5.5.4 Simulink Model of a Nonlinear Pendulum The pendulum has the following nonlinear equation of motion, if there is viscous friction in the pivot and if there is an applied moment 𝑀(𝑡) about the pivot 𝐼𝜃 + 𝑐𝜃 + 𝑚𝑔𝐿𝑠𝑖𝑛𝜃 = 𝑀(𝑡) 𝐼: the mass moment of inertia about the pivot Create a Simulink model for this system for the case where 𝐼 = 4, 𝑚𝑔𝐿 = 10, 𝑐 = 0.8, and 𝑀(𝑡) is a square wave with an amplitude of and a frequency of 0.5𝐻𝑧 Assume that the initial conditions are 𝜃(0) = 𝜋/4 and 𝜃(0) = HCM City Univ of Technology, Faculty of Mechanical Engineering System Dynamics 5.56 Nguyen Tan Tien State Variable Models and Simulation Methods §4 Simulink and Linear Models Solution Rewrite the equation 𝜃 = −𝑐𝜃 − 𝑚𝑔𝐿𝑠𝑖𝑛𝜃 + 𝑀(𝑡) 𝐼 = 0.25[−0.8𝜃 − 10𝑠𝑖𝑛𝜃 + 𝑀 𝑡 ] then obtain Simulink solution HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 28 ... of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 11/17/2012 System Dynamics 5.07 State Variable Models and Simulation Methods §1 State Variable Models 2.Standard Form of the State. .. Models and Simulation Methods §1 State Variable Models HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 11/17/2012 System Dynamics 5.19 State Variable Models and Simulation. .. Technology, Faculty of Mechanical Engineering Nguyen Tan Tien 10 11/17/2012 System Dynamics 5.21 State Variable Models and Simulation Methods §2 State Variable Methods with Matlab 2.Creates state- space

Ngày đăng: 07/11/2017, 14:54

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan