Spline

Model ElementSplines are piecewise polynomial functions that possess a user controlled degree of smoothness.

Spline

Description

In mathematics, splines are often used for fitting and interpolating measured data. Reference_Spline defines a spline with two or three independent variables. In other words, the data can be a curve or a surface.

Attribute Summary

Name Property Modifiable by command? Designable?
id Int ()
label Str ()
x Double (count=0) Yes FD Only
y Double (count=0) Yes FD Only
z Double (count=0)   FD Only
linear_extrapolate Bool (False) Yes
file String () Yes
block String () Yes

Usage

MotionSolve provides four different ways for defining splines.
#1: Spline for X-Y data
Spline (x=list, y=list, optional_attributes)

#2: Spline for X-Y-Z data
Spline (x=list, y=list, optional_attributes)

#3: Spline data read from a file by a compiled user subroutine
Spline (file=string, function=userString, routine=string, optional_attributes)

#4: Spline data read from a file by a Python function
Spline (file=string, function=userString, routine=functionPointer, optional_attributes)

Attributes

Spline for X-Y data
x
List of numeric values.
Specifies the list of the X values of the spline.
The x attribute is mandatory.
Requirements: len (x) ≥ 4
y
List of numeric values
Specifies the list of the Y values of the spline.
The y attribute is mandatory.
Requirements:
• len (y) ≥ 4
• len (x) = len (y)
Spline for X-Y-Z data
x
List of numeric values.
Specifies the list of the X values of the spline.
The x attribute is mandatory.
Requirements: len (x) ≥ 4.
z
List of numeric values.
Specifies the list of the Z values of the spline.
The z attribute is optional.
y
List of numeric values.
Specifies the list of the Y values of the spline.
The y attribute is mandatory.
Requirements when Z is specified:
• y is a matrix of dimensions (M,N) specified as a two-dimensional list.
• M is the number of z values.
• N is the number of x values.
• Each row corresponds to one value of z.
Requirements when Z is not specified:
• y is a matrix of dimensions (1,N) specified as a one-dimensional list.
• N is the number of x values.
• There must be at least four numbers in each row.
• All rows must have the same length.
Spline data read from a file by a compiled user subroutine
file
String
Specifies the path and name of the file containing the spline data. Use only when the data is contained in an external file.
The file attribute is mandatory.
function
String
The list of parameters that are passed from the data file to the user-defined subroutine.
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 Surface. The second is the name of the function in the shared library that does the computation.
• "/staff/Altair/ engine.dll is the DLL
• "mySplineRead" is the function within this DLL that performs the calculations
The attribute routine is optional.
When not specified, routine defaults to Spline_Read.
The attribute routine is optional.
block
String
Specifies the block name containing the spline data. A single file may contain several blocks of data.
This parameter is optional. Use only when the data is contained in an external file with many blocks of data.
The block attribute is optional.
Spline data read from a file by a Python function
file
String
Specifies the path and name of the file containing the spline data. Use only when the data is contained in an external file.
The file attribute is mandatory.
function
String
The list of parameters that are passed from the data file to the user-defined subroutine.
The function attribute is mandatory.
routine
Pointer to a callable function in Python.
• my_Spline_Read is a Python function or method that can be called from wherever the model resides.
The attribute routine is optional.
When not specified, routine defaults to Spline_Read.
block
String
Specifies the block name containing the spline data. A single file may contain several blocks of data.
This parameter is optional. Use only when the data is contained in an external file with many blocks of data.
The block attribute is optional.
Optional Attributes - Available to all description methods
id
Integer
Specifies the element identification number. This number must be unique among all the Spline 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 Spline object.
This attribute is optional. When not specified, MotionSolve will create a label for you.
linear_extrapolate
Boolean
A logical flag that specifies how MotionSolve is to deal with the situation when the independent coordinate falls out of the range of data provided. Select either True or False.
• True indicates that MotionSolve is to use linear extrapolation to estimate the spline value.
• False indicates that MotionSolve should not extrapolate; instead it should return an error.
This attribute is optional. When not specified, MotionSolve will set linear_extrapolate = True.

Example

XML vs. Python syntax for the same model.
XML Syntax Python Syntax
<Reference_Spline
id = "301001"
label = "SWA vs. Time"
num_x = "11"
0.00E+00  1.09E+00
1.00E-01  6.88E+00
2.00E-01  2.52E+00
3.00E-01  3.02E+00
4.00E-01  3.30E+00
5.00E-01  3.23E+00
6.00E-01 -8.91E-02
7.00E-01 -4.20E+00
8.00E-01 -3.00E+00
9.00E-01  2.05E+00
1.00E+00  0.04E+00
</Reference_Spline>
time = [ 0, .1, .2, .3, .4, .5, .6, .7, .8, .9, 1]
swa = [1.09, 6.88, 2.52, 3.02, 3.30, 3.23,-.0891,-4.20, 3, 2.05, 0]
spl1 = Spline (label="SWA vs. Time", x=time, y=swa)
<Reference_Spline
id = "301001"
num_x = "5"
num_z = "3">
<!--x Y(zl) Y(z2) Y(z3)-->
0.00 0.00 0.00 0.00
0.25 0.50 0.70 0.90
0.50 0.00 0.00 0.00
0.75 0.50 0.70 0.90
1.00 0.00 0.00 0.00
<!--Z values-->
0.00 1.00 20.0
</Reference_Spline>
xval = [ 0, 0.25, 0.5, 0.75, 1]
zval = [ 0.0, 1.0, 20.0 ]
yval = [[0, 0.5, 0, 0.5, 0]
[0, 0.7, 0, 0.7, 0]
[0, 0.9, 0, 0.9, 0]]spl2 = Spline (label="jagged surface", x=xval, y=yval, z=zval)
<Reference_Spline
id              = "301001"
usrsub_dll_name = "./wheel.so"
file_name       = "./wheel_1.dat"
block_name      = "wheel_angle"
/>
dll = "./wheel.dll"
fnam = "./wheel_1 .dat"
blk = "wheel angle"
spl3 = Spline (label="SWA vs. Time", routine=dll,
file=fnam, block=blk)