BuildingSystems icon indicating copy to clipboard operation
BuildingSystems copied to clipboard

Replacing Reals with Units

Open jmoeckel opened this issue 9 years ago • 2 comments

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:


  • [ ] Buildings\Airpathes\AirpathConstant.mo
  • [ ] Buildings\Airpathes\AirpathPrescribedPressure.mo
  • [ ] Buildings\Airvolumes\Airvolume3D.mo
  • [ ] Buildings\Airvolumes\AirvolumeCompressible0D.mo
  • [ ] Buildings\Ambient.mo
  • [ ] Buildings\BaseClasses\AirpathGeneral.mo
  • [ ] Buildings\BuildingTemplates\Building1Zone0DDistrict.mo
  • [ ] Buildings\Constructions\Windows\Window.mo
  • [ ] Buildings\Data\AirpathCharacteristics\AirpathCharacteristicWindow.mo
  • [ ] Fluid\Interfaces\TemperatureControlledHeatFlow.mo
  • [ ] Interfaces\AirchangeRateInput.mo
  • [ ] Interfaces\AirchangeRateOutput.mo
  • [ ] Interfaces\Angle_degInput.mo
  • [ ] Interfaces\Angle_degOutput.mo
  • [ ] Interfaces\HeatFlowRateInput.mo
  • [ ] Interfaces\HeatFlowRateOutput.mo
  • [ ] Interfaces\LengthInput.mo
  • [ ] Interfaces\LengthOutput.mo
  • [ ] Interfaces\MassFlowRateInput.mo
  • [ ] Interfaces\MassFlowRateOutput.mo
  • [ ] Interfaces\Moisture_absInput.mo
  • [ ] Interfaces\Moisture_absOutput.mo
  • [ ] Interfaces\PowerInput.mo
  • [ ] Interfaces\PowerOutput.mo
  • [ ] Interfaces\RadiantEnergyFluenceRateInput.mo
  • [ ] Interfaces\RadiantEnergyFluenceRateOutput.mo
  • [ ] Interfaces\Temp_KInput.mo
  • [ ] Interfaces\Temp_KOutput.mo
  • [ ] Interfaces\VelocityInput.mo
  • [ ] Interfaces\VelocityOutput.mo
  • [ ] Technologies\Photovoltaics\BaseClasses\ElectricalModels\ElectricalModelGeneral.mo
  • [ ] Technologies\Photovoltaics\BaseClasses\ElectricalModels\ElectricalModelOneDiode.mo
  • [ ] Technologies\Photovoltaics\BaseClasses\ElectricalModels\ElectricalModelOneDiodeGeneral.mo
  • [ ] Technologies\Photovoltaics\BaseClasses\ElectricalModels\ElectricalModelOneDiodeMPP.mo
  • [ ] Technologies\Photovoltaics\BaseClasses\ElectricalModels\ElectricalModelTwoDiodes.mo
  • [ ] Technologies\Photovoltaics\BaseClasses\ElectricalModels\ElectricalModelTwoDiodesMPP.mo
  • [ ] Technologies\Photovoltaics\BaseClasses\PVModuleGeneral.mo
  • [ ] Technologies\Photovoltaics\BaseClasses\ThermalModels\ThermalModelSimple.mo
  • [ ] Technologies\Photovoltaics\PVModules\PVModuleComplex.mo
  • [ ] Technologies\Photovoltaics\PVModules\PVModuleComplexMPP.mo
  • [ ] Technologies\Photovoltaics\PVModules\PVModuleSimple.mo
  • [ ] Technologies\Photovoltaics\PVModules\PVModuleSimpleMPP.mo
  • [ ] Technologies\SolarThermal\Data\Collectors\CollectorPartial.mo
  • [ ] Technologies\ThermalStorages\BaseClasses\StratificationModel\PartialInletStratification.mo
  • [ ] Technologies\ThermalStorages\FluidStorage.mo

jmoeckel avatar Nov 11 '15 12:11 jmoeckel

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 avatar Nov 17 '16 13:11 thorade

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

thorade avatar Dec 05 '16 10:12 thorade