Generating the Modelica Model

You can generate a Modelica behavior (model) of a mechanism of a physical product.

This task shows you how to:


Before you begin:
  • Make sure that you have access to both the Dymola Behavior Modeling app and the Mechanical Systems Design app.
  • Make sure that the CATIAMultiBody library is installed.
  • The mechanism in the physical product must have commands so that the number of DOF (degree of freedom) when considering the commands is equal to zero. If this is not the case, a warning appears; the Modelica representation is however still generated.
  • The mechanism must have no command dependency. If so, a warning message appears; the Modelica representation is however still generated.
Tip: You can analyze this before translating, using the Mechanism Manager in the Mechanical Systems Design app. See Mechanism Manager User's Guide: Defining Mechanisms: Setting Up a Mechanism.

For more information, see About Generating a Modelica Representation of a Mechanism of a Physical Product.

Note: If the physical data involved in a mechanism of such a model is later modified, you can update the model, see Updating, from the Physical or Logical Model, a Generated Modelica Model of a Kinematic Mechanism or an Engineering Model.

Generate a Modelica Model from a Kinematic Mechanism, Using a Command

You can generate a Modelica model from a kinematic mechanism of a physical product, using a command.

Context: The following options are only available when using the command:

  • Creating 3D representations of the shapes in VRML format.
  • Generating a World component and connect it to fixed parts if the physical model contains published axes.

  1. Open a physical product containing a mechanism:
    1. From the top bar, search for the physical product.

      For more information about searching, see 3DEXPERIENCE Platform:Top Bar.

    2. To open both the physical and logical parts of the product, right-click it in the Search Results panel and select Open With > Smart Open in RFLP .
      The product is opened in authoring mode.
    3. Analyze and compute the masses and inertia of the 3D parts. For more information, see Managing Masses and Inertia.

      Note: If you only want to update mass and inertia on parts before translation, skip this step.

  2. To store the generated model, create a new Dymola Behavior library, with the name MyGeneratedModels. See Create a Dymola Behavior Library.
    • You enter the Dymola Behavior Modeling app in a new tab.
    • A Dymola Behavior Library MyGeneratedModels is created in the new tab.
    Note: To work more comfortably between the apps, make both tabs visible on the screen.
  3. From the Behavior Tools section of the action bar, click Generate from Kinematic to generate the Modelica model.
    The Generate from Kinematic dialog box appears.
    Note: If you already have an active model that is generated by this command, the dialog is prefilled with the setup used for generating this model.
  4. Select the mechanism:
    1. Click the Mechanism: box.
    2. In the tab where the mechanical model is seen, in the tree, click any joint or command of the mechanism to be used for Modelica model generation.
    The name of the mechanism appears in the Mechanism: box.
  5. Select the parent class where the generated model should be inserted:
    1. Click the Insert In: box.
    2. In the Dymola Behavior Modeling app, from the Package Browser, or from the tree, click the package where you want to insert the Modelica representation.
  6. Click the Output class name: box and enter the name of the Modelica model to be created. In this scenario, enter MyGeneratedCylinder.
  7. Optional: You can specify more options by clicking More:
    OptionDescription
    Generate VRML from parts Generates 3D representations of the shapes, in VRML format.
    Note: If cleared, the generated model includes links to the initial 3D physical model, so it can be animated from the results. By default, this option is cleared.
    Update mass and inertia on parts before translation Updates mass and inertia on parts before translation.
    Note: By default, this option is cleared.
    Include motors Includes motors attached to commands.
    Note: By default, this option is cleared. In this scenario, keep this option cleared.
    Always generate a world component Generates a World component and connects it to fixed parts, even if the physical model contains published axes by activating.
    Note: If not activated, the World model is only generated when the physical model does not contain any published axes. By default, this option is cleared. In this scenario, keep this option cleared.
    Rebuild at PLMUpdate Rebuilds the model when performing any general update command, that is, any of the commands Update or Update Assistant.
    Note: By default, this option is activated. A reason for clearing this option can be if you want to compare two alternatives of a model without risking that an update command updates the wrong model.
    Joint boundary kind Defines how to interpret limiters on revolute, prismatic, and cylindrical joints when generating the Modelica representation. Select any of:
    • Warning: When the joint reaches the limit value, a warning appears and the simulation continues.
    • Error: When the joint reaches the limit value, an error appears and the simulation stops.
    • Limiter: A Modelica limiter is inserted between the flanges of the Modelica joint, limiting the joint´s movements between the defined limits.
  8. Click OK to start the model generation.
    The following is created under the selected target package MyGeneratedModels:
    • A class InternalGenerated that contains the generated model MyGeneratedCylinder.
      Note: This class is locked, you should not edit this class.
    • An extended class MyGeneratedCylinder.
      Note: This is the class that you can edit, for example to extend the model or replace components.


    Notes:
    • If required, the geometries of the parts involved in the mechanism are loaded.
    • The root physical model containing the mechanism you selected is set to authoring mode to retrieve some data from that model.
    • If you have already loaded the physical product in the session, for example, you have opened it in a tab, only the relevant parts are loaded, not the full product, to not alter any filtering you have done. If the product is not in the session, the full product is loaded.
    • For the features of the generated classes, for example, handling of mechanism commands, user-driven Point-Curve joints, dress-up pattern, published axes, color animation, replacing of components, see About Generating a Modelica Representation of a Mechanism of a Physical Product.
    • If the physical model contains any publications of Knowledgeware parameters directly under the product that contains the selected mechanism, then the corresponding Modelica parameters are created in the generated model. Those Modelica parameters are exposed in Knowledgeware, and a formula is created to assign the same value as the value of the published parameter.
      Important: To keep the link between Knowledgeware parameters in the physical model and the Modelica parameters, select Keep link with selected object from Me > Preferences > Common Preferences > Object Properties > 3D Shape > Infrastructure. For more information, see Native Apps Preferences Guide: 3D Shape Infrastructure.
  9. Test the generated model. For more information, see Testing the Generated Model.

