Model Element |
|||||||||||||||||||||||||||||||
Class NameDiff Description |
|||||||||||||||||||||||||||||||
Diff defines a single, first order, user-defined differential equation in MotionSolve. For additional information on the definition of DIFF, please see Control_Diff. The Diff may be defined in the three different ways:
|
|||||||||||||||||||||||||||||||
Attribute Summary
Usage |
|||||||||||||||||||||||||||||||
# Defined in a MotionSolve expression Diff (function=expressionString, optional_attributes)
# Defined in a compiled user-subroutine Diff (function=userString, routine=string optional_attributes)
# Defined in a Python function Diff (function=userString, routine=functionPointer optional_attributes) |
|||||||||||||||||||||||||||||||
Attribute Description |
|||||||||||||||||||||||||||||||
Defined as a MotionSolve expression |
|||||||||||||||||||||||||||||||
function |
String A MotionSolve expression defining the Diff. The function attribute is mandatory |
||||||||||||||||||||||||||||||
Defined as a user-subroutine in a compiled DLL |
|||||||||||||||||||||||||||||||
function |
String defining a valid user function MotionSolve expression The list of parameters that are passed from the data file to the user defined subroutine where the Variable is defined. The function attribute is mandatory. |
||||||||||||||||||||||||||||||
routine |
String Specifies an alternative name for the user subroutine. The name consists of two pieces of information, separated by “∷”. The first is the pathname to the shared library containing the function that computes the response of the user-defined Variable. The second is the name of the function in the shared library that does the computation. An example is: routine=”/staff/Altair/engine.dll∷myDiff”
The attribute routine is optional. When not specified, routine defaults to DIFSUB. |
||||||||||||||||||||||||||||||
Defined as a user-subroutine in a Python script |
|||||||||||||||||||||||||||||||
function |
String defining a valid user function MotionSolve expression The list of parameters that are passed from the data file to the user defined subroutine where the Variable is defined. The function attribute is mandatory. |
||||||||||||||||||||||||||||||
routine |
Pointer to a callable function in Python An example is: routine=myDiff
The attribute routine is optional. When not specified, routine defaults to DIFSUB. |
||||||||||||||||||||||||||||||
Optional attributes – Available to all variants |
|||||||||||||||||||||||||||||||
id |
Integer Specifies the element identification number. This number must be unique among all the Diff objects in the model. This attribute is optional. MotionSolve will automatically create an ID when one is not specified. Range of values: id > 0 |
||||||||||||||||||||||||||||||
label |
String Specifies the name of the Diff object. This attribute is optional. When not specified, MotionSolve will create a label for you. |
||||||||||||||||||||||||||||||
ic |
Double or list of two doubles Specifies the initial conditions associated the differential equation. For explicit differential equations only one value is needed. For implicit differential equations, two values must be specified. The first value defines the initial condition for the dynamic state.
The second value defines the initial condition for the time derivative of the dynamic state.
This attribute is optional. |
||||||||||||||||||||||||||||||
static hold |
Boolean Specifies whether the value of the dynamic state is kept fixed or not during static equilibrium and quasi-static solutions.
If not specified, it defaults to FALSE. This attribute is optional. |
||||||||||||||||||||||||||||||
implicit |
Boolean Specifies whether the derivative of the state is implicitly defined by the differential equation or not.
If not specified, IMPLICIT defaults to FALSE. |
||||||||||||||||||||||||||||||
active |
Bool Select one from True or False.
The attribute active is optional. When not specified, active defaults to True |
||||||||||||||||||||||||||||||
Comments
|
|||||||||||||||||||||||||||||||
Example
|
|||||||||||||||||||||||||||||||
d1 = Diff (id=1, label=”vdot=(Cv–Kx)/m”, function=”-200*DIF(1)-2E4*DIF(2)”, ic=0.0) d2 = Diff (id=2, label=”xdot=v”, function=”DIF(1)”, ic=0.2) |
|||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||
def springMassDamper (id, time, par, npar, dflag, iflag)
v = DIF(1) x = DIF(2)
if iflag: return 0.0
if id == 1: M = par[0] C = par[1] K = par[2] return (-C*v–K*x)/M
else: return v
################################################################################ # Model definition # ################################################################################
# Force balance equation d1 = Diff (id=1, function=”user(0.5, 1E2, 1E4)”, ic=0, label=”vdot=(-Cv–Kx)/m”, routine = springMassDamper)
# Differential equation for displacement equation d2 = Diff (id=2, function=”user(0)”, ic=0.2, label=”xdot=v”, routine= springMassDamper) |