-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Utilities.bak-mo
248 lines (162 loc) · 10.6 KB
/
Utilities.bak-mo
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
within PropulsionSystem;
model Utilities
extends Modelica.Icons.UtilitiesPackage;
model SetIndependent
//********** internal variables **********
Real independent(start= independent_init);
//********** initialization parameters **********
parameter Real independent_init= 1.0
""
annotation(Dialog(tab="Initialization"));
Modelica.Blocks.Interfaces.RealOutput independent_out
""
annotation(
Placement(visible = true, transformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
independent= independent_out;
/********************************************************
Graphics
********************************************************/
annotation(
Icon(graphics = {Rectangle(origin = {0, -1}, fillColor = {225, 225, 225}, fillPattern = FillPattern.Solid, extent = {{-100, 101}, {100, -99}}), Text(origin = {-12, -95}, extent = {{-88, 15}, {112, -5}}, textString = "%name"), Text(origin = {-9, 22}, extent = {{-91, 18}, {109, -62}}, textString = "Free to Vary", fontSize = 26)}, coordinateSystem(initialScale = 0.1)));
end SetIndependent;
model SetDependent
//********** Parameters **********
parameter Real tgtValue_paramInput
""
annotation(
Dialog(group = "Characteristics"));
//----- switches -----
parameter PropulsionSystem.Types.switches.switchHowToDetVar switchDetermine_targetVal
= PropulsionSystem.Types.switches.switchHowToDetVar.viaRealInput
"switch how to determine target value" annotation(
Dialog(group = "switch"),
choicesAllMatching = true,
Evaluate = true,
HideResult = true);
//********** Interfaces **********
Modelica.Blocks.Interfaces.RealInput u_variable
annotation(
Placement(visible = true, transformation(origin = {-120, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Interfaces.RealInput u_targetValue
if (switchDetermine_targetVal
== PropulsionSystem.Types.switches.switchHowToDetVar.viaRealInput)
""
annotation(
Placement(visible = true, transformation(origin = {120, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 180), iconTransformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
equation
if(switchDetermine_targetVal
== PropulsionSystem.Types.switches.switchHowToDetVar.param)then
tgtValue_paramInput = u_variable;
elseif (switchDetermine_targetVal
== PropulsionSystem.Types.switches.switchHowToDetVar.viaRealInput)then
u_targetValue = u_variable;
end if;
/********************************************************
Graphics
********************************************************/
annotation(
Diagram,
Icon(graphics = {Rectangle(fillColor = {39, 39, 39}, fillPattern = FillPattern.Solid, extent = {{-100, 100}, {100, -100}}), Text(origin = {-3, -83}, lineColor = {255, 255, 255}, extent = {{-97, 3}, {103, -17}}, textString = "%name"), Text(origin = {-3, 37}, lineColor = {255, 255, 255}, extent = {{-97, 3}, {103, -77}}, textString = "Constraint", fontSize = 28)}, coordinateSystem(initialScale = 0.1)));
end SetDependent;
block SplitFlow_by_BPR
//********** Parameters **********
parameter Real BPRdes=10
""
annotation(
Dialog(group = "Characteristics"));
//----- switches -----
parameter PropulsionSystem.Types.switches.switch_parameter_input switchInput_BPR
=PropulsionSystem.Types.switches.switch_parameter_input.use_desValue
""
annotation(
Dialog(group = "switch"),
choicesAllMatching= true,
Evaluate = true,
HideResult = true
);
Real BPR;
//********** Interfaces **********
Modelica.Blocks.Interfaces.RealInput flow_total annotation(
Placement(visible = true, transformation(origin = {-120, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Interfaces.RealOutput flow_secondary annotation(
Placement(visible = true, transformation(origin = {110, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Interfaces.RealOutput flow_primary annotation(
Placement(visible = true, transformation(origin = {110, -40}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, -40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Interfaces.RealInput BPR_in
if (switchInput_BPR== PropulsionSystem.Types.switches.switch_parameter_input.use_inputSignal)
""
annotation(
Placement(visible = true, transformation(origin = {-80, 120}, extent = {{-20, -20}, {20, 20}}, rotation = -90), iconTransformation(origin = {-80, 110}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
algorithm
flow_secondary:= flow_total * BPR/(1.0+BPR);
flow_primary:= flow_total * 1.0/(1.0+BPR);
equation
if (switchInput_BPR== PropulsionSystem.Types.switches.switch_parameter_input.use_desValue)then
BPR=BPRdes;
elseif (switchInput_BPR== PropulsionSystem.Types.switches.switch_parameter_input.use_inputSignal)then
BPR=BPR_in;
end if;
//##### none #####
/********************************************************
Graphics
********************************************************/
annotation(
Icon(graphics = {Rectangle(fillColor = {209, 209, 209}, fillPattern = FillPattern.Solid, extent = {{-100, 100}, {100, -100}}), Text(origin = {43, 41}, extent = {{-7, 14}, {57, -16}}, textString = "Sec.", fontSize = 25, horizontalAlignment = TextAlignment.Right), Text(origin = {41, -33}, extent = {{-5, 6}, {57, -16}}, textString = "Pri.", fontSize = 25, horizontalAlignment = TextAlignment.Right), Text(origin = {-93, 5}, extent = {{-7, 14}, {65, -24}}, textString = "Total", fontSize = 25, horizontalAlignment = TextAlignment.Right), Line(origin = {6, 27}, points = {{-30, -25}, {-6, -25}, {-6, 15}, {26, 15}}, thickness = 0.5, arrow = {Arrow.None, Arrow.Open}, arrowSize = 5), Line(origin = {17.09, -22.51}, points = {{-17, 25}, {-17, -17}, {15, -17}}, thickness = 0.5, arrow = {Arrow.None, Arrow.Open}, arrowSize = 5), Text(origin = {2, -83}, extent = {{-102, 13}, {98, -7}}, textString = "%name"), Text(origin = {2, 87}, extent = {{-102, 13}, {98, -7}}, textString = "BPR= %BPR")}));
end SplitFlow_by_BPR;
model SetConstraint
//********** Parameters **********
parameter Real tgtValue_paramInput=1.0 "target value ot constraint, valid only when switchDetermine_targetVal==param" annotation(
Dialog(group = "Characteristics"));
//----- switches -----
parameter PropulsionSystem.Types.switches.switchHowToDetVar switchDetermine_targetVal = PropulsionSystem.Types.switches.switchHowToDetVar.viaRealInput "switch how to determine target value" annotation(
Dialog(group = "switch"),
choicesAllMatching = true,
Evaluate = true,
HideResult = true);
//********** Interfaces **********
Modelica.Blocks.Interfaces.RealInput u_variable annotation(
Placement(visible = true, transformation(origin = {-120, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Interfaces.RealInput u_targetValue if (switchDetermine_targetVal == PropulsionSystem.Types.switches.switchHowToDetVar.viaRealInput) "" annotation(
Placement(visible = true, transformation(origin = {120, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 180), iconTransformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
equation
if switchDetermine_targetVal == PropulsionSystem.Types.switches.switchHowToDetVar.param then
tgtValue_paramInput = u_variable;
elseif switchDetermine_targetVal == PropulsionSystem.Types.switches.switchHowToDetVar.viaRealInput then
u_targetValue = u_variable;
end if;
/********************************************************
Graphics
********************************************************/
annotation(
Diagram,
Icon(graphics = {Rectangle(fillColor = {39, 39, 39}, fillPattern = FillPattern.Solid, extent = {{-100, 100}, {100, -100}}), Text(origin = {-3, -83}, lineColor = {255, 255, 255}, extent = {{-97, 3}, {103, -17}}, textString = "%name"), Text(origin = {-3, 37}, lineColor = {255, 255, 255}, extent = {{-97, 3}, {103, -77}}, textString = "Constraint", fontSize = 28)}, coordinateSystem(initialScale = 0.1)));
end SetConstraint;
model SetSolverIndependent
/* ---------------------------------------------
parameters
--------------------------------------------- */
//********** Initialization Parameters **********
parameter Real independent_init = 1.0 "" annotation(
Dialog(tab = "Initialization"));
/* ---------------------------------------------
Internal variables
--------------------------------------------- */
Real independent(start= independent_init);
/* ---------------------------------------------
Interface
--------------------------------------------- */
Modelica.Blocks.Interfaces.RealOutput y_independent "" annotation(
Placement(visible = true, transformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
independent = y_independent;
/********************************************************
Graphics
********************************************************/
annotation(
Icon(graphics = {Rectangle(origin = {0, -1}, fillColor = {225, 225, 225}, fillPattern = FillPattern.Solid, extent = {{-100, 101}, {100, -99}}), Text(origin = {-12, -95}, extent = {{-88, 15}, {112, -5}}, textString = "%name"), Text(origin = {-37, 18}, extent = {{-63, 50}, {137, 10}}, textString = "Solver", fontSize = 26), Text(origin = {-37, -18}, extent = {{-63, 50}, {137, 10}}, textString = "Independent", fontSize = 26), Text(origin = {-37, -60}, extent = {{-63, 50}, {137, 10}}, textString = "Variable", fontSize = 26)}, coordinateSystem(initialScale = 0.1)));
end SetSolverIndependent;
model VariableBySolver
equation
end VariableBySolver;
end Utilities;