Generate a Modelica Model from a Kinematic Mechanism, Using a Scripting Method

You can generate a Modelica model from a kinematic mechanism of a physical product, using an Engineering Knowledge Language (EKL) method when both the kinematic mechanism and the target Modelica package are created and open.

Context:

Note: Compared to the scenario above, in the below scenario you create a behavior with the Modelica target package, not a stand-alone target package.

  1. Open a physical product containing a mechanism:
    1. From the top bar, search for the physical product.

      For more information about searching, see 3DEXPERIENCE Platform:Top Bar.

    2. To open both the physical and logical parts of the product, right-click it in the Search Results panel and select Open With > Smart Open in RFLP .
      The product is opened in authoring mode.
    3. Analyze and compute the masses and inertia of the 3D parts. For more information, see Managing Masses and Inertia.
  2. On the Logical node in the tree, create a new logical reference containing a Dymola behavior:
    1. In the tree, right-click the Logical node and select Insert New Logical Component.
    2. In the New Content panel, expand Logical and select Logical Reference.
      A logical reference appears under the Logical node in the tree.
    3. From the Behaviors section of the action bar, click Insert New Behavior Representation .
    4. In the tree, click the logical reference you created.
    5. In the New Content panel, select Dymola Behavior.
    You have created a logical reference (component) with a Dymola behavior inside it.

    For more information, see the corresponding documentation in Functional & Logical Design User´s Guide: Managing Behaviors in Functions and Logical Components.

  3. In the Dymola behavior, create a package that is to be the target for the Modelica representation of the mechanism:
    1. In the tree, expand the logical reference you created and double-click the node MainModel .

      The MainModel represents the Dymola behavior.

      The behavior is opened in the Dymola Behavior Modeling app.
    2. From the Behavior Authoring section of the action bar, click New Modelica Class .
    3. In the New Class dialog box, do the following:

      1. In the Name box enter, for this scenario, MyGeneratedModels.
      2. From the Class type list, select the Package type.
      3. Make sure that the Insert in dialog box displays MainModel, otherwise select this model from the Package Browser.
      4. Click Ok to validate the selections.

    4. To leave the Dymola Behavior Modeling app, from the action bar, click Exit App .
    You have created the empty target package MyGeneratedModels in the Dymola behavior. You can see it under MainModel in the tree.

    For more information, see Create a New Class or Extend from an Existing Class Using the New Class Command.

  4. Create the scripting function:

    From the Compass, click 3D Modeling Apps > Roles and Apps > My 3D Modeling apps > Engineering Rules Capture

  5. From the action bar, click Action . For more information about actions, see Engineering Rules Capture Users Guide: Working with Actions: Creating an Action.
  6. Create a script with two arguments corresponding to the target Modelica package and the source mechanism. In the Action Editor, do the following:
    1. In the Argument list:

      • Right-click <Add new argument> and select Add new argument.
        Tip: You can also double-click <Add new argument>.
      • Type MyTargetPackage.
      • Click the corresponding Type box.
      • From the list, double-click ModelicaPackage

    2. Create a second argument MySourceMechanism of type Feature in the same way as the first argument.
    3. Click the text pane to enter it and press Enter to go to a new line.
    4. Create the text in the script:

      • Type MyTargetModelicaPackage. and wait for the list of available methods to appear.
      • From the list, double-click GenerateBehaviorModelFromMechanism.
      • Enter a left bracket.

        A tooltip with an argument list appears.

      • Type MySourceMechanism,"MyGeneratedCylinder").

      The script is complete. MyGeneratedCylinder is the name you select for the model to be generated in the Modelica target package, to be consistent with the task above.
      Note: If you want to take into account any motors defined in the physical mechanism, enter instead MySourceMechanism,"MyGeneratedCylinder",true)

      The script is now

      MyTargetModelicaPackage.GenerateBehaviorModelFromMechanism(MySourceMechanism,"MyGeneratedCylinder")

    5. Click OK.
    In the tree, under the Relations.1 node, the action is displayed with an icon .
  7. In the tree, under the Relations.1 node, right-click Action.1 and select Action.1 object > Run.
  8. From the Insert Object dialog box, specify the arguments and run the script:
    1. In the tree, click MyGeneratedModels to specify the target Modelica package for the generation.
    2. In the tree, under the Physical node, click the mechanism representation of the mechanism to be used in the generation.

      Important: You must click the mechanism representation.

    3. Click OK.
    The script is executed with the result corresponding to the result of Step 13 in the task above, except that the model is generated inside a behavior.
  9. Leave the Engineering Rules Capture app:

    From the Compass, click 3D Modeling Apps > Roles and Apps > My 3D Modeling apps > Functional & Logical Design.

  10. Test the generated model. For more information, see Testing the Generated Model.

