State Event Handling - Decay1

Gallery
Tutorial
Click on the image to view it full size
The Modelica By Example target code (using 'initial equation') is:

model Decay1
  Real x;
initial equation
  x = 1;
equation
  der(x) = -sqrt(x);
end Decay1;

The exported Modelica code is:


model Decay1
  Real x(start=1.0,fixed=true);
equation
  der(x)=-sqrt(x);
end Decay1;
Note that because SysPhS-1.1 does not support Modelica's 'initial equation' the 'start' value is set directly on x:

  Real x(start=1.0,fixed=true);

The exported version ran fine in Wolfram SystemModeler without any of the kinds of numerical issues indicated in the Modelica By Example discussion.


MagicDraw/Cameo could not handle export of the following guard expressions, so the Decay2 and Decay3 examples could not be directly reproduced:


der(x) = if x>=0 then -sqrt(x) else 0;

der(x) = if noEvent(x>=0) then -sqrt(x) else 0;

It turns out, however, that MagicDraw/Cameo can export the following fine (just not the inline "switching" form):


if x>=0 then
  der(x)=-sqrt(x);
else
  der(x)=0;
end if;
Up next
Notes
Snippets (quotes/extracts)
Visit also
Visit also (backlinks)
Related slides (includes other tutorials)
Related slides (backlinks, includes other tutorials)
External links