#5460 closed enhancement (invalid)
Enhance possibilities to re-simulate
Reported by: | massimo ceraolo | Owned by: | somebody |
---|---|---|---|
Priority: | normal | Milestone: | 1.14.0 |
Component: | *unknown* | Version: | |
Keywords: | Cc: |
Description (last modified by )
Consider the following model
model Test2 import Modelica.Constants.pi; parameter Real Ipm; parameter Real varPar (fixed=false); initial equation if Ipm>1.0 then varPar=pi/2; else varPar=asin(Ipm); end if; equation end Test2;
This model does not run under Dymola, which issues the following error message:
The following parameter doesn't have any value: Ipm
It is instead brilliantly run by OpenModelica, which uses the available start value (start=0.0) for Ipm, and also allows changing Ipm and re-simulating.
I.e., OpenModelica is able to run this model without taking Ipm as a structural parameter.
If I change the row
parameter Real Ipm;
into
parameter Real Ipm=1.5;
OM runs it, but Ipm has become unchangeable.
I think that it is very good that OM succeeds in keeping Ipm non-structural, even though it is used in an if-clause condition. But since it is able to do so, why not allowing this also when an explicit value is given to the parameter?
I made my tests with OMEdit connected to OMC v1.14.0-dev-234-g5ef43cce8 (64-bit), under Windows.
I marked this ticket as "enhancement", but probably it requires just a very small change in what OM already does.
Change History (3)
comment:1 by , 6 years ago
Description: | modified (diff) |
---|
comment:2 by , 6 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:3 by , 6 years ago
Ah, ok.
It is very useful to have the chance to change run time parameters in (if-statement) if-clause conditions, and in fact I was happy, although somewhat surprised, that OM allowed it.
In reality, using the OF, in the model I have this works well, so I thought this feature was somewhat already implemented, even beyond specifications. Unfortunately, it happens not to be this way with the NF.
I mean OF is able to consider this parameter as being non-structural, so the parameter expression Ipm>1.
According to the Modelica Specifcation 8.6,
In this case
Ipm
does not have a modifier for the start value, so the model is invalid, and it should also be rejected by OMC.In fact, this is the case if the new frontend is used.
If you add the (start = 0) modifier to Ipm and use the new front-end, Ipm is indeed evaluated, although the parameter still seems to be changeable while it's not, see #5454.
I can't see any easy way for the OMC front-end to avoid evaluating a parameter which is used in the selection of conditional equations. However, what you want to achieve can be obtained by using a conditional expression instead: