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 Simulation Problem

Bouncing Ball Simulation Problem

Dear all,
I am not able to understand how to use when loop for bouncing ball problem. The standard code given in Michael Tiller's book is as follows:

model BouncingBall "The 'classic' bouncing ball model"
type Height=Real(unit="m");
type Velocity=Real(unit="m/s");
parameter Real e=0.8 "Coefficient of restitution";
parameter Height h0=1.0 "Initial height";
Height h;
Velocity v;
initial equation
h = h0;
equation
v = der(h);
der(v) = -9.81;
when h<0 then
reinit(v, -e*pre(v));
end when;
end BouncingBall;

This code works extremely fine but let's say when I make h==0 (instead of h<0 i.e. ball hits the ground) in when statement then I get weird output in simulation and I am not able to understand it. So, any help would be appreciated.

Thank you.

Edited by: aggajjar - Apr-24-17 06:43:15
There are 0 guests and 0 other users also viewing this topic
You are here: