SimuLink-2 Chp10: Engr/Math/Physics 25 Bruce Mayer, PE

advertisement
Engr/Math/Physics 25
Chp10:
SimuLink-2
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_Lec-25_SimuLink-2.ppt
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
Engineering/Math/Physics 25: Computational Methods
2
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Problem 10.30 (1)
 Make A subsystem
Block for
 Inputs
• q (kg/s)
• Pl & Pr (Pa)
• Rl & Rr ([ΔP]/[kg/s])
Engineering/Math/Physics 25: Computational Methods
3
 It has been found
that for many Valves
the Flow Thru the
valve is Related to
the Pressure Drop
q  Phi  Plo  P
 Using the Industry
Constant of
Proportionality, Cv
q  Cv P
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Problem 10.30 (2)
 Cv is essentially the
NonLinear Valve
CONDUCTANCE
 The Valve RESISTANCE
then is simply the inverse
of the Cv Rv  1 Cv
 Then the Flow Thru a
typical On/Off Valve
q  Cv
1
P 
Rv
Engineering/Math/Physics 25: Computational Methods
4
P
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Problem 10.30 (3)
 To Account for
 Where the SSR Fcn
potential BACK Flow
 P
If P  0
SSR  P   
under NEGATIVE
  P If P  0
ΔP Conditions use
the Signed
 Back to the Tank;
Square-Root
ID the In-Flows
Relation; the “SSR”
Assuming Pr & Pl
are Less than Pbot
1
q
Rv

SSR P
Engineering/Math/Physics 25: Computational Methods
5

• i.e., There is
OUTFLOW at the
Left & Right
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
 The Result
10
|u|
6
Signed
Sqrt
 An quick Example
|u|
sint
SSR
8
4
9sin(t); SSR(10sin(t))
 The SSR fcn is
BUILT into
SimuLink
2
0
-2
-4
Sine Wave
Signed
Sqrt
Scope
-6
-8
Yssr
To Workspace1
Yin
P10_30_SSR_demo_1111.mdl
To Workspace
Engineering/Math/Physics 25: Computational Methods
6
-10
0
1
2
3
4
5
t
6
7
8
9
10
 For This Problem
We’ll Build our OWN
SSR
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
plot(tout, Yin, tout, Yssr, 'LineWidth', 3), xlabel('t'),
ylabel('9sin(t); SSR(10sin(t))'), grid, legend('sint', 'SSR')
SSR Digression
Problem 10.30 (4)
 The Tank Flows
ql
qr
 Now the Tank mass
mT  V    Ah 
• mT  Tank Mass (kg)
• V  Tank Volume (m3)
• ρ = Fluid Density
(kg/m3)
Engineering/Math/Physics 25: Computational Methods
7
 Next the Time-Rateof-Change of mT is
just the difference
between INflow &
OUTflow;
Mathematically
dmT d
dh
   Ah   A
dt
dt
dt
 qin  qout  q  ql  qr 
dh
OR A
 q  ql  qr 
dt
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Problem 10.30 (5)
 Now the OutFlows in  Next, Sub into the
Terms of the FluiddmT/dt eqn
Flow Resistances
dh
A  q  ql  qr 
1
ql ,r 
SSR p  pl ,r 
Rl ,r
• p  Pressure at the
BOTTOM of the Tank
(Pa)
 And From Fluid
Mechanics p  gh
Engineering/Math/Physics 25: Computational Methods
8
A
dt
A
1

dh
1
 q   SSR p  pl  
SSR p  pr 
dt
Rr
 Rl

1

dh
1
 q   SSRgh  pl  
SSRgh  pr 
dt
Rr
 Rl

 A NONlinear
ODE in h(t)
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Problem 10.30 (6)
 Put the ODE into Integrable Form

dh
1  1
1

SSRght   pr  
q   SSRght   pl  
dt A   Rl
Rr


1  1
1
h0  dy  z 0 A q   Rl SSRghz   pl   Rr SSRghz   pr  dz


h t 
z t
 If the Pressure in the Tank is greater than
Outside the ODE simplifies to
ghz   pr
1   gh z   pl

h0  dy  z 0 A q  
Rl
Rr
 
h t 
z t
Engineering/Math/Physics 25: Computational Methods
9
 
 dz
 
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Problem 10.30 (6a)
 Using 1/R = Cv in the ODE
1

