Ticket #4229: BouncingBall.mo

File BouncingBall.mo, 417 bytes (added by Bernhard Thiele, 8 years ago)
Line 
1model BouncingBall
2 parameter Real e=0.7 "coefficient of restitution";
3 parameter Real g=9.81 "gravity acceleration";
4 Real h(start=1) "height of ball";
5 Real v "velocity of ball";
6 Boolean flying(start=true) "true, if ball is flying";
7
8equation
9 der(h) = v;
10 der(v) = if flying then -g else 0;
11 flying = not (h <= 0 and v <= 0);
12
13 when h <= 0.0 then
14 reinit(v, -e*pre(v));
15 end when;
16
17end BouncingBall;