MV-7000: Model Differential Equations Using MotionView and MotionSolve

In this tutorial, you will build a model and apply solver variables and differential equations before running the model.

Differential equations are very versatile and have many different applications in modeling multibody systems. User-defined dynamic states are commonly used to create low pass filters, apply time lags to signals, model simple feedback loops, and integrate signals. The signal may be used to:
  • define forces.
  • used as independent variables for interpolating through splines or curves.
  • used as input signals for generic control modeling elements.
  • define program output signals.

The MotionSolve expressions and user-subroutines allow you to define fairly complex user-defined dynamic states.

The expression type is used when the algorithm defining the differential equation is simple enough to be expressed as a simple formula. In many situations, the dynamic state is governed by substantial logic and data manipulation. In such cases, it is preferable to use a programming language to define the value of a differential equation. The user-defined subroutine, DIFSUB, allows you to accomplish this.

Build and Analyze a Simplified Model

In the following exercise, you will build and analyze a simplified model of a pressure vessel blown down using MotionView and MotionSolve. The following steps outline the process.

  1. Specify the following parameters (state variables) as solver variables:
    k = 1.4 A = 0.047 V = 18.3 C p R = 3.5
  2. Model the following differential equations:
    (1) P ˙ T P T + C P R T ˙ T T T =0 (2) P ˙ T P T T ˙ T T T m ˙ T m T =0 (3) m ˙ T =A k m T P T V ( 2 k+1 ) k+1 2( k1 )

    The three states of the system are PT, TT and mT.

  3. Specify the initial conditions for the system as:
    P T ( 0 ) = 2000 T T ( 0 ) = 560 m ( 0 ) = 2.5602 e 04 P ˙ T = 5.8875 e + 04 T ˙ T = 4.7100 e + 03 m ˙ = 0.0054
  4. Run the model in MotionSolve and post-process the results in HyperGraph.

Add a Solver Variable

A solver variable defines an explicit, algebraic state in MotionSolve. The algebraic state may be a function of the state of the system or any other solver variables that are defined. Recursive or implicit definitions are not allowed at this time.

Two types of solver variables are available. The first, and probably the most convenient, is the expression valued variable. The second is the user-subroutine valued variable.

The expression method is used when the algorithm defining the algebraic state is simple. In many situations, the algebraic state is governed by substantial logic and data manipulation. In those cases, it is preferable to use a programming language to define the value of a solver variable. The user-defined subroutine, VARSUB, enables you to do this.

Solver variables are quite versatile and have many different applications in modeling multibody systems. They are commonly used to create signals of interest in the simulation. The signal may then be used to define forces, independent variables for interpolation, inputs to generic control elements, and output signals.

MotionSolve expressions and user-subroutines allow for fairly complex algebraic states to be defined.

For more information, please refer to the MotionView and MotionSolve User's Guides in the online help.

  1. Launch a new session of MotionView.
  2. From the Project Browser, right-click Model and select Add > Control Entity > Solver Variable (or right-click Solver Variables from the toolbar).
    The Add Solver Variable dialog is displayed.
  3. In the Label field, assign the label K to the solver variable.
  4. In the Variable field, assign a variable name to the solver variable or leave the default name.
  5. Click OK.


    Figure 1.
  6. From the Properties tab, under Type, select Linear and enter a value of 1.4 in the field.


    Figure 2.
  7. Repeat steps 1 through 6 to create the three remaining solver variables:
    (4) A=0.047 V=18.3 C p R =3.5

Model Differential Equations

  1. From the Project Browser, right-click Model and select Add General MDL Entity > Solver Differential Equation (or right-click Solver Differential Equation, t from the toolbar.
    The Add SolverDiff dialog is displayed.
  2. In the Label field, assign a label to the solver diff or leave the default label.
  3. In the Variable field, assign a variable name to the solver diff or leave the default name.
  4. Click Apply twice.
  5. Click OK.
    Three solver differential equations will be created.

Next, you will model the first differential equation:

P ˙ T P T + C p R T ˙ T T T = 0

This is an implicit differential equation that has a constant ( C p R ). The initial condition of the differential equation (IC) and its first derivative (IC dot) are known (given).

  1. Select SolverDiff 0.
  2. From the Properties tab, select Implicit and specify IC and IC dot as 2000 and -58875, respectively.


    Figure 3.
  3. Select the type as Expression.
  4. To access the expression builder, click in the text field and select F(x) from the trio of buttons at the top of the panel.
    This will display the Expression Builder. In this dialog, you can enter expressions in text boxes without extensive typing and memorization. It can be used to construct mathematical expressions.
  5. Populate the expression as shown in the image below:


    Figure 4.
    `-DIF1 ({diff_0.id})/DIF({diff_0.id})+{sv_3.value.lin}*DIF1({diff_1.id})/DIF({diff_1.id})`
  6. Optional: You can use the model tree to access entity variables in your model. As you can see for the above expression, to refer to the ID of the differential equation, browse for it from the list-tree on the Properties tab and select the ID. Click Apply.
    The name of the selected entity or property is inserted into the expression.
  7. Click OK.
    The new expression is displayed in the text box on the panel.
  8. Repeat steps 6 through 12 to modify the remaining two differential equations:
    P ˙ T P T T ˙ T T T m ˙ T m T = 0

    Implicit: Yes

    IC: 560

    IC_dot: -4710

    Value Expression:
    `DIF1({diff_0.id})/DIF({diff_0.id})-DIF1({diff_1.id})/DIF({diff_1.id})-DIF1({diff_2.id})/DIF({diff_2.id})`

    m ˙ T = A k m T P T V ( 2 k + 1 ) k + 1 2 ( k 1 )

    Implicit: No

    IC: 0.000256

    Value Expression:
    `-{sv_1.value.lin} *sqrt(abs({sv_0.value.lin}*DIF({diff_2.id})*DIF({diff_0.id}) /{sv_2.value.lin}))*0.5787`

Run the Model in MotionSolve

  1. Click Run on the toolbar.
    The Run panel is displayed.
  2. Specify the values as shown below:


    Figure 5.
  3. From the Main tab, choose Save and run current model.
  4. Click on the browser icon and specify a filename of your choice.
  5. Click Save.
  6. Click Check Model to check the model.
  7. To run the model, click Run.
    The solver will get invoked here.
  8. Post-process the results using HyperGraph.