Testing the Generated Model

You can test the generated model.


Before you begin: Generate a modelica model from a kinematic mechanism. For more information, see Generating the Modelica Model.
  1. To prepare the generated model for testing, do the following:

    Usually generated components are just components. They have to be connected to be tested. Below is a simple example to fix the cylinder before simulating it.

    1. In MyGeneratedModels, create a new model TestMyGeneratedCylinder. See Create a New Class or Extend from an Existing Class Using the New Class Command.
    2. Instantiate MyGeneratedCylinder by dragging it into the TestMyGeneratedCylinder model.

      Note: Make sure you drag the right model, do not drag the locked one.

    3. Drag Modelica.Mechanics.MultiBody.World into TestMyGeneratedCylinder.
    4. Connect the World component to the main axis frame of the MyGeneratedCylinder component.
    5. Change the direction of gravity to the negative z axis by changing the parameter n of the World component.
    The MyGeneratedCylinder model is now connected to a simple "test rig" to test it.
    Notes:
    • The structure of libraries is often more elaborate, for example, it is common to have a separate library for some generated models, and another library for the use of them in customer models.
    • It is useful to look at the diagram of the generated model. Components with mass equal to zero, but volume not null, are marked by red on the diagram.
  2. Simulate the model. See Simulating a Behavior.
    Considering the mass, inertia, and joints, the result is computed and the corresponding 3D appears.
    Notes:
    Tip: It can be useful in some cases, for example for faultfinding, to visualize the animation of shapes related to the Modelica bodies, axis systems, or Modelica joints of the generated model. To do so, three parameters are available at top level in the generated model:
    • The animateBodies parameter enables the animation of all Body shapes in the model, including the "fixedRotation" shapes (for example, rigid bars) between the center of gravity and the various frames of the body.
    • The animateBodyFrames parameter enables the animation of all axis systems in the model.
    • The animateJoints parameter enables the animation of all Modelica joints in the model.

    For each Modelica body, the two first parameters are also available locally for each body, to have a more refined debug visualization. For joints, the last parameter is available locally for the same reason.

    If you want to adjust the size of joints or bodies, you must modify the parameters in the Modelica.Mechanics.MultiBody.World component, since this component defines sizes for such joints and body shapes.