VirtualLabBuilder.Examples.BBall

Bouncing ball

Information


 

BBall package

BBall package includes the description of the bouncing-ball virtual-lab. The BBModel has been extracted from (Dynasim 2004) and have been adapted for interactive simulation.

References

Dynasim (2004): Dymola. User's Manual. Dynasim AB.Version 5.3a.

Package Content

NameDescription
BBModel Virtual-lab model
VirtualLabBuilder.Examples.BBall.BBView BBView Virtual-lab view description
BBInteractive Interactive model


VirtualLabBuilder.Examples.BBall.BBModel

Virtual-lab model

Information



This model has been extracted from (Dynasim 2004). It has been adapted for interactive simulation. The interactive variables of the models are shown in Table 1.

Table 1. Interactive variables.
x Ball position.
v Ball velocity.
ebounce Ellasticity coefficient.


References

Dynasim (2004): Dymola. User's Manual. Dynasim AB.Version 5.3a.


Parameters

TypeNameDefaultDescription
HeightxStart10[m]
VelocityvStart0[m/s]
Massm2[kg]
RealebounceIni0.8Initial value of the ellasticity coefficient
Realvsmall1e-4 

Modelica definition

model BBModel "Virtual-lab model" 
  import Modelica.SIunits;
  parameter SIunits.Height xStart = 10;
  parameter SIunits.Velocity vStart = 0;
  
  SIunits.Height x(start=xStart, stateSelect = StateSelect.always);
  SIunits.Velocity v(start = vStart);
  
  SIunits.Force f;
  parameter SIunits.Mass m=2;
  
  parameter Real ebounceIni=0.8 "Initial value of the ellasticity coefficient"; //Code added 
  
  Real ebounce( start = ebounceIni); //Code added 
  
  Real var( start = 0); //Code added
  parameter Real vsmall = 1e-4;
  Boolean locked(start = false);
equation 
 der(x)=v;
 m*der(v)= f;
 f=if locked then 0 else -m*Modelica.Constants.g_n;
 when (x<0 or locked) then
  reinit(x,0);
  reinit(v, if locked then 0 else  -ebounce*v);
    
 end when;
  
 der(ebounce) = 0; //Code added 
 der(var) = 0; //Code added
locked=if pre(locked) then x<=0 else x<=0 and 
abs(v)<=vsmall and f<=0;
 when var>0.5 then
  reinit(x,xStart);
  reinit(v,vStart);
 end when;
end BBModel;

VirtualLabBuilder.Examples.BBall.BBView VirtualLabBuilder.Examples.BBall.BBView

Virtual-lab view description

VirtualLabBuilder.Examples.BBall.BBView

Information



This model has been composed by extending the PartialView class and by instantiating and connecting the required components of the VirtualLabBuilder library. The connection rules are described in the documentation of the ViewElements package.

Parameters

TypeNameDefaultDescription
RealTcom0.1Communication interval
IntegerserverPort4242Server Port number
StringsourceCodePath"C:/Program Files/Dymola/Sou...Path where the C-functions, graphics.jar and delayrun.exe are located
StringfileName"gui.java"Java file name

Modelica definition

model BBView "Virtual-lab view description" 
             extends VirtualLabBuilder.VLabModels.PartialView(fileName = "BBall.java");
  
  
  VirtualLabBuilder.ViewElements.Containers.PlottingPanel PP(
      axesType="cartesian1",
      title="Ball",
      titleX="time (s)",
      titleY="x(t)",
      autoScaleY="false",
      maxY=12,
      position="CENTER");
  VirtualLabBuilder.ViewElements.Containers.Dialog D(varName="var",
        xPosition=600);
  VirtualLabBuilder.ViewElements.Containers.MainFrame MF(LayoutPolicy=
          "BorderLayout()", Width=600);
  VirtualLabBuilder.ViewElements.Containers.DrawingPanel DP(
      YMin=0,
      position="CENTER",
      YMax=12);
  VirtualLabBuilder.ViewElements.Containers.Panel pNorth(
    LayoutPolicy="GridLayout",
    position="NORTH",
      nRows=1,
      nColumns=4);
  VirtualLabBuilder.ViewElements.BasicElements.CheckBox checkBox(label="Show plot");
    VirtualLabBuilder.ViewElements.Drawables.Trail trail(nSkip=0,
        maximumPoints=2000);
    VirtualLabBuilder.ViewElements.BasicElements.InfoButton infoButton(
      tooltip="Displays the introduction of the lab",
      sizeFont=20,
      path="D:\\VisualizacionDymola\\BouncingBall\\BBModel.html",
      title="Introduction",
      xPos=600,
      image="D:\\VisualizacionDymola\\BouncingBall\\info.jpg",
      label="Info");
    VirtualLabBuilder.ViewElements.InteractiveControls.Button1Action reset(label="Reset", tooltip=
          "Reset");
    src.ViewElements.InteractiveControls.Slider slider(stringFormat=
          "ebounce = 0.0");
    src.ViewElements.Drawables.Oval oval(intCenter=1);
equation 
  
    connect(slider.cLLeft, checkBox.pLLeft);
    connect(checkBox.cLLeft, infoButton.pLLeft);
    connect(infoButton.cLLeft, reset.pLLeft);
    connect(root.cLLeft, MF.pLLeft);
    connect(pNorth.cLRight, slider.pLLeft);
    connect(pNorth.cLLeft, DP.pLLeft);
    connect(MF.cLLeft, D.pLLeft);
    connect(MF.cLRight, pNorth.pLLeft);
    connect(DP.cRight, oval.pLeft);
    connect(PP.cRight, trail.pLeft);
    connect(D.cLRight, PP.pLLeft);
end BBView;

VirtualLabBuilder.Examples.BBall.BBInteractive

Interactive model

Information



This model has been composed by instantiating the VirtualLab Model, which is included in the VirtualLabBuilder library. The BBInteractive model includes the equations required to link the model and the view variables.

Modelica definition

model BBInteractive "Interactive model" 
  
  VirtualLabBuilder.VLabModels.VirtualLab interactive(redeclare model ViewI = 
        BBView, redeclare model ModelI = BBModel,
      Tcom=0.001);
equation 
  
 interactive.View.oval.Center = {0.0, interactive.Model.x};
 interactive.View.oval.Axes = {0.1, 1};
  
 interactive.View.trail.point = {time, interactive.Model.x};
 interactive.View.slider.var = interactive.Model.ebounce;
 interactive.View.reset.var = interactive.Model.var;
  
end BBInteractive;

HTML-documentation generated by Dymola Tue Jul 24 18:58:11 2007.