| 1 | package SIunits |
|---|
| 2 | "Type and unit definitions based on SI units according to ISO 31-1992" |
|---|
| 3 | package UsersGuide "Users Guide" |
|---|
| 4 | annotation (DocumentationClass=true, Documentation(info="<HTML> |
|---|
| 5 | <h3><font color=\"#008000\" size=5>Users Guide of package SIunits</font></h3> |
|---|
| 6 | <p> |
|---|
| 7 | Library <b>SIunits</b> is a <b>free</b> Modelica package providing |
|---|
| 8 | predefined types, such as <i>Mass</i>, |
|---|
| 9 | <i>Length</i>, <i>Time</i>, based on the international standard |
|---|
| 10 | on units.</p> |
|---|
| 11 | |
|---|
| 12 | </HTML>")); |
|---|
| 13 | |
|---|
| 14 | package HowToUseSIunits "How to use SIunits" |
|---|
| 15 | |
|---|
| 16 | annotation (DocumentationClass=true, Documentation(info="<html> |
|---|
| 17 | <h3><font color=\"#008000\" size=5>How to use SIunits</font></h3> |
|---|
| 18 | |
|---|
| 19 | <p> |
|---|
| 20 | When implementing a Modelica model, every variable needs to |
|---|
| 21 | be declared. Physical variables should be declared with a unit. |
|---|
| 22 | The basic approach in Modelica is that the unit attribute of |
|---|
| 23 | a variable is the <b>unit</b> in which the <b>equations</b> are <b>written</b>, |
|---|
| 24 | for example: |
|---|
| 25 | </p> |
|---|
| 26 | |
|---|
| 27 | <pre> <b>model</b> MassOnGround |
|---|
| 28 | <b>parameter</b> Real m(quantity=\"Mass\", unit=\"kg\") \"Mass\"; |
|---|
| 29 | <b>parameter</b> Real f(quantity=\"Force\", unit=\"N\") \"Driving force\"; |
|---|
| 30 | Real s(unit=\"m\") \"Position of mass\"; |
|---|
| 31 | Real v(unit=\"m/s\") \"Velocity of mass\"; |
|---|
| 32 | <b>equation</b> |
|---|
| 33 | <b>der</b>(s) = v; |
|---|
| 34 | m*<b>der</b>(v) = f; |
|---|
| 35 | <b>end</b> MassOnGround; |
|---|
| 36 | </pre> |
|---|
| 37 | |
|---|
| 38 | <p> |
|---|
| 39 | This means that the equations in the equation section are only correct |
|---|
| 40 | for the specified units. A different issue is the user interface, i.e., |
|---|
| 41 | in which unit the variable is presented to the user in graphical |
|---|
| 42 | user interfaces, both for input (e.g., parameter menu), as well as |
|---|
| 43 | for output (e.g., in the plot window). Preferably, the Modelica tool |
|---|
| 44 | should provide a list of units from which the user can select, e.g., |
|---|
| 45 | \"m\", \"cm\", \"km\", \"inch\" for quantity \"Length\". When storing the value in |
|---|
| 46 | the model as a Modelica modifier, it has to be converted to the unit defined |
|---|
| 47 | in the declaration. Additionally, the unit used in the graphical |
|---|
| 48 | user interface has to be stored. In order to have a standardized way |
|---|
| 49 | of doing this, Modelica provides the following three attributs |
|---|
| 50 | for a variable of type Real: |
|---|
| 51 | </p> |
|---|
| 52 | |
|---|
| 53 | <ul> |
|---|
| 54 | <li><b>quantity</b> to define the physical quantity (e.g. \"Length\", or \"Energy\").</li> |
|---|
| 55 | <li><b>unit</b> to define the unit that has to be used |
|---|
| 56 | in order that the equations are correct (e.g. \"N.m\").</li> |
|---|
| 57 | <li><b>displayUnit</b> to define the unit used in the graphical |
|---|
| 58 | user interface as default display unit for input and/or output.</li> |
|---|
| 59 | </ul> |
|---|
| 60 | |
|---|
| 61 | <p> |
|---|
| 62 | Note, a unit, such as \"N.m\", is not sufficient to define uniquely the |
|---|
| 63 | physical quantity, since, e.g., \"N.m\" might be either \"torque\" or |
|---|
| 64 | \"energy\". The \"quantity\" attribute might therefore be used by a tool |
|---|
| 65 | to select the corresponding menu from which the user can select |
|---|
| 66 | a unit for the corresponding variable. |
|---|
| 67 | </p> |
|---|
| 68 | |
|---|
| 69 | <p> |
|---|
| 70 | For example, after providing a value for \"m\" and \"f\" in a parameter |
|---|
| 71 | menu of an instance of MassOnGround, a tool might generate the following code: |
|---|
| 72 | </p> |
|---|
| 73 | |
|---|
| 74 | <pre> |
|---|
| 75 | MassOnGround myObject(m(displayUnit=\"g\")=2, f=3); |
|---|
| 76 | </pre> |
|---|
| 77 | |
|---|
| 78 | <p> |
|---|
| 79 | The meaning is that in the equations a value of \"2\" is used |
|---|
| 80 | and that in the graphical user interface a value of \"2000\" should be used, |
|---|
| 81 | together with the unit \"g\" from the unit set \"Mass\" (= the quantity name). |
|---|
| 82 | Note, according to the Modelica specification |
|---|
| 83 | a tool might ignore the \"displayUnit\" attribute. |
|---|
| 84 | </p> |
|---|
| 85 | |
|---|
| 86 | <p> |
|---|
| 87 | In order to help the Modelica model developer, the Modelica.SIunits |
|---|
| 88 | library provides about 450 predefined type names, |
|---|
| 89 | together with values for the attributes <b>quantity</b>, <b>unit</b> and sometimes |
|---|
| 90 | <b>displayUnit</b> and <b>min</b>. The unit is always selected as SI-unit according to the |
|---|
| 91 | ISO standard. The type and the quantity names are the |
|---|
| 92 | quantity names used in the ISO standard. \"quantity\" and \"unit\" are defined |
|---|
| 93 | as \"<b>final</b>\" in order that they cannot be modified. Attributes \"displayUnit\" |
|---|
| 94 | and \"min\" can, however, be changed in a model via a modification. The example above, |
|---|
| 95 | might therefore be alternatively also defined as: |
|---|
| 96 | </p> |
|---|
| 97 | |
|---|
| 98 | <pre> <b>model</b> MassOnGround |
|---|
| 99 | <b>parameter</b> Modelica.SIunits.Mass m \"Mass\"; |
|---|
| 100 | <b>parameter</b> Modelica.SIunits.Force f \"Driving force\"; |
|---|
| 101 | ... |
|---|
| 102 | <b>end</b> MassOnGround; |
|---|
| 103 | </pre> |
|---|
| 104 | |
|---|
| 105 | <p> |
|---|
| 106 | or in a short hand notation as |
|---|
| 107 | </p> |
|---|
| 108 | |
|---|
| 109 | <pre> |
|---|
| 110 | <b>model</b> MassOnGround |
|---|
| 111 | <b>import</b> SI = Modelica.SIunits; |
|---|
| 112 | <b>parameter</b> SI.Mass m \"Mass\"; |
|---|
| 113 | <b>parameter</b> SI.Force f \"Driving force\"; |
|---|
| 114 | ... |
|---|
| 115 | <b>end</b> MassOnGround; |
|---|
| 116 | </pre> |
|---|
| 117 | |
|---|
| 118 | <p> |
|---|
| 119 | For some often |
|---|
| 120 | used Non SI-units (like hour), some additional type definitions are |
|---|
| 121 | present as Modelica.SIunits.Conversions.NonSIunits. If this is not sufficient, |
|---|
| 122 | the user has to define its own types or use the attributes directly |
|---|
| 123 | in the declaration as in the example at the beginning. |
|---|
| 124 | </p> |
|---|
| 125 | |
|---|
| 126 | </html>")); |
|---|
| 127 | |
|---|
| 128 | end HowToUseSIunits; |
|---|
| 129 | |
|---|
| 130 | package Conventions "Conventions" |
|---|
| 131 | |
|---|
| 132 | annotation (DocumentationClass=true, Documentation(info="<html> |
|---|
| 133 | <h3><font color=\"#008000\" size=5>Conventions</font></h3> |
|---|
| 134 | |
|---|
| 135 | <p>The following conventions are used in package SIunits:</p> |
|---|
| 136 | <ul> |
|---|
| 137 | <li>Modelica quantity names are defined according to the recommendations |
|---|
| 138 | of ISO 31. Some of these name are rather long, such as |
|---|
| 139 | \"ThermodynamicTemperature\". Shorter alias names are defined, e.g., |
|---|
| 140 | \"type Temp_K = ThermodynamicTemperature;\".</li> |
|---|
| 141 | <li>Modelica units are defined according to the SI base units without |
|---|
| 142 | multiples (only exception \"kg\").</li> |
|---|
| 143 | <li>For some quantities, more convenient units for an engineer are |
|---|
| 144 | defined as \"displayUnit\", i.e., the default unit for display |
|---|
| 145 | purposes (e.g., displayUnit=\"deg\" for quantity=\"Angle\").</li> |
|---|
| 146 | <li>The type name is identical to the quantity name, following |
|---|
| 147 | the convention of type names.</li> |
|---|
| 148 | <li>All quantity and unit attributes are defined as final in order |
|---|
| 149 | that they cannot be redefined to another value.</li> |
|---|
| 150 | <li>Similiar quantities, such as \"Length, Breadth, Height, Thickness, |
|---|
| 151 | Radius\" are defined as the same quantity (here: \"Length\").</li> |
|---|
| 152 | <li>The ordering of the type declarations in this package follows ISO 31: |
|---|
| 153 | <pre> |
|---|
| 154 | Chapter 1: <b>Space and Time</b> |
|---|
| 155 | Chapter 2: <b>Periodic and Related Phenomena</b> |
|---|
| 156 | Chapter 3: <b>Mechanics</b> |
|---|
| 157 | Chapter 4: <b>Heat</b> |
|---|
| 158 | Chapter 5: <b>Electricity and Magnetism</b> |
|---|
| 159 | Chapter 6: <b>Light and Related Electro-Magnetic Radiations</b> |
|---|
| 160 | Chapter 7: <b>Acoustics</b> |
|---|
| 161 | Chapter 8: <b>Physical Chemistry</b> |
|---|
| 162 | Chapter 9: <b>Atomic and Nuclear Physics</b> |
|---|
| 163 | Chapter 10: <b>Nuclear Reactions and Ionizing Radiations</b> |
|---|
| 164 | Chapter 11: (not defined in ISO 31-1992) |
|---|
| 165 | Chapter 12: <b>Characteristic Numbers</b> |
|---|
| 166 | Chapter 13: <b>Solid State Physics</b> |
|---|
| 167 | </pre> |
|---|
| 168 | </li> |
|---|
| 169 | <li>Conversion functions between SI and non-SI units are available in subpackage |
|---|
| 170 | <b>Conversions</b>.</li> |
|---|
| 171 | </ul> |
|---|
| 172 | </html>")); |
|---|
| 173 | |
|---|
| 174 | end Conventions; |
|---|
| 175 | |
|---|
| 176 | class Literature "Literature" |
|---|
| 177 | |
|---|
| 178 | annotation (Documentation(info="<html> |
|---|
| 179 | <h3><font color=\"#008000\" size=5>Literature</font></h3> |
|---|
| 180 | |
|---|
| 181 | <p> This package is based on the following references |
|---|
| 182 | </p> |
|---|
| 183 | |
|---|
| 184 | <dl> |
|---|
| 185 | <dt>ISO 31-1992:</dt> |
|---|
| 186 | <dd> <b>General principles concerning |
|---|
| 187 | quantities, units and symbols</b>.<br> </dd> |
|---|
| 188 | |
|---|
| 189 | <dt>ISO 1000-1992:</dt> |
|---|
| 190 | <dd> <b>SI units and recommendations for the use |
|---|
| 191 | of their multiples and of certain other units</b>.<br> </dd> |
|---|
| 192 | |
|---|
| 193 | <dt>Cardarelli F.:</dt> |
|---|
| 194 | <dd> <b>Scientific Unit Conversion - A Practical |
|---|
| 195 | Guide to Metrication</b>. Springer 1997.</dd> |
|---|
| 196 | </dl> |
|---|
| 197 | |
|---|
| 198 | </html> |
|---|
| 199 | ")); |
|---|
| 200 | end Literature; |
|---|
| 201 | |
|---|
| 202 | class Contact "Contact" |
|---|
| 203 | |
|---|
| 204 | annotation (Documentation(info="<html> |
|---|
| 205 | <h3><font color=\"#008000\" size=5>Contact</font></h3> |
|---|
| 206 | |
|---|
| 207 | <dl> |
|---|
| 208 | <dt><b>Main Author:</b> |
|---|
| 209 | <dd><a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a><br> |
|---|
| 210 | Deutsches Zentrum für Luft und Raumfahrt e.V. (DLR)<br> |
|---|
| 211 | Institut für Robotik und Mechatronik<br> |
|---|
| 212 | Abteilung für Entwurfsorientierte Regelungstechnik<br> |
|---|
| 213 | Postfach 1116<br> |
|---|
| 214 | D-82230 Wessling<br> |
|---|
| 215 | Germany<br> |
|---|
| 216 | email: <A HREF=\"mailto:Martin.Otter@dlr.de\">Martin.Otter@dlr.de</A><br> |
|---|
| 217 | </dl> |
|---|
| 218 | |
|---|
| 219 | |
|---|
| 220 | <p><b>Acknowledgements:</b></p> |
|---|
| 221 | <ul> |
|---|
| 222 | <li> Astrid Jaschinski, Hubertus Tummescheit and Christian Schweiger |
|---|
| 223 | contributed to the implementation of this package.</li> |
|---|
| 224 | </ul> |
|---|
| 225 | </html> |
|---|
| 226 | ")); |
|---|
| 227 | end Contact; |
|---|
| 228 | |
|---|
| 229 | end UsersGuide; |
|---|
| 230 | extends Modelica.Icons.Library2; |
|---|
| 231 | |
|---|
| 232 | annotation(preferedView="info", |
|---|
| 233 | Window( |
|---|
| 234 | x=0.08, |
|---|
| 235 | y=0.04, |
|---|
| 236 | width=0.58, |
|---|
| 237 | height=0.84, |
|---|
| 238 | library=1, |
|---|
| 239 | autolayout=1), |
|---|
| 240 | Invisible=true, |
|---|
| 241 | Icon(Text( |
|---|
| 242 | extent=[-63, -13; 45, -67], |
|---|
| 243 | string="[kg.m2]", |
|---|
| 244 | style(color=0))), |
|---|
| 245 | Documentation(info="<html> |
|---|
| 246 | <p>This package provides predefined types, such as <i>Mass</i>, |
|---|
| 247 | <i>Angle</i>, <i>Time</i>, based on the international standard |
|---|
| 248 | on units, e.g., |
|---|
| 249 | </p> |
|---|
| 250 | |
|---|
| 251 | <pre> <b>type</b> Angle = Real(<b>final</b> quantity = \"Angle\", |
|---|
| 252 | <b>final</b> unit = \"rad\", |
|---|
| 253 | displayUnit = \"deg\"); |
|---|
| 254 | </pre> |
|---|
| 255 | |
|---|
| 256 | <p> |
|---|
| 257 | as well as conversion functions from non SI-units to SI-units |
|---|
| 258 | and vice versa in subpackage |
|---|
| 259 | <a href=\"Modelica://Modelica.SIunits.Conversions\">Conversions</a>. |
|---|
| 260 | </p> |
|---|
| 261 | |
|---|
| 262 | <p> |
|---|
| 263 | For an introduction how units are used in the Modelica standard library |
|---|
| 264 | with package SIunits, have a look at: |
|---|
| 265 | <a href=\"Modelica://Modelica.SIunits.UsersGuide.HowToUseSIunits\">How to use SIunits</a>. |
|---|
| 266 | </p> |
|---|
| 267 | |
|---|
| 268 | <p> |
|---|
| 269 | Copyright © 1998-2006, Modelica Association and DLR. |
|---|
| 270 | </p> |
|---|
| 271 | <p> |
|---|
| 272 | <i>This Modelica package is <b>free</b> software; it can be redistributed and/or modified |
|---|
| 273 | under the terms of the <b>Modelica license</b>, see the license conditions |
|---|
| 274 | and the accompanying <b>disclaimer</b> |
|---|
| 275 | <a href=\"Modelica://Modelica.UsersGuide.ModelicaLicense\">here</a>.</i> |
|---|
| 276 | </p> |
|---|
| 277 | |
|---|
| 278 | </html>", revisions="<html> |
|---|
| 279 | <ul> |
|---|
| 280 | <li><i>Dec. 14, 2005</i> |
|---|
| 281 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br> |
|---|
| 282 | Add users guide and removed \"min\" values for Resistance and Conductance.</li> |
|---|
| 283 | <li><i>October 21, 2002</i> |
|---|
| 284 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a> |
|---|
| 285 | and <a href=\"http://www.robotic.dlr.de/Christian.Schweiger/\">Christian Schweiger</a>:<br> |
|---|
| 286 | Added new package <b>Conversions</b>. Corrected typo <i>Wavelenght</i>.</li> |
|---|
| 287 | <li><i>June 6, 2000</i> |
|---|
| 288 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br> |
|---|
| 289 | Introduced the following new types<br> |
|---|
| 290 | type Temperature = ThermodynamicTemperature;<br> |
|---|
| 291 | types DerDensityByEnthalpy, DerDensityByPressure, |
|---|
| 292 | DerDensityByTemperature, DerEnthalpyByPressure, |
|---|
| 293 | DerEnergyByDensity, DerEnergyByPressure<br> |
|---|
| 294 | Attribute \"final\" removed from min and max values |
|---|
| 295 | in order that these values can still be changed to narrow |
|---|
| 296 | the allowed range of values.<br> |
|---|
| 297 | Quantity=\"Stress\" removed from type \"Stress\", in order |
|---|
| 298 | that a type \"Stress\" can be connected to a type \"Pressure\".</li> |
|---|
| 299 | <li><i>Oct. 27, 1999</i> |
|---|
| 300 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br> |
|---|
| 301 | New types due to electrical library: Transconductance, InversePotential, |
|---|
| 302 | Damping.</li> |
|---|
| 303 | <li><i>Sept. 18, 1999</i> |
|---|
| 304 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br> |
|---|
| 305 | Renamed from SIunit to SIunits. Subpackages expanded, i.e., the |
|---|
| 306 | SIunits package, does no longer contain subpackages.</li> |
|---|
| 307 | <li><i>Aug 12, 1999</i> |
|---|
| 308 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br> |
|---|
| 309 | Type \"Pressure\" renamed to \"AbsolutePressure\" and introduced a new |
|---|
| 310 | type \"Pressure\" which does not contain a minimum of zero in order |
|---|
| 311 | to allow convenient handling of relative pressure. Redefined |
|---|
| 312 | BulkModulus as an alias to AbsolutePressure instead of Stress, since |
|---|
| 313 | needed in hydraulics.</li> |
|---|
| 314 | <li><i>June 29, 1999</i> |
|---|
| 315 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br> |
|---|
| 316 | Bug-fix: Double definition of \"Compressibility\" removed |
|---|
| 317 | and appropriate \"extends Heat\" clause introduced in |
|---|
| 318 | package SolidStatePhysics to incorporate ThermodynamicTemperature.</li> |
|---|
| 319 | <li><i>April 8, 1998</i> |
|---|
| 320 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a> |
|---|
| 321 | and Astrid Jaschinski:<br> |
|---|
| 322 | Complete ISO 31 chapters realized.</li> |
|---|
| 323 | <li><i>Nov. 15, 1997</i> |
|---|
| 324 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a> |
|---|
| 325 | and <a href=\"http://www.control.lth.se/~hubertus/\">Hubertus Tummescheit</a>:<br> |
|---|
| 326 | Some chapters realized.</li> |
|---|
| 327 | </ul> |
|---|
| 328 | </html>"), |
|---|
| 329 | Diagram( |
|---|
| 330 | Rectangle(extent=[169, 86; 349, 236], style(fillColor=30, fillPattern=1)), |
|---|
| 331 | Polygon(points=[169, 236; 189, 256; 369, 256; 349, 236; 169, 236], style( |
|---|
| 332 | fillColor=30, fillPattern=1)), |
|---|
| 333 | Polygon(points=[369, 256; 369, 106; 349, 86; 349, 236; 369, 256], style( |
|---|
| 334 | fillColor=30, fillPattern=1)), |
|---|
| 335 | Text( |
|---|
| 336 | extent=[179, 226; 339, 196], |
|---|
| 337 | string="Library", |
|---|
| 338 | style( |
|---|
| 339 | color=9, |
|---|
| 340 | fillColor=0, |
|---|
| 341 | fillPattern=1)), |
|---|
| 342 | Text( |
|---|
| 343 | extent=[206, 173; 314, 119], |
|---|
| 344 | string="[kg.m2]", |
|---|
| 345 | style(color=0)), |
|---|
| 346 | Text( |
|---|
| 347 | extent=[163, 320; 406, 264], |
|---|
| 348 | string="Modelica.SIunits", |
|---|
| 349 | style(color=1)))); |
|---|
| 350 | |
|---|
| 351 | package Conversions |
|---|
| 352 | "Conversion functions to/from non SI units and type definitions of non SI units" |
|---|
| 353 | |
|---|
| 354 | extends Modelica.Icons.Library2; |
|---|
| 355 | |
|---|
| 356 | annotation(preferedView="info", Icon( |
|---|
| 357 | Text( |
|---|
| 358 | extent=[-33, -7; -92, -67], |
|---|
| 359 | string="°C", |
|---|
| 360 | style(color=0, thickness=4)), |
|---|
| 361 | Text( |
|---|
| 362 | extent=[82, -7; 22, -67], |
|---|
| 363 | string="K", |
|---|
| 364 | style(color=0)), |
|---|
| 365 | Line(points=[-26, -36; 6, -36], style(color=0)), |
|---|
| 366 | Polygon(points=[6, -28; 6, -45; 26, -37; 6, -28], style(pattern=0, |
|---|
| 367 | fillColor=0))), Documentation(info="<HTML> |
|---|
| 368 | <p>This package provides conversion functions from the non SI Units |
|---|
| 369 | defined in package Modelica.SIunits.Conversions.NonSIunits to the |
|---|
| 370 | corresponding SI Units defined in package Modelica.SIunits and vice |
|---|
| 371 | versa. It is recommended to use these functions in the following |
|---|
| 372 | way (note, that all functions have one Real input and one Real output |
|---|
| 373 | argument):</p> |
|---|
| 374 | <pre> |
|---|
| 375 | <b>import</b> SI = Modelica.SIunits; |
|---|
| 376 | <b>import</b> Modelica.SIunits.Conversions.*; |
|---|
| 377 | ... |
|---|
| 378 | <b>parameter</b> SI.Temperature T = from_degC(25); // convert 25 degree Celsius to Kelvin |
|---|
| 379 | <b>parameter</b> SI.Angle phi = from_deg(180); // convert 180 degree to radian |
|---|
| 380 | <b>parameter</b> SI.AngularVelocity w = from_rpm(3600); // convert 3600 revolutions per minutes |
|---|
| 381 | // to radian per seconds |
|---|
| 382 | </pre> |
|---|
| 383 | |
|---|
| 384 | </HTML> |
|---|
| 385 | ")); |
|---|
| 386 | |
|---|
| 387 | package NonSIunits "Type definitions of non SI units" |
|---|
| 388 | |
|---|
| 389 | extends Modelica.Icons.Library2; |
|---|
| 390 | |
|---|
| 391 | type Temperature_degC = Real (final quantity="ThermodynamicTemperature", |
|---|
| 392 | final unit="degC"); |
|---|
| 393 | type Temperature_degF = Real (final quantity="ThermodynamicTemperature", |
|---|
| 394 | final unit="degF"); |
|---|
| 395 | type Temperature_degRk = Real (final quantity="ThermodynamicTemperature", |
|---|
| 396 | final unit="degRk"); |
|---|
| 397 | type Angle_deg = Real (final quantity="Angle", final unit="deg"); |
|---|
| 398 | type AngularVelocity_rpm = Real (final quantity="AngularVelocity", final unit |
|---|
| 399 | = "rev/min"); |
|---|
| 400 | type Velocity_kmh = Real (final quantity="Velocity", final unit="km/h"); |
|---|
| 401 | type Time_day = Real (final quantity="Time", final unit="d"); |
|---|
| 402 | type Time_hour = Real (final quantity="Time", final unit="h"); |
|---|
| 403 | type Time_minute = Real (final quantity="Time", final unit="min"); |
|---|
| 404 | type Volume_litre = Real (final quantity="Volume", final unit="l"); |
|---|
| 405 | type Energy_kWh = Real (final quantity="Energy", final unit="kW.h"); |
|---|
| 406 | type Pressure_bar = Real (final quantity="Pressure", final unit="bar"); |
|---|
| 407 | type MassFlowRate_gps = Real (final quantity="MassFlowRate", final unit= |
|---|
| 408 | "g/s"); |
|---|
| 409 | |
|---|
| 410 | annotation(preferedView="info", Documentation(info="<HTML> |
|---|
| 411 | <p> |
|---|
| 412 | This package provides predefined types, such as <b>Angle_deg</b> (angle in |
|---|
| 413 | degree), <b>AngularVelocity_rpm</b> (angular velocity in revolutions per |
|---|
| 414 | minute) or <b>Temperature_degF</b> (temperature in degree Fahrenheit), |
|---|
| 415 | which are in common use but are not part of the international standard on |
|---|
| 416 | units according to ISO 31-1992 \"General principles concerning quantities, |
|---|
| 417 | units and symbols\" and ISO 1000-1992 \"SI units and recommendations for |
|---|
| 418 | the use of their multiples and of certain other units\".</p> |
|---|
| 419 | <p>If possible, the types in this package should not be used. Use instead |
|---|
| 420 | types of package Modelica.SIunits. For more information on units, see also |
|---|
| 421 | the book of Francois Cardarelli <b>Scientific Unit Conversion - A |
|---|
| 422 | Practical Guide to Metrication</b> (Springer 1997).</p> |
|---|
| 423 | <p>Some units, such as <b>Temperature_degC/Temp_C</b> are both defined in |
|---|
| 424 | Modelica.SIunits and in Modelica.Conversions.NonSIunits. The reason is that these |
|---|
| 425 | definitions have been placed erroneously in Modelica.SIunits although they |
|---|
| 426 | are not SIunits. For backward compatibility, these type definitions are |
|---|
| 427 | still kept in Modelica.SIunits.</p> |
|---|
| 428 | </HTML> |
|---|
| 429 | "), Icon(Text( |
|---|
| 430 | extent=[-66, -13; 52, -67], |
|---|
| 431 | string="[rev/min]", |
|---|
| 432 | style(color=0)))); |
|---|
| 433 | end NonSIunits; |
|---|
| 434 | |
|---|
| 435 | function to_degC "Convert from Kelvin to °Celsius" |
|---|
| 436 | extends ConversionIcon; |
|---|
| 437 | input Temperature Kelvin "Kelvin value"; |
|---|
| 438 | output NonSIunits.Temperature_degC Celsius "Celsius value"; |
|---|
| 439 | annotation (Icon(Text( |
|---|
| 440 | extent=[-20, 100; -100, 20], |
|---|
| 441 | style(color=0), |
|---|
| 442 | string="K"), Text( |
|---|
| 443 | extent=[100, -20; 20, -100], |
|---|
| 444 | style(color=0), |
|---|
| 445 | string="°C"))); |
|---|
| 446 | algorithm |
|---|
| 447 | Celsius := Kelvin + Modelica.Constants.T_zero; |
|---|
| 448 | end to_degC; |
|---|
| 449 | |
|---|
| 450 | function from_degC "Convert from °Celsius to Kelvin" |
|---|
| 451 | extends ConversionIcon; |
|---|
| 452 | input NonSIunits.Temperature_degC Celsius "Celsius value"; |
|---|
| 453 | output Temperature Kelvin "Kelvin value"; |
|---|
| 454 | annotation (Icon(Text( |
|---|
| 455 | extent=[-20, 100; -100, 20], |
|---|
| 456 | style(color=0), |
|---|
| 457 | string="°C"), Text( |
|---|
| 458 | extent=[100, -20; 20, -100], |
|---|
| 459 | style(color=0), |
|---|
| 460 | string="K"))); |
|---|
| 461 | algorithm |
|---|
| 462 | Kelvin := Celsius - Modelica.Constants.T_zero; |
|---|
| 463 | end from_degC; |
|---|
| 464 | |
|---|
| 465 | function to_degF "Convert from Kelvin to °Fahrenheit" |
|---|
| 466 | extends ConversionIcon; |
|---|
| 467 | input Temperature Kelvin "Kelvin value"; |
|---|
| 468 | output NonSIunits.Temperature_degF Fahrenheit "Fahrenheit value"; |
|---|
| 469 | annotation (Icon(Text( |
|---|
| 470 | extent=[-20, 100; -100, 20], |
|---|
| 471 | style(color=0), |
|---|
| 472 | string="K"), Text( |
|---|
| 473 | extent=[100, -20; 20, -100], |
|---|
| 474 | style(color=0), |
|---|
| 475 | string="°F"))); |
|---|
| 476 | algorithm |
|---|
| 477 | Fahrenheit := (Kelvin + Modelica.Constants.T_zero)*(9/5) + 32; |
|---|
| 478 | end to_degF; |
|---|
| 479 | |
|---|
| 480 | function from_degF "Convert from °Fahrenheit to Kelvin" |
|---|
| 481 | extends ConversionIcon; |
|---|
| 482 | input NonSIunits.Temperature_degF Fahrenheit "Fahrenheit value"; |
|---|
| 483 | output Temperature Kelvin "Kelvin value"; |
|---|
| 484 | annotation (Icon(Text( |
|---|
| 485 | extent=[-20, 100; -100, 20], |
|---|
| 486 | style(color=0), |
|---|
| 487 | string="°F"), Text( |
|---|
| 488 | extent=[100, -20; 20, -100], |
|---|
| 489 | style(color=0), |
|---|
| 490 | string="K"))); |
|---|
| 491 | algorithm |
|---|
| 492 | Kelvin := (Fahrenheit - 32)*(5/9) - Modelica.Constants.T_zero; |
|---|
| 493 | end from_degF; |
|---|
| 494 | |
|---|
| 495 | function to_degRk "Convert from Kelvin to °Rankine" |
|---|
| 496 | extends ConversionIcon; |
|---|
| 497 | input Temperature Kelvin "Kelvin value"; |
|---|
| 498 | output NonSIunits.Temperature_degRk Rankine "Rankine value"; |
|---|
| 499 | annotation (Icon(Text( |
|---|
| 500 | extent=[-20, 100; -100, 20], |
|---|
| 501 | style(color=0), |
|---|
| 502 | string="K"), Text( |
|---|
| 503 | extent=[100, -20; 20, -100], |
|---|
| 504 | style(color=0), |
|---|
| 505 | string="°Rk"))); |
|---|
| 506 | algorithm |
|---|
| 507 | Rankine := (9/5)*Kelvin; |
|---|
| 508 | end to_degRk; |
|---|
| 509 | |
|---|
| 510 | function from_degRk "Convert from °Rankine to Kelvin" |
|---|
| 511 | extends ConversionIcon; |
|---|
| 512 | input NonSIunits.Temperature_degRk Rankine "Rankine value"; |
|---|
| 513 | output Temperature Kelvin "Kelvin value"; |
|---|
| 514 | annotation (Icon(Text( |
|---|
| 515 | extent=[-20, 100; -100, 20], |
|---|
| 516 | style(color=0), |
|---|
| 517 | string="°Rk"), Text( |
|---|
| 518 | extent=[100, -20; 20, -100], |
|---|
| 519 | style(color=0), |
|---|
| 520 | string="K"))); |
|---|
| 521 | algorithm |
|---|
| 522 | Kelvin := (5/9)*Rankine; |
|---|
| 523 | end from_degRk; |
|---|
| 524 | |
|---|
| 525 | function to_deg "Convert from radian to degree" |
|---|
| 526 | extends ConversionIcon; |
|---|
| 527 | input Angle radian "radian value"; |
|---|
| 528 | output NonSIunits.Angle_deg degree "degree value"; |
|---|
| 529 | annotation (Icon(Text( |
|---|
| 530 | extent=[-20, 100; -100, 20], |
|---|
| 531 | style(color=0), |
|---|
| 532 | string="rad"), Text( |
|---|
| 533 | extent=[100, -20; 20, -100], |
|---|
| 534 | style(color=0), |
|---|
| 535 | string="deg"))); |
|---|
| 536 | algorithm |
|---|
| 537 | degree := (180.0/Modelica.Constants.pi)*radian; |
|---|
| 538 | end to_deg; |
|---|
| 539 | |
|---|
| 540 | function from_deg "Convert from degree to radian" |
|---|
| 541 | extends ConversionIcon; |
|---|
| 542 | input NonSIunits.Angle_deg degree "degree value"; |
|---|
| 543 | output Angle radian "radian value"; |
|---|
| 544 | annotation (Icon(Text( |
|---|
| 545 | extent=[-20, 100; -100, 20], |
|---|
| 546 | style(color=0), |
|---|
| 547 | string="deg"), Text( |
|---|
| 548 | extent=[100, -20; 20, -100], |
|---|
| 549 | style(color=0), |
|---|
| 550 | string="rad"))); |
|---|
| 551 | algorithm |
|---|
| 552 | radian := (Modelica.Constants.pi/180.0)*degree; |
|---|
| 553 | end from_deg; |
|---|
| 554 | |
|---|
| 555 | function to_rpm "Convert from radian per second to revolutions per minute" |
|---|
| 556 | extends ConversionIcon; |
|---|
| 557 | input AngularVelocity rs "radian per second value"; |
|---|
| 558 | output NonSIunits.AngularVelocity_rpm rpm "revolutions per minute value"; |
|---|
| 559 | annotation (Icon(Text( |
|---|
| 560 | extent=[-20, 100; -100, 20], |
|---|
| 561 | style(color=0), |
|---|
| 562 | string="rad/s"), Text( |
|---|
| 563 | extent=[100, -20; 20, -100], |
|---|
| 564 | style(color=0), |
|---|
| 565 | string="rev/min"))); |
|---|
| 566 | algorithm |
|---|
| 567 | rpm := (30/Modelica.Constants.pi)*rs; |
|---|
| 568 | end to_rpm; |
|---|
| 569 | |
|---|
| 570 | function from_rpm |
|---|
| 571 | "Convert from revolutions per minute to radian per second" |
|---|
| 572 | extends ConversionIcon; |
|---|
| 573 | input NonSIunits.AngularVelocity_rpm rpm "revolutions per minute value"; |
|---|
| 574 | output AngularVelocity rs "radian per second value"; |
|---|
| 575 | annotation (Icon(Text( |
|---|
| 576 | extent=[-20, 100; -100, 20], |
|---|
| 577 | style(color=0), |
|---|
| 578 | string="rev/min"), Text( |
|---|
| 579 | extent=[100, -20; 20, -100], |
|---|
| 580 | style(color=0), |
|---|
| 581 | string="rad/s"))); |
|---|
| 582 | algorithm |
|---|
| 583 | rs := (Modelica.Constants.pi/30)*rpm; |
|---|
| 584 | end from_rpm; |
|---|
| 585 | |
|---|
| 586 | function to_kmh "Convert from metre per second to kilometre per hour" |
|---|
| 587 | extends ConversionIcon; |
|---|
| 588 | input Velocity ms "metre per second value"; |
|---|
| 589 | output NonSIunits.Velocity_kmh kmh "kilometre per hour value"; |
|---|
| 590 | annotation (Icon(Text( |
|---|
| 591 | extent=[-20, 100; -100, 20], |
|---|
| 592 | style(color=0), |
|---|
| 593 | string="m/s"), Text( |
|---|
| 594 | extent=[100, -20; 20, -100], |
|---|
| 595 | style(color=0), |
|---|
| 596 | string="km/h"))); |
|---|
| 597 | algorithm |
|---|
| 598 | kmh := 3.6*ms; |
|---|
| 599 | end to_kmh; |
|---|
| 600 | |
|---|
| 601 | function from_kmh "Convert from kilometre per hour to metre per second" |
|---|
| 602 | extends ConversionIcon; |
|---|
| 603 | input NonSIunits.Velocity_kmh kmh "kilometre per hour value"; |
|---|
| 604 | output Velocity ms "metre per second value"; |
|---|
| 605 | annotation (Icon(Text( |
|---|
| 606 | extent=[-20, 100; -100, 20], |
|---|
| 607 | style(color=0), |
|---|
| 608 | string="km/h"), Text( |
|---|
| 609 | extent=[100, -20; 20, -100], |
|---|
| 610 | style(color=0), |
|---|
| 611 | string="m/s"))); |
|---|
| 612 | algorithm |
|---|
| 613 | ms := kmh/3.6; |
|---|
| 614 | end from_kmh; |
|---|
| 615 | |
|---|
| 616 | function to_day "Convert from second to day" |
|---|
| 617 | extends ConversionIcon; |
|---|
| 618 | input Time s "second value"; |
|---|
| 619 | output NonSIunits.Time_day day "day value"; |
|---|
| 620 | annotation (Icon(Text( |
|---|
| 621 | extent=[-20, 100; -100, 20], |
|---|
| 622 | style(color=0), |
|---|
| 623 | string="s"), Text( |
|---|
| 624 | extent=[100, -20; 20, -100], |
|---|
| 625 | style(color=0), |
|---|
| 626 | string="day"))); |
|---|
| 627 | algorithm |
|---|
| 628 | day := s/86400; |
|---|
| 629 | end to_day; |
|---|
| 630 | |
|---|
| 631 | function from_day "Convert from day to second" |
|---|
| 632 | extends ConversionIcon; |
|---|
| 633 | input NonSIunits.Time_day day "day value"; |
|---|
| 634 | output Time s "second value"; |
|---|
| 635 | annotation (Icon(Text( |
|---|
| 636 | extent=[-20, 100; -100, 20], |
|---|
| 637 | style(color=0), |
|---|
| 638 | string="day"), Text( |
|---|
| 639 | extent=[100, -20; 20, -100], |
|---|
| 640 | style(color=0), |
|---|
| 641 | string="s"))); |
|---|
| 642 | algorithm |
|---|
| 643 | s := 86400*day; |
|---|
| 644 | end from_day; |
|---|
| 645 | |
|---|
| 646 | function to_hour "Convert from second to hour" |
|---|
| 647 | extends ConversionIcon; |
|---|
| 648 | input Time s "second value"; |
|---|
| 649 | output NonSIunits.Time_hour hour "hour value"; |
|---|
| 650 | annotation (Icon(Text( |
|---|
| 651 | extent=[-20, 100; -100, 20], |
|---|
| 652 | style(color=0), |
|---|
| 653 | string="s"), Text( |
|---|
| 654 | extent=[100, -20; 20, -100], |
|---|
| 655 | style(color=0), |
|---|
| 656 | string="hour"))); |
|---|
| 657 | algorithm |
|---|
| 658 | hour := s/3600; |
|---|
| 659 | end to_hour; |
|---|
| 660 | |
|---|
| 661 | function from_hour "Convert from hour to second" |
|---|
| 662 | extends ConversionIcon; |
|---|
| 663 | input NonSIunits.Time_hour hour "hour value"; |
|---|
| 664 | output Time s "second value"; |
|---|
| 665 | annotation (Icon(Text( |
|---|
| 666 | extent=[-20, 100; -100, 20], |
|---|
| 667 | style(color=0), |
|---|
| 668 | string="hour"), Text( |
|---|
| 669 | extent=[100, -20; 20, -100], |
|---|
| 670 | style(color=0), |
|---|
| 671 | string="s"))); |
|---|
| 672 | algorithm |
|---|
| 673 | s := 3600*hour; |
|---|
| 674 | end from_hour; |
|---|
| 675 | |
|---|
| 676 | function to_minute "Convert from second to minute" |
|---|
| 677 | extends ConversionIcon; |
|---|
| 678 | input Time s "second value"; |
|---|
| 679 | output NonSIunits.Time_minute minute "minute value"; |
|---|
| 680 | annotation (Icon(Text( |
|---|
| 681 | extent=[-20, 100; -100, 20], |
|---|
| 682 | style(color=0), |
|---|
| 683 | string="s"), Text( |
|---|
| 684 | extent=[100, -20; 20, -100], |
|---|
| 685 | style(color=0), |
|---|
| 686 | string="minute"))); |
|---|
| 687 | algorithm |
|---|
| 688 | minute := s/60; |
|---|
| 689 | end to_minute; |
|---|
| 690 | |
|---|
| 691 | function from_minute "Convert from minute to second" |
|---|
| 692 | extends ConversionIcon; |
|---|
| 693 | input NonSIunits.Time_minute minute "minute value"; |
|---|
| 694 | output Time s "second value"; |
|---|
| 695 | annotation (Icon(Text( |
|---|
| 696 | extent=[-20, 100; -100, 20], |
|---|
| 697 | style(color=0), |
|---|
| 698 | string="minute"), Text( |
|---|
| 699 | extent=[100, -20; 20, -100], |
|---|
| 700 | style(color=0), |
|---|
| 701 | string="s"))); |
|---|
| 702 | algorithm |
|---|
| 703 | s := 60*minute; |
|---|
| 704 | end from_minute; |
|---|
| 705 | |
|---|
| 706 | function to_litre "Convert from cubic metre to litre" |
|---|
| 707 | extends ConversionIcon; |
|---|
| 708 | input Volume m3 "cubic metre value"; |
|---|
| 709 | output NonSIunits.Volume_litre litre "litre value"; |
|---|
| 710 | annotation (Icon(Text( |
|---|
| 711 | extent=[-20, 100 |
|---|