Managing Masses and Inertia

You can manage the masses and inertia of the 3D parts.

  1. To analyze the masses and inertia of the 3D parts, do the following:
    1. In the tree, double-click the root node of the physical product to select it.
      An example of selection:

    2. From the Tools section of the action bar, click B.I. Essentials .
    3. In the B.I. Essentials dialog box, select Weight Definition.
      • The result or the analysis appears in the B.I. Essentials dialog box.
      • An information message appears displaying links.

      For more information about weight definition, see Weight Analysis Users´s Guide: Defining Weight: Launching Weight Definition.

  2. Compute the masses and inertia of the 3D parts.

    Tip: Do not select this option if you have manually entered all masses and inertia in the 3D model.

    1. In the information message, click Click this hyperlink to update the weight of this element considering each child weight declared in the system.
    2. In the weight attributes table, click Update to perform a heavy update.

      For more information about the weight attributes table and the corresponding commands, see Weight Analysis Users´s Guide: Defining Weight: About Defining Weight: About the Weight Attributes Table.

      • The masses and inertia are updated.
      • An information message appears displaying links.
    3. Optional: To replace computed by declared weight for a part, you can select different 3D parts and click the link Click this hyperlink to replace computed by declared weight.
  3. Close the B.I. Essentials dialog box.
  4. Leave the B.I. Essentials app:

    From the Compass, click 3D Modeling Apps > Roles and Apps > My 3D Modeling apps > Mechanical Systems Design

The mechanism is open and the masses and inertia of the 3D parts are computed.