| 1 | within Modelica; |
|---|
| 2 | package Constants |
|---|
| 3 | "Library of mathematical constants and constants of nature (e.g., pi, eps, R, sigma)" |
|---|
| 4 | |
|---|
| 5 | import SI = Modelica.SIunits; |
|---|
| 6 | import NonSI = Modelica.SIunits.Conversions.NonSIunits; |
|---|
| 7 | |
|---|
| 8 | extends Modelica.Icons.Library2; |
|---|
| 9 | |
|---|
| 10 | // Mathematical constants |
|---|
| 11 | final constant Real e=Modelica.Math.exp(1.0); |
|---|
| 12 | final constant Real pi=2*Modelica.Math.asin(1.0); // 3.14159265358979; |
|---|
| 13 | final constant Real D2R=pi/180 "Degree to Radian"; |
|---|
| 14 | final constant Real R2D=180/pi "Radian to Degree"; |
|---|
| 15 | |
|---|
| 16 | // Machine dependent constants |
|---|
| 17 | // (the definition is a temporary fix since not adapted to the |
|---|
| 18 | // machine where the Modelica translator is running) |
|---|
| 19 | final constant Real eps=1.e-15 "Biggest number such that 1.0 + eps = 1.0"; |
|---|
| 20 | final constant Real small=1.e-60 |
|---|
| 21 | "Smallest number such that small and -small are representable on the machine"; |
|---|
| 22 | final constant Real inf=1.e+60 |
|---|
| 23 | "Biggest Real number such that inf and -inf are representable on the machine"; |
|---|
| 24 | final constant Integer Integer_inf=2147483647 |
|---|
| 25 | "Biggest Integer number such that Integer_inf and -Integer_inf are representable on the machine"; |
|---|
| 26 | |
|---|
| 27 | // Constants of nature |
|---|
| 28 | // (name, value, description from http://physics.nist.gov/cuu/Constants/) |
|---|
| 29 | final constant SI.Velocity c=299792458 "Speed of light in vacuum"; |
|---|
| 30 | final constant SI.Acceleration g_n=9.80665 |
|---|
| 31 | "Standard acceleration of gravity on earth"; |
|---|
| 32 | final constant Real G(final unit="m3/(kg.s2)") = 6.6742e-11 |
|---|
| 33 | "Newtonian constant of gravitation"; |
|---|
| 34 | final constant SI.FaradayConstant F = 9.64853399e4 "Faraday constant, C/mol"; |
|---|
| 35 | final constant Real h(final unit="J.s") = 6.6260693e-34 "Planck constant"; |
|---|
| 36 | final constant Real k(final unit="J/K") = 1.3806505e-23 "Boltzmann constant"; |
|---|
| 37 | final constant Real R(final unit="J/(mol.K)") = 8.314472 "Molar gas constant"; |
|---|
| 38 | final constant Real sigma(final unit="W/(m2.K4)") = 5.670400e-8 |
|---|
| 39 | "Stefan-Boltzmann constant"; |
|---|
| 40 | final constant Real N_A(final unit="1/mol") = 6.0221415e23 |
|---|
| 41 | "Avogadro constant"; |
|---|
| 42 | final constant Real mue_0(final unit="N/A2") = 4*pi*1.e-7 "Magnetic constant"; |
|---|
| 43 | final constant Real epsilon_0(final unit="F/m") = 1/(mue_0*c*c) |
|---|
| 44 | "Electric constant"; |
|---|
| 45 | final constant NonSI.Temperature_degC T_zero=-273.15 |
|---|
| 46 | "Absolute zero temperature"; |
|---|
| 47 | |
|---|
| 48 | annotation ( |
|---|
| 49 | Documentation(info="<html> |
|---|
| 50 | <p> |
|---|
| 51 | This package provides often needed constants from mathematics, machine |
|---|
| 52 | dependent constants and constants from nature. The latter constants |
|---|
| 53 | (name, value, description) are from the following source: |
|---|
| 54 | </p> |
|---|
| 55 | |
|---|
| 56 | <dl> |
|---|
| 57 | <dt>Peter J. Mohr and Barry N. Taylor (1999):</dt> |
|---|
| 58 | <dd><b>CODATA Recommended Values of the Fundamental Physical Constants: 1998</b>. |
|---|
| 59 | Journal of Physical and Chemical Reference Data, Vol. 28, No. 6, 1999 and |
|---|
| 60 | Reviews of Modern Physics, Vol. 72, No. 2, 2000. See also <a href= |
|---|
| 61 | \"http://physics.nist.gov/cuu/Constants/\">http://physics.nist.gov/cuu/Constants/</a></dd> |
|---|
| 62 | </dl> |
|---|
| 63 | |
|---|
| 64 | <p>CODATA is the Committee on Data for Science and Technology.</p> |
|---|
| 65 | |
|---|
| 66 | <dl> |
|---|
| 67 | <dt><b>Main Author:</b></dt> |
|---|
| 68 | <dd><a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a><br> |
|---|
| 69 | Deutsches Zentrum für Luft und Raumfahrt e. V. (DLR)<br> |
|---|
| 70 | Oberpfaffenhofen<br> |
|---|
| 71 | Postfach 11 16<br> |
|---|
| 72 | D-82230 Weßling<br> |
|---|
| 73 | email: <a href=\"mailto:Martin.Otter@dlr.de\">Martin.Otter@dlr.de</a></dd> |
|---|
| 74 | </dl> |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | <p> |
|---|
| 78 | Copyright © 1998-2008, Modelica Association and DLR. |
|---|
| 79 | </p> |
|---|
| 80 | <p> |
|---|
| 81 | <i>This Modelica package is <b>free</b> software; it can be redistributed and/or modified |
|---|
| 82 | under the terms of the <b>Modelica license</b>, see the license conditions |
|---|
| 83 | and the accompanying <b>disclaimer</b> |
|---|
| 84 | <a href=\"Modelica://Modelica.UsersGuide.ModelicaLicense\">here</a>.</i> |
|---|
| 85 | </p><br> |
|---|
| 86 | </html> |
|---|
| 87 | ", revisions="<html> |
|---|
| 88 | <ul> |
|---|
| 89 | <li><i>Nov 8, 2004</i> |
|---|
| 90 | by <a href=\"http://www.robotic.dlr.de/Christian.Schweiger/\">Christian Schweiger</a>:<br> |
|---|
| 91 | Constants updated according to 2002 CODATA values.</li> |
|---|
| 92 | <li><i>Dec 9, 1999</i> |
|---|
| 93 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br> |
|---|
| 94 | Constants updated according to 1998 CODATA values. Using names, values |
|---|
| 95 | and description text from this source. Included magnetic and |
|---|
| 96 | electric constant.</li> |
|---|
| 97 | <li><i>Sep 18, 1999</i> |
|---|
| 98 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br> |
|---|
| 99 | Constants eps, inf, small introduced.</li> |
|---|
| 100 | <li><i>Nov 15, 1997</i> |
|---|
| 101 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br> |
|---|
| 102 | Realized.</li> |
|---|
| 103 | </ul> |
|---|
| 104 | </html>") |
|---|
| 105 | , |
|---|
| 106 | Invisible=true, |
|---|
| 107 | Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100, |
|---|
| 108 | 100}}), graphics={ |
|---|
| 109 | Line( |
|---|
| 110 | points={{-34,-38},{12,-38}}, |
|---|
| 111 | color={0,0,0}, |
|---|
| 112 | thickness=0.5), |
|---|
| 113 | Line( |
|---|
| 114 | points={{-20,-38},{-24,-48},{-28,-56},{-34,-64}}, |
|---|
| 115 | color={0,0,0}, |
|---|
| 116 | thickness=0.5), |
|---|
| 117 | Line( |
|---|
| 118 | points={{-2,-38},{2,-46},{8,-56},{14,-64}}, |
|---|
| 119 | color={0,0,0}, |
|---|
| 120 | thickness=0.5)}), |
|---|
| 121 | Diagram(graphics={ |
|---|
| 122 | Rectangle( |
|---|
| 123 | extent={{200,162},{380,312}}, |
|---|
| 124 | fillColor={235,235,235}, |
|---|
| 125 | fillPattern=FillPattern.Solid, |
|---|
| 126 | lineColor={0,0,255}), |
|---|
| 127 | Polygon( |
|---|
| 128 | points={{200,312},{220,332},{400,332},{380,312},{200,312}}, |
|---|
| 129 | fillColor={235,235,235}, |
|---|
| 130 | fillPattern=FillPattern.Solid, |
|---|
| 131 | lineColor={0,0,255}), |
|---|
| 132 | Polygon( |
|---|
| 133 | points={{400,332},{400,182},{380,162},{380,312},{400,332}}, |
|---|
| 134 | fillColor={235,235,235}, |
|---|
| 135 | fillPattern=FillPattern.Solid, |
|---|
| 136 | lineColor={0,0,255}), |
|---|
| 137 | Text( |
|---|
| 138 | extent={{210,302},{370,272}}, |
|---|
| 139 | lineColor={160,160,164}, |
|---|
| 140 | fillColor={0,0,0}, |
|---|
| 141 | fillPattern=FillPattern.Solid, |
|---|
| 142 | textString="Library"), |
|---|
| 143 | Line( |
|---|
| 144 | points={{266,224},{312,224}}, |
|---|
| 145 | color={0,0,0}, |
|---|
| 146 | thickness=1), |
|---|
| 147 | Line( |
|---|
| 148 | points={{280,224},{276,214},{272,206},{266,198}}, |
|---|
| 149 | color={0,0,0}, |
|---|
| 150 | thickness=1), |
|---|
| 151 | Line( |
|---|
| 152 | points={{298,224},{302,216},{308,206},{314,198}}, |
|---|
| 153 | color={0,0,0}, |
|---|
| 154 | thickness=1), |
|---|
| 155 | Text( |
|---|
| 156 | extent={{152,412},{458,334}}, |
|---|
| 157 | lineColor={255,0,0}, |
|---|
| 158 | textString="Modelica.Constants")})); |
|---|
| 159 | end Constants; |
|---|