Sweeping Parameters

To get an intuitive knowledge of the behavior of a model, you can vary the model parameters by sweeping them and analyze the result.

In these scenarios, you sweep one parameter and two parameters.

This task shows you how to:

Sweep One Parameter

You can sweep one parameter, and display the result as trajectories or last points.

In this scenario, you work with the model example Coupled Clutches and sweep the parameter J1.J and plot the trajectories and last points of the parameters J1.w and J2.w.

Before you begin:

Open the model example Coupled Clutches and simulate it.

  1. To select the parameter J1.J to sweep, drag it, from the Variable Browser, into the Parameters to sweep section of the Sweep Parameters immersive panel.
  2. To generate an equidistant grid for the sweep of J1.J, click the corresponding and, in the dialog box that appears:
    1. In the Minimum value field, enter 0.5
    2. In the Maximum value field, enter 1.5
    3. In the Number of points field, enter 5

    Note: To generate a grid with logarithmic scale (not used in this scenario) you can activate Logarithmic scale.

  3. To select to plot J1.w and J2.w, drag them from the Variable Browser, into the Variables to plot section of the Sweep Parameters immersive panel.
  4. In the panel, select Trajectory and then click Run Sweep.
    • The trajectories of J1.w and J2.w are plotted according to the equidistant grid specified.
      Tip: To change the display unit of a curve, right-click in the diagram and select Options, then select the Item Curve. You now have, in the Unit column, a list of display units for each curve to select from.
    • A Modelica Scripting window appears, displaying the underlying function call of the sweep.
  5. To instead plot the last points, in the panel, select Last Point and then click Run Sweep.
    • The last points of J1.w and J2.w are plotted.
      Tip: To change the display unit of a curve, right-click in the diagram and select Options, then select the Item Curve. You now have, in the Unit column, a list of display units for each curve to select from.
    • In the Modelica Scripting window, the underlying function call of the new sweep is displayed.

Sweep Two Parameters

You can sweep two parameters, and display the result as trajectories or last points.

Note: In this scenario, you extend the previous scenario and sweep the parameters J1.J and J2.J and plot the last points of the parameter J2.w.

Before you begin:

You have performed the previous scenario above.

  1. From the Variable Browser, drag the missing parameter J2.J into the Parameters to sweep section of the Sweep Parameters panel.
  2. In the panel, for J2.J perform Step 3 from the previous task on it, to generate an equidistant grid like for J1.J.

    Tip: You can mark, copy, and paste texts from the fields.

  3. In the panel, for J1.w clear the corresponding check box to deactivate the plotting of it.

    Note: You can also click to remove the parameter from the panel.
    Important: It is not used in this scenario, but note that you can drag the same variable to both sections of the Sweep Parameters panel if you need to.

  4. In the panel, select Last Point and then click Run Sweep.
    The last points of J2.w given the combinations J1.J and J2.J are calculated. The Modelica Scripting window displays:
    • The underlying function call of the sweep.
    • The generated numerical results of the sweep.
      Tip: You can copy these values to use them in a third-party tool.
      Note: Scatter plot is used to generate the numerical result.

Sweep More Than Two Parameters

You can sweep more than two parameters, and display the result as last points.

Note: In this scenario, you extend the previous scenario and sweep the parameters J1.J, J2.J, and J3.J and plot the last points of the parameter J3.w.

Before you begin:

You have performed the previous scenario above.

  1. From the Variable Browser, drag the missing parameter J3.J into the Parameters to sweep section of the Sweep Parameters panel.
  2. In the panel, for J3.J perform Step 3 from the first task above on it, to generate an equidistant grid like for J1.J.

    Tip: You can mark, copy, and paste texts from the fields.

  3. In the panel, for J2.w clear the corresponding check box to deactivate the plotting of it.

    Note: You can also click to remove the parameter from the panel.
    Important: It is not used in this scenario, but note that you can drag the same variable to both sections of the Sweep Parameters panel if you need to.

  4. In the panel, select Last Point and then click Run Sweep.
    The last points of J3.w given the combinations J1.J, J2.J, and J3.J are calculated. The Modelica Scripting window displays:
    • The underlying function call of the sweep.
    • The generated numerical results of the sweep.
      Tip: You can copy these values to use them in a third-party tool.
      Note: Scatter plot is used to generate the numerical result.