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.
*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.
- In a text editor, create a new document.
-
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
Note: You can also define other types of members such as: integers, strings, options, or a file (as applicable to your model). -
Use one *Real() statement to define each data member.
Your file should look like the example below:
*DefineDataSet(ds_def_force) *Real(start_time, "Starting Time") *Real(mid_time, "Mid Time") *Real(end_time, "End Time") *Real(force_magnitude, "Force Magnitude") *EndDefine()
- 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.
- In a text editor, open the analysis definition you created in MV-1080: Create an Analysis Using MDL.
-
Use the *Include() statement before the
*DefineAnalysis() statement to include the dataset:
*Include("dataset.mdl")
-
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).
-
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.
ds_name.real_name
. -
Change the appropriate values in the *SetForce() statement
by incorporating the dataset members.
Prior to your edits, the statement looks like this:
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,.3,0,.31,10) +step(TIME,.31,0,.32,-10)`)
*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}, - {ds_force.force_magnitude.value})`,0,0)
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:*Include("dataset.mdl") *DefineAnalysis( def_ana_0,j_att ) *Attachment(j_att, "Joint Attachment", Joint, "Select joint to apply torque") *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}, - {ds_force.force_magnitude.value})`) *Output( o_force, "Input Torque", FORCE, FORCE, force_1, Global_Frame) *EndDefine()
- 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.
- In MotionView, load the triple pendulum model you created in MV-1080: Create an Analysis Using MDL.
-
Delete any existing analysis.
- In the Project Browser, right-click on the Analysis.
- In the context menu, click Delete.
- In the Project Browser, click Model.
- In the Systems/Assembly panel, click the Import/Export tab.
-
Import the new analysis definition file
(analysis.dataset.mdl).
Note: Select the Analysis definition type as shown in the figure below.
-
In the Project Browser, expand the
Datasets folder and click Force
Data.
- 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.
- Solve the model.
-
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.
- Save your model as triplependulum_dataset.mdl.