- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Mixed Continous/Discrete System problem
Mixed Continous/Discrete System problem
Mixed Continous/Discrete System problem
The following model snippet, I was trying did not work as expected. The code snippet was based on publication
"Modelling of mixed Continuous/Discrete Systems in Modelica" by Martin et.al.
Code:
model tick
parameter Real sampleTime = 0.1 ;
Real x(start=0, fixed=true) ;
discrete Real nextTime(start=0) ;
equation
when time >= pre(nextTime) then
nextTime = time + sampleTime ;
end when;
x = nextTime ;
end tick;
The above code produces no change in x at all. It remains at zero. But then when I change the when expression to " time > pre(nextTime)" it works. I get the stair step changes in x. Is this expected or is it a bug? Some explanation of this behavior would be much appreciated. I am using omc verison v1.9.3-dev.1258+gf9a05a1.
- ravi
- 32 Posts
Re: Mixed Continous/Discrete System problem
I think that is the expected behavior. If you want to get the stair step signal, you could change the when condition to “time > pre(nextTime)”.
The reason for the behavior is, that a when clauses is only invoked, if the condition changed from false to true. In your model the condition is true from the beginning and therefore the when clause is never invoked.
- lochel
- 45 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Mixed Continous/Discrete System problem