4.7.1.7. Equation

4.7.1.7.1. DIF

The DIF function returns the value of the state variable which is used in a differential equation.

Format

DIF(Diff. Eq.)

Arguments definition

Diff. Eq.

The name of the differential equation entity or argument number

Formulation

\(\begin{aligned} & \dot{\xi }=f(\xi ,x,t)\,\,\,\,\text{(Explicit}\,\,\text{Type)} \\ & 0=f(\xi ,\dot{\xi },x,t)\,\,\,\,\text{(Implicit}\,\,\text{Type)} \\ & \text{(where, }\xi \text{ : the differential equation's state variable, }\,x\,\text{:}\,\text{other state variable)} \\ \end{aligned}\)

Example

DIF(Model1.DE1)
DIF(1) <Argument: (1)Model1.DE1>
../_images/image1754.png

Figure 4.42 Example of using the DIF function

\(\begin{aligned} & V=RI+L\frac{dI}{dt}\,\,\,,\,\,\,Torque=K\cdot I \\ & V=\cos (2t),\,\,R=1,\,\,L=0.08,\,K=6 \\ \end{aligned}\)

An explicit differential equation can be used to create a torque model for the electrical motor described above.

\(\frac{dI}{dt}=\frac{V-RI}{L}\,\text{ (Explicit}\,\text{Type)}\)

To define the explicit differential equation above:

Create a parametric value for each coefficient (R,L,K), and build models for the body, revolute joint, and rotational axial force. The result is derived by running the organized differential equation through the expression and DIF and applying each entity through the Rotational Axial Force model.

  1. Create Parametric Value for each values of R, L, K.

    ../_images/image1765.png
  2. Create Cylinder Body, Revolute Joint and Rotational Axial Force step by step.

    ../_images/image1754.png
  3. Create a dummy differential equation.

    • Name: IDot

    • Function Type: Explicit

    • Expression: 1

      ../_images/image1776.png
  4. Create above two equations as expression.

    • Torque: K*DIF(1) <Argument: (1) IDot>

    • EX1: cos(2*time)/L-R*DIF(1)/L <Argument: (1) IDot>

      ../_images/image1783.png
  5. Change the IDot of expression Ex1 to EX1.

    ../_images/image1795.png
  6. Simulate an Example model.

  7. Check result

    Plot > Model Database > DifferentialEq > IDot > DIF, DIF1

    ../_images/image1805.png ../_images/image1816.png

4.7.1.7.2. DIF1

The DIF1 function returns the time derivative of the state variable which is used in a differential equation.

Format

DIF1(Diff. Eq.)

Arguments definition

Diff. Eq.

The name of the differential equation entity or argument number

Formulation

\(\begin{aligned} & \dot{\xi }=f(\xi ,x,t)\,\,\,\,\text{(Explicit}\,\,\text{Type)} \\ & 0=f(\xi ,\dot{\xi },x,t)\,\,\,\,\text{(Implicit}\,\,\text{Type)} \\ & \text{(where, }\xi \text{ : the differential equation's state variable, }\,x\,\text{:}\,\text{other state variable)} \\ \end{aligned}\)

Example

DIF1(Model1.DE1)
DIF1(1) <Argument: (1)Model1.DE1>

The following is a comparison of the DIF and DIF1 functions on F(t)= 2t through the expression scope:

\(\begin{aligned} & \text{DIF}\,\,\,\text{(}f(t)\text{)}=\int{2t\,\,dt}={{t}^{2}} \\ & \text{DIF1(}f(t)\text{)}=\frac{d}{dt}\int{2t\,\,dt}=2t \\ \end{aligned}\)

../_images/image1835.png

4.7.1.7.3. VARVAL

The VARVAL function returns the result of a variable equation and enables an expression to use the calculation derived from a variable equation entity.

Format

VARVAL(Variable Eq.)

Arguments definition

Variable Eq.

The name or argument number for the variable equation entity

Example

VARVAL(Model1.DE1)

VARVAL(1) <Argument: (1)DE1>

  1. Create two expressions for Variable Equation.

    • Test1: sin(2*pi*time)

    • Test2: 2*sin(2*pi*time*0.5)

      ../_images/image1856.png
  2. Create two variable equations.

    ../_images/image1867.png ../_images/image1875.png
  3. Create an expression for VE1 add VE2.

    • Ex3: VARVAL(VE1) + VARVAL(VE2)

      ../_images/image1887.png
  4. Make an expression scope.

    ../_images/image1895.png

    Figure 4.43 Scope result using the VARVAL function

4.7.1.7.4. EXPVAL

The EXPVAL function returns the result of an expression equation and enables an expression to use the calculation value derived from another expression equation entity.

Format

EXPVAL(Expression Eq.)

Arguments definition

Expression Eq.

The name or argument number for the expression equation entity

Example

EXPVAL(Model1.Expression1)

EXPVAL(1) <Argument: (1)Expression1>

  1. Create two expressions for EXPVAL Equation.

    • Test1: sin(2*pi*time)

    • Test2: 2*sin(2*pi*time*0.5)

      ../_images/image1918.png
  2. Create an expression using Test1 add Test2 .

    • Ex3: EXPVAL(Test1) + EXPVAL(Test2)

      ../_images/image1935.png
  3. Verify an expression result used EXPVAL.

    ../_images/image1946.png

    Figure 4.44 Expression result using the EXPVAL function

4.7.1.7.5. HOLDVAL

The HOLDVAL function returns the result of a held equation under nonzero condition. Once held, the value is not changed.

Format

HOLDVAL(c1, f1)

Arguments definition

c1


Defines the equation that provides the conditions under which to derive the value of the holding expression equation.
0: release condition
non zero: holding condition (Use the “IF(c1: 1, 0, 1)” expression internally)

f1

Defines the holding expression equation.

Example

HOLDVAL(Model1.Expression1, Model1.Expression2)

HOLDVAL(EXPVAL(1), EXPVAL(2)) <Argument: (1)Expression1, (2)Expression2>

  1. Create two expressions for HOLDVAL Equation.

    • Ex_Condition: STEP(TIME,0.2,0,0.4,1)-STEP(TIME,0.6,0,0.8,1)

    ../_images/imageHoldVal_Condition.png
    • Ex_STEP: STEP(TIME,0,0,1,100)

  2. Create an expression using Ex_Condition add Ex_STEP.

    • Ex_HOLDVAL: HOLDVAL(EXPVAL(Ex_Condition), EXPVAL(Ex_STEP))

  3. Verify an expression result used HOLDVAL (RED) and Ex_STEP (BLUE).

    ../_images/imageHoldVal_Results.png

    Figure 4.45 Expression result using the HOLDVAL function

Note

The Scope Expression created from HOLDVAL expression function does not give the result because it cannot be calculated in GUI.