Engineering 25 Chp9 Tutorial: Prob 9.32 Solution Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu Engineering/Math/Physics 25: Computational Methods 1 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt Unit Summary A summary of the Units of Measure in this problem: • y(t) → meters • dy/dt → meters/second (m/s) • dy2/(dt)2 → meter/second2 (m/s2) • m → kg • k → Newtons/meter (N/m) • M → Newtons • K, B → meters • ωp , ωc → rads/sec (r/s) Engineering/Math/Physics 25: Computational Methods 2 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt The Physical Situation f t 10 N sin p t m 3 kg k k 75N m m y A FrictionLESS mass-spring (m-k) system SINSOIDAL Forcing Function, f(t) • Pull/Push Magnitude, M = 10N (2.248 lbs) Engineering/Math/Physics 25: Computational Methods 3 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt The Math Model Using Newton’s 2nd Law (ΣF = ma) find the MassSpring System y(t) ODE d2y N 3 kg 2 75 y 10 Nsin pt dt m Or m y 0 y ky M sin p t With 0th & 1st order I.C.’s dy y0 0 m & y0 0 m s dt t 0 Find y(t) for ωp = 1, 5.1, 10 r/s Engineering/Math/Physics 25: Computational Methods 4 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt Engineering/Math/Physics 25: Computational Methods 5 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt Engineering/Math/Physics 25: Computational Methods 6 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt Engineering/Math/Physics 25: Computational Methods 7 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt Engineering/Math/Physics 25: Computational Methods 8 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt Engineering/Math/Physics 25: Computational Methods 9 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt Engineering/Math/Physics 25: Computational Methods 10 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt P9.32 Analytical Soln % Bruce Mayer, PE * 15Apr12 % ENGR25 * problem 9.32 % file = Prob9_32_Analytical_Soln_1204.m %* NOTE: Analytical Solutions are NOT Covered in the TextBook % % Implements Analytical Soln %* y(t) = K*sin(wp*t) - [K*wp/wc]*sin(wc*t) %* Forcing Fcn: f(t) = 10N*sin(wp*t) = M*sin(wp*t) % clear % clears memory % % Eqn Constants m = 3; % in kg k = 75; % in N/m wp =[1 5.1 10]; % in rads/sec % % Calc Constants in Soln as a fcn of wp K = (10./(k-m*wp.^2)) % in m wc = 5; % rads/sec B1 = -K.*wp/wc % in m % tmax = 20; % solve over adjustable time frame: 20, 100, 500 %* Use 70 sec to determine "Beating" Period t = linspace(0, tmax, 1000); % 1000 plotting Points pts tLen = length(t); % % Calc soln for 3 wp cases % ya = B1(1)*sin(wc*t) + K(1)*sin(wp(1)*t); % wp = 1 rad/sec yb = B1(2)*sin(wc*t) + K(2)*sin(wp(2)*t); % wp = 5.1 rad/sec yc = B1(3)*sin(wc*t) + K(3)*sin(wp(3)*t); % wp = 10 rad/sec % % Plot one on top of the other using subplot subplot(3,1,1) plot(t,ya, 'LineWidth',2), grid, xlabel('t (sec)'),... ylabel('ya (m)'),title('Case a. wp = 1 r/s') subplot(3,1,2) plot(t,yb, 'LineWidth',2), grid, xlabel('t (sec)'),... ylabel('yb (m)'), title('Case b. wp = 5.1 r/s') subplot(3,1,3) plot(t,yc, 'LineWidth',2), grid, xlabel('t (sec)'),... ylabel('yc (m)'), title('Case b. wp = 10 r/s') Engineering/Math/Physics 25: Computational Methods 11 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt P9.29 Analytical Plot Case a. wp = 1 r/s 0.15 0.1 ya (m) 0.05 0 -0.05 -0.1 -0.15 -0.2 0 2 4 6 8 10 t (sec) 12 14 16 18 20 14 16 18 20 14 16 18 20 Case b. wp = 5.1 r/s 6 4 yb (m) 2 0 -2 -4 -6 0 2 4 6 8 10 t (sec) 12 Case b. wp = 10 r/s 0.15 0.1 yc (m) 0.05 0 -0.05 -0.1 -0.15 -0.2 10 t (sec) Engineering/Math/Physics 25: Computational Methods 12 0 2 4 6 8 12 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt Solve by ODE23 Engineering/Math/Physics 25: Computational Methods 13 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt Solve by ODE23 Engineering/Math/Physics 25: Computational Methods 14 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt P9.32 Numerical Soln-a The Function file for the ODE Solver Call function dxdt = dxdt_P9_32(t,z); % Bruce Mayer, PE * 15Apr12 % ENGR25 * P9.32 ODE soln by Matrix Methods % % Receive parameters using GLOBAL constants global m k wp % % the two 1st order eqns inside the dxdt vector [dx1/dt; dx2/dt] dxdt = [z(2); (10*sin(wp*t) - k*z(1))/m] Engineering/Math/Physics 25: Computational Methods 15 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt P9.32 Numerical Soln-a % Bruce Mayer, PE * 15Apr12 % ENGR25 * problem 9.32 % file = Prob9_32_dxdt_Soln.m % % Use with Function File = dxdt_P9_32.m % % Implements Numerical Soln %* y(t) = K*sin(wp*t) - [K*wp/wc]*sin(wc*t) %** Forcing Fcn: f(t) = 10N*sin(wp*t) % clear % clears memory % % Pass Parameters to ODE function dxdt as GLOBAL values global m k wp % % one of the cases below is ACTIVE; comment out others wp = 1; % case a %wp = 5.1; % case b %wp = 10; % case c m = 3;k = 75; M = 10; % % use ode23 solver %* fcn = dxdt_P9_32.m %* t interval = 0-20 sec (or more) => t = 0-70 is quite interesting %* IC's y(0) = 0; dy/dt @ t=0 = 0 % [t, x] = ode23('dxdt_P9_32', [0, 70], [0, 0]); f = M*sin(wp*t); % % Soln & Forcing Function on Top of Each Other using SubPlot % subplot(2,1,1) plot(t,x(:,1), 'LineWidth',2),xlabel('t (sec)'),ylabel('y(t) (m)'), title('P8.28 dxdt Form Soln'), grid subplot(2,1,2) plot(t,f, 'LineWidth',2),xlabel('t (sec)'),ylabel('f(t) (N)'), title('Forcing Fcn'), grid % disp('showing solution & Forcing-Funtion -- Hit AnyKey to continue') pause % % Soln VALUE & SLOPE on Top of Each Other using SubPlot % subplot(2,1,1) plot(t,x(:,1), 'LineWidth',2),xlabel('t (sec)'),ylabel('y(t) (m)'), title('Position'), grid subplot(2,1,2) plot(t,x(:,2), 'LineWidth',2),xlabel('t (sec)'),ylabel('dy/dt @ t (m/s)'), title('Slope'), grid % Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 16 BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt Anonymous Function Quick Solution Entirely from Command Window Using an ANONYMOUS Function >> m = 3;k = 75; M = 10; wp = 1; >> dxdt = @(t,z) [z(2); (10*sin(wp*t) - k*z(1))/m] dxdt = @(t,z)[z(2);(10*sin(wp*t)-k*z(1))/m] >> [T, Y] = ode23(dxdt, [0,14], [0, 0]); >> plot(T,Y, 'LineWidth', 2), grid, legend('y(t)', 'dy/dt = slope') y(t) dy/dt = slope 0.25 0.2 0.15 0.1 0.05 0 -0.05 -0.1 -0.15 -0.2 -0.25 0 2 4 6 8 Engineering/Math/Physics 25: Computational Methods 17 10 12 14 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt Anonymous Function Plot ONLY(T) >> >> plot(T,Y(:,1), 'LineWidth', 2), grid, xlabel('t'), ylabel('y(t)') 0.15 0.1 y(t) 0.05 0 -0.05 -0.1 -0.15 0 2 4 6 8 10 t Engineering/Math/Physics 25: Computational Methods 18 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt 12 14 Engineering/Math/Physics 25: Computational Methods 19 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt Engineering/Math/Physics 25: Computational Methods 20 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt P9.32 Numerical Soln-b The Function file for the ODE Solver Call function xDot = mksine_P9_32(t,z); % Bruce Mayer, PE * 15Apr12 % ENGR25 * P 9.32 ODE soln by Matrix Methods % % Pass parameters using GLOBAL constants global m k wp % % the matrix elements A = [0,1;-k/m,0]; B = [0;1/m]; f = 10*sin(wp*t); xDot=A*z+B*f; Engineering/Math/Physics 25: Computational Methods 21 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt P9.32 Numerical Soln-b % Bruce Mayer, PE * 15Apr12 % ENGR25 * problen 9.32 % file = Prob9_32_Matrix_Soln.m % % Use with Function File = mksine_P9_32.m % % Implements Numerical Soln %* y(t) = K*sin(wp*t) - [K*wp/wc]*sin(wc*t) %* Forcing Fcn: f(t) = 10N*sin(wp*t) % clear % clears memory % % Pass Parameters as Global values global m k wp % % one of the cases below is ACTIVE; comment out others %wp = 1; % case a wp = 5.1; % case b %wp = 10; % case c m = 3;k = 75; M = 10; % % use ode23 solver %* fcn = mksine_P9_32 %* t interval = 0-20 sec %* IC's y(0) = 0; dy/dy @ t=0 = 0 % [t, x] = ode23('mksine_P9_32', [0, 20], [0, 0]); f = M*sin(wp*t); % Soln & Forcing Function on Top of Each Other using SubPlot % subplot(2,1,1) plot(t,x(:,1), 'LineWidth', 2),xlabel('t (sec)'),ylabel('y(t) (N)'),... title('P9.32 Matrix Form Soln'), grid subplot(2,1,2) plot(t,f, 'LineWidth', 2),xlabel('t (sec)'),ylabel('f(t) (N)'),... title('Forcing Fcn'), grid Engineering/Math/Physics 25: Computational Methods 22 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt Case-a: ωp = 1 rad/sec P8.28 Matrix Form Soln 0.15 0.1 y(t) (N) 0.05 0 -0.05 -0.1 -0.15 -0.2 0 5 10 t (sec) 15 20 15 20 Forcing Fcn 10 f(t) (N) 5 0 -5 -10 0 5 10 t (sec) Engineering/Math/Physics 25: Computational Methods 23 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt Case-b: ωp = 5.1 rad/sec P8.28 Matrix Form Soln 6 4 y(t) (N) 2 0 -2 -4 -6 0 5 10 t (sec) 15 20 15 20 Forcing Fcn 10 f(t) (N) 5 0 -5 -10 0 5 10 t (sec) Engineering/Math/Physics 25: Computational Methods 24 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt Case-c: ωp = 10 rad/sec P8.28 Matrix Form Soln 0.15 0.1 y(t) (N) 0.05 0 -0.05 -0.1 -0.15 -0.2 0 5 10 t (sec) 15 20 15 20 Forcing Fcn 10 f(t) (N) 5 0 -5 -10 0 5 10 t (sec) Engineering/Math/Physics 25: Computational Methods 25 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt Case-b: 100 sec P8.28 Matrix Form Soln 8 6 4 y(t) (N) 2 0 -2 -4 -6 -8 0 10 20 30 40 50 t (sec) 60 70 80 Note the “beating” with a Period of about 63 sec Engineering/Math/Physics 25: Computational Methods 26 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt 90 100 SimuLink Solution ODE by Newton’s 2nd Law d y m 2 ky M sin p t dt 2 Solve for Highest Order Term d y M sin p t ky 2 dt m 2 Find y by Double Integral Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE M sin pt ky y dt dt m 27 BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt SimuLink Model P9_32_mk_1104.mdl Note Changes in IC’s Engineering/Math/Physics 25: Computational Methods 28 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_HW-01_Solution.ppt