MV-1090: Creating a Dataset Using MDL

In this tutorial, you will learn to create a dataset to specify the start time, mid time, end time, and the force magnitude, include dataset definition in the analysis definition, and vary the magnitude and time of the impulse torque.

Sometimes, you will find it convenient to provide inputs or change the design variables of a model through a single interface. Having a dataset enables such a modeling scenario. A dataset is a collection of user-defined variables whose values are used or referred by another entity within MDL. Datasets are either created using the MDL language or the graphical user interface. This exercise will focus on creating a dataset using MDL. A dataset is defined using a *DefineDataSet() - *EndDefine() block, which is similar to other definition based entities such as Systems and Analyses. The definition is then instantiated using the *DataSet() statement.

Create a Dataset Definition

In this step you will create a dataset definition.

Refer to the MDL Language Reference online help for the correct syntax for the MDL statements you choose to use.

  1. In a text editor, create a new document.
  2. Create a *DefineDataSet() and *EndDefine() block. You will create data members belonging to the dataset between these statements.
    You need the following data members in the dataset:
    • Starting time
    • Mid time
    • End time
    • Force magnitude
    You can use the *Real() statement to define each data member, since they are all real numbers.
    Note: You can also define other types of members such as: integers, strings, options, or a file (as applicable to your model).
  3. Use one *Real() statement to define each data member.
    Your file should look like the example below:
     *Real(start_time, "Starting Time")
     *Real(mid_time, "Mid Time") 
     *Real(end_time, "End Time")
     *Real(force_magnitude, "Force Magnitude")
  4. Save the file in your <working directory> as dataset.mdl.

Include the Dataset in the Analysis Definition

In this step you will use the *Include() statement to add the dataset to the analysis definition and instantiate. You will include the dataset entities in the expression for torque.

  1. In a text editor, open the analysis definition you created in MV-1080: Create an Analysis Using MDL.
  2. Use the *Include() statement before the *DefineAnalysis() statement to include the dataset:
  3. Use the *DataSet() statement to instantiate the dataset definition. Place the statement within the *DefineAnalysis() block and after the *Attachment() statement.
    *DataSet(ds_force, "Force Data", ds_def_force)
    The syntax for the dataset is shown in the following:
    *DataSet(ds_name, "ds_label", ds_def, [optional arguments])
    • ds_name The variable name of the dataset.
    • ds_label The label of the dataset.
    • ds_def The variable name of the existing dataset definition.
    • optional arguments Arguments that are passed as attachments (if any).
  4. Use the *SetReal() statement (placed after the *DataSet() statement) to set the default values of the data members in the dataset:
    *SetReal(ds_force.start_time, 0.3) 
    *SetReal(ds_force.mid_time, 0.31)
    *SetReal(ds_force.end_time, 0.32) 
    *SetReal(ds_force.force_magnitude, 10)
    The syntax for the *SetReal() statement is shown in the following:
    *SetReal(real_name, real_value)
    • real_name The variable name of the data member for which the value is being set.
    • real_value The value of the data member.
    As the data members are part of a dataset, the correct form of referring the variable name of the real entity is ds_name.real_name.
  5. Change the appropriate values in the *SetForce() statement by incorporating the dataset members.
    Prior to your edits, the statement looks like this:

    *SetForce( force_1, EXPR, `step(TIME,.3,0,.31,10) +step(TIME,.31,0,.32,-10)`)

    The idea is to use the dot operator to browse through the model hierarchy and access the dataset values. This is illustrated in the following:
    *SetForce(force_1, EXPR, `step(TIME, {ds_force.start_time.value}, 0,
        {ds_force.force_magnitude.value}) + step(TIME,
        {ds_force.mid_time.value}, 0, {ds_force.end_time.value}, -

    The expressions in the curly brackets ({}) are processed by Templex in MotionView and are evaluated to the appropriate values defined in the dataset.

    The analysis definition should look like the example in the following:
    *DefineAnalysis( def_ana_0,j_att )
     *Attachment(j_att, "Joint Attachment", Joint, "Select joint to apply
    *DataSet(ds_force, "Force Data", ds_def_force)
    *SetReal(ds_force.start_time, 0.3)
    *SetReal(ds_force.mid_time, 0.31)
    *SetReal(ds_force.end_time, 0.32)
    *SetReal(ds_force.force_magnitude, 10)
    *ActionReactionForce( force_1, "Torque", ROT, j_att.b1, j_att.b2,
    j_att.origin, Global_Frame )
    *SetForce(force_1, EXPR, `step(TIME, {ds_force.start_time.value}, 0,
    {ds_force.mid_time.value}, {ds_force.force_magnitude.value}) +
    step(TIME, {ds_force.mid_time.value}, 0, {ds_force.end_time.value}, -
    *Output( o_force, "Input Torque", FORCE, FORCE, force_1, Global_Frame)
  6. Save the new analysis definition file as analysis_dataset.mdl.

Change the Dataset Parameters and Run the Analysis

In this step you will change the dataset parameters and run an analysis with MotionSolve.

  1. In MotionView, load the triple pendulum model you created in MV-1080: Create an Analysis Using MDL.
  2. Delete any existing analysis.
    1. In the Project Browser, right-click on the Analysis.
    2. In the context menu, click Delete.
  3. In the Project Browser, click Model.
  4. In the Systems/Assembly panel, click the Import/Export tab.
  5. Import the new analysis definition file (analysis.dataset.mdl).
    Note: Select the Analysis definition type as shown in the figure below.

    Figure 1.
  6. In the Project Browser, expand the Datasets folder and click Force Data.

    Figure 2.
  7. In the dataset panel, change the Starting Time to 0.5, the Mid Time to 0.55, the End Time to 0.6, and the Force Magnitude to 15.
  8. Solve the model.
  9. Compare the Input Torque in the plot window with that of the analysis you did in MV-1080: Create an Analysis Using MDL.
    Now you can easily chang ethe force parameters through the dataset graphical user interface and re-run your analysis.
  10. Save your model as triplependulum_dataset.mdl.