Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

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.

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.

Edited by: lochel - Aug-31-15 06:31:00
There are 0 guests and 0 other users also viewing this topic
You are here: