This repository has been archived by the owner on Mar 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pumpfluidsystem.himaude
157 lines (126 loc) · 4.35 KB
/
pumpfluidsystem.himaude
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
*** #############################
*** Toy model of a gravitational fluid exchange system.
***
*** Author: Gary Read
***
*** Start: 15/02/2015
*** Last Edit: 20/04/2015
***
*** In this example of a physical system we simply want to
*** exhibit modelling another physical system, in this case
*** a fluidic system.
***
*** #############################
(homod PUMP-FLUID-SYSTEM is
pr FLOAT .
inc HYBRID-LIB . --- provides effortDyn etc.
sort onOffType .
ops on off : -> onOffType .
class FluidEntity | area : Float, height : Float .
subclass FluidEntity < PhysicalEntity .
class GravitationalPipeFlow | orificeArea : Float, dischargeCoef : Float, headerTankArea : Float, gravAcc : Float .
subclass GravitationalPipeFlow < PhysicalInteraction .
class Pump | status : onOffType, maxVolume : Float, minVolume : Float .
subclass Pump < FlowSource .
*** Tanks
var HTANK FTANK : Oid . --- Header/Footer tank objects
vars SF, A, H : Float . --- sum of fluid flow, mass, heat cap
eq effortDyn(< HTANK : FluidEntity | area : A, height : H >, SF)
= SF .
eq effortDyn(< FTANK : FluidEntity | area : A, height : H >, SF)
= SF .
*** Pump
vars PUMP : Oid .
eq flowDyn (< PUMP : Pump | status : on >, SF)
= 8.0 .
eq flowDyn (< PUMP : Pump | status : off >, SF)
= 0.0 .
*** Gravitation flow though outlet
var GRAVFLOW : Oid . --- Grav pipe flow
vars HTAREA GA OA DCOEF V1 V2 : Float . --- header tank area, grav acc, orificeArea, dischargeCoef, volume of E1 and E2
ceq flowDyn(< GRAVFLOW : GravitationalPipeFlow | headerTankArea : HTAREA, gravAcc : GA, orificeArea : OA, dischargeCoef : DCOEF >, V1, V2)
= DCOEF * OA * sqrt(2.0 * GA * (V1 / HTAREA))
if V1 > 0.0 .
ceq flowDyn(< GRAVFLOW : GravitationalPipeFlow | headerTankArea : HTAREA, gravAcc : GA, orificeArea : OA, dischargeCoef : DCOEF >, V1, V2)
= 0.0
if V1 < 0.0 .
*** ###############################
*** Rewrite Rules
*** ###############################
vars HTANK : Oid .
vars VOLUME MAXVOL MINVOL : Float .
var STATE : onOffType .
vars CONFIG REST : Configuration . *** Placeholders?
crl[pump-off] :
< HTANK : FluidEntity | effort : VOLUME >
< PUMP : Pump | entity : HTANK, status : on, maxVolume : MAXVOL >
=>
< HTANK : FluidEntity | >
< PUMP : Pump | status : off >
if VOLUME >= MAXVOL .
crl[pump-on] :
< HTANK : FluidEntity | effort : VOLUME >
< PUMP : Pump | entity : HTANK, status : off, minVolume : MINVOL >
=>
< HTANK : FluidEntity | >
< PUMP : Pump | status : on >
if VOLUME <= MINVOL .
*** ###############################
*** Discrete Events
*** ###############################
eq timeCanAdvanceMult(
< PUMP : Pump | entity : HTANK, status : STATE, minVolume : MINVOL, maxVolume : MAXVOL >
< HTANK : FluidEntity | effort : VOLUME > REST )
=
((STATE == on and VOLUME <= MAXVOL) or (STATE == off and VOLUME >= MINVOL)) and timeCanAdvanceMult(REST) .
endhom)
(homod SCENE is
pr FLOAT .
inc PUMP-FLUID-SYSTEM .
ops cs1 cs2 : -> GlobalSystem .
op zzDataCol : -> Oid .
ops headerTank footerTank gravFlow pump : -> Oid .
op sm : -> Oid .
ops HTAREA HTHEIGHT FTAREA FTHEIGHT GA OAREA DCOEF : -> Float .
eq HTAREA = 2.0 * 2.0 .
eq HTHEIGHT = 1000.0 .
eq FTAREA = 5.0 * 5.0 .
eq FTHEIGHT = 0.0 .
eq GA = 9.81 .
eq OAREA = 0.157 .
eq DCOEF = 0.81 .
eq cs1 = {
< headerTank : FluidEntity | effort : 30.0,
effT : 0.0,
effP : 0.0,
edb : no,
area : HTAREA,
height : HTHEIGHT,
effort : HTAREA * HTHEIGHT >
< footerTank : FluidEntity | effort : 0.0,
effT : 0.0,
effP : 0.0,
edb : no,
area : FTAREA,
height : FTHEIGHT >
< gravFlow : GravitationalPipeFlow | flow : 0.0,
entity1 : headerTank,
entity2 : footerTank,
floT1 : 0.0, floT2 : 0.0, floT3 : 0.0,
edb : no,
contDyn : component,
headerTankArea : HTAREA,
gravAcc : GA,
orificeArea : OAREA,
dischargeCoef : DCOEF >
< pump : Pump | flow : 0.0,
entity : headerTank,
floT1 : 0.0, floT2 : 0.0, floT3 : 0.0,
edb : no,contDyn : component,
minVolume : 100.0,maxVolume : 136.0,
status : on >
< zzDataCol : DataCollector | source : (headerTank footerTank), time : 0.0, result : "",dataShown : effort >
---< zzDataCol : DataCollector | source : (pump gravFlow), time : 0.0, result : "",dataShown : flow >
} .
endhom)
eof .