Open modelica-trac-importer opened 6 years ago
Comment by jfrenkel on 4 Aug 2017 11:12 UTC
OpenModelica behave different. There the first activation of the clock of x is independent from the fixation of b at around time=4.71
. When b
switches from false
to true
the first time.
Comment by anonymous on 4 Aug 2017 11:47 UTC Specificationh page 203: "Clock with Boolean Condition": The output argument is of base type Clock that ticks when edge(condition) becomes true.
In the example, when Boolean b has a start value of false (=default) and then changes to true at time=0.0, there is an edge and therefore the clock ticks. When Boolean b has a start value of true (-> pre(b) = true) and then changes to true at time=0.0, there is no edge and therefore the clock does not tick. Therefore, the behavior of Dymola is correct.
Modified by beutlich on 6 Oct 2017 06:08 UTC
Comment by hansolsson on 19 Oct 2017 12:35 UTC
Dymola's behavior is not clearly inconsistent with the specification and means the Clock is triggered during initialization.
However, for when-clauses we have changed this so that the corresponding when b
would not trigger; if one wants to trigger a when-clause during the initialization it is necessary to use when {initial(),b}
.
And in 16.9 definition of initialization for clocked partitions does not explicitly state that Clocks may not tick during initialization - even though they cannot be used during the initialization; and there is nothing corresponding to "{initial(),...}"
Thus the specification should be made clearer; maybe forbid Clocks ticking during the initialization.
Bernhard: Rüdiger maybe wants Clocks during initialization (a bit unclear).
Comment by otter on 20 Oct 2017 05:58 UTC One important application is to download clocked partitions to embedded systems. On an embedded system there is no "Modelica initialization", but the equations of the clocked partition are evaluated whenever the clock ticks. This means, at the first clock tick the equations of the clocked partition are evaluated the first time.
In the example, "x" is a clocked variable and "b" is a continuous-time variable. Whenever "b" changes its value from false to true, the clock ticks. However, initialization is something that is outside of the "real world", and is just used to define a starting point when simulating the "real world". Therefore, clearly, clocks should never tick during initialization, also not for triggered clocks. "Initialization" takes place at t0 and then at lim(t0+eps) eps->0, the simulation of the "real world" is starting. Clocks can only tick at this time instant (the first model evaluation after initialization), or later.
Now, in the first model we have "b(start=false)" (since the default) and in the second model we have "b(start=true, fixed=true)".
So to summarize, if you think that the specification is not clear, please add a sentence that the first tick of a clock can only be after initialization (this is such a fundamental principle, that I thought this is fully clear).
Modified by beutlich on 10 Jan 2018 08:23 UTC
Reported by jfrenkel on 4 Aug 2017 11:00 UTC Regarding the following example
The first activation of the clock of
x
is attime=0
.But if we change the model to
the first activation of the clock of
x
is aroundtime=4.71
in Dymola.The question is if this is a expected behaviour or not?
Migrated-From: https://trac.modelica.org/Modelica/ticket/2195