You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
parameterReal e=0.8"Coefficient of restitution";
constantReal 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 then0else-9.81;
when {h<0,h<-eps} then
done = h<-eps;
reinit(v, -e*(if h<-eps then0elsepre(v)));
end when;
The text was updated successfully, but these errors were encountered:
structural_simplify should be able to recognize that D(y) is present in the system and handle it appropriately. To avoid having to specify constraints that are binding as initialization_eqs are, we can also search defaults. The user can remove the initial condition without having to re-simplify the system. For a nicer API, structural_simplify could take a higher_order_derivatives keyword which takes an array of higher order derivatives to compute.
I'm not fully sure about this, but maybe we can handle this outside of structural simplification too? If y is an observed variable y ~ f(..) then D(y) ~ D(f(..)) and we should be able to use expand_derivatives to reduce this. Recursively applying this procedure to the RHS and combining with dummy_sub for known derivatives should just work?
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 despiteder(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
https://playground.modelica.university/?model=ICBwYXJhbWV0ZXIgUmVhbCBlPTAuOCAiQ29lZmZpY2llbnQgb2YgcmVzdGl0dXRpb24iOwoKICBjb25zdGFudCBSZWFsIGVwcz0xZS0zICJTbWFsbCBoZWlnaHQiOwogIEJvb2xlYW4gZG9uZSAiRmxhZyB3aGVuIHRvIHR1cm4g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D0iMTAiIHN0cm9rZT0iYmxhY2siLz4KPC9zdmc%252BCgo8Y2hhcnQgc2lnbmFscz0iaCI%252BPC9jaGFydD4%253D
The model is reproduced below in case the link stops working
The text was updated successfully, but these errors were encountered: