Comparing Simulated Models

You can compare simulations of evolutions of the same model or simulations of different models. This can help you to analyze the effect of model alternatives on system performance.

The comparison

  • Focuses on model architecture changes (components added, removed, or replaced) and parameter changes.
  • Is done based on computed results, meaning that comparison can be done after the model definition has been modified. This makes it possible to compare several simulated alternatives of the same model.

In this scenario you work with three alternatives of a copy of the Modelica model Coupled Clutches:

  • The original model duplicated to a new class to be able to later change it.
  • An alternative with the the component J4 deleted and the parameter J1.J changed from 1 to 2.
  • An alternative where also the class of the component clutch3 is exchanged to another class.

This task shows you how to:

Compare Two Alternatives of a Model

In this task you compare the two first alternatives of a model according to the description above.

Note: Two alternatives of the model are created and simulated, and the simulations are compared in the task. The model alternatives are not saved in this task, however.

Before you begin: Create an editable copy of the model example Coupled Clutches according to Creating an Editable Copy of a Model Example in a New Library.
  1. Simulate the model.

    For more information, see Simulating a Behavior.

  2. From the Variable Browser, right-click any node or signal and select Add to Results Manager .
    The Results Manager appears, containing the content of the Variable Browser for the currently simulated model.
  3. Perform the following changes in the model:
    1. In the diagram, right-click the component J4 and select Delete.
      The component is deleted.
    2. Change the parameter J in the component J1 from 1 to 2 the following way:

      1. In the diagram, right-click the component J1 and select Edit Component Parameters.
      2. Change the value of the parameter J from 1 to 2.

  4. Simulate the model.
  5. From the current Variable Browser, right-click any node or signal and select Add to Results Manager .
    The following is the result:
    • The content of the current Variable Browser is added to the Results Manager in the following way, looking at the columns of the Results Manager.
      • The column Variable Name contains the variables that are present in any of the Variable Browsers added.
      • After the column Variable Name, one column of values is added for each of the two Variable Browsers added, with the name of the Variable Browser added.
      • The Unit column and the Description contain the units and the description of the variables in the Variable Name column.
    • The simulations of the two alternatives of the model are compared, and the result is displayed in the following way:
      • Changed variable values give the following indications:
        • A variable value that has been changed (for example, by the user) between the simulations is marked by an solid orange line in front of the value, in all models.
        • For the parent nodes of this variable, the corresponding value cells are indicated by solid orange lines, to make it easy to identify deeply buried value differences from any level of the variable tree.
        • Variables that are impacted by the changed variable (that is, they get different values in the simulations since they depend on the variable that has been changed) are also indicated by dashed orange lines.
        • For the parent nodes of impacted variables, the corresponding value cells are also indicated by dashed orange lines.
          Note: If the parent node also contains any values that has been changed (for example, by the user), this takes precedence, and the marking is a solid orange line.

        In this scenario, for example, this results in:

        • The value field of J1.J (the value you changed) is marked a solid orange line in all models.
        • The parent field of J1 is marked with a dashed orange line in all models.
        • The variables J1.der(w) and J1.a are impacted by the change of J1.J, so the corresponding value filed are marked with a dashed orange lines in all models.
        • Some variables in the components clutch1, J3, clutch3, and J4 are also impacted by the change of J1.J, the value fields of these variables, and the corresponding parents, are also marked with dashed orange lines, in all models.

      • If a component exists in a simulated model but does not exist in other simulated models, then the corresponding node and underlying components and variables in the columns for the simulations are colored green where the component exists, red where the component does not exist. All corresponding cells in the Variable Name column are colored yellow to indicate a structure change - see last item in this list.

        In this scenario, the component J4 and underlying variables are marked green for the first simulation, red for the second one. The corresponding cells in the Variable Name column are yellow.

      • If a variable exists in a simulated model but does not exist in other simulated models, then the corresponding cell in the columns for simulations are colored green where the variable exists, red where the variable does not exist. The cells of the node containing this variable are colored yellow to indicate a structure change - see last item in this list. All corresponding cells in the Variable Name column are colored yellow to indicate a structure change - see last item in this list.

        For an example in this scenario, see next task.

      • If the structure of a component is changed in any way, the corresponding cells in the Variable Name column are colored yellow.

        In this scenario, the cells of the node J4 are marked yellow in the Variable Name column.

Add a Third Model Alternative to the Comparison

In this task you create and add a third alternative of the model to the comparison.

Note: A third alternative of the model is created and simulated, and the simulation is compared to the previous ones. The model alternative is not saved in this task, however.

Before you begin: Do the previous task.
  1. Exchange the class of the component step2 with the class Modelica.Blocks.Sources.Sine.

    For more information, see Exchanging a Component Class.

  2. Simulate the model.
  3. From the current Variable Browser, right-click any node or signal and select Add to Results Manager .
    The following is the result:
    • The new simulation is added as the fourth column in the Results Manager.
    • The simulations of the three alternatives of the model are compared and the differences highlighted according to the last step of the previous task. Adding this last simulation to the comparison results in the following additional highlighting for step2:
      • The node is marked yellow both in the Variable Name column and the columns of simulations to indicate a structure change.
      • All variables are marked yellow in the Variable Name column to indicate structure changes.
      • The variable cells for variables existing in a simulation but not in others are marked green in the simulations where they exist, red where they do not.

Filter, Sort, and Plot the Compared Simulations

You can filter, sort and plot the compared simulations in the Results Manager. You can also remove simulations from the Results Manager by deleting the corresponding columns. Finally you can replay animation from the context menu of signals.

Before you begin: Do the previous tasks.
  1. To only see the parts of the simulations that are different, you can filter out all parts of the simulations that are not changed. To do this, do the following:
    1. In the upper corner of the Results Manager, click Show/hide advanced filtering preferences.
      Filtering preferences appear.
    2. Clear Show Lines with No Differences.
      Only the parts of the simulations that are different are displayed in the Results Manager.

    Tip: You can perform a number of other filtering, sorting, etc. in the Results Manager, like in the Variable Browser. For more information, see relevant sections in Working with the Variable Browser.

  2. To plot all simulations of a variable, right-click the variable and select Plot, and then the plot you want to add the signal in, or a new plot.

    Tip: You can select several signals by keeping Ctrl pressed when selecting the signals.

  3. To compare only the first and the last model alternative in this scenario, right-click the column of the second simulation and select Remove this column.
    Only the first and the last simulations are compared.
  4. To replay animation, right-click a signal and select Replay Animation.

    For more information about this command, see Replaying an Animation.

    Note: If you replay the animation, you must finish the animation by, for example, closing the animation player, to be able to use the context command for plot or replay animation again.