QCalc is a free, open-source Modelica library to represent quantities using various units, including but not limited to SI. The approach is based on quantity calculus (hence the name "QCalc").
QCalc can be used like this:
import Q = QCalc.Quantities; import U = QCalc.Units; Q.Pressure p = U.atm + 50*U.Pa;
Nonscalar units such as degree Celsius and
decibel are also
supported. The *
and /
operators are
overloaded to call the unit's transformation (number ↦
quantity) and its inverse, respectively. For example, this
will give a value of x = 100:
Real x = (0*U.degC + 100*U.K)/U.degC;
and this will too:
Real x = (10/U.dB + 10/U.dB)*U.dB;
since we have multiplied the numbers by adding their logarithms.
The quantities are not directly compatible with the Modelica Standard Library (MSL) since MSL expresses quantities in SI units. To convert between QCalc and MSL, create an adapter with equations like this:
p = p_SI*U.Pa;
where p
is pressure as a quantity (in QCalc),
p_SI
is pressure in pascal (in MSL),
and U.Pa
is the pascal from
QCalc.Units.
Please see the getting started page for more information. If you wish to use the same approach with Modelica results in Python, please see ModelicaRes and natu.
Licensed by the Hawaii Natural Energy Institute under the
Modelica License 2
Copyright © 2009–2014, Hawaii
Natural Energy Institute and Georgia Tech Research
Corporation.
This Modelica package is free software and the use is completely at your own risk; it can be redistributed and/or modified under the terms of the Modelica License 2. For license conditions (including the disclaimer of warranty) see QCalc.UsersGuide.License or visit http://www.modelica.org/licenses/ModelicaLicense2.
Name | Description |
---|---|
User's Guide | |
Input/output blocks to convert units | |
Constants and units of physical measure | |
Types to represent physical values | |
Library of mathematical functions (e.g., sin, cos), where angle is a quantity | |
Package of icons |