ObjectGenericODE1

A system of \(n\) ODE1, having a system matrix, a rhs vector, but mostly it will use a user function to describe special ODE1 systems. It is based on NodeGenericODE1 nodes. NOTE that all matrices, vectors, etc. must have the same dimensions \(n\) or \((n \times n)\), or they must be empty \((0 \times 0)\), using [] in Python.

Interface

  • Nodes: see the detailed description

Parameters

The parameters of the item; in a dictionary, its type is ‘GenericODE1’:

name

type

size

default

description

name

String

‘’

objects’s unique name

nodeNumbers

ArrayNodeIndex

[]

(symbol: \(\mathbf{n}_n = [n_0,\,\ldots,\,n_n]\tp\)) node numbers which provide the coordinates for the object (consecutively as provided in this list)

systemMatrix

NumpyMatrix

[]

(symbol: \(\Am \in \Rcal^{n \times n}\)) system matrix (state space matrix) of first order ODE

rhsVector

NumpyVector

[]

(symbol: \(\fv \in \Rcal^{n}\)) a constant rhs vector (e.g., for constant input)

rhsUserFunction

ObjectGenericODE1RhsUserFunction

0

(symbol: \(\fv_{user} \in \Rcal^{n}\)) A Python user function which computes the right-hand-side (rhs) of the first order ODE; see description below

coordinateIndexPerNode

ArrayIndex

[]

this list contains the local coordinate index for every node, which is needed, e.g., for markers; the list is generated automatically every time parameters have been changed

tempCoordinates

NumpyVector

[]

(symbol: \(\cv_{temp} \in \Rcal^{n}\)) temporary vector containing coordinates

tempCoordinates_t

NumpyVector

[]

(symbol: \(\dot \cv_{temp} \in \Rcal^{n}\)) temporary vector containing velocity coordinates

visualization

VObjectGenericODE1

parameters for visualization of item

Visualization parameters

VObjectGenericODE1 has no parameters.

Drawing

The item draws nothing.

Output variables

Available as OutputVariableType in sensors, Get...Output() and other functions:

output variable

symbol

description

CoordinatesTotal

all ODE2 displacement plus reference coordinates of object

Coordinates

all ODE1 coordinates

Coordinates_t

all ODE1 velocity coordinates

Detailed description

Coordinates

An object with node numbers \([n_0,\,\ldots,\,n_n]\) and according numbers of nodal coordinates \([n_{c_0},\,\ldots,\,n_{c_n}]\), the total number of equations (=coordinates) of the object is

\[ n = \sum_{i} n_{c_i}, \]

which is used throughout the description of this object.

Equations of motion

(64)\[ \dot \qv = \fv + \fv_{user}(mbs, t, i_N, \qv) \]

Note that the user function \(\fv_{user}(mbs, t, i_N, \qv)\) may be empty (=0), and that iN represents the itemNumber (=objectNumber).

CoordinateLoads are added for the respective ODE1 coordinate on the RHS of the latter equation.

Marker interfaces

The object is no body: markers act on its coordinates only, MarkerNodeODE1Coordinate on a coordinate of one of its nodes, e.g. for a LoadCoordinate - which adds to the right-hand side of that coordinate’s equation - or a coupling to a mechanical system in a user function.

Example:

A = numpy.diag([200,100])
#simple linear user function returning A*q + const
def UFrhs(mbs, t, itemNumber, q):
    return np.dot(A, q) + np.array([0,2])

nODE1 = mbs.AddNode(NodeGenericODE1(referenceCoordinates=[0,0],
                                    initialCoordinates=[1,0], numberOfODE1Coordinates=2))

#now add object instead of object in mini-example:
oGenericODE1 = mbs.AddObject(ObjectGenericODE1(nodeNumbers=[nODE1],
                   rhsUserFunction=UFrhs))

Userfunction: rhsUserFunction(mbs, t, itemNumber, q) A user function, which computes a RHS vector depending on current time and states of the object. Can be used to create any kind of first order system, especially state space equations (inputs are added via CoordinateLoads to every node). Note that itemNumber represents the index of the ObjectGenericODE1 object in mbs, which can be used to retrieve additional data from the object through mbs.GetObjectParameter(itemNumber, ...), see the according description of GetObjectParameter.

arguments / return

type or size

description

mbs

MainSystem

provides MainSystem mbs to which object belongs

t

Real

current time in mbs

itemNumber

Index

integer number \(i_N\) of the object in mbs, allowing easy access to all object data via mbs.GetObjectParameter(itemNumber, …)

q

Vector \(\in \Rcal^n\)

object coordinates (composed from ODE1 nodal coordinates) in current configuration, without reference values

return value

Vector \(\in \Rcal^{n}\)

returns force vector for object

Mini example

#set up a 2-DOF system
nODE1 = mbs.AddNode(NodeGenericODE1(referenceCoordinates=[0,0],
                                    initialCoordinates=[1,0],
                                    numberOfODE1Coordinates=2))

#build system matrix and force vector
#undamped mechanical system with m=1, K=100, f=1
A = np.array([[0,1],
              [-100,0]])
b = np.array([0,1])

oGenericODE1 = mbs.AddObject(ObjectGenericODE1(nodeNumbers=[nODE1], 
                                               systemMatrix=A, 
                                               rhsVector=b))

#assemble and solve system for default parameters
mbs.Assemble()

sims=exu.SimulationSettings()
solverType = exu.DynamicSolverType.RK44
mbs.SolveDynamic(solverType=solverType, simulationSettings=sims)

#check result at default integration time
exu.sys['testResult'] = mbs.GetNodeOutput(nODE1, exu.OutputVariableType.Coordinates)[0]

Relevant Examples (Ex) and TestModels (TM) with weblink to github: HydraulicsUserFunction.py (Ex), lugreFrictionODE1.py (Ex), lugreFrictionTest.py (Ex), genericODE1duplicateNodeTest.py (TM), solverExplicitODE1ODE2test.py (TM), taskmanagerTest.py (TM)