Help - Search - Members - Calendar
Full Version: terminal equation or algorithm exist in Modelica with Dymola
Modelica Forum > Modelica > Modelica
laurent
Hello,

I try to connect a Modelica Simulation with Dymola to my "DCS Simulator" by OPC.

In initial equation, I call my C function ConnectOPC().

But I don't found how or where call my function DisconnectOPC()?
I want to disconnect at the last cycle or better after the last cycle.

My final objective is to use option Real Time of Dymola, so I don't know how many time my simulation works.

Thanks for your idea.

Laurent
wagner
Hello Laurent,

you can detect the last step of your simulation by using terminal().

Using terminal() as condition of a when block, you can make actions at the end of a successful simulation.

CODE

when terminal() then
   DisconnectOPC();
end when;


Regards

Florian
laurent
Thanks it works,

For my information, somebody know difference between:
intial equation and when initial() then ... end when;

Laurent
wagner
Hello Laurent,

I looked it up in literature a few days, cause there was a discussion about this in another thread. But I found two different descriptions about this matter.

In the book by Fritzson it's said that there is no difference between "initial equation" and "when initial". In both cases the equations are part of the initialization before simulation starts.

In the book by Tiller it's described that there is a difference (Chapter 13):

"initial equation" is evaluated before simulation starts, whereas "when initial" is evaluated when simulation just started. Using "when initial" means that there are two initialization problems to be solved. One before simulation starts and another when simulation just started.

Maybe someone else knows the "truth" about this.

Regards

Florian
Carsten
at least in Dymola there is no difference between initial equation and when initial() block.

if there would be any difference (initial equation before start and when initial() at the begin of the simulation), the following model should work, but it does not wink.gif

QUELLTEXT
model Unnamed
  Real a;
initial equation
  a=3;
equation
  when initial() then
    a=5;
  end when;
  der(a)=2;
end Unnamed;


Removing one of both parts turns the model in a valid one...

regards
Carsten
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.