q  Cv ,l SSRgh z   pl   Cv ,r SSRgh z   pr dz
z  0 A
ht   h0   
z t
1
q  Cv,l SSRghz   pl   Cv,r SSRghz   pr dz  h0
ht   
z  0 A
z t
 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
Engineering/Math/Physics 25: Computational Methods
10
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Problem 10.30 (7)
 Now Make a
SimuLink Model To
Determine h(t)
• A  Tank CrossSection Area
 In This Case The
Parameters will be
VARIABLES with
values Taken from
the WORKSPACE
• Rl,r  Hydraulic
Resistances of the
LEFT & RIGHT
Valves
 The Parameter List:
Engineering/Math/Physics 25: Computational Methods
11
– Assumed Circular
(Cylindrical Tank)
• ρ  Liquid Density
• q  Liquid InFlow
• h(0)  Liquid Height
at t = 0
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Problem 10.30 (8)
 Design a SimuLink Model to Solve for
h(t) Given

1 z t   1
1
ht   h0  
z 0 q   SSRgh  pl   SSRgh  pr  dz
A
 Rl


Rr

1  1
1
ht   h0   
q   SSR ph   pl   SSR ph   pr  dz
z  0 A
Rr

  Rl
z t
ql
ql
qr
Engineering/Math/Physics 25: Computational Methods
12
qr
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Problem 10.30 (9)
 Now have 3-port
Tank Model
1
Left P
Left P
2
2
Liquid Height
Liquid
Height
Right P
Right P
3
InFlow , q
1
Bottom P
Bottom P
InFlow, q
3Port Tank Subsystem
 Use this SubSystem
Model To Analyze a
CASCADING Tank
System
Engineering/Math/Physics 25: Computational Methods
13
 Need to Properly MAP
