-
Notifications
You must be signed in to change notification settings - Fork 41
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
Common unit inconsistency pattern #3416
Comments
For CompareTransformers it would be possible to have I assume the explanation is that some electrical engineers give inductance as resistance at nominal-frequency (or something like that). |
Right but the pattern is used in many places, let me know if you want me to try and compile an exhaustive list. |
If this is a common usage pattern, it at least should be considered if modelers would like to keep using it, even at the cost of getting less unit checking. Maybe one could have special rules for the units of literals in binding equations (for parameters, or in general). I realize that would mean less unit checking when literals occur in binding equations. Consider:
|
Calling @casella as I think he might want to opine here at some point. |
I think the root cause/issue is the assumption that all bare numbers in formulas should have unit="1". I just ran into a random example the other day where I had a length parameter and a mass parameter. In that particular situation, the mass was expected to scale roughly with the length, so for convenience I set the default parameter for the mass as follows:
Unfortunately, using the assumption that 20 and 1.5 have unit="1", this wouldn't pass unit checks. Now, to fix this, I could have been verbose and had written the following:
And sometimes, when there is some precise physical theory, I might want to be this verbose. However, when it's just a rough rule of thumb for the application at hand, I'd really prefer the first implementation. So, the issue is in the first implementation is that we have Some potential solutions:
I would strongly prefer something like (3) or even (2b) since the very situation where I want to do this, I specifically and intentionally do not want to have to be precise and specify the units for every value like in (1) or (2a). Anyways, that's my 2 cents here. Looking to see some resolution. |
We keep coming back to the need for something like this. I've mentioned it elsewhere, but I'll repeat myself here; I think it would be fairly straight-forward to support a very readable syntax like this:
(The syntax could be generalized once we have the general subcripting syntax from #3395, as in Edit: Considering how compactly the solution can be expressed in this way, I would say it qualifies as a solution for those asking for a quick way to jot down an expression that will pass unit checking. |
I think the use of a an annotation counteracts the purpose of catering for the quick'n dirty equations, as it probably wouldn't be very easy for tools to support adding such annotations when writing equations. (A component declaration annotation would be easier, but still unlikely to be within easy reach for quick'n dirty declaration equations.) On the other hand, I can't think of any simple solution to express that one wants to opt in for the wildcard effect. Although I'm generally not in favor of having an annotation for turning unit checking off locally, I'd just like to note that if we had such an annotation, it would make more sense to make use of it in this situation, than to introduce another annotation specifically for opting in for the wildcard effect. |
@henrikt-ma What about what I mentioned in 2b? In general, somebody could just drop a |
The problem I see with
|
I would find it more natural to let something like |
In my simple mass and length example, i might just drop in the real units as it's pretty obvious and lightweight, but for the example that started this discussion, that sounds a little annoying, I might just drop the |
By the way, regarding this concern: had the potential feature we are talking about been available, wouldn't you have done the following to resolve the issue with the |
To me it seems very important that there is a way to define a constant as an abstraction for a literal value or a subexpression without any declared units, and I really like the idea we've had that this is what I also think it would be very unfortunate if
That I see the two as different is also a reason for me to not introduce
I'm not looking for the answer to this particular question, but just want to point at the sort of complexity we would add to the design if introducing a new concept for wildcard units. |
Here are concrete examples that I believe should inform our unit specification effort. Here is a small model capturing the inconsistencies in Modelica.Electrical.Machines.Utilities.ParameterRecords.SM_ReluctanceRotorData:
The bindings of
Lmd
,Lmq
andLrsigmad
are found to be expressed in"1/Hz"
, which is obviously different from the expected unit.Similarly
Modelica.Electrical.Analog.Examples.CompareTransformers
has the following pattern:Here our unit inference finds a unit for
n
which is not"1"
.I suspect both cases come down to the ability to attach a unit to a literal value with a dedicated operator. But in any case our standardization effort should propose a nice solution to this pattern.
The text was updated successfully, but these errors were encountered: