Opened 6 years ago
Last modified 3 years ago
#4994 assigned defect
Is startTime a built-in variable in OMC?
Reported by: | Francesco Casella | Owned by: | Adeel Asghar |
---|---|---|---|
Priority: | critical | Milestone: | |
Component: | OMEdit | Version: | |
Keywords: | Cc: | danieljose.penagos@…, Adrian Pop |
Description
Consider this test case
model Test parameter Real startTime = 1; end Test;
When simulating it with OMC, the value of startTime is computed to be the value of StartTime in the simulation setup window, completely disregarding the binding equation.
Since startTime is a perfectly legal Modelica parameter name, if you use it in a model some nasty surprises will ensue...
Change History (17)
comment:1 by , 6 years ago
Cc: | added |
---|
follow-up: 3 comment:2 by , 6 years ago
Cc: | added |
---|---|
Component: | OMEdit → Frontend |
Owner: | changed from | to
Status: | new → assigned |
comment:3 by , 6 years ago
Component: | Frontend → OMEdit |
---|
Replying to adeas31:
Note sure if this is a frontend or backend issue.
This script returns the correct value:
loadString(" model Test parameter Real startTime = 1; end Test; "); simulate(Test, startTime = 4, stopTime = 5); readSimulationResult("Test_res.mat", startTime);
So the issue seems to be either with OMEdit or the API commands OMEdit uses to simulate. So I'm kicking it back to OMEdit until someone can show that the issue lies elsewhere.
comment:4 by , 6 years ago
Owner: | changed from | to
---|
comment:5 by , 6 years ago
Ah okay I know why its happening. In OMEdit we call the simulation executable like this -override=startTime=4,stopTime=5
(note that this is actually required for re-simulation but to keep the code simple I have used it for both normal and re-simulation). This is overriding the parameter defined in the model. Not sure how fix this. Maybe in the runtime we should have a different override flag for simulation parameters and model parameters.
comment:7 by , 6 years ago
After the discussions in the OSMC dev meeting we decided to go with a new namespace for the settings: -override=settings.startTime=1,startTime=5
comment:8 by , 6 years ago
Of course this assumes that nobody will ever put a top-level object named settings
containing those parameters in his/her model :)
I guess the likelyhood of that happening is very close to zero...
comment:11 by , 6 years ago
@adeas31: names can start with "." but only if they are classes and surely cannot start with "$".
IDENT = NONDIGIT { DIGIT | NONDIGIT } | Q-IDENT Q-IDENT = "’" ( Q-CHAR | S-ESCAPE ) { Q-CHAR | S-ESCAPE } "’" NONDIGIT = "_" | letters "a" to "z" | letters "A" to "Z"
comment:12 by , 6 years ago
I'm for $startTime
. BTW, this also allows to keep backwards compatibility by accepting startTime
with the old meaning if the model does not have a top-level startTime parameter, while at the same time issuing a warining such as "please use $startTime instead".
The remaining question is, should we use €startTime
instead?
Just kidding :)
comment:14 by , 5 years ago
Milestone: | 1.14.0 → 1.16.0 |
---|
Releasing 1.14.0 which is stable and has many improvements w.r.t. 1.13.2. This issue is rescheduled to 1.16.0
comment:16 by , 4 years ago
Milestone: | 1.17.0 → 1.18.0 |
---|
Retargeted to 1.18.0 because of 1.17.0 timed release.
Note sure if this is a frontend or backend issue.