Spline interpolation
## Copyright © EDF 2002 - 2026
## ThermoSysPro Version 4.2
Spline interpolation function. The resulting spline will be continuous and have a continuous first derivative.
Implementation
It uses a cardinal spline interpolation algorithm. Cardinal splines are a sub-set of cubic Hermite splines where each piece is a third-degree polynomial specified in Hermite form: i.e specified by its values and the first derivatives at the end points of the reference interval.
The derivatives are calculated based on the non-uniform cardinal grid approach according to:
y1_der=0.5(1-t)(y1-y0/(x1-x0)+(y2-y1/(x2-x1)
I.e. the derivative in a point is calculated as an average of the surrounding points with an extra input shape parameter t.
Inputs
TabX: Vector containing x-table values
TabY: Vector containing y-table values
X: The x-value that the spline should be evaluated at
t: Cardinal spline shape parameter. t = 0.5 is default and is generally a good choice. A value close to 1 will yield a stiff spline, t=0 corresponds to a Catmull-Rom spline and t < 0 corresponds to a more “loose” spline. From testing, t=0.5 seems to be a good choice in general and is therefore chosen as a default value. A value of t = 1 corresponds to that the derivative in all data points is zero, which may result in strange curves . See Examples > TestSplineInterpolation for a demonstration.
Output
Y: Interpolated value evaluated at X
Extrapolation
Linear extrapolation is employed if the reference value is not contained in the reference value table.
Example
TabX = {1,2,3,4};
TabY = {4,3,5,2};
References
http://people.cs.clemson.edu/~dhouse/courses/405/notes/splines.pdf
function SplineInterpolation
input Real TabX[:] "References table";
input Real TabY[:] "Results table";
input Real X "Reference value";
input Real t(max = 1) = 0.5 "Stiffness parameter";
output Real Y "Interpolated result";
end SplineInterpolation;
Generated at 2026-07-12T20:48:41Z by OpenModelicaOpenModelica 1.27.0 using
GenerateDoc.mos