@@ -7,21 +7,38 @@ package Nonlinear
7
7
block Limiter "Limit the range of a signal"
8
8
parameter Real uMax(start= 1 ) "Upper limits of input signals" ;
9
9
parameter Real uMin= - uMax "Lower limits of input signals" ;
10
- parameter Boolean strict= false
11
- "= true, if strict limits with noEvent(..)"
10
+ parameter Boolean strict= false "= true, if strict limits with noEvent(..)"
12
11
annotation (Evaluate=true, choices(checkBox=true), Dialog(tab="Advanced" ));
12
+ parameter Types.LimiterHomotopy homotopyType = Modelica.Blocks.Types.LimiterHomotopy.Linear "Simplified model for homotopy-based initialization"
13
+ annotation (Evaluate=true, Dialog(group="Initialization" ));
13
14
parameter Boolean limitsAtInit= true
14
- "Has no longer an effect and is only kept for backwards compatibility (the implementation uses now the homotopy operator)"
15
+ "Has no longer an effect and is only kept for backwards compatibility (the implementation uses now the homotopy operator)"
15
16
annotation (Dialog(tab="Dummy" ),Evaluate=true, choices(checkBox=true));
16
17
extends Interfaces.SISO;
18
+ protected
19
+ Real simplifiedExpr "Simplified expression for homotopy-based initialization" ;
17
20
18
21
equation
19
22
assert (uMax > = uMin, "Limiter: Limits must be consistent. However, uMax (=" + String (uMax) +
20
23
") < uMin (=" + String (uMin) + ")" );
24
+ simplifiedExpr = (if homotopyType == Types.LimiterHomotopy.Linear then u
25
+ else if homotopyType == Types.LimiterHomotopy.UpperLimit then uMax
26
+ else if homotopyType == Types.LimiterHomotopy.LowerLimit then uMin
27
+ else 0 );
21
28
if strict then
22
- y = homotopy (actual = smooth (0 , noEvent (if u > uMax then uMax else if u < uMin then uMin else u)), simplified= u);
29
+ if homotopyType == Types.LimiterHomotopy.NoHomotopy then
30
+ y = smooth (0 , noEvent (if u > uMax then uMax else if u < uMin then uMin else u));
31
+ else
32
+ y = homotopy (actual = smooth (0 , noEvent (if u > uMax then uMax else if u < uMin then uMin else u)),
33
+ simplified= simplifiedExpr);
34
+ end if ;
23
35
else
24
- y = homotopy (actual = smooth (0 ,if u > uMax then uMax else if u < uMin then uMin else u), simplified= u);
36
+ if homotopyType == Types.LimiterHomotopy.NoHomotopy then
37
+ y = smooth (0 ,if u > uMax then uMax else if u < uMin then uMin else u);
38
+ else
39
+ y = homotopy (actual = smooth (0 ,if u > uMax then uMax else if u < uMin then uMin else u),
40
+ simplified= simplifiedExpr);
41
+ end if ;
25
42
end if ;
26
43
annotation (
27
44
Documentation(info="<html>
@@ -31,6 +48,20 @@ as long as the input is within the specified upper and lower
31
48
limits. If this is not the case, the corresponding limits are passed
32
49
as output.
33
50
</p>
51
+ <p>
52
+ The parameter <code>homotopyType</code> in the Advanced tab specifies the
53
+ simplified behaviour if homotopy-based initialization is used:
54
+ <ul>
55
+ <li><code>NoHomotopy</code>: the actual expression with limits is used</li>
56
+ <li><code>Linear</code>: a linear behaviour y = u is assumed (default option)</li>
57
+ <li><code>UpperLimit</code>: it is assumed that the output is stuck at the upper limit u = uMax</li>
58
+ <li><code>LowerLimit</code>: it is assumed that the output is stuck at the lower limit u = uMin</li>
59
+ </ul>
60
+ </p>
61
+ <p>
62
+ If it is known a priori in which region the input signal will be located, this option can help
63
+ a lot by removing one strong nonlinearity from the initialization problem.
64
+ </p>
34
65
</html>" ), Icon(coordinateSystem(
35
66
preserveAspectRatio=true,
36
67
extent={{-100,-100},{100,100}}), graphics={
@@ -99,7 +130,11 @@ as output.
99
130
block VariableLimiter "Limit the range of a signal with variable limits"
100
131
extends Interfaces.SISO;
101
132
parameter Boolean strict= false "= true, if strict limits with noEvent(..)"
102
- annotation (Evaluate=true, choices(checkBox=true));
133
+ annotation (Evaluate=true, choices(checkBox=true), Dialog(tab="Advanced" ));
134
+ parameter Types.VariableLimiterHomotopy homotopyType = Modelica.Blocks.Types.VariableLimiterHomotopy.Linear "Simplified model for homotopy-based initialization"
135
+ annotation (Evaluate=true, Dialog(group="Initialization" ));
136
+ parameter Real ySimplified = 0 "Fixed value of output in simplified model"
137
+ annotation (Dialog(tab="Advanced" , enable=homotopyType == Modelica.Blocks.Types.VariableLimiterHomotopy.Fixed));
103
138
parameter Boolean limitsAtInit= true
104
139
"Has no longer an effect and is only kept for backwards compatibility (the implementation uses now the homotopy operator)"
105
140
annotation (Dialog(tab="Dummy" ),Evaluate=true, choices(checkBox=true));
@@ -109,13 +144,27 @@ as output.
109
144
Interfaces.RealInput limit2
110
145
"Connector of Real input signal used as minimum of input u"
111
146
annotation (Placement(transformation(extent={{-140,-100},{-100,-60}})));
147
+ protected
148
+ Real simplifiedExpr "Simplified expression for homotopy-based initialization" ;
112
149
equation
113
150
assert (limit1 > = limit2, "Input signals are not consistent: limit1 < limit2" );
114
-
151
+ simplifiedExpr = (if homotopyType == Types.VariableLimiterHomotopy.Linear then u
152
+ else if homotopyType == Types.VariableLimiterHomotopy.Fixed then ySimplified
153
+ else 0 );
115
154
if strict then
116
- y = homotopy (actual = smooth (0 , noEvent (if u > limit1 then limit1 else if u < limit2 then limit2 else u)), simplified= u);
155
+ if homotopyType == Types.VariableLimiterHomotopy.NoHomotopy then
156
+ y = smooth (0 , noEvent (if u > limit1 then limit1 else if u < limit2 then limit2 else u));
157
+ else
158
+ y = homotopy (actual = smooth (0 , noEvent (if u > limit1 then limit1 else if u < limit2 then limit2 else u)),
159
+ simplified= simplifiedExpr);
160
+ end if ;
117
161
else
118
- y = homotopy (actual = smooth (0 ,if u > limit1 then limit1 else if u < limit2 then limit2 else u), simplified= u);
162
+ if homotopyType == Types.VariableLimiterHomotopy.NoHomotopy then
163
+ y = smooth (0 ,if u > limit1 then limit1 else if u < limit2 then limit2 else u);
164
+ else
165
+ y = homotopy (actual = smooth (0 ,if u > limit1 then limit1 else if u < limit2 then limit2 else u),
166
+ simplified= simplifiedExpr);
167
+ end if ;
119
168
end if ;
120
169
121
170
annotation (
@@ -127,6 +176,19 @@ limits specified by the two additional inputs limit1 and
127
176
limit2. If this is not the case, the corresponding limit
128
177
is passed as output.
129
178
</p>
179
+ <p>
180
+ The parameter <code>homotopyType</code> in the Advanced tab specifies the
181
+ simplified behaviour if homotopy-based initialization is used:
182
+ <ul>
183
+ <li><code>NoHomotopy</code>: the actual expression with limits is used</li>
184
+ <li><code>Linear</code>: a linear behaviour y = u is assumed (default option)</li>
185
+ <li><code>Fixed</code>: it is assumed that the output is fixed at the value <code>ySimplified</code></li>
186
+ </ul>
187
+ </p>
188
+ <p>
189
+ If it is known a priori in which region the input signal will be located, this option can help
190
+ a lot by removing one strong nonlinearity from the initialization problem.
191
+ </p>
130
192
</html>" ), Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
131
193
100}}), graphics={
132
194
Line(points={{0,-90},{0,68}}, color={192,192,192}),
0 commit comments