Open
Description
MTK requires that all derivatives that are referred to in initialization equations and the varmap are present also in the regular equations. In modelica, one can specify der(y) = 0
in initialization equations despite der(y)
not appearing in any regular equation, which is nice because it's common to want to initialize at zero derivative of outputs of block components.
Here's a link to a simple modelica model that demonstrates this
The model is reproduced below in case the link stops working
parameter Real e=0.8 "Coefficient of restitution";
constant Real eps=1e-3 "Small height";
Boolean done "Flag when to turn off gravity";
Real h "Height";
Real v "Velocity";
Real y;
initial equation
h = 7.0 "Initial height";
der(y) = 0.0 "Initial vel but expressed in terms of der of output";
//v = 0.0 "Initial vel";
done = false;
equation
v = der(h);
y = h;
der(v) = if done then 0 else -9.81;
when {h<0,h<-eps} then
done = h<-eps;
reinit(v, -e*(if h<-eps then 0 else pre(v)));
end when;
Metadata
Metadata
Assignees
Labels
No labels