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
\(\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.
Create Parametric Value for each values of R, L, K.
Create Cylinder Body, Revolute Joint and Rotational Axial Force step by step.
Create a dummy differential equation.
Name: IDot
Function Type: Explicit
Expression: 1
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>
Change the IDot of expression Ex1 to EX1.
Simulate an Example model.
Check result
Plot > Model Database > DifferentialEq > IDot > DIF, DIF1
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
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}\)
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>
Create two expressions for Variable Equation.
Test1: sin(2*pi*time)
Test2: 2*sin(2*pi*time*0.5)
Create two variable equations.
Create an expression for VE1 add VE2.
Ex3: VARVAL(VE1) + VARVAL(VE2)
Make an expression scope.
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>
Create two expressions for EXPVAL Equation.
Test1: sin(2*pi*time)
Test2: 2*sin(2*pi*time*0.5)
Create an expression using Test1 add Test2 .
Ex3: EXPVAL(Test1) + EXPVAL(Test2)
Verify an expression result used EXPVAL.
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>
Create two expressions for HOLDVAL Equation.
Ex_Condition: STEP(TIME,0.2,0,0.4,1)-STEP(TIME,0.6,0,0.8,1)
Ex_STEP: STEP(TIME,0,0,1,100)
Create an expression using Ex_Condition add Ex_STEP.
Ex_HOLDVAL: HOLDVAL(EXPVAL(Ex_Condition), EXPVAL(Ex_STEP))
Verify an expression result used HOLDVAL (RED) and Ex_STEP (BLUE).
Note
The Scope Expression created from HOLDVAL expression function does not give the result because it cannot be calculated in GUI.