external functions

6 posts / 0 new
Last post
Joined: 2009-10-20
external functions

Hello Community :),

I tried to use an external function my model. In the examples-directory there is one example concerning external function. My question is: Is the directory-structure ( 1.Resources 1.1 Include 1.2 Library 1.3 src) necessary ? I need for every model one .h (header), .a (lib) and .c ? Can I also use .dll ? Which possibilities do I have?
Thanks :)
Best Regards

Joined: 2009-10-18
Hi   The src dir is just

The src dir is just there because we thought it was convenient to have the source file for the external function in the same place as the other stuff. As for the other directories, that is a standard directory structure that is assumed if no other is given. This is according to the Modelica Language Specification v3.2, section 12.9.4. I suggest reading that section for more information about this.
The basic premise is that you need one header file and one library file for each library of external functions you want to use. You can then use an annotation in the external function declaration (in Modelica code) to give the information that is necessary to compile and link against the library.
As for using a .dll, that is something we haven't tested, but according to gcc's documentation is should work.

Joined: 2009-10-20
I tried to use external

I tried to use external functions in my model, but it failed. It seems that it doesn't work with IPOPT? In the external-functions-example the option

compiler_target='model_noad' was set. But it doesn't work with IPOPT.

Can you give me more information about it and "model_noad"?

Thank you for your support :)

Best Regards

Joined: 2009-03-14
Hi Torben!   The model_noad

Hi Torben!
The model_noad target does not use automatic differentiation - there is no support for AD in combination with external functions currently. And without derivatives, IPOPT won't work. The plan is to support external functions combined with AD by means by requiring the user to supply derivative annotations for external functions, but we are not there yet.

Joined: 2016-03-07
Optimica - OpenModelica - External function

I have the same problem. If I provide the density value by hand, I can optimize the model. But if I calculate the density using an external function  this is the result:

optimize(opt, numberOfIntervals=16, stopTime=1, tolerance=1e-8)

record SimulationResult

resultFile = "",

simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 16, tolerance = 1e-008, method = 'optimization', fileNamePrefix = 'opt', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",

messages = "Failed to run the optimize command: opt",

timeFrontend = 0.0,

timeBackend = 0.0,

timeSimCode = 0.0,

timeTemplates = 0.0,

timeCompile = 0.0,

timeSimulation = 0.0,

timeTotal = 0.0

end SimulationResult;

Does Optimica already support external functions?



Joined: 2018-02-13
external functions

As we saw with the InterpolateExternalVector work in our Interpolation related illustrations, it is conceivable to call capacities not written in Modelica. Regularly, such capacities are composed in C or Fortran. Coursework Writers A capacity actualized outside Modelica does not contain a calculation segment. Rather, it ought to incorporate an outside explanation that gives data about the outer capacity and how to pass data to and from the capacity. 

Login or register to post comments