- Index
- » Programming
- » Modelica Language
- » vectors with "when" and "reinit"
vectors with "when" and "reinit"
vectors with "when" and "reinit"
Hello
Here is my purpose . This program works fine
model chute
Real ax(start = 0.0);
Real ay(start = 0.0);
Real vx(start = 1.0);
Real vy(start = 1.0);
Real x;
Real y;
parameter Real sol = -2.0;
equation
vx = der(x);
vy = der(y);
ax = der(vx);
ay = der(vy);
ax = 0;
ay = -9.81;
when y < sol then
reinit(y, 2 * sol - y);
reinit(vy, -vy);
end when;
end chute;
I want to simplify and test this version
model chuteVectors
Real a[2];
Real v[2](start = {1, 1});
Real xy[2](start = {0, 0});
equation
v = der(xy);
a = der(v);
a = {0, -9.81};
when xy[2] < sol then
reinit(xy, {xy[1], 2 * sol - xy[2]});
reinit(v, {v[1], -v[2]});
end when;
end chuteVectors;
But this second version doesn't work . the flying of the bal is ok but not the rebouncing
Can someone explain me what is wrong in the second version ?
Thank you ?
- Index
- » Programming
- » Modelica Language
- » vectors with "when" and "reinit"