Presentation is loading. Please wait.

Presentation is loading. Please wait.

ENGR-25_Lec-25_SimuLink-2.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical.

Similar presentations


Presentation on theme: "ENGR-25_Lec-25_SimuLink-2.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical."— Presentation transcript:

1 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu Engr/Math/Physics 25 Chp10: SimuLink-2

2 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 2 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Learning Goals  Implement Mathematical Operations in MATLAB using SimuLink Functional Blocks  Employ FeedBack in the SimuLink Environment to numerically Solve ODEs  Create Simulations of Dynamic Control Systems using SimuLink Block Models Export Simulation result to MATLAB WorkSpace for Further Analysis

3 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 3 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Problem 10.30 (1)  Make A subsystem Block for  It has been found that for many Valves the Flow Thru the valve is Related to the Pressure Drop  Inputs q (kg/s) P l & P r (Pa) R l & R r ([  ΔP]/[kg/s])  Using the Industry Constant of Proportionality, C v

4 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 4 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Problem 10.30 (2)  C v is essentially the NonLinear Valve CONDUCTANCE  The Valve RESISTANCE then is simply the inverse of the C v  Then the Flow Thru a typical On/Off Valve

5 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 5 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Problem 10.30 (3)  To Account for potential BACK Flow under NEGATIVE ΔP Conditions use the Signed Square-Root Relation; the “SSR”  Where the SSR Fcn  Back to the Tank; ID the In-Flows Assuming P r & P l are Less than P bot i.e., There is OUTFLOW at the Left & Right

6 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 6 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods SSR Digression  The SSR fcn is BUILT into SimuLink  An quick Example  The Result  For This Problem We’ll Build our OWN SSR plot(tout, Yin, tout, Yssr, 'LineWidth', 3), xlabel('t'), ylabel('9sin(t); SSR(10sin(t))'), grid, legend('sint', 'SSR')

7 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 7 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Problem 10.30 (4)  The Tank Flows  Next the Time-Rate- of-Change of m T is just the difference between INflow & OUTflow; Mathematically  Now the Tank mass m T  Tank Mass (kg) V  Tank Volume (m 3 ) ρ = Fluid Density (kg/m 3 )

8 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 8 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Problem 10.30 (5)  Now the OutFlows in Terms of the Fluid- Flow Resistances p  Pressure at the BOTTOM of the Tank (Pa)  And From Fluid Mechanics  A NONlinear ODE in h(t)  Next, Sub into the dm T /dt eqn

9 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 9 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Problem 10.30 (6)  Put the ODE into Integrable Form  If the Pressure in the Tank is greater than Outside the ODE simplifies to

10 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 10 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Problem 10.30 (6a)  Using 1/R = C v in the ODE  Use the SimuLink Integrator (1/s) on the Complicated Integrand to Find h(t) Note that h(0) is a ParaMeter (i.e., a number) within the Integrator Block

11 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 11 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Problem 10.30 (7)  Now Make a SimuLink Model To Determine h(t)  In This Case The Parameters will be VARIABLES with values Taken from the WORKSPACE  The Parameter List: A  Tank Cross- Section Area –Assumed Circular (Cylindrical Tank) R l,r  Hydraulic Resistances of the LEFT & RIGHT Valves ρ  Liquid Density q  Liquid InFlow h(0)  Liquid Height at t = 0

12 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 12 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Problem 10.30 (8)  Design a SimuLink Model to Solve for h(t) Given

13 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 13 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Problem 10.30 (9)  Now have 3-port Tank Model  Use this SubSystem Model To Analyze a CASCADING Tank System  Need to Properly MAP the I/O to use SubSys Mdl

14 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 14 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Final Model

15 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 15 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Result for 1hr Simulation

16 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 16 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods ½ Hour Simulation Dip Due to q2(t=0) =0 Normal Time Lag >> plot(tout,simout), xlabel('time (sec)'), ylabel('Liquid Height, h (ft)'),... grid h2 final = 6.4 ft h1 final = 3.6 ft

17 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 17 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods All Done for Today Hoke DV1 Diaphram Valve

18 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 18 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu Engr/Math/Physics 25 Appendix

19 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 19 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (1)  INPORT Block for Rt & Lt Pressure Values Inport  Create an input port for a subsystem or an external input Library → Ports & Subsystems, Sources  Chg Label, No Parameters  Summing Bloks for Rt & Lt ΔP’s = P-P l,r Sum  Add or subtract inputs Library → Math Operations  Painful RePosition of “+” & “-” connection Locations Top Node = |-+ Bot Node = +-|

20 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 20 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (2)  Fcn Blok for SSR Fcn  Apply a specified expression to the input Library → User- Defined Functions  Need to Implement for u = ΔP  Parameters for Fcn

21 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 21 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (3)  Gain Bloks for Hydraulic Resistances Gain  Multiply the input by a constant Library → Math Operations  Resistance Values will come from Variables Defined in WORKSPACE

22 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 22 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (4)  Now  INport Blok for Inflow Click on Block, and Use FORMAT to Flip & Twist Block  Sum the OUTflow = q l + q r +|+ |−+ +−|

23 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 23 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (5)  Then the NET INflow = q - (q l + q r )  Parameters for Scaling Gain-Blok  Now Scale Net InFlow by 1/ρA ρ & A values set in WorkSpace  GainBlok OutPut is the INTEGRAND

24 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 24 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (6)  Integrate using 1/s Block to Find h(t) Integrator  Integrate a signal Library → Continuous  The Integrator Parameters Set IC, H(t=0) as VARIABLE h0 assigned in WorkSpace  Integrator Parameters

25 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 25 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (7)  Scale h(t) to Determine Pressure at the Bottom of the Tank, P  FeedBack P to P l & P r to find the ΔP’s

