Help - Search - Members - Calendar
Full Version: Is OpenModelica implementation compliant to the modelica specifications?
Modelica Forum > Modelica > MathModelica / OpenModelica
Zied Kelboussi
Hi all,
In the modelica specification, the modelica builtin operator reinit() can be equally used inside an algorithm or an equation section. However, the OpenModelica simulator is issuing a simulation error when I try to use the reinit() operator inside an algorithm section.
In fact, I'm trying to model a Hybrid Automaton Behavior in modelica. So, I'm using When-Statements to define the state machine. Each When-Branch of the When-Statement correponds to a transition in the original automaton. here is an example :

CODE

model toto

algorithm
  when (x >= tmax) and (state == on) then
    state := off;
    reinit(x, expression1);   // openModelica does not accept the reinit() operator : generates a simulation error
  elsewhen (x <= tmin) and (state == off) then
    state := on;
    reinit(x, expression2);
  end when;

equation
  some equations...;

end toto;

So is the reinit() operator not supported in algorithm section in OpenModelica? or am I missing some thing?
Thank you.

Carsten
Hi,

well I tried the following model in Dymola and it works fine..

QUELLTEXT
model toto
  Real x;
  parameter Real tmax=0.3;
  parameter Real tmin=0.1;
  Boolean state(start = true);
  Real expression1 = 0.05;
  Real expression2 = 0.2;
  
algorithm
  when (x >= tmax) and (state == true) then
    state := false;
    reinit(x, expression1);   // openModelica does not accept the reinit() operator : generates a simulation error
  elsewhen (x <= tmin) and (state == false) then
    state := true;
    reinit(x, expression2);
  end when;
  
equation
  der(x) = 1;
  
end toto;


But you have to make shure, that x is selected as state, otherwise reinit has no influence. E.g. changing in the above model
QUELLTEXT

Real x;
to
QUELLTEXT
Real x = time
and remove
QUELLTEXT
der(x)=1
results in a simulation, where reinit has no influence x, as x is not seleted as state variable. Dymola provides a warning message during translation in that case.

If that is not the reason, then try to contact the people from OpenModelica directly.

regards
Carsten
Jawhar
QUOTE(Zied Kelboussi @ Aug 7 2007, 08:23 AM) *

Hi all,
In the modelica specification, the modelica builtin operator reinit() can be equally used inside an algorithm or an equation section. However, the OpenModelica simulator is issuing a simulation error when I try to use the reinit() operator inside an algorithm section.
In fact, I'm trying to model a Hybrid Automaton Behavior in modelica. So, I'm using When-Statements to define the state machine. Each When-Branch of the When-Statement correponds to a transition in the original automaton. here is an example :



hello Zied;

I have done an implementation of a hybrid automata with modelica and i have create a modelica library for this. I have published an article about this (in frensh). If you want more details i can help you. Please, ask me here in the forum so the other users can have an idea about this library and the method i had used to model an hybrid automatra with modelica. Thank u.
jfdupuis
QUOTE(Jawhar @ Sep 26 2007, 06:18 PM) *

hello Zied;

I have done an implementation of a hybrid automata with modelica and i have create a modelica library for this. I have published an article about this (in frensh). If you want more details i can help you. Please, ask me here in the forum so the other users can have an idea about this library and the method i had used to model an hybrid automatra with modelica. Thank u.



Hi Jawhar,

I would be interested to know more about your hybrid automata library. Is it possible for you the give a link where you article is available. French is fine for me.

Thanks
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.