Marine systems simulation
Math function

Perform mathematical functions.

+ Collaboration diagram for Math function:

Performs basic mathematical functions (exp, log, log10, root, sqrt, pow). The mathfunction object is defined through its parameters, which give the kind of mathfunction, the port widths and the number of input ports.

Author
Benjamin Scholz
Date
05.09.2007 BSC: Second version.
20.07.2011 KGA: Ported to FhSim 2.0.
25.07.2011 KGA: Added documentation.

Example configuration excerpt

<Lib
LibName = "fhsim_base"
SimObject = "Math/Mathfunction"
Name = "Exp"
MathType = "exp"
PorthWidth = "2"
/>
...
<Connection
A.In = "1.1,0.9"
/>

Supported mathematical functions

Function Input ports Input name
Exponential 1 exp
Natural logarithm 1 log
Base 10 logarithm 1 log10
Square root 1 sqrt
Raise to power 2 pow
Root of number 2 root

Input Ports

Name Width Description
In <PortWidth> The input signal. This input is used for the following functions: exp, log, log10 and sqrt
In1 <PortWidth> The base for pow and root. This input is used for the following functions: pow and root
In2 <PortWidth> The the exponent or root value. This input is used for the following functions: pow and root

Output Ports

Name Width Description
Out <PortWidth> The result of the operations on the input

Configuration parameters

Name Width Description
PortWidth -

The number of elements in the input and output ports

MathType - Specify the math function: exp / log / log10 / sqrt / pow / root

Initial conditions

There are no initial conditions for this function.

Full example file

<Contents>
<OBJECTS>
<Lib
LibName="base"
SimObject="Math/Mathfunction"
Name="Exp"
MathType="exp"
/>
<Lib
LibName="base"
SimObject="Math/Mathfunction"
Name="Log"
MathType="log"
/>
<Lib
LibName="base"
SimObject="Math/Mathfunction"
Name="Log10"
MathType="log10"
/>
<Lib
LibName="base"
SimObject="Math/Mathfunction"
Name="Sqrt"
MathType="sqrt"
/>
<Lib
LibName="base"
SimObject="Math/Mathfunction"
Name="Pow"
MathType="pow"
/>
<Lib
LibName="base"
SimObject="Math/Mathfunction"
Name="Root"
MathType="root"
/>
</OBJECTS>
<INTERCONNECTIONS>
<Connection
Exp.In="1"
Log.In="2.718281828459045"
Log10.In="1000"
Sqrt.In="49"
Pow.In1="3"
Pow.In2="2"
Root.In1="8"
Root.In2="3"
/>
</INTERCONNECTIONS>
<INITIALIZATION>
<InitialCondition
/>
</INITIALIZATION>
<INTEGRATION>
<Engine
IntegratorMethod="2"
NumCores="1"
TOutput="0, 1, 30"
LogStates ="1"
stepsize ="0"
HMax="0.002"
HMin="0.00000001"
AbsTol="1e-3" RelTol="1e-3"
UseRSSNormInsteadOfInfNorm="0"
FileOutput="objects:all"
/>
</INTEGRATION>
</Contents>

This SimObject is referred to as Math/Mathfunction