| 1 | package Math "Mathematical functions as input/output blocks" |
|---|
| 2 | import Modelica.SIunits; |
|---|
| 3 | import Modelica.Blocks.Interfaces; |
|---|
| 4 | extends Modelica.Icons.Library; |
|---|
| 5 | |
|---|
| 6 | annotation ( |
|---|
| 7 | preferedView="info", |
|---|
| 8 | Coordsys( |
|---|
| 9 | extent=[0, 0; 446, 493], |
|---|
| 10 | grid=[1, 1], |
|---|
| 11 | component=[20, 20]), |
|---|
| 12 | Window( |
|---|
| 13 | x=0.05, |
|---|
| 14 | y=0.09, |
|---|
| 15 | width=0.44, |
|---|
| 16 | height=0.71, |
|---|
| 17 | library=1, |
|---|
| 18 | autolayout=1), |
|---|
| 19 | Documentation(info=" |
|---|
| 20 | <HTML> |
|---|
| 21 | <p> |
|---|
| 22 | This package contains basic <b>mathematical operations</b>, |
|---|
| 23 | such as summation and multiplication, and basic <b>mathematical |
|---|
| 24 | functions</b>, such as <b>sqrt</b> and <b>sin</b>, as |
|---|
| 25 | input/output blocks. All blocks of this library can be either |
|---|
| 26 | connected with continuous blocks or with sampled-data blocks. |
|---|
| 27 | </p> |
|---|
| 28 | </HTML> |
|---|
| 29 | ", revisions="<html> |
|---|
| 30 | <ul> |
|---|
| 31 | <li><i>October 21, 2002</i> |
|---|
| 32 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a> |
|---|
| 33 | and <a href=\"http://www.robotic.dlr.de/Christian.Schweiger/\">Christian Schweiger</a>:<br> |
|---|
| 34 | New blocks added: RealToInteger, IntegerToReal, Max, Min, Edge, BooleanChange, IntegerChange.</li> |
|---|
| 35 | <li><i>August 7, 1999</i> |
|---|
| 36 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br> |
|---|
| 37 | Realized (partly based on an existing Dymola library |
|---|
| 38 | of Dieter Moormann and Hilding Elmqvist). |
|---|
| 39 | </li> |
|---|
| 40 | </ul> |
|---|
| 41 | </html>")); |
|---|
| 42 | encapsulated package UnitConversions |
|---|
| 43 | import Modelica; |
|---|
| 44 | import SI = Modelica.SIunits; |
|---|
| 45 | import NonSI = Modelica.SIunits.Conversions.NonSIunits; |
|---|
| 46 | |
|---|
| 47 | block ConvertAllUnits "Convert signal to a signal with different unit" |
|---|
| 48 | replaceable block ConversionBlock = |
|---|
| 49 | Modelica.Blocks.Interfaces.PartialConversionBlock "Conversion block" |
|---|
| 50 | annotation (choicesAllMatching=true); |
|---|
| 51 | extends ConversionBlock; |
|---|
| 52 | |
|---|
| 53 | annotation ( |
|---|
| 54 | defaultComponentName="convert", |
|---|
| 55 | Icon(Line(points=[-90, 0; 30, 0],style(color=42)), Polygon(points=[90, |
|---|
| 56 | 0; 30, 20; 30, -20; 90, 0], style(color=42, fillColor=42))), |
|---|
| 57 | Documentation(info="<html> |
|---|
| 58 | <p>This block implements the Modelica.SIunits.Conversions functions as a fixed causality block to |
|---|
| 59 | simplify their use. The block contains a replaceable block class <b>ConversionBlock</b> that can be |
|---|
| 60 | changed to be any of the blocks defined in Modelica.Blocks.Math.UnitConversions, and more generally, any |
|---|
| 61 | blocks that extend from Modelica.Blocks.Interfaces.PartialConversionBlock.</p> |
|---|
| 62 | </html>")); |
|---|
| 63 | end ConvertAllUnits; |
|---|
| 64 | |
|---|
| 65 | block To_degC "Convert from Kelvin to °Celsius" |
|---|
| 66 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="K"), y( |
|---|
| 67 | unit="degC")); |
|---|
| 68 | |
|---|
| 69 | annotation (Icon(Text( |
|---|
| 70 | extent=[-20, 100; -100, 20], |
|---|
| 71 | style(color=0), |
|---|
| 72 | string="K"), Text( |
|---|
| 73 | extent=[100, -20; 20, -100], |
|---|
| 74 | style(color=0), |
|---|
| 75 | string="°C"))); |
|---|
| 76 | equation |
|---|
| 77 | y = SI.Conversions.to_degC(u); |
|---|
| 78 | end To_degC; |
|---|
| 79 | |
|---|
| 80 | block From_degC "Convert from °Celsius to Kelvin" |
|---|
| 81 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="degC"), |
|---|
| 82 | y(unit="K")); |
|---|
| 83 | annotation (Icon(Text( |
|---|
| 84 | extent=[-20, 100; -100, 20], |
|---|
| 85 | style(color=0), |
|---|
| 86 | string="°C"), Text( |
|---|
| 87 | extent=[100, -20; 20, -100], |
|---|
| 88 | style(color=0), |
|---|
| 89 | string="K"))); |
|---|
| 90 | equation |
|---|
| 91 | y = SI.Conversions.from_degC(u); |
|---|
| 92 | end From_degC; |
|---|
| 93 | |
|---|
| 94 | block To_degF "Convert from Kelvin to °Fahrenheit" |
|---|
| 95 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="K"), y( |
|---|
| 96 | unit="degF")); |
|---|
| 97 | annotation (Icon(Text( |
|---|
| 98 | extent=[-20, 100; -100, 20], |
|---|
| 99 | style(color=0), |
|---|
| 100 | string="K"), Text( |
|---|
| 101 | extent=[100, -20; 20, -100], |
|---|
| 102 | style(color=0), |
|---|
| 103 | string="°F"))); |
|---|
| 104 | equation |
|---|
| 105 | y = SI.Conversions.to_degF(u); |
|---|
| 106 | end To_degF; |
|---|
| 107 | |
|---|
| 108 | block From_degF "Convert from °Fahrenheit to Kelvin" |
|---|
| 109 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="degF"), |
|---|
| 110 | y(unit="K")); |
|---|
| 111 | annotation (Icon(Text( |
|---|
| 112 | extent=[-20, 100; -100, 20], |
|---|
| 113 | style(color=0), |
|---|
| 114 | string="°F"), Text( |
|---|
| 115 | extent=[100, -20; 20, -100], |
|---|
| 116 | style(color=0), |
|---|
| 117 | string="K"))); |
|---|
| 118 | equation |
|---|
| 119 | y = SI.Conversions.from_degF(u); |
|---|
| 120 | end From_degF; |
|---|
| 121 | |
|---|
| 122 | block To_degRk "Convert from Kelvin to °Rankine" |
|---|
| 123 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="K"), y( |
|---|
| 124 | unit="degRk")); |
|---|
| 125 | annotation (Icon(Text( |
|---|
| 126 | extent=[-20, 100; -100, 20], |
|---|
| 127 | style(color=0), |
|---|
| 128 | string="K"), Text( |
|---|
| 129 | extent=[100, -20; 20, -100], |
|---|
| 130 | style(color=0), |
|---|
| 131 | string="°Rk"))); |
|---|
| 132 | equation |
|---|
| 133 | y = SI.Conversions.to_degRk(u); |
|---|
| 134 | end To_degRk; |
|---|
| 135 | |
|---|
| 136 | block From_degRk "Convert from °Rankine to Kelvin" |
|---|
| 137 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="degRk"), |
|---|
| 138 | y(unit="K")); |
|---|
| 139 | annotation (Icon(Text( |
|---|
| 140 | extent=[-20, 100; -100, 20], |
|---|
| 141 | style(color=0), |
|---|
| 142 | string="°Rk"), Text( |
|---|
| 143 | extent=[100, -20; 20, -100], |
|---|
| 144 | style(color=0), |
|---|
| 145 | string="K"))); |
|---|
| 146 | equation |
|---|
| 147 | y = SI.Conversions.from_degRk(u); |
|---|
| 148 | end From_degRk; |
|---|
| 149 | |
|---|
| 150 | block To_deg "Convert from radian to degree" |
|---|
| 151 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="rad"), |
|---|
| 152 | y(unit="deg")); |
|---|
| 153 | annotation (Icon(Text( |
|---|
| 154 | extent=[-20, 100; -100, 20], |
|---|
| 155 | style(color=0), |
|---|
| 156 | string="rad"), Text( |
|---|
| 157 | extent=[100, -20; 20, -100], |
|---|
| 158 | style(color=0), |
|---|
| 159 | string="deg"))); |
|---|
| 160 | equation |
|---|
| 161 | y = SI.Conversions.to_deg(u); |
|---|
| 162 | end To_deg; |
|---|
| 163 | |
|---|
| 164 | block From_deg "Convert from degree to radian" |
|---|
| 165 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="deg"), |
|---|
| 166 | y(unit="rad")); |
|---|
| 167 | annotation (Icon(Text( |
|---|
| 168 | extent=[-20, 100; -100, 20], |
|---|
| 169 | style(color=0), |
|---|
| 170 | string="deg"), Text( |
|---|
| 171 | extent=[100, -20; 20, -100], |
|---|
| 172 | style(color=0), |
|---|
| 173 | string="rad"))); |
|---|
| 174 | equation |
|---|
| 175 | y = SI.Conversions.from_deg(u); |
|---|
| 176 | end From_deg; |
|---|
| 177 | |
|---|
| 178 | block To_rpm "Convert from radian per second to revolutions per minute" |
|---|
| 179 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="rad/s"), |
|---|
| 180 | y(unit="rev/min")); |
|---|
| 181 | annotation (Icon(Text( |
|---|
| 182 | extent=[26,82; -98,50], |
|---|
| 183 | style(color=0), |
|---|
| 184 | string="rad/s"), Text( |
|---|
| 185 | extent=[100,-42; -62,-74], |
|---|
| 186 | style(color=0), |
|---|
| 187 | string="rev/min"))); |
|---|
| 188 | equation |
|---|
| 189 | y = SI.Conversions.to_rpm(u); |
|---|
| 190 | end To_rpm; |
|---|
| 191 | |
|---|
| 192 | block From_rpm "Convert from revolutions per minute to radian per second" |
|---|
| 193 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit= |
|---|
| 194 | "rev/min"), y(unit="rad/s")); |
|---|
| 195 | annotation (Icon(Text( |
|---|
| 196 | extent=[50,84; -94,56], |
|---|
| 197 | style(color=0), |
|---|
| 198 | string="rev/min"), Text( |
|---|
| 199 | extent=[94,-42; -26,-74], |
|---|
| 200 | style(color=0), |
|---|
| 201 | string="rad/s"))); |
|---|
| 202 | equation |
|---|
| 203 | y = SI.Conversions.from_rpm(u); |
|---|
| 204 | end From_rpm; |
|---|
| 205 | |
|---|
| 206 | block To_kmh "Convert from metre per second to kilometre per hour" |
|---|
| 207 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="m/s"), |
|---|
| 208 | y(unit="km/h")); |
|---|
| 209 | annotation (Icon(Text( |
|---|
| 210 | extent=[0,82; -96,42], |
|---|
| 211 | style(color=0), |
|---|
| 212 | string="m/s"), Text( |
|---|
| 213 | extent=[92,-40; -14,-84], |
|---|
| 214 | style(color=0), |
|---|
| 215 | string="km/h"))); |
|---|
| 216 | equation |
|---|
| 217 | y = SI.Conversions.to_kmh(u); |
|---|
| 218 | end To_kmh; |
|---|
| 219 | |
|---|
| 220 | block From_kmh "Convert from kilometre per hour to metre per second" |
|---|
| 221 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="km/h"), |
|---|
| 222 | y(unit="m/s")); |
|---|
| 223 | annotation (Icon(Text( |
|---|
| 224 | extent=[26,80; -96,48], |
|---|
| 225 | style(color=0), |
|---|
| 226 | string="km/h"), Text( |
|---|
| 227 | extent=[92,-46; -20,-82], |
|---|
| 228 | style(color=0), |
|---|
| 229 | string="m/s"))); |
|---|
| 230 | equation |
|---|
| 231 | y = SI.Conversions.from_kmh(u); |
|---|
| 232 | end From_kmh; |
|---|
| 233 | |
|---|
| 234 | block To_day "Convert from second to day" |
|---|
| 235 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="s"), y( |
|---|
| 236 | unit="d")); |
|---|
| 237 | annotation (Icon(Text( |
|---|
| 238 | extent=[-20, 100; -100, 20], |
|---|
| 239 | style(color=0), |
|---|
| 240 | string="s"), Text( |
|---|
| 241 | extent=[100, -20; 20, -100], |
|---|
| 242 | style(color=0), |
|---|
| 243 | string="day"))); |
|---|
| 244 | equation |
|---|
| 245 | y = SI.Conversions.to_day(u); |
|---|
| 246 | end To_day; |
|---|
| 247 | |
|---|
| 248 | block From_day "Convert from day to second" |
|---|
| 249 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="d"), y( |
|---|
| 250 | unit="s")); |
|---|
| 251 | annotation (Icon(Text( |
|---|
| 252 | extent=[-20, 100; -100, 20], |
|---|
| 253 | style(color=0), |
|---|
| 254 | string="day"), Text( |
|---|
| 255 | extent=[100, -20; 20, -100], |
|---|
| 256 | style(color=0), |
|---|
| 257 | string="s"))); |
|---|
| 258 | equation |
|---|
| 259 | y = SI.Conversions.from_day(u); |
|---|
| 260 | end From_day; |
|---|
| 261 | |
|---|
| 262 | block To_hour "Convert from second to hour" |
|---|
| 263 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="s"), y( |
|---|
| 264 | unit="h")); |
|---|
| 265 | annotation (Icon(Text( |
|---|
| 266 | extent=[-20, 100; -100, 20], |
|---|
| 267 | style(color=0), |
|---|
| 268 | string="s"), Text( |
|---|
| 269 | extent=[100, -20; 20, -100], |
|---|
| 270 | style(color=0), |
|---|
| 271 | string="hour"))); |
|---|
| 272 | equation |
|---|
| 273 | y = SI.Conversions.to_hour(u); |
|---|
| 274 | end To_hour; |
|---|
| 275 | |
|---|
| 276 | block From_hour "Convert from hour to second" |
|---|
| 277 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="h"), y( |
|---|
| 278 | unit="s")); |
|---|
| 279 | annotation (Icon(Text( |
|---|
| 280 | extent=[-20, 100; -100, 20], |
|---|
| 281 | style(color=0), |
|---|
| 282 | string="hour"), Text( |
|---|
| 283 | extent=[100, -20; 20, -100], |
|---|
| 284 | style(color=0), |
|---|
| 285 | string="s"))); |
|---|
| 286 | equation |
|---|
| 287 | y = SI.Conversions.from_hour(u); |
|---|
| 288 | end From_hour; |
|---|
| 289 | |
|---|
| 290 | block To_minute "Convert from second to minute" |
|---|
| 291 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="s"), y( |
|---|
| 292 | unit="min")); |
|---|
| 293 | annotation (Icon(Text( |
|---|
| 294 | extent=[-20, 100; -100, 20], |
|---|
| 295 | style(color=0), |
|---|
| 296 | string="s"), Text( |
|---|
| 297 | extent=[100, -20; 20, -100], |
|---|
| 298 | style(color=0), |
|---|
| 299 | string="minute"))); |
|---|
| 300 | equation |
|---|
| 301 | y = SI.Conversions.to_minute(u); |
|---|
| 302 | end To_minute; |
|---|
| 303 | |
|---|
| 304 | block From_minute "Convert from minute to second" |
|---|
| 305 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="min"), |
|---|
| 306 | y(unit="s")); |
|---|
| 307 | annotation (Icon(Text( |
|---|
| 308 | extent=[-20, 100; -100, 20], |
|---|
| 309 | style(color=0), |
|---|
| 310 | string="minute"), Text( |
|---|
| 311 | extent=[100, -20; 20, -100], |
|---|
| 312 | style(color=0), |
|---|
| 313 | string="s"))); |
|---|
| 314 | equation |
|---|
| 315 | y = SI.Conversions.from_minute(u); |
|---|
| 316 | end From_minute; |
|---|
| 317 | |
|---|
| 318 | block To_litre "Convert from cubic metre to litre" |
|---|
| 319 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="m3"), y( |
|---|
| 320 | unit="l")); |
|---|
| 321 | annotation (Icon(Text( |
|---|
| 322 | extent=[-20, 100; -100, 20], |
|---|
| 323 | style(color=0), |
|---|
| 324 | string="m3"), Text( |
|---|
| 325 | extent=[100, -20; 20, -100], |
|---|
| 326 | style(color=0), |
|---|
| 327 | string="litre"))); |
|---|
| 328 | equation |
|---|
| 329 | y = SI.Conversions.to_litre(u); |
|---|
| 330 | end To_litre; |
|---|
| 331 | |
|---|
| 332 | block From_litre "Convert from litre to cubic metre" |
|---|
| 333 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="l"), y( |
|---|
| 334 | unit="m3")); |
|---|
| 335 | annotation (Icon(Text( |
|---|
| 336 | extent=[-20, 100; -100, 20], |
|---|
| 337 | style(color=0), |
|---|
| 338 | string="litre"), Text( |
|---|
| 339 | extent=[100, -20; 20, -100], |
|---|
| 340 | style(color=0), |
|---|
| 341 | string="m3"))); |
|---|
| 342 | equation |
|---|
| 343 | y = SI.Conversions.from_litre(u); |
|---|
| 344 | end From_litre; |
|---|
| 345 | |
|---|
| 346 | block To_kWh "Convert from Joule to kilo Watt hour" |
|---|
| 347 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="J"), y( |
|---|
| 348 | unit="kW.h")); |
|---|
| 349 | annotation (Icon(Text( |
|---|
| 350 | extent=[-20, 100; -100, 20], |
|---|
| 351 | style(color=0), |
|---|
| 352 | string="J"), Text( |
|---|
| 353 | extent=[100, -20; 20, -100], |
|---|
| 354 | style(color=0), |
|---|
| 355 | string="kW.h"))); |
|---|
| 356 | equation |
|---|
| 357 | y = SI.Conversions.to_kWh(u); |
|---|
| 358 | end To_kWh; |
|---|
| 359 | |
|---|
| 360 | block From_kWh "Convert from kilo Watt hour to Joule" |
|---|
| 361 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="kW.h"), |
|---|
| 362 | y(unit="J")); |
|---|
| 363 | annotation (Icon(Text( |
|---|
| 364 | extent=[-20, 100; -100, 20], |
|---|
| 365 | style(color=0), |
|---|
| 366 | string="kW.h"), Text( |
|---|
| 367 | extent=[100, -20; 20, -100], |
|---|
| 368 | style(color=0), |
|---|
| 369 | string="J"))); |
|---|
| 370 | equation |
|---|
| 371 | y = SI.Conversions.from_kWh(u); |
|---|
| 372 | end From_kWh; |
|---|
| 373 | |
|---|
| 374 | block To_bar "Convert from Pascal to bar" |
|---|
| 375 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="Pa"), y( |
|---|
| 376 | unit="bar")); |
|---|
| 377 | annotation (Icon(Text( |
|---|
| 378 | extent=[-20, 100; -100, 20], |
|---|
| 379 | style(color=0), |
|---|
| 380 | string="Pa"), Text( |
|---|
| 381 | extent=[100, -20; 20, -100], |
|---|
| 382 | style(color=0), |
|---|
| 383 | string="bar"))); |
|---|
| 384 | equation |
|---|
| 385 | y = SI.Conversions.to_bar(u); |
|---|
| 386 | end To_bar; |
|---|
| 387 | |
|---|
| 388 | block From_bar "Convert from bar to Pascal" |
|---|
| 389 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="bar"), |
|---|
| 390 | y(unit="Pa")); |
|---|
| 391 | annotation (Icon(Text( |
|---|
| 392 | extent=[-20, 100; -100, 20], |
|---|
| 393 | style(color=0), |
|---|
| 394 | string="bar"), Text( |
|---|
| 395 | extent=[100, -20; 20, -100], |
|---|
| 396 | style(color=0), |
|---|
| 397 | string="Pa"))); |
|---|
| 398 | equation |
|---|
| 399 | y = SI.Conversions.from_bar(u); |
|---|
| 400 | end From_bar; |
|---|
| 401 | |
|---|
| 402 | block To_gps "Convert from kilogram per second to gram per second" |
|---|
| 403 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="kg/s"), |
|---|
| 404 | y(unit="g/s")); |
|---|
| 405 | annotation (Icon(Text( |
|---|
| 406 | extent=[-20, 100; -100, 20], |
|---|
| 407 | style(color=0), |
|---|
| 408 | string="kg/s"), Text( |
|---|
| 409 | extent=[100, -20; 20, -100], |
|---|
| 410 | style(color=0), |
|---|
| 411 | string="g/s"))); |
|---|
| 412 | equation |
|---|
| 413 | y = SI.Conversions.to_gps(u); |
|---|
| 414 | end To_gps; |
|---|
| 415 | |
|---|
| 416 | block From_gps "Convert from gram per second to kilogram per second" |
|---|
| 417 | extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="g/s"), |
|---|
| 418 | y(unit="kg/s")); |
|---|
| 419 | annotation (Icon(Text( |
|---|
| 420 | extent=[-20, 100; -100, 20], |
|---|
| 421 | style(color=0), |
|---|
| 422 | string="g/s"), Text( |
|---|
| 423 | extent=[100, -20; 20, -100], |
|---|
| 424 | style(color=0), |
|---|
| 425 | string="kg/s"))); |
|---|
| 426 | equation |
|---|
| 427 | y = SI.Conversions.from_gps(u); |
|---|
| 428 | end From_gps; |
|---|
| 429 | annotation (Documentation(info="<html> |
|---|
| 430 | |
|---|
| 431 | </html>")); |
|---|
| 432 | end UnitConversions; |
|---|
| 433 | |
|---|
| 434 | block TwoInputs |
|---|
| 435 | "Change causality of input signals by defining that two input signals are identical (e.g. for inverse models)" |
|---|
| 436 | extends Blocks.Interfaces.BlockIcon; |
|---|
| 437 | annotation(structurallyIncomplete, |
|---|
| 438 | Coordsys( |
|---|
| 439 | extent=[-100, -100; 100, 100], |
|---|
| 440 | grid=[2, 2], |
|---|
| 441 | component=[20, 20]), |
|---|
| 442 | Window( |
|---|
| 443 | x=0.15, |
|---|
| 444 | y=0.21, |
|---|
| 445 | width=0.6, |
|---|
| 446 | height=0.6), |
|---|
| 447 | Documentation(info="<HTML> |
|---|
| 448 | <p> |
|---|
| 449 | This block is used to enable asignment of values to variables preliminary |
|---|
| 450 | defined as outputs (e.g. useful for inverse model generation). |
|---|
| 451 | </p> |
|---|
| 452 | |
|---|
| 453 | </HTML> |
|---|
| 454 | "), Icon(Text( |
|---|
| 455 | extent=[-95,50; 95,-50], |
|---|
| 456 | string="=", |
|---|
| 457 | style(color=74, rgbcolor={0,0,127})))); |
|---|
| 458 | Blocks.Interfaces.RealInput u1 "Connector of first Real input signal" |
|---|
| 459 | annotation (extent=[-139.742, -19.0044; -100, 20], layer="icon"); |
|---|
| 460 | Blocks.Interfaces.RealInput u2 |
|---|
| 461 | "Connector of second Real input signal (u1=u2)" |
|---|
| 462 | annotation ( |
|---|
| 463 | extent=[100, -20; 140, 20], |
|---|
| 464 | rotation=180, |
|---|
| 465 | layer="icon"); |
|---|
| 466 | equation |
|---|
| 467 | u1 = u2; |
|---|
| 468 | end TwoInputs; |
|---|
| 469 | |
|---|
| 470 | block TwoOutputs |
|---|
| 471 | "Change causality of output signals by defining that two output signals are identical (e.g. for inverse models)" |
|---|
| 472 | extends Blocks.Interfaces.BlockIcon; |
|---|
| 473 | annotation(structurallyIncomplete, |
|---|
| 474 | Coordsys( |
|---|
| 475 | extent=[-100, -100; 100, 100], |
|---|
| 476 | grid=[2, 2], |
|---|
| 477 | component=[20, 20]), |
|---|
| 478 | Window( |
|---|
| 479 | x=0.21, |
|---|
| 480 | y=0.28, |
|---|
| 481 | width=0.6, |
|---|
| 482 | height=0.6), |
|---|
| 483 | Documentation(info=" |
|---|
| 484 | <HTML> |
|---|
| 485 | <p> |
|---|
| 486 | This block is used to enable calculation of values preliminary defined as inputs. |
|---|
| 487 | (e.g. useful for inverse model generation). |
|---|
| 488 | </p> |
|---|
| 489 | |
|---|
| 490 | </HTML> |
|---|
| 491 | "), Icon(Text( |
|---|
| 492 | extent=[-95,50; 95,-50], |
|---|
| 493 | string="=", |
|---|
| 494 | style(color=74, rgbcolor={0,0,127})))); |
|---|
| 495 | output Blocks.Interfaces.RealOutput y1 |
|---|
| 496 | "Connector of first Real output signal" |
|---|
| 497 | annotation (extent=[100, -10; 120, 10]); |
|---|
| 498 | output Blocks.Interfaces.RealOutput y2 |
|---|
| 499 | "Connector of second Real output signal (y1=y2)" |
|---|
| 500 | annotation (extent=[-120.366, -10.9029; |
|---|
| 501 | -100.365, 9.09712], rotation=180); |
|---|
| 502 | equation |
|---|
| 503 | y1 = y2; |
|---|
| 504 | end TwoOutputs; |
|---|
| 505 | |
|---|
| 506 | block Gain "Output the product of a gain value with the input signal" |
|---|
| 507 | |
|---|
| 508 | parameter Real k=1 "Gain value multiplied with input signal"; |
|---|
| 509 | public |
|---|
| 510 | Interfaces.RealInput u "Input signal connector" |
|---|
| 511 | annotation (extent=[-140, -20; -100, 20]); |
|---|
| 512 | Interfaces.RealOutput y "Output signal connector" |
|---|
| 513 | annotation (extent=[100, -10; 120, 10]); |
|---|
| 514 | annotation ( |
|---|
| 515 | Coordsys( |
|---|
| 516 | extent=[-100, -100; 100, 100], |
|---|
| 517 | grid=[2, 2], |
|---|
| 518 | component=[20, 20]), |
|---|
| 519 | Window( |
|---|
| 520 | x=0.19, |
|---|
| 521 | y=0.02, |
|---|
| 522 | width=0.59, |
|---|
| 523 | height=0.6), |
|---|
| 524 | Documentation(info=" |
|---|
| 525 | <HTML> |
|---|
| 526 | <p> |
|---|
| 527 | This block computes output <i>y</i> as |
|---|
| 528 | <i>product</i> of gain <i>k</i> with the |
|---|
| 529 | input <i>u</i>: |
|---|
| 530 | </p> |
|---|
| 531 | <pre> |
|---|
| 532 | y = k * u; |
|---|
| 533 | </pre> |
|---|
| 534 | |
|---|
| 535 | </HTML> |
|---|
| 536 | "), Icon( |
|---|
| 537 | Polygon(points=[-100, -100; -100, 100; 100, 0; -100, -100], style( |
|---|
| 538 | color=74, |
|---|
| 539 | rgbcolor={0,0,127}, |
|---|
| 540 | fillColor=7, |
|---|
| 541 | rgbfillColor={255,255,255})), |
|---|
| 542 | Text( |
|---|
| 543 | extent=[-150, -140; 150, -100], |
|---|
| 544 | string="k=%k", |
|---|
| 545 | style(color=0)), |
|---|
| 546 | Text(extent=[-150, 140; 150, 100], string="%name")), |
|---|
| 547 | Diagram(Polygon(points=[-100, -100; -100, 100; 100, 0; -100, -100], |
|---|
| 548 | style( |
|---|
| 549 | color=74, |
|---|
| 550 | rgbcolor={0,0,127}, |
|---|
| 551 | fillColor=7, |
|---|
| 552 | rgbfillColor={255,255,255})), |
|---|
| 553 | Text(extent=[-76, 38; 0, -34], string="k"))); |
|---|
| 554 | equation |
|---|
| 555 | y = k*u; |
|---|
| 556 | end Gain; |
|---|
| 557 | |
|---|
| 558 | block MatrixGain |
|---|
| 559 | "Output the product of a gain matrix with the input signal vector" |
|---|
| 560 | |
|---|
| 561 | parameter Real K[:, :]=[1, 0; 0, 1] |
|---|
| 562 | "Gain matrix which is multiplied with the input"; |
|---|
| 563 | extends Interfaces.MIMO(final nin=size(K, 2), final nout=size(K, 1)); |
|---|
| 564 | annotation ( |
|---|
| 565 | Documentation(info=" |
|---|
| 566 | <HTML> |
|---|
| 567 | <p> |
|---|
| 568 | This blocks computes output vector <b>y</b> as <i>product</i> of the |
|---|
| 569 | gain matrix <b>K</b> with the input signal vector <b>u</b>: |
|---|
| 570 | </p> |
|---|
| 571 | <pre> |
|---|
| 572 | <b>y</b> = <b>K</b> * <b>u</b>; |
|---|
| 573 | </pre> |
|---|
| 574 | <p> |
|---|
| 575 | Example: |
|---|
| 576 | </p> |
|---|
| 577 | <pre> |
|---|
| 578 | parameter: <b>K</b> = [0.12 2; 3 1.5] |
|---|
| 579 | results in the following equations: |
|---|
| 580 | | y[1] | | 0.12 2.00 | | u[1] | |
|---|
| 581 | | | = | | * | | |
|---|
| 582 | | y[2] | | 3.00 1.50 | | u[2] | |
|---|
| 583 | </pre> |
|---|
| 584 | |
|---|
| 585 | </HTML> |
|---|
| 586 | "), Icon(Text( |
|---|
| 587 | extent=[-90, -60; 90, 60], |
|---|
| 588 | string="*K", |
|---|
| 589 | style(color=9)), Text(extent=[-150, 150; 150, 110], string= |
|---|
| 590 | "%name")), |
|---|
| 591 | Diagram(Rectangle(extent=[-100, -100; 100, 100], style(color=3, |
|---|
| 592 | fillColor=7)), Text( |
|---|
| 593 | extent=[-90, -60; 90, 60], |
|---|
| 594 | string="*K", |
|---|
| 595 | style(color=9))), |
|---|
| 596 | Coordsys( |
|---|
| 597 | extent=[-100, -100; 100, 100], |
|---|
| 598 | grid=[2, 2], |
|---|
| 599 | component=[20, 20]), |
|---|
| 600 | Window( |
|---|
| 601 | x=0.35, |
|---|
| 602 | y=0.09, |
|---|
| 603 | width=0.6, |
|---|
| 604 | height=0.6)); |
|---|
| 605 | equation |
|---|
| 606 | y = K*u; |
|---|
| 607 | end MatrixGain; |
|---|
| 608 | |
|---|
| 609 | block Sum "Output the sum of the elements of the input vector" |
|---|
| 610 | extends Interfaces.MISO; |
|---|
| 611 | parameter Real k[nin]=ones(nin) "Optional: sum coefficients"; |
|---|
| 612 | annotation (defaultComponentName="sum1", |
|---|
| 613 | Coordsys( |
|---|
| 614 | extent=[-100, -100; 100, 100], |
|---|
| 615 | grid=[2, 2], |
|---|
| 616 | component=[20, 20]), |
|---|
| 617 | Window( |
|---|
| 618 | x=0.35, |
|---|
| 619 | y=0.08, |
|---|
| 620 | width=0.54, |
|---|
| 621 | height=0.66), |
|---|
| 622 | Documentation(info=" |
|---|
| 623 | <HTML> |
|---|
| 624 | <p> |
|---|
| 625 | This blocks computes output <b>y</b> as |
|---|
| 626 | <i>sum</i> of the elements of the input signal vector |
|---|
| 627 | <b>u</b>: |
|---|
| 628 | </p> |
|---|
| 629 | <pre> |
|---|
| 630 | <b>y</b> = <b>u</b>[1] + <b>u</b>[2] + ...; |
|---|
| 631 | </pre> |
|---|
| 632 | <p> |
|---|
| 633 | Example: |
|---|
| 634 | </p> |
|---|
| 635 | <pre> |
|---|
| 636 | parameter: nin = 3; |
|---|
| 637 | results in the following equations: |
|---|
| 638 | y = u[1] + u[2] + u[3]; |
|---|
| 639 | </pre> |
|---|
| 640 | |
|---|
| 641 | </HTML> |
|---|
| < |
|---|