-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Units for mathematical constants? #4046
Comments
I wouldn't worry about the ones with Regarding the others, what is the expected status of
Are tools expected to know that |
The original idea was that variables shall be in base-SI-units, so variables shall not have unit="deg". |
Right, but then someone came up with |
And, of course, there was originally a bug in using them. The better solution is to correct that at some point in the future; as indicated by #3158 |
@henrikt-ma For pi and other unit="1" items: if you think it's prudent to wait then that seems reasonable. I will just say I hope/expect I should be able to catch the following unit errors in the near future:
As is, at least in the Modelica tool I'm using today, neither of those unit issues would be caught. The first seems to largest offender in my mind because conceptually there is no good reason it's not caught. The proposed change would address that today without waiting for changes to spec and waiting for agreement on how to handle situations when Regarding the
|
I cannot imagine that we'd consider MCP-0027 resolved without being able to reject both of these with support in the specification. For example, this is how
|
Perhaps only to not introduce a backwards incompatible change in the MSL? Note that it could be tricky do introduce a library conversion annotation that would describe what to do as a replacement for referencing these constants, as it's currently not on the table to perform unit conversions using a Modelica expression. For example, we are currently not considering anything like |
Regarding the mention of #2127 above, the unit checking discussions are now going in the direction of having special semantics for constants, deprecating declaration without explicitly setting
as the only way of saying that
This would be totally in agreement in the original suggestions made in this issue. I have a hard time seeing that we would regret introducing these explicit units already today, even if the unit checking discussions in MCP-0027 are far from settled. |
For completeness and to support the unit checking work, we could also consider adding explicit |
We can also separate them into the ones with explicit Whether we should add One possibility is that we introduce a rule that an explicit unit is required, and in that case it sort of circumvents that check, another is that there are no special rules for constants (in which case it would be redundant; but sort of ok), and a third is that the special rule is that we for constants (or possibly all variables with a definition equation) the unit can only be derived from its definition equation (in which case it is redundant; but sort of ok). |
Sure, I'd welcome a PR on that to start with.
How would you fix the following if the unit can only be derived from the definition equation?
|
Good that we have agreement.
I meant that it can be given a unit or derived from the definition equation, but not inferred in other ways. |
That makes more sense. However, I would only want this when the definition equation comes with a concrete unit, so that |
I think we might revisit this for pi after looking at Modelica.Electrical.Analog.Examples - with examples such as CompareTransformers, SeriesResonance where inductance equations involve pi in a way that seems unit-odd (clearly there other unit issues with CompareTransformers). If user models has similar models this change may cause the impression that this is not a minor upgrade for users. I don't see a similar issue with the other constants. |
To clarify how significant: I enabled the proposed unit-checking in Dymola and tested the master-branch, and there were:
Clearly it is in one sense good to make the change, but I don't think we can focus that much on those issues. |
since it is causing too many regressions for a minor release. With proposed unit-checking in Dymola this reduces the warnings from 2301 to 1224 (Most - but not all are unit-related.) Obviously many of them could be corrected, but I don't see that we have the resources to focus on that for this minor release. The first models found were CompareTransformers, SeriesResonance in Modelica.Electrical.Analog.Examples.
...reading through some of the recent activity in the Modelica spec(modelica/ModelicaSpecification#3259 and modelica/ModelicaSpecification#2127 and others), it seems like it might be a natural step to specify the units for the various mathematical constants in Modelica.Constants.
I might propose the following, which seems a bit more correct:
Without this step, it seems to me like we are missing out on some unit checking opportunities since the units for pi (and others) can be inferred incorrectly.
Thoughts/comments?
The text was updated successfully, but these errors were encountered: