Opened 8 years ago

Last modified 8 years ago

#4229 new defect

Augmented bouncing ball model falls through if exported and imported as FMU

Reported by: Bernhard Thiele Owned by: Adeel Asghar
Priority: high Milestone: Future
Component: FMI Version:
Keywords: Cc: Peter Fritzson, alejandro.danos@…, rd.castro@…, Martin Sjölund, Lennart Ochel, Willi Braun

Description

The following bouncing ball model

model BouncingBall
  parameter Real e=0.7 "coefficient of restitution";
  parameter Real g=9.81 "gravity acceleration";
  Real h(start=1) "height of ball";
  Real v "velocity of ball";
  Boolean flying(start=true) "true, if ball is flying";
equation
  der(h) = v;
  der(v) = if flying then -g else 0;
  flying = not (h <= 0 and v <= 0);
  when h <= 0.0 then
    reinit(v, -e*pre(v));
  end when;
end BouncingBall;

avoids the well-known "fall-through" effect by the additional logic around the flying flag.

However if one exports and imports the model by the following MOS script, the ball will fall through.

bb_file_path :=realpath("BouncingBall.mo");
loadFile(bb_file_path);
translateModelFMU(BouncingBall);

bb_fmu_file_path := realpath("BouncingBall.fmu");
imported_fmu_mo_file := importFMU("BouncingBall.fmu");
loadFile(imported_fmu_mo_file);
simulate(BouncingBall_me_FMU, stopTime=3.0,outputFormat="csv");

Bouncing ball plot

Attachments (4)

bouncingballplot.png (7.5 KB ) - added by Bernhard Thiele 8 years ago.
Bouncing ball plot
BouncingBall.mo (417 bytes ) - added by Bernhard Thiele 8 years ago.
writeBB.mos (409 bytes ) - added by Bernhard Thiele 8 years ago.
readBB.mos (439 bytes ) - added by Bernhard Thiele 8 years ago.

Download all attachments as: .zip

Change History (6)

by Bernhard Thiele, 8 years ago

Attachment: bouncingballplot.png added

Bouncing ball plot

by Bernhard Thiele, 8 years ago

Attachment: BouncingBall.mo added

by Bernhard Thiele, 8 years ago

Attachment: writeBB.mos added

by Bernhard Thiele, 8 years ago

Attachment: readBB.mos added

comment:1 by Lennart Ochel, 8 years ago

Cc: Lennart Ochel added

comment:2 by Adeel Asghar, 8 years ago

Cc: Willi Braun added

AFAIR, Willi told me that this is because OpenModelica run-time takes an extra event at the end.

Note: See TracTickets for help on using tickets.