UdK-VPT / BuildingSystems

Modelica BuildingSystems library
http://modelica-buildingsystems.de/
BSD 3-Clause "New" or "Revised" License
68 stars 33 forks source link

Replacing Reals with Units #7

Open jmoeckel opened 8 years ago

jmoeckel commented 8 years ago

This is a follow-up issue to #1.

There are several variables declared as Real and have a unit. In many cases these are derived physical quantities which only appears once or twice.

In order to have consistent code: Should we change the style-guide in such way, that a Real variable must not have a unit property. Instead, each time a unit is set, a new type must be declared or an already defined type must be used respectively.


Would concern following 45 files:


thorade commented 7 years ago

Technologies.Photovoltaics.BaseClasses.ElectricalModels.ElectricalModelTwoDiodesGeneral had units but we removed them, because parameter Real cs2 "2nd coefficient ISat2"; had the fractional unit cs2(final unit = "A.K-5/2") and this is not allowed according to the spec, as discussed here: https://trac.modelica.org/Modelica/ticket/376

In order to add a unit, one could change the equation ISat2 = cs2 * sqrt(T * T * T * T * T) * Modelica.Math.exp(-(Eg * e)/(2.0 * k * T)); by moving the cs2 into the sqrt() part ISat2 = sqrt(cs2 * T * T * T * T * T) * Modelica.Math.exp(-(Eg * e)/(2.0 * k * T)); and then we can use the unit cs2(final unit = "A.K-5").

Also see: http://unitsofmeasure.org/trac/ticket/51

thorade commented 7 years ago

checkModel("BuildingSystems.HAM.HeatConduction.OneLayerHeatConduction3D"); returns a couple of warnings. For dimensionless variables like factors or coefficients, use unit="1" instead of unit="-".