590 likes | 687 Views
Engr/Math/Physics 25. Chp10: SimuLink-2. Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu. Learning Goals. Implement Mathematical Operations in MATLAB using SimuLink Functional Blocks Employ FeedBack in the SimuLink Environment to numerically Solve ODEs
E N D
Engr/Math/Physics 25 Chp10: SimuLink-2 Bruce Mayer, PE Licensed Electrical & Mechanical EngineerBMayer@ChabotCollege.edu
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
Make A subsystem Block for Problem 10.30 (1) • It has been found that for many Valves the Flow Thru the valve is Related to the Pressure Drop • Inputs • q (kg/s) • Pl & Pr (Pa) • Rl & Rr ([ΔP]/[kg/s]) • Using the Industry Constant of Proportionality, Cv
Cv is essentially the NonLinear Valve CONDUCTANCE Problem 10.30 (2) • The Valve RESISTANCE then is simply the inverse of the Cv • Then the Flow Thru a typical On/Off Valve
To Account for potential BACK Flow under NEGATIVE ΔP Conditions use the SignedSquare-Root Relation; the “SSR” Problem 10.30 (3) • Where the SSR Fcn • Back to the Tank; ID the In-Flows Assuming Pr & Pl are Less than Pbot • i.e., There is OUTFLOW at the Left & Right
SSR Digression • The SSR fcn is BUILT into SimuLink • An quick Example • The Result • For This Problem We’ll Build our OWNSSR plot(tout, Yin, tout, Yssr, 'LineWidth', 3), xlabel('t'), ylabel('9sin(t); SSR(10sin(t))'), grid, legend('sint', 'SSR')
The Tank Flows Problem 10.30 (4) • Next the Time-Rate-of-Change of mT is just the difference between INflow & OUTflow; Mathematically • Now the Tank mass • mT Tank Mass (kg) • V Tank Volume (m3) • ρ = Fluid Density (kg/m3)
Now the OutFlows in Terms of the Fluid-Flow Resistances Problem 10.30 (5) • Next, Sub into the dmT/dt eqn • p Pressure at the BOTTOM of the Tank (Pa) • And From Fluid Mechanics • A NONlinear ODE in h(t)
Put the ODE into Integrable Form Problem 10.30 (6) • If the Pressure in the Tank is greater than Outside the ODE simplifies to
Using 1/R = Cv in the ODE Problem 10.30 (6a) • 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
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: Problem 10.30 (7) • A Tank Cross-Section Area • Assumed Circular (Cylindrical Tank) • Rl,r Hydraulic Resistances of the LEFT & RIGHT Valves • ρ Liquid Density • q Liquid InFlow • h(0) Liquid Height at t = 0
Problem 10.30 (8) • Design a SimuLink Model to Solve for h(t) Given Time For Live Demo
Now have 3-port Tank Model Problem 10.30 (9) • Need to Properly MAP the I/O to use SubSys Mdl • Use this SubSystem Model To Analyze a CASCADING Tank System Time For WhtBd Demo
½ Hour Simulation h2final = 6.4 ft h1final = 3.6 ft >> plot(tout,simout), xlabel('time (sec)'), ylabel('Liquid Height, h (ft)'),... grid • Dip Due to • q2(t=0) =0 • Normal Time Lag
All Done for Today Hoke DV1DiaphramValve
Engr/Math/Physics 25 Appendix Time For WhtBd Demo Time For Live Demo Bruce Mayer, PE Licensed Electrical & Mechanical EngineerBMayer@ChabotCollege.edu
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-Pl,r Sum Add or subtract inputs Library → Math Operations Painful RePosition of “+” & “-” connection Locations Top Node = |-+ Bot Node = +-| Prob10.30 (1)
Fcn Blok for SSR Fcn Apply a specified expression to the input Library → User-Defined Functions Need to Implement for u = ΔP Prob10.30 (2) • Parameters for Fcn
Gain Bloks for Hydraulic Resistances Gain Multiply the input by a constant Library → Math Operations Resistance Values will come from Variables Defined in WORKSPACE Prob10.30 (3)
Now Prob10.30 (4) • INport Blok for Inflow • Click on Block, and Use FORMAT to Flip & Twist Block • Sum the OUTflow = ql + qr |−+ +|+ +−|
Then the NET INflow = q - (ql + qr) Prob10.30 (5) • Parameters for Scaling Gain-Blok • Now Scale Net InFlow by 1/ρA • ρ & A values set in WorkSpace • GainBlok OutPut is the INTEGRAND
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 Prob10.30 (6) • Integrator Parameters
Scale h(t) to Determine Pressure at the Bottom of the Tank, P Prob10.30 (7) • FeedBack P to Pl & Pr to find the ΔP’s
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 Prob10.30 (8)
Test the model with some realistic Values taken from Work Space Need to apply SOURCES to the Inputs Prob10.30 (9) >> 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>> P10_30_Model_Input_Parameters_1111.m
Prob10.30 (9a) • Parameters for STEP-Block are CRITICALLY important to obtaining the Correct Answer in the Tank-Model Test
The Result from the Scope Prob10.30 (10) • Looks OK … can forge ahead
Make the Model into a SUBSYSTEM Select All Components with Bounding Box Prob10.30 (11)
Use Menus: EDIT → CREATE SUBSYTEM Prob10.30 (12)
ReSize SubSys Blok for Readability Prob10.30 (13) • Move Blok w/ Mouse & Cursor Keys • Flip & Twist InFlow Blok • Increase Font Size using Format Menu
Copy & Paste TWICE the SubSys Block into file Prob10_30_Cascade_Tank.mdl Prob10.30 (14) • The Cascade Model after the Pastes
Use CONSTANT blok to set Atmospheric pressures to ZERO Constant Generate a constant value Library → Sources The Parameters For CONSTANT Blok Prob10.30 (15)
Delete Pressure INPORTS and replace w/ Patm = 0 Prob10.30 (16) • 2x Click the SubSys block to expose its contents • COPY the SSR and R Gain-Blok from the SubSys Window
PASTE the SSR and R Gain-Blok in Cascade-Tank Mdl Prob10.30 (17) • Flip the SSR & Gain Blocks • Reset the Gain to 1/R1
Convert Pb1 to q1 using Cv1 = 1/R1 Connect q1 to InFlow Port on Tank2 subsys Prob10.30 (18)
Now Use STEP block for qmi Step Generate a step function Library → Sources The Parameters for the step blok Prob10.30 (19)
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 Prob10.30 (20) • Scope Block • Scope, Floating Scope, Signal Viewer Scope Display signals generated during a simulation • Library → Sinks
InterConnects Completed Prob10.30 (21) • Now Need to Edit INSIDE SubSys block for new Variable Names
Edit Values in Tank1 SubSys Prob10.30 (22)
Edit Values in Tank1 SubSys Prob10.30 (23)
Edit Values in Tank1 SubSys Be Sure to Change the INITIAL CONDITION Somewhat Hidden in the 1/s block Prob10.30 (24)
Edit Values in Tank2 SubSys Prob10.30 (25)
Edit Values in Tank2 SubSys Prob10.30 (26)
Edit Values in Tank2 SubSys Be Sure to Change the INITIAL CONDITION Somewhat Hidden in the 1/s block Prob10.30 (27)
Prob10.30 (28) • Simulate for 1hr = 3600 seconds • Simulate for 1hr = 3600 seconds
Prob9_30_Cascade_Tank_ToWorkSpace.mdl Prob10.30 (29) To WorkSpace • Note: SimOut Sends Tank Heights ONLY to WorkSpace • tout is AutoMatically sent to WorkSpace by SimuLink
Test Values to paste into WkSpc • For Model Test • For Cascade Test A = 3 q_in = .7 rho = 1.94 h_0 = 4.3 g = 32.2 R_l = 47 R_r = 71 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 P10_30_Model_Input_Parameters_1111.m