#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 in the model I have it works (using OF) like a charm.
I see that you don't see an easy way to evaluate a parameter which is used in the condition of an if statement, but this is what, at least in my example, OM's OF is able to do.
In this model I cannot use an initial equation with an if-expression since the condition I must test varies with time.
The rule you mention does not forbid doing what the OF already does, so I thought was an useful feature possibly coming (nearly) for free.
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: