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

Bouncing Ball with spring-damper component

Bouncing Ball with spring-damper component

Hi everybody! i need help by an Bouncing Ball with spring-damper component program!

The impact should not be  an event that only changes the initial values ​​for the calculation of the flight phase,it should by a own differential equation model that consider the deformation of the ball.

h=height ; y=deformation;d=damper; k=spring;
fc= max(-k * h - der(h) * d, 0) =normalized contact force is not positive due to the unilateral contact between ball and ground
can be

for the flight phase i got :
   der(v) = -g;
    der(h) = v;                           
    der(y) = -(y * k) / d;
for impact:
der(v) = -g + fc;
    der(h) = v;
    der(y) = -der(h);

i know that the impact starts when h + y = 0 and ends when fc=0 but i don´t know how to write it into the program!

I'm trying it since 7 hours and i only got this:

model Bouncing03
 
  Real h(unit = "m", start = 10);

  Real v(unit = "m/s", start = 0);
 
  Real y(start = 0);
 
  parameter Real g(unit = "m/s^2") = 9.81;
 
  parameter Real d = 500;
 
  parameter Real k = 1000000;

  annotation(experiment(StartTime = 0.0, StopTime = 20.0, Tolerance = 0.000001));

  Boolean flying(start = true);
  Boolean impact;
  Real v_new;
equation
  impact = h + y < 0;
  if h + y > 0 then
    der(v) = -g;
    der(h) = v;
    der(y) = -(y * k) / d;
  else
    der(v) = -g + max(-k * h - der(h) * d, 0);
    der(h) = v;
    der(y) = -der(h);
  end if;
  when {impact,max(-k * h - der(h) * d, 0) == 0} then
      v_new = if edge(impact) then pre(v) else 0;
    flying = v_new > 0;
    reinit(v, v_new);
 
  end when;
end Bouncing03;

thanks for the help

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