the I/O to use SubSys
Mdl
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Final Model
0
Left P
Liquid Height
Pl1 = 0
0
Right P
Pr1 at
Atmos
Bottom P
InFlow , q
q_mi
Tank 1
1/R1
f(u)
0
h1, h2
Scope
SSR
Cv1
Left P
Liquid Height
Pl2 = 0
0
Pr2 at
Atmos
Right P
InFlow , q
Bottom P
Tank2
Engineering/Math/Physics 25: Computational Methods
14
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Result for 1hr Simulation
Engineering/Math/Physics 25: Computational Methods
15
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
½ Hour Prob
Simulation
9.30 • Cascading Tank Filling
6.5
h2final = 6.4 ft
Liquid Height, h (ft)
5.5
h1final = 3.6 ft
5
4.5
Dip Due to
• q2(t=0) =0
• Normal Time Lag
4
3.5
3
Tank1
Tank2
2.5
2
0
200
400
600
800
1000
time (sec)
Engineering/Math/Physics 25: Computational Methods
16
1200
1400
1600
>> plot(tout,simout), xlabel('time
(sec)'), ylabel('Liquid Height, h
(ft)'),...
grid
6
1800
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
All Done for Today
Hoke DV1
Diaphram
Valve
Engineering/Math/Physics 25: Computational Methods
17
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Engr/Math/Physics 25
Appendix
f x   2 x  7 x  9 x  6
3

2

5 y  3 y  7 y  f t 
Bruce Mayer, PE
Licensed Electrical & Mechanical Engineer
BMayer@ChabotCollege.edu
Engineering/Math/Physics 25: Computational Methods
18
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (1)
 INPORT Block for Rt  Summing Bloks for Rt
& Lt Pressure
& Lt ΔP’s = P-Pl,r
Values
• Sum  Add or subtract
• Inport  Create an
input port for a
subsystem or an
external input
• Library → Ports &
Subsystems,
Sources
 Chg Label, No
Parameters
Engineering/Math/Physics 25: Computational Methods
19
inputs
• Library → Math
Operations
 Painful RePosition of
“+” & “-” connection
Locations
• Top Node = |-+
• Bot Node = +-|
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (2)
 Fcn Blok for SSR
 Parameters for Fcn
• Fcn  Apply a
specified expression
to the input
• Library → UserDefined Functions
 Need to Implement
for u = ΔP
 u
SSRu   
  u
If u  0
If u  0
Engineering/Math/Physics 25: Computational Methods
20
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
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
Engineering/Math/Physics 25: Computational Methods
21
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (4)
 Now
1
ql ,r 
SSR p  pl ,r 
Rl ,r
 INport Blok for Inflow
• Click on Block, and
Use FORMAT to Flip &
Twist Block
 Sum the OUTflow =
ql + qr
1
Left P
f(u)
|−+
SSR
1/R_l
ql
Left R1
+|+
2
Right P
f(u)
+−|
SSR1
1/R_r
Right R
qr
Engineering/Math/Physics 25: Computational Methods
22
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (5)
 Then the NET
INflow = q - (ql + qr)
 Parameters for
Scaling Gain-Blok
3
1
f(u)
Left P
SSR
2
f(u)
Right P
SSR1
1/R_l
Left R1
ql
1/R_r
qr
InFlow, q
q
Right R
 Now Scale Net
InFlow by 1/ρA
• ρ & A values set in
WorkSpace
Engineering/Math/Physics 25: Computational Methods
23
 GainBlok OutPut is
the INTEGRAND
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (6)
 Integrator Parameters
 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
Engineering/Math/Physics 25: Computational Methods
24
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (7)
 Scale h(t) to
Determine Pressure
at the Bottom of the
Tank, P
 FeedBack P to Pl & Pr
to find the ΔP’s
3
1
Left P
f(u)
SSR
InFlow, q
1/R_l
Left R1
1/(rho*A)
1/[rho*A]
2
Right P
Engineering/Math/Physics 25: Computational Methods
25
f(u)
SSR1
1/R_r
Right R
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
1
s
Integrator
rho*g
rho*g
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
3
1
Left P
f(u)
SSR
InFlow, q
Liquid
Height
Left R1
1/(rho*A)
1/[rho*A]
2
Right P
f(u)
SSR1
1
s
rho*g
Integrator
1
Bottom P
rho*g
1/R_r
Right R
Engineering/Math/Physics 25: Computational Methods
26
2
1/R_l
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (9)
 Test the model with some realistic Values
taken from Work Space
• Need to apply SOURCES to the Inputs
inflow, q_in
0
f(u)
Constant
SSR-delP
1/R_l
Scope
Left R
1/(rho*A)
1/rho*A
>>
>>
>>
>>
0
f(u)
Constant1
SSR-delP1
1
s
rho*g
Integrator
p=rho*g*h
1/R_r
Right R
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
Engineering/Math/Physics 25: Computational Methods
27
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (9a)
 Parameters for
STEP-Block
are
CRITICALLY
important to
obtaining the
Correct Answer
in the TankModel Test
Engineering/Math/Physics 25: Computational Methods
28
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (10)
 The Result from the Scope
 Looks OK
… can
forge
ahead
Engineering/Math/Physics 25: Computational Methods
29
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (11)
 Make the Model into a SUBSYSTEM
• Select All Components with Bounding Box
Engineering/Math/Physics 25: Computational Methods
30
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (12)
 Use Menus: EDIT → CREATE SUBSYTEM
Engineering/Math/Physics 25: Computational Methods
31
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (13)
 ReSize SubSys Blok for Readability
1
Left P
Left P
2
2
Liquid Height
Liquid
Height
Right P
Right P
3
InFlow , q
1
Bottom P
Bottom P
InFlow, q
3Port Tank Subsystem
Engineering/Math/Physics 25: Computational Methods
32
• Move Blok w/ Mouse &
Cursor Keys
• Flip & Twist InFlow Blok
• Increase Font Size
using FormatBruce
Menu
Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (14)
 Copy & Paste
TWICE the SubSys
Block into file
Prob9_30_Cascade
_Tank.mdl
 The Cascade Model
after the Pastes
1
Left P
2
2
Liquid Height
Left P
Liquid
Height
Right P
Right P
3
InFlow , q
1
Bottom P
Bottom P
InFlow, q
Tank 1
4
Left P
Left P1
5
4
Liquid Height
Liquid
Height1
Right P
Right P1
6
InFlow , q
3
Bottom P
Bottom P1
InFlow, q1
3Port Tank Subsystem1
Engineering/Math/Physics 25: Computational Methods
33
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
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
Engineering/Math/Physics 25: Computational Methods
34
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (16)
 Delete Pressure
INPORTS and
replace w/ Patm = 0
0
Left P
Liquid Height
Pl1 = 0
0
 2x Click the SubSys
block to expose its
contents
2
h1
Right P
Pr1 at
Atmos
1
Bottom P
InFlow , q
1
Pb1
InFlow, q
Tank 1
0
Left P
Liquid Height
Pl2 = 0
0
Pr2 at
Atmos
h2
Right P
2
InFlow , q
Bottom P
InFlow, q1
Tank2
Engineering/Math/Physics 25: Computational Methods
35
3
 COPY the SSR and
R Gain-Blok from
the SubSys Window
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (17)
 PASTE the SSR and  Flip the SSR & Gain
R Gain-Blok in
Blocks
Cascade-Tank Mdl
 Reset the Gain to
1/R1
0
Left P
0
Pr1 at
Atmos
2
Liquid Height
Pl1 = 0
h1
Right P
1
1
Bottom P
InFlow , q
Pb1
InFlow, q
Tank 1
f(u)
SSR
0
Left P
1/R_l
Left R1
Liquid Height
Pl2 = 0
0
Pr2 at
Atmos
3
h2
Right P
2
InFlow , q
Bottom P
InFlow, q1
Tank2
Engineering/Math/Physics 25: Computational Methods
36
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (18)
 Convert Pb1 to q1
using Cv1 = 1/R1
 Connect q1 to
InFlow Port on
Tank2 subsys
0
Left P
Liquid Height
Pl1 = 0
h1
0
Pr1 at
Atmos
Right P
1
Bottom P
InFlow , q
Pb1
InFlow, q
Tank 1
q1
1/R1
f(u)
SSR
Cv1
0
Left P
Liquid Height
Pl2 = 0
0
Pr2 at
Atmos
37
2
h2
Right P
Bottom P
InFlow , q
Tank2
Engineering/Math/Physics 25: Computational Methods
1
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (19)
 Now Use STEP
block for qmi
• Step  Generate a
step function
• Library → Sources
 The Parameters for
the step blok
Engineering/Math/Physics 25: Computational Methods
38
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
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
Engineering/Math/Physics 25: Computational Methods
39
 Scope Block
• Scope, Floating
Scope, Signal
Viewer Scope 
Display signals
generated during a
simulation
• Library → Sinks
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (21)
 InterConnects Completed
0
Left P
Liquid Height
Pl1 = 0
0
Right P
Pr1 at
Atmos
Bottom P
InFlow , q
q_mi
Tank 1
f(u)
1/R1
0
Left P
Liquid Height
Pl2 = 0
Pr2 at
Atmos
Right P
InFlow , q
Bottom P
Tank2
Engineering/Math/Physics 25: Computational Methods
40
h1, h2
Scope
SSR
Cv1
0
h1
h2
 Now Need to Edit
INSIDE SubSys
block for new
Variable Names
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (22)
 Edit Values in Tank1 SubSys
Engineering/Math/Physics 25: Computational Methods
41
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (23)
 Edit Values in
Tank1 SubSys
Engineering/Math/Physics 25: Computational Methods
42
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (24)
 Edit Values in
Tank1 SubSys
 Be Sure to Change
the INITIAL
CONDITION
• Somewhat Hidden in
the 1/s block
Engineering/Math/Physics 25: Computational Methods
43
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (25)
 Edit Values in Tank2 SubSys
Engineering/Math/Physics 25: Computational Methods
44
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (26)
 Edit Values in
Tank2 SubSys
Engineering/Math/Physics 25: Computational Methods
45
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (27)
 Edit Values in
Tank2 SubSys
 Be Sure to Change
the INITIAL
CONDITION
• Somewhat Hidden in
the 1/s block
Engineering/Math/Physics 25: Computational Methods
46
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (28)
 Simulate for 1hr = 3600 seconds
 Simulate for 1hr = 3600 seconds
Engineering/Math/Physics 25: Computational Methods
47
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Prob 10.30 (29) To WorkSpace
 Prob9_30_Cascade_Tank_ToWorkSpace.mdl
0
Left P
Liquid Height
Pl1 = 0
0
Right P
Pr1 at
Atmos
Bottom P
InFlow , q
q_mi
Tank 1
1/R1
– tout is AutoMatically sent
to WorkSpace by SimuLink
f(u)
SSR
Cv1
0
• Note: SimOut Sends
Tank Heights ONLY to
WorkSpace
Left P
h1, h2
Scope
Liquid Height
Pl2 = 0
0
Pr2 at
Atmos
Right P
simout
InFlow , q
Bottom P
To Workspace
Tank2
Engineering/Math/Physics 25: Computational Methods
48
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Test Values to paste into WkSpc
 For Model Test
A = 3
q_in = .7
rho = 1.94
h_0 = 4.3
g = 32.2
R_l = 47
R_r = 71
 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
Engineering/Math/Physics 25: Computational Methods
49
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
MALAB 2010 has Built in SSR
Engineering/Math/Physics 25: Computational Methods
50
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Tank Model & Test
3
1
Left P
f(u)
SSR-L
1
Liq Hgt
InFlw q
1/R_l
Left R
1
s
1/(rho*A)
rho*g
Integrator
2
Right P
f(u)
SSR-P
2
Pbot
to Pbot
scale
q-net
1/R_r
Right R
q_in
0
f(u)
Constant 1
SSR-L
1/R_l
Scope
Left R
1/(rho*A)
1
s
Integrator
0
f(u)
Constant
SSR-P
1/R_r
Right R
Engineering/Math/Physics 25: Computational Methods
51
scale
q-net
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
rho*g
to Pbot
4
Left P
Parameters for q_in on Test
 Step Time
MUST be
Zero
Engineering/Math/Physics 25: Computational Methods
52
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Engineering/Math/Physics 25: Computational Methods
53
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
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
P9_30_TankModel_SubSys_1304.mdl
1
1304 SubSys
Design
Lef t P
P Bot
Left P
1
P Bot
2
Right P
Right P
Liq Hgt
3
qin
2
Liq
Hgt
qin
Tank Subsystem
qin
3
Sign
1
1/R_l
Left P
|u|
Abs
u
SSRout
Left
2
CvL
Liq
Hgt
Sqrt
1/(rho*A)
1
s
rho*g
to h(t)
to P
Gain
Sign1
2
1/R_r
Right P
|u|
Abs1
u
SSRout
Right
P9_30_TankModel_1304.mdl
Bruce Mayer, PE
ENGR25 * 30Apr13
Sqrt1
Engineering/Math/Physics 25: Computational Methods
54
CvR
1
P Bot
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
1304 Subsys Test 1304
InFlow q_in
Sign
0
1/R_l
PL
Product
|u|
Abs
u
h(t) Scope
CvL
Sqrt
1/(rho*A)
1
s
rho*g
to h(t)
to P
Gain
Sign1
0
1/R_r
PR
Product1
|u|
Abs1
u
Sqrt1
Engineering/Math/Physics 25: Computational Methods
55
CvR
P9_30_TankModel_Test_1304.mdl
Bruce Mayer, PE
ENGR25 * 30Apr13
Use with
P10_30_TankBLK_Model_Test_Input_Parameters_1111.m
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Bruce Mayer, PE
P9_30_Cascade_Tank_1304.mdl
30Apr13
Tank Cascade 1304
P9_30_TankModel_SubSys_1304.mdl
Scope2
0
Lef t P
P Bot
Constant
Scope1
0
Right P
Constant1
Liq Hgt
qin
LiqHgt
Scope
Step
Upper Tank Subsystem
Scope3
Scope
Sign
SSRout
Left
CvL
Sqrt
1/R1
Abs
u
|u|
P9_30_TankModel_SubSys_1304.mdl
hOFt
To Workspace
0
Lef t P
P Bot
Constant2
0
1
P Bot1
Right P
Constant3
Liq Hgt
qin
Use With
P10_30_Model_Input_Parameters_1111.m
Lower Tank Subsystem
Engineering/Math/Physics 25: Computational Methods
56
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
P9-30 Notes Pg-1
Engineering/Math/Physics 25: Computational Methods
57
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
P9-30 Notes Pg-2
Engineering/Math/Physics 25: Computational Methods
58
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
P9-30 Notes Pg-3
Engineering/Math/Physics 25: Computational Methods
59
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Using a Fixxed Step Size
Apr07
No. of Time Pts appears to max out at 1000
Engineering/Math/Physics 25: Computational Methods
60
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Cascading Tanks
Problem 9.30 - Cascading Tank Liquid Levels by SimuLink (Apr07)
6.5
6
Upper
Lower
Liquid Height, h (ft)
5.5
5
4.5
4
3.5
3
2.5
2
0
200
400
Engineering/Math/Physics 25: Computational Methods
61
600
800
t (sec)
1000
1200
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
1400
Cascading Tanks
Problem 9.30 - Casading Tanks Apr07*
6.5
6
Water Level Height (ft)
5.5
Upper
Lower
5
4.5
4
3.5
3
2.5
2
1.5
0
100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500
Time (s)
Engineering/Math/Physics 25: Computational Methods
62
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-25_SimuLink-2.ppt
Download