26 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 26 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (8)  Use OUTPORTs To pick off h(t) & P Outport  Create an output port for a subsystem or an external output Library → Ports & Subsystems, Sinks  The Final Model

27 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 27 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (9)  Test the model with some realistic Values taken from Work Space Need to apply SOURCES to the Inputs >> A = 3; %sf >> q_in = 0.7; % slug/sec >> rho = 1.94; % slug/cu-ft >> h_0 = 4.3; % ft >> g = 32.2; %ft/sq-sec >> R_l = 47; R_r = 71; % valve resistances>> P9_30_TankBLK_Model_Test_Input_Parameters_0905.m

28 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 28 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (9a)  Parameters for STEP-Block are CRITICALLY important to obtaining the Correct Answer in the Tank- Model Test

29 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 29 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (10)  The Result from the Scope  Looks OK … can forge ahead

30 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 30 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (11)  Make the Model into a SUBSYSTEM Select All Components with Bounding Box

31 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 31 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (12)  Use Menus: EDIT → CREATE SUBSYTEM

32 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 32 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (13)  ReSize SubSys Blok for Readability Move Blok w/ Mouse & Cursor Keys Flip & Twist InFlow Blok Increase Font Size using Format Menu

33 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 33 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (14)  Copy & Paste TWICE the SubSys Block into file Prob9_30_Cascade _Tank.mdl  The Cascade Model after the Pastes

34 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 34 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (15)  Use CONSTANT blok to set Atmospheric pressures to ZERO Constant  Generate a constant value Library → Sources  The Parameters For CONSTANT Blok

35 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 35 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (16)  Delete Pressure INPORTS and replace w/ P atm = 0  2x Click the SubSys block to expose its contents  COPY the SSR and R Gain-Blok from the SubSys Window

36 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 36 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (17)  PASTE the SSR and R Gain-Blok in Cascade-Tank Mdl  Flip the SSR & Gain Blocks  Reset the Gain to 1/R1

37 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 37 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (18)  Convert Pb1 to q1 using Cv1 = 1/R1  Connect q1 to InFlow Port on Tank2 subsys

38 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 38 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (19)  Now Use STEP block for q mi Step  Generate a step function Library → Sources  The Parameters for the step blok

39 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 39 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (20)  Document Heights by MUXing height Outputs to Scope  MUX Block Mux  Combine several input signals into a vector or bus output signal Library → Signal Routing  Scope Block Scope, Floating Scope, Signal Viewer Scope  Display signals generated during a simulation Library → Sinks

40 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 40 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (21)  InterConnects Completed  Now Need to Edit INSIDE SubSys block for new Variable Names

41 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 41 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (22)  Edit Values in Tank1 SubSys

42 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 42 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (23)  Edit Values in Tank1 SubSys

43 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 43 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (24)  Edit Values in Tank1 SubSys  Be Sure to Change the INITIAL CONDITION Somewhat Hidden in the 1/s block

44 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 44 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (25)  Edit Values in Tank2 SubSys

45 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 45 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (26)  Edit Values in Tank2 SubSys

46 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 46 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (27)  Edit Values in Tank2 SubSys  Be Sure to Change the INITIAL CONDITION Somewhat Hidden in the 1/s block

47 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 47 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (28)  Simulate for 1hr = 3600 seconds

48 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 48 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.30 (29) To WorkSpace  Prob9_30_Cascade_Tank_ToWorkSpace.mdl Note: SimOut Sends Tank Heights ONLY to WorkSpace –tout is AutoMatically sent to WorkSpace by SimuLink

49 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 49 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Test Values to paste into WkSpc A = 3 q_in =.7 rho = 1.94 h_0 = 4.3 g = 32.2 R_l = 47 R_r = 71  For Model Test  For Cascade Test A1 = 3; % sq-ft A2 = 5; % sq-ft g = 32.2; %ft/sq-sec R1 = 30; R2 = 40; rho = 1.94; % slug/cu-ft q_mi = 0.5; % slug/sec h1_0 = 2; % ft h2_0 = 5; % ft P9_30_TankSYS_Model_Input_Parameters_0712.m

50 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 50 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods MALAB 2010 has Built in SSR

51 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 51 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Tank Model & Test

52 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 52 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Parameters for q_in on Test  Step Time MUST be Zero

53 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 53 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Parameters in m-file % Bruce Mayer, PE % ENGR25 * 2Dec07 % file = P9_30_TankSYS_Model_Input_Parameters_0712.m % for use with files % Prob9_30_3port_Tank_SubSys_TEST_0712.mdl % Prob9_30_Cascade_Tank_0712.mdl % A =3 q_in = 0.7 rho = 1.94 h_0 = 4.3 g = 32.2 R_l = 47 R_r = 71 clc A1 = 3 A2 = 5 R1 = 30 R2 = 40 rho = 1.94 q_mi = 0.5 h1_0 = 2 h2_0 = 5 % % copy-n-paste Plot Statement into Command Window % plot(tout,simout), xlabel('time (sec)'), ylabel('Liquid Height, h (ft)'), grid

54 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 54 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 1304 SubSys Design

55 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 55 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 1304 Subsys Test 1304

56 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 56 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Tank Cascade 1304

57 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 57 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods P9-30 Notes Pg-1

58 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 58 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods P9-30 Notes Pg-2

59 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 59 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods P9-30 Notes Pg-3

60 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 60 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Using a Fixxed Step Size Apr07 No. of Time Pts appears to max out at 1000

61 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 61 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Cascading Tanks

62 BMayer@ChabotCollege.edu ENGR-25_Lec-25_SimuLink-2.ppt 62 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Cascading Tanks


Download ppt "ENGR-25_Lec-25_SimuLink-2.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical."

Similar presentations


Ads by Google