Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

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

https://openmodelica.org/images/agorapro/attachments/5603/mini_Capture.PNG

https://openmodelica.org/images/agorapro/attachments/5603/mini_Capture2.JPG

Can someone explain me what is wrong in the second version ?
Thank you ?

There are 0 guests and 0 other users also viewing this topic
You are here: