-
Notifications
You must be signed in to change notification settings - Fork 168
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
Unit-checking using Gain and LimIntegrator-blocks #3878
Comments
I am rather in favour to fix the actual unit of the gain. For example, in Modelica.Electrical.Batteries.BaseClasses.BaseCellStack.limIntegrator it is See also: ModelicaStandardLibrary/Modelica/Electrical/Machines/Utilities/DQCurrentController.mo Line 65 in 3057a76
Unfortunately, it is called |
It was implicitly present in those block prior to #227.
At first I was also considering that for the specific cases, but then I realized that this is also a general issue where we need to give a guideline for users. That's when I realized that deducing the unit for k is just tedious work - you look at the formula for I'm not saying that giving the specific unit is wrong - just that it tedious and gains very little; but we can still state that it is an alternative. BTW: I think the reason you got k.unit="A-1" instead of "A-1.s-1" is that you missed that the integrator also integrates. |
I find this an interesting discussion about a largely unspecified topic. One question I find particularly interesting is whether a model with a unit error involving the inferred unit of a variable should be considered an invalid model. That is, it would be great if we could agree that the specification should define this as a model error:
To clarify, the alternative interpretation that I would like to be ruled out is that the original empty unit of |
Yes, that would be the intent - but we currently haven't even defined the rules to forbid the simpler
Note that MCP-0027, modelica/ModelicaSpecification#2127 has been stuck after starting on such simple cases, since instead of discussing small incremental changes we got side-tracked into redefining everything and trying to make it super-strict. |
I need some clarification here, please.
I have to admit I was not aware of the fact (so far) that using
I assume this is somewhere written in the specification (which I could not yet find) and consequently the different meaning and intention of When looking at the Modelica Language Specification 3.5 I found: So obviously, |
Because internally the Gain, Integrator and some other blocks have the modifier unit="1" due to #227, so adding unit="" for specific uses of them gets back to the original unit="", and the logical conclusion is that it should behave the same as the original (MCP-0009 might give another way of doing that). As noted above one alternative fix for this would be to revert #227 and don't set unit for those blocks - I could make such a PR if that is desired. (There's also the possibility of mixing; but that's probably too messy.) |
I would argue #227 should be rolled back. While, of course, there are situations where the units on a gain block or a gain term in an integrator block have units of "1", I don't think those situations should be assumed by default as I'm not even convinced they are the majority. Better to leave the units blank and then add when the unit="1" situation applies. From a pure downstream use case perspective, the workflow of adding units to gain blocks is much more natural than the workflow of removing units from gain blocks. I'm a bit of a purist, but this is my line of thinking. |
If you want unit="1" for a gain-block, add parameter with unit="1" as in the updated test-case. Closes modelica#3878
Reading the original #227 and this ticket here it occurs to me that #227 was basically a tool specific hack to silence Dymola at the time. So I'm in favour of reverting #227 again and this in the way as it is done in #3881 since it seems strange to first define |
Looking at the model I don't see how it is silencing. If I tried to restore the functionality and log units in Dymola getting: AsUnitless.u(unit= "A") So, as expected, setting unit="1" (and activating some flags) gives consistent units to more variables which seems desirable. I don't see any error messages being silenced.
I can still understand this. |
I see that the topic of unit deduction and the presence of
However, I see in MSL an issue of consistency. Consider as an example block This is not consistent. (BTW, I think that is is more common to have unitless So, if Dymola's present behaviour is compliant to MS, the situation is inconsistent and, I would say, displaced towards the wrong direction. But discussing whether For all this, I think that it would be very useful to drop
Naturally, if this proposal is considered in principle acceptable, the whole list of blocks should be verified and made consistent with it. |
See my last comment in #4439. I also think we should not have unit = "1" in Gain, and instead have it in Add. Units are complicated... |
Currently Dymola as default sort of ignores unit="1"; and thus the change in #227 is not yet active.
Trying to activate that check triggers warnings in several models, some can be traced to
Modelica.Electrical.Batteries.BaseClasses.BaseCellStack
( https://github.com/modelica/ModelicaStandardLibrary/blob/3057a7665290da6111c62c04ec40e29c9c8c069b/Modelica/Electrical/Batteries/BaseClasses/BaseCellStack.mo and similarly BaseCellStackWithSensors in the same package) whereand
cellData.Qnom.unit="A.s"
, andcellData.OCVmax.unit="V"
.I assume we want the improved unit-checking, and that in most cases
unit="1"
is correct, so we should change these uses - and the simplest correction in that case is to add a modifier withunit=""
and just let normal unit-deduction work out the result.That gives
k(unit="")=1/(Np*cellData.Qnom)
, and we can provide that as a recommendation for users.The other alternative is
k(unit="s-1.A-1")=1/(Np*cellData.Qnom)
, but that just puts the burden on the user of the library and doesn't add anything meaningful.I can provide a PR for it.
Also in Modelica.Electrical.Machines.Examples.DCMachines.DCPM_CurrentControlled
The text was updated successfully, but these errors were encountered: