1

I need to perform an interpolation of some tabulated data in Dymola Modelica, but I can only find a function that does linear interopolation (Modelica.Math.Vectors.interpolate). I really need some sort of higher order interpolation like polynomial or preferably spline. Has anyone written a function to do this?

Chad
  • 1,434
  • 1
  • 15
  • 30
  • This text http://dx.doi.org/10.3384/ecp09430013 describes a library for spline interpolation. In the conclusion the authors state that the library will be made freely available. – matth Sep 28 '13 at 11:26
  • I found that paper. They do make their library available here: http://www.netlib.org/dierckx/, but unless I am missing something, the authors made only Fortran libraries available. This is no better than my plan of calling a python interpolation function: http://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html – Chad Sep 30 '13 at 12:30
  • 1
    The way I read the paper, Ungethüm and Hülsebusch wrote a Modelica interface that "talks" to the Fortran DIERCKX library. You will need both, the Fortran code and the wrapper interface. Did you consider contacting the authors of that paper? – matth Sep 30 '13 at 14:04
  • 1
    And here is another paper, describing another library: http://dx.doi.org/10.3384/ecp12076323 – matth Sep 30 '13 at 14:50
  • 3
    Four years later, it seems you can find a copy of the code here: https://github.com/tbeu/ApproxSpline – matth Jan 31 '18 at 19:34

2 Answers2

3

In Dymola, there are some "built-in" features that allow you to do tabular interpolation. I do not remember the specifics or the maximum order for interpolation, but I'm sure it is there. You'll just have to check to documentation.

It is also worth noting that as of Modelica 3.2.1 there is a new table interpolation implementation that is open source. I haven't looked to carefully, but I'm pretty sure it features up to cubic polynomials and since it is open source I suspect you can figure out a way to repurpose it in nearly any way you want. The only downside is that you have to use the very latest version of the MSL (which shouldn't be a huge problem).

Michael Tiller
  • 9,291
  • 3
  • 26
  • 41
  • 1
    If I read the annotation of the new MSL 3.2.1 `Modelica.Blocks.Tables` correctly it features linear interpolation only. – matth Sep 28 '13 at 16:45
1

Oddly enough, I found a polynomial fitting function here: Modelica.Media.Incompressible.TableBased.Polynomials_Temp.fitting

There are also functions for evaluating polynomials in the same place.

Chad
  • 1,434
  • 1
  • 15
  • 30