OpenModelica / OpenModelica

OpenModelica is an open-source Modelica-based modeling and simulation environment intended for industrial and academic usage.
https://openmodelica.org
Other
816 stars 305 forks source link

Add non-standard flag to accept models without parameter binding equations nor explicit start attribute modifiers #12592

Open casella opened 3 months ago

casella commented 3 months ago

After #10386, some models of some libraries (e.g. ThermoFluidStream) are failing because there are parameters that lack a binding equation and an explicit start attribute.

This is potentially problematic when analyzing libraries that we want to get running in OMC. We should the add a provision to only give a warning if the appropriate --allowNonStandardModelica flag is set.

Specifically, we should add a --allowNonStandardModelica=implicitParameterStartAttribute flag that allows to compile models with parameters that have no binding and no explicitly set start attribute, of course with a warning. Basically, the same behaviour we had before #10386, but with an opt-in flag, as appropriate.

I think the easiest way to implement this feature is to do it in the front end: when instantiating parameters, if this flag is set, then add explicit start = <default value> to all parameters that have no binding equation.

@perost could you please take care of that?

We should also probably put this feature in the GUI, but I'm not sure what is the best way to do that. Let's do it first in the compiler.

Adding @olivleno to the loop.

perost commented 3 months ago

12595 implements the flag and the requested behaviour.

There's one minor issue, which is that it doesn't work for structural parameters (because the bindings are added to the flat model and not the instance tree which is used when evaluating component references). It should be possible to handle that too if needed, but we didn't handle it before #10386 anyway so I assume it won't be an issue for you.

casella commented 3 months ago

Well, one could assume that structural parameters should get a properly defined default binding 😅

olivleno commented 3 months ago

I assume it won't be an issue for you.

Well, the purpose is to allow translating non-standard models no matter when and how the compiler handles it.

I strongly vote for making this flag cover the entire translation process.

casella commented 3 months ago

If it is easy to do that, I'm all for it. If it isn't, I think we should focus our scarce resources at implementing the standard, rather than implementing non-standard features 😃. Or at least take care of non-standard features that if we have requests from users. At the moment, I'm not aware of any that involve structural parameters.