Would it be possible to add the passing of functions to the External Function Interface? #4230
Replies: 3 comments 6 replies
-
perhaps this is seen as a problem more on the "tool vendor" side of things... however, without granting external code (C) access to Modelica functions, one is forced to add user-defined functions to separate .c files, which need to be pre-compiled and added to the external library before the model can compile / run within the OMEdit or Dymola environment. |
Beta Was this translation helpful? Give feedback.
-
I believe that is a language issue, not a library issue; and it gets tricky because the Modelica language has "partial function applications"; which seems good if one wants to e.g., integrate a Modelica function - but it also makes the C-interface more complicated. |
Beta Was this translation helpful? Give feedback.
-
well, i managed to get this working... in some fashion. see the integration examples (and related functions) in v1.0.2: https://github.com/tburch-LSS/Modelica-GNU_ScientificLibrary one needs to "simulate" the 'CreateIntegrand' model first. this basically creates a C-version of the desired function to be integrated, then compiles, and archives it (together with the interface routines). then one can run any larger model which may then repeatedly use GSL integration routines with the function (see, e.g., 'ExampleIntegral'). the one wrinkle is that i had to resort to 'gcc' and 'ar' system commands to compile and archive. until i can find a workaround for this, windows users will have to implement mingw / msys to have access to these. updating this to include other GSL routines, more than one integrand, and parameter passing should be simple enough. however, i would still advocate expanding Modelica's capabilities either to include the passing of functions or to offer the choice to have simplistic versions of some of the translated functions to simplify interfacing. |
Beta Was this translation helpful? Give feedback.
-
i have been contributing to the Modelica-GNU_ScientificLibrary package:
https://github.com/ORNL-Modelica/Modelica-GNU_ScientificLibrary
and have found that, for implementing many of the GSL capabilities, it would be quite helpful if one could pass Modelica functions to external C libraries. Within C itself, this is possible. i have quite a bit of experience with coding in C and also some Modelica experience, so i might be able to contribute here myself... anyone have any tips on where to start? e.g., where the source code for the interface is to be found? thanks!
Beta Was this translation helpful? Give feedback.
All reactions