Tags and keywords
The Modelica By Example target code (using 'initial equation') is:
model BouncingBall "The 'classic' bouncing ball model"
type Height=Real(unit="m");
type Velocity=Real(unit="m/s");
parameter Real e=0.8 "Coefficient of restitution";
parameter Height h0=1.0 "Initial height";
Height h "Height";
Velocity v(start=0.0, fixed=true) "Velocity";
initial equation
h = h0;
equation
v = der(h);
der(v) = -9.81;
when h<0 then
reinit(v, -e*pre(v));
end when;
end BouncingBall;
This case could not be directly reproduced in SysPhS-1.1 because:
Indeed 'when/then' statements are not explicitly listed under SysPhS-1.1 8 Language for Mathematical Expressions.
The exported Modelica code is:
model BouncingBall
BouncingBall _BouncingBall;
model BouncingBall
parameter Real e(start=0.8,fixed=true);
parameter Height h0(start=1.0,fixed=true);
Height h(start=1.0,fixed=true);
Velocity v(start=0.0,fixed=true);
equation
v=der(h);
der(v)=-9.81;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull;
end BouncingBall;
type Height=Real(unit="m");
type Velocity=Real(unit="m/s");
end BouncingBall;
Note that the when/then constraint equation completely failed to export (and it does not seem to matter how it is formatted or what constraint language is chosen).
Note that because SysPhS-1.1 does not support Modelica's 'initial equation' theh0
is ignored in this trail version and the same 'start' value is set directly on h
:
Height h(start=1.0,fixed=true);
If you do HACK the when/then code back into the exported Modelica code it runs fine. The other Modelica By Example involving when/then variants were not further explored.