Equations

<< Click to Display Table of Contents >>

Navigation:  Flexcom > Theory > Fundamentals > Keyword Parameterisation >

Equations

Previous pageNext page

Mathematical Equations

Numerical variables may also be replaced by mathematical equations. For example, you might like to position a vessel in the region of the mean water line, as follows:

$PREPROCESSOR

*PARAMETERS

 OceanDepth, 500

 

$MODEL

*VESSEL

 VESSEL=FPSO

 INITIAL POSITION==[OceanDepth+5], 0, 0, 0

This means that the vessel reference point will always be positioned at 5m above the mean water line, regardless of the water depth.

Refer to Mathematical Operators and Mathematical Functions for a full list of the mathematical features supported by Flexcom.

Logical Expressions

It is also possible to use logical expressions. Let’s suppose you would like to alternate between metric and imperial unit systems. Unit conversion is now handled more conveniently with the CONVERT function (see below) and dedicated keyword file extensions (keyxm and keyxi) but this is useful to illustrate logical expressions. The following specification converts water depth from metres to feet, and seawater density from kg/m3 to slugs/ft3.

$PREPROCESSOR

*PARAMETERS

 Gravity, 9.81

 LengthFactor, 3.28084

 DensityFactor, 0.0019403233

 OceanDepth, =[if(Gravity<10, 500, 500*LengthFactor) ]

 SeawaterDensity, =[if(Gravity<10, 1025, 1025*DensityFactor) ]

 

$MODEL

*OCEAN

 =[OceanDepth], =[SeawaterDensity], =[Gravity]

 

Refer to Logical Operators and Functions for a full list of the logical features supported by Flexcom.

String Expressions

The preceding sections have focused primarily on the use of parameters in defining numerical values, or expressions which equate to a numerical value. It is also possible to use parameters to define string expressions; for example:

$PREPROCESSOR

*PARAMETERS

 Offset, -100

 OffsetFolder, Near

In this simple example, the parameter OffsetFolder has the value Near. If however the folder name is more complex and contains spaces, then it needs to be wrapped in double quotation marks:

$PREPROCESSOR

*PARAMETERS

 Offset, -100

 OffsetFolder, "C:\Test Case\Near"

Without quotation marks, the program would interpret this as a pair of values (C:\Test  and Case\Near) following OffsetFolder with a space between them, not what is intended. The quotation marks are therefore required in this case.

When constructing a path name containing spaces using an equation, you need a way to make sure that it's wrapped in double quotation marks. That is straightforward to do; in an equation, the built-in constant QQ represents a double-quotation mark. For example:

$PREPROCESSOR

*PARAMETERS

BaseFolder, "C:\Test Case\"

OffsetFolder, =[QQ + BaseFolder + "Near" + QQ]

This will result in the OffsetFolder having the value of "C:\Test Case\Near", including quotation marks.

Note also that any unusual characters may be defined explicitly using ASCII character codes, using the general function char(N), where N is the ASCII code corresponding to the required character. In fact, QQ is defined internally using char(34).

Refer to String Operators and Functions for a full list of the logical features supported by Flexcom.

Relevant Keywords

*PARAMETERS is used to define parameters whose names may be referenced subsequently in the definition of other input variables.

If you would like to see an example of how mathematical equations are used in practice, refer to C02 - Multi-Line Flexible System or C03 - Turret Disconnect.

If you would like to see an example of how string expression are used in practice, refer to K02 - Worked Example - Complex.