Contents

1 Introduction

2 Legend

IconDescription
<element>A XML element of name 'element'
attrNameA XML attribute of name 'attrName'
namespaceA XML namespace of name 'namespace'
typeA XML element or attribute type of name 'type'

3 Element Name

Elements which must be referable must have a name. Mostly this name is given by the attribute name. A valid name starts with a letter or a underscore. The following characters can be letters, underscores or digits. The content between '{' and '}' can be any Expression Evaluator and is substituted by the result of the evaluator (which must be a valid name; normal a integer number).

The following table shows examples for valid element names (on the left) and the substituted names (on the right), if there exist a scalar (integer) parameter of name n with the value 2:

Element NameSubstituted Element Name
Object1Object1
myname_3myname_3
body{n+6}body8
Obj_{n+4}_{if n==2; ret=3; else ret=6; end}Obj_6_3

4 Types

4.1 Scalar Type

A scalar type can be of any unit defined in measurements. The unit is given by a optional attribute of name unit. The type name of a scalar of measure length is pv:lengthScalar and so on. Where pv is mapped to the namespace-uri http://www.mbsim-env.de/MBXMLUtils.

The content of a scalar type must be a Expression Evaluator. The following examples are valid, if there exist a scalar paremter a and b in the parameter file:

<myScalarElement unit="mm">4*sin(a)+b</myScalarElement>
<myScalarElement>[a,2]*[3;b]</myScalarElement>

There is also a special unit of name unknown defined. This unit dose not take the optional unit attribute, it takes an optional attribute of name convertUnit. The value of this attribute can be a Expression Evaluator which must contain a parameter of name value. The given value is then converted by this expression.

4.2 Vector Type

A vector type can be of any unit defined in measurements. The unit is given by a optional attribute of name unit. The type name of a vector of measure length is pv:lengthVector and so on. Where pv is mapped to the namespace-uri http://www.mbsim-env.de/MBXMLUtils.

The content of a vector type can be one of the following:

For the special unit of name unknown see Scalar Type

4.3 Matrix Type

A matrix type can be of any unit defined in measurements. The unit is given by a optional attribute of name unit. The type name of a matrix of measure length is pv:lengthMatrix and so on. Where pv is mapped to the namespace-uri http://www.mbsim-env.de/MBXMLUtils.

The content of a matrix type can be one of the following:

For the special unit of name unknown see Scalar Type

5 Parameters

A example for a parameter file is given below:

<Parameter xmlns="http://www.mbsim-env.de/MBXMLUtils">
  <scalarParameter name="N">9</scalarParameter>
  <vectorParameter name="a">[1;2;3]*N</scalarParameter>
  <scalarParameter name="lO">0.2*N</scalarParameter>
  <matrixParameter name="A">[1,2;3,4]</scalarParameter>
</Parameter>

The parameter names must be unique. The parameters are added from top to bottom. Parameters may depend on parameters already added. The parameter values can be given as Expression Evaluator. Hence a parameter below another parameter may reference this value.

6 Expression Evaluator

Different expression evaluators can be used. Currently implemented is only octave as evaluator. Hence this section covers only the octave expression evaluator.

A octave expression/program can be arbitary octave code. So it can be a single statement or a statement list.

If it is a single statement, then the value for the XML element is just the value of the evaluated octave statement. The type of this value must match the type of the XML element (scalar, vector or matrix). The following examples shows valid examples for a single octave statement (one per line), if a scalar parameter of name a and b exist:

4
b
3+a*8
[4;a]*[6,b]

If the text is a statement list, then the value for the XML element is the value of the variable 'ret' which must be set by the statement list. The type of the variable 'ret' must match the type of the XML element (scalar, vector or matrix). The following examples shows valid examples for a octave statement list (one per line), if a scalar parameter of name a and b exist:

if 1==a; ret=4; else ret=8; end
myvar=[1;a];myvar2=myvar*2;ret=myvar2*b;dummy=3

A octave expression can also expand over more then one line like below. Note that the characters '&', '<' and '>' are not allowed in XML. So you have to quote them with '&amp;', '&lt;' and '&gt;', or you must enclose the octave code in a CDATA section:

<![CDATA[
function r=myfunc(a)
  r=2*a;
end
if 1 & 2, x=9; else x=8; end
ret=myfunc(m1/2);
]]>

The following m-functions extent the octave functionality being useful for several applications:

T=rotateAboutX(φ)
Returns the transformation matrix by angle φ around the x-axis:
100
0cos(φ)-sin(φ)
0sin(φ)cos(φ)
T=rotateAboutY(φ)
Returns the transformation matrix by angle φ around the y-axis:
cos(φ)0sin(φ)
010
-sin(φ)0cos(φ)
T=rotateAboutZ(φ)
Returns the transformation matrix by angle φ around the z-axis:
cos(φ)-sin(φ)0
sin(φ)cos(φ)0
001
T=cardan(α,β,γ)
Returns the cardan transformation matrix:
cos(β)cos(γ)-cos(β)sin(γ)sin(β)
cos(α)sin(γ)+sin(α)sin(β)cos(γ)cos(α)cos(γ)-sin(α)sin(β)sin(γ)-sin(α)cos(β)
sin(α)sin(γ)-cos(α)sin(β)cos(γ)cos(α)sin(β)sin(γ)+sin(α)cos(γ)cos(α)cos(β)
T=euler(Φ,θ,φ)
Returns the Euler transformation matrix:
cos(φ)cos(Φ)-sin(φ)cos(θ)sin(Φ)-cos(φ)cos(θ)sin(Φ)-sin(φ)cos(Φ)sin(θ)sin(Φ)
cos(φ)sin(Φ)+sin(φ)cos(θ)cos(Φ)cos(φ)cos(θ)cos(Φ)-sin(φ)sin(Φ)-sin(θ)cos(Φ)
sin(φ)sin(θ)cos(φ)sin(θ)cos(θ)
r=rad2deg(a)
Returns r=a*180/pi
r=deg2rad(a)
Returns r=a*pi/180

7 Embeding

Using the <pv:Embed> element, where the prefix pv is mapped to the namespace-uri http://www.mbsim-env.de/MBXMLUtils it is possible to embed a XML element multiple times. The full valid example syntax for this element is:

<pv:Embed href="file.xml" count="2+a" counterName="n" onlyif="n!=2"/>

or

<pv:Embed count="2+a" counterName="n" onlyif="n!=2">
  <any_element_with_childs/>
</pv:Embed>

This will substitute the <pv:Embed> element in the current context 2+a times with the element defined in the file file.xml or with <any_element_with_childs>. The insert elements have access to the global parameters and to a parameter named n which counts from 1 to 2+a for each insert element. The new element is only insert if the octave expression defined by the attribute onlyif evaluates to 1 (true). If the attribute onlyif is not given it is allways 1 (true).
The attributes count and counterName must be given both or none of them. If none are given, then count is 1 and counterName is not used.

The first child element of <pv:Embed> can be the element <pv:localParameter> which has one child element <p:parameter> OR a attribute named href. In this case the global parameters are expanded by the parameters given by the element <p:parameter> or in the file given by href. If a parameter already exist then the parameter is overwritten.

<pv:Embed count="2+a" counterName="n" onlyif="n!=2">
  <p:Parameter>
    <p:scalarParameter name="h1">0.5</p:scalarParameter>
    <p:scalarParameter name="h2">h1</p:scalarParameter>
  </p:Parameter>
  <any_element_with_childs/>
</pv:Embed>

8 Measurements

The following subsections show all defined measurements.

The column "Unit Name" in the tables is the name of the unit and the column "Conversion to SI Unit" is a expression which converts a value of this unit to the SI unit.

The highlighted row shows the SI unit of this measurement which always has a conversion of "value".

acceleration

Unit NameConversion to SI Unit
m/s^2value

amount

Unit NameConversion to SI Unit
molvalue

angle

Unit NameConversion to SI Unit
radvalue
degreevalue/360*2*3.141592653589793238462643383279502884

area

Unit NameConversion to SI Unit
mum^2value*1e-6**2
mm^2value*1e-3**2
cm^2value*1e-2**2
dm^2value*1e-1**2
m^2value
ar^2value*1e1**2
havalue*1e2**2
km^2value*1e3**2

bulkModulus

Unit NameConversion to SI Unit
N/m^2value
N/mm^2value*1/1e-3**2

current

Unit NameConversion to SI Unit
Avalue

damping

Unit NameConversion to SI Unit
N*s/mvalue

density

Unit NameConversion to SI Unit
kg/m^3value
g/cm^3value*1e-3/1e-2**3
t/m^3value*1e3/1**3

dynamicViscosity

Unit NameConversion to SI Unit
mPa*svalue*1e-3*1
Pa*svalue

flow

Unit NameConversion to SI Unit
mm^3/svalue*1e-3**3/1
m^3/svalue
l/svalue*1e-1**3/1
l/minvalue*1e-1**3/60

force

Unit NameConversion to SI Unit
mNvalue*1e-3
Nvalue
kNvalue*1e3

illumination

Unit NameConversion to SI Unit
cdvalue

inertia

Unit NameConversion to SI Unit
kg*m^2value
kg*mm^2value*1*1e-3**2
g*mm^2value*1e-3*1e-3**2

kinematicViscosity

Unit NameConversion to SI Unit
m^2/svalue
mm^2/svalue*1e-3**2/1

length

Unit NameConversion to SI Unit
mumvalue*1e-6
mmvalue*1e-3
cmvalue*1e-2
dmvalue*1e-1
mvalue
kmvalue*1e3

mass

Unit NameConversion to SI Unit
mgvalue*1e-6
gvalue*1e-3
kgvalue
tvalue*1e3

nounit

Unit NameConversion to SI Unit
value
-value
%value/100

pressure

Unit NameConversion to SI Unit
mPavalue*1e-3
Pavalue
mbarvalue*1e2
barvalue*1e5

stiffness

Unit NameConversion to SI Unit
N/mvalue
N/mmvalue*1/1e-3

temperature

Unit NameConversion to SI Unit
Kvalue
degCvalue+273.16
degF(value+459.67)*5/9

time

Unit NameConversion to SI Unit
musvalue*1e-6
msvalue*1e-3
svalue
secvalue
minvalue*60
hvalue*3600
dvalue*86400

torque

Unit NameConversion to SI Unit
N*cmvalue*1e-2
N*mvalue

velocity

Unit NameConversion to SI Unit
m/svalue
km/hvalue*1e3/3600

volume

Unit NameConversion to SI Unit
mum^3value*1e-6**3
mm^3value*1e-3**3
cm^3value*1e-2**3
dm^3value*1e-1**3
lvalue*1e-1**3
m^3value
km^3value*1e3**3

Impressum / Disclaimer / Datenschutz Generated on Tue Jun 21 2016 04:47:42 for MBXMLUtils by MBXMLUtils Valid HTML