-
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
Significant issue in MLS interpretation between SystemModeler, Dymola and Modelon Impact #2835
Comments
Note that the units also cause problems in Dymola and is not according to https://specification.modelica.org/master/unit-expressions.html
Additionally BusinessSimulation.Flows.Unidirectional.Transition seems to breaks the rules regarding use of conditional components (outside of connections cp. https://specification.modelica.org/master/class-predefined-types-and-declarations.html#conditional-component-declaration ), and the ones for non-real equations. And the restriction regarding Reals declared as discrete isn't just Dymola but specified in https://specification.modelica.org/master/class-predefined-types-and-declarations.html#component-variability-prefixes-discrete-parameter-constant (I thought there was an old issue for this, but I didn't find it.) |
I tried running 10 examples that were included in the library (10 models that had the experiment annotation) in MapleSim. Two failed with lookup issues:
The declaration is:
As the error states In other example,
all use at some point
So they all fail in MapleSim. |
All of the examples are rejected by OpenModelica too. Most of them fail because they use a component of type |
I agree that this is a problem, and has been for a long time. We (for System Modeler) will of course go through the cases mentioned here, and we aim to get better at rejecting all the things that are not valid according to the specification. A vital part of rejecting invalid things, is a good suite of test models, and we have found the ModelicaCompliance library to be very helpful in this regard. |
Thanks all for looking into this quickly and thoroughly. I had noted some of the issues Hans noted as well but didn't report. It would be nice to get the library into a specification-compliant form. I found the library interesting since it is from a new domain, but don't currently have the bandwidth to help with that. |
Dear all, I must "out" myself as the unfortunate author of that ambitious, unphysical library (the first I have ever written for that). Like Icaraus in ancient times I must realize: He (or she) who has high-flying ambitions, can fail most spectactularly. Given the great clarity of the Modelica specification—how could this fail on such a grand scale? :-) Unfortunately, coming from a different domain makes the use of Modelica not an easy one and naively I had expected that using 300+ unit tests written in Mathematica using the Wolfram Language with its Allow me to quickly comment on some issues raised here simply as being a programmer very interested in complying to a precisely and unambiguously specified modeling language to the best of his abilities:
Thanks to you all for pointing out my follies. I will probably publish the library on my public GitHub account as well and hope that—as is common practice—errors (euphemistically called "bugs" these days) will be raised as issues there. |
Yes, of course every tool vendor needs to have a good business case, but I can guarantee that Wolfram does not want to make a business case of using Modelica in a way that is not compliant with the specification. One of the great user benefits of choosing a Modelica-based tool for his/her modeling work is the access to a free and tool-independent language specification. This, I assume is an important business case for any Modelica tool vendor in a world with many competing modeling technologies. |
Can someone help me out here (maybe point me to a separate issue or to clearly written sections in the specs)? In what is called
That code does not raise any issue, but effectively
That code begs two questions: a) is there a better way than this (rather bloated) example to do this and b) is there in fact no good reason to have UPDATE |
Yes, I also expected there to be an issue on the matter, but I couldn't find it either.
Only for the clarity it brings in form of a guarantee that the variable is discrete-time. The issue that also I couldn't find was asking why the |
Since the output has parameter variability, why not use the You can read more on this topic here: modelica/ModelicaStandardLibrary#3112 |
I think this is the start of the discussion @HansOlsson and I were looking for: #2521 (comment) I also found a fragment in the same spirit here: #2526 (comment) |
b. There's no good reason to have it be discrete. The benefit is that a block that adds, subtracts, multiplies etc two signals doesn't need to care whether the signals are continuous, discrete, or clocked; so we only need one for all of those cases. |
This would be better handled by allowing functions to be used as blocks: The fact that a function doesn't hold a state is both an important characteristic often emphasized in block-oriented control systems work, and would for Modelica be the important property that could allow our variability analysis do its job. |
[I have not read through the cited ticket, yet.]
To me that simply leaves |
So in my simple case none of the advantages given in 4.4.4 of the Specification v3.5—see below—does apply?
|
We should remove those statements. (Added: As many other problematic statements they are old. In this case they originate in Modelica Specification 1.1.) The first part is actually false, and should be removed. If the variable is discrete then index-reduction cannot assume that the derivative is zero as that breaks index-reduction. A variable (such as a parameter) with zero derivative the entire integration can be handled specially, but if the variable jumps differentiation just breaks down. The second part is sort of true (might actually implement it some day) - but you don't need to declare the variable as discrete to do that. A tool should be able to deduce that property directly. |
While we are checking compatibility across all relevant tools, I would like to point at something very basic: Design. Could maybe the other platforms report on how they are rendering Icons and Diagrams? In the following examples I have placed images taken from System Modeler on the left hand side and images taken from Open Modelica v1.16 on the right hand side. I find these differences striking—how can we come up with complicated language compatibility when drawing lines, points, and arrows are not even matching up? ;-) Class BrowserSourcesOrSinks PackageIconsDiagrams |
You are right, one needs to rely on tools doing some bookkeeping to be able to take advantage of the constrained variability of the block's output. Hence, if the output was set equal to discrete-time variable assigned in a when-clause, the source variable could be declared In your case, however, it looks as the variability you want to capture is parameter, and then you should be able to just mimic the way it's done in (I must admit that I don't quite understand the reasons behind not allowing variability prefixes on connector components as a way of expressing upper bounds on the variability of the variables of the connect set. To me, this would seem useful for blocks as well as functions. However, I can see that it would be a hassle to support all needed combinations in a library such as |
That is exactly the fix I have now applied. ;-) |
On short notice: I have just now released PS: I would still be interested to know, how the Icons and Diagrams turn out in other tools ... It's sad to see such divergence as between SystemModeler and OMEdit. |
I would also be interested to see how the icons and diagrams look in other tools. Differences like this are a problem when designing icons in MSL as well, and if we could find out if there are parts of the specification that need clarification, that would be great. |
Resolves parts of modelica#2835
Hans Olsson asked me to check in Dymola, and it is a mixed bag. Dymola can present icons in two sizes in the class browser. The bigger "icon view" which I think is closer to SystemModeler looks quite similar. For the "tree view" which has very small icons the results are not so good, indicating some problem with line width scaling. This is something we need to investigate on our side. I checked the other examples too with very similar results. |
* Clarify discrete and remove odd statement about Pantelides. Resolves parts of #2835 Co-authored-by: Henrik Tidefelt <[email protected]>
Seems that further tool investigation is needed. |
I think the bottom line is basically that SystemModeler gets it right. At least for these icons. |
I have now published the Business Simulation library (v1.0.1) in a public repository as announced: https://github.com/bslMS/BusinessSimulation Cheers, |
As far as I can tell, the examples are still not expected to work due to variability errors here: https://github.com/bslMS/BusinessSimulation/blob/19a34c8e80613ef814e6c24552061e327ce5e9c1/BusinessSimulation/Interfaces/PartialFlows/BidirectionalFlow.mo#L22 Hence, it might still be a little early to try this with tools that don't like non-discrete-time |
Sneakily someone (maybe @DagBruck ) corrected this for Dymola 2022x (or possibly earlier). |
Regarding 'year': one definition of year ('a' for annus) is the astronomical definition of 31,557,600 seconds (365.25 days - lead-seconds and the special leap-handling for some centuries not included). |
To me it seems that the remaining issues are issues in the models and tool-issues. |
Gents,
I saw a post about a BusinessSimulation library available for free in the SystemModeler Library store, and since I was interested in that, I checked the license, extracted the pure Modelica, and tried it. Neither in Dymola nor in Modelon Impact this was accepted as legal, the most common error message being about discrete variables not being assigned in when-clauses, but also others. I didn't get one Example I tried to run.
We have worked quite hard over years to get the specification into a state that we made good progress towards "write once, run everywhere" Modelica models. This was a disappointment. There are definitely issues where there are different opinions on what is legal semantics for discrete-time models. There are other, much smaller issues, and style issues about how to do libraries as well, but they don't matter as much.
For simplicity, I extracted the pure Modelica code that is inside a wrapper for SystemModeler and attached it here.
BusinessSimulation 1.0.0.zip
I'd like to get comments from others on the legality of this, maybe SimulationX or MapleSim want to try the models?
Thanks, Hubertus
The text was updated successfully, but these errors were encountered: