I'm trying to get temperature differences quantities to report the correct result when displayed in non-absolute temperature scales. See the following example:
model tempDiffTest
Modelica.Blocks.Interfaces.RealOutput test1(quantity="ThermodynamicTemperature", unit="K") = 1 annotation(absoluteValue=false);
Real test2(quantity="ThermodynamicTemperature", unit="K") = 2 annotation(absoluteValue=false);
Modelica.SIunits.TemperatureDifference test3 = 3;
end tempDiffTest;
Note that
type TemperatureDifference = Real (
final quantity="ThermodynamicTemperature",
final unit="K") annotation(absoluteValue=false);
which is what drove the modifications I made to the test1 and test2 variables.
Now, the expectation is that when I display my results in degrees celsius they should be 1, 2, and 3 for test1, test2, and test3, respectively. The actual results are shown below from Dymola:
Therefore, only test3 was apparently successful (note that none of the results were successful in OpenModelica). Now, my question is how do I achieve what I'm after for test1 and test2?
Dymola does not support the usage of the absoluteValue
annotation in the declaration of test1
and test2
.
If you enable the annotation check in Dymola with
Advanced.EnableAnnotationCheck=true
Dymola reports during check
In class tempDiffTest component test1, the annotation 'absoluteValue' is unknown.
Looking at the Modelica spec, we note that it tells
A simple type or component of a simple type may have: annotation(absoluteValue=false);
In my opinion, this is a bit vague and your code should work (as test2
is a component of the predefined type Real
). But Dymola accepts the annotation only in class definitions.
So to solve your problem, you simply have to declare a connector and a type to be able to use this annotation.
package tempDiffTest
connector Test1 = Modelica.Blocks.Interfaces.RealOutput (quantity="ThermodynamicTemperature", unit="K") annotation(absoluteValue=false);
type Test2 = Real(quantity="ThermodynamicTemperature", unit="K") annotation(absoluteValue=false);
model Example
Test1 test1 = 1;
Test2 test2 = 2;
Modelica.SIunits.TemperatureDifference test3 = 3;
end Example;
end tempDiffTest;