- Index
- » Users
- » geire
- » Profile
Posts
Posts
Hi,
I discovered something odd using the external function which is returning a double vector. When I use it in a class like this:
class MyModel
ThermoObject p = ThermoObject()
Real r[17] = getvector_data_from_external_function(p, "property",17);
end MyModel;
The function getvector_data_from_external_function in the above code is called 17 times. Do I do something wrong in the code?
KR,
Hi,
Your example works fine on the compiler version I have (1.8.0 (r10207)), and thanks to it I was able to figure out what was wrong in my "non-simplified" code.
Thanks for your excellent support!
Hi,
I have made a routine that should retrieve some information from a underlying thermodynamic calculation, but I can't get it to work. I get an error in function 'bound_parameters' when I compile the model. The below code shows the code that is causing the problem:
function get_results
extends Modelica.Icons.Function;
input ModelHolder m;
input String property;
input Integer n;
output Real res[n];
external "C" getresults(m, property, res) annotation(Library="srk_modelica", Include="#include \"srk_modelica.h\"")
end get_results;
If i set a static size to res, e.g. res[2] the code above compiles fine.
Is this a feature that is not supported? If not, is there a way to get around this by defining the function differently?
Thanks in advance.
I've made an external library file (.so) that should linked with the model, but when gcc tries to link it does not find the library. The library resides in the same catalog as the .mo file. I've recognized that the gcc - command that is executed does not include -L.
Is it possible to add a path to omc such that it finds the external library? If not, where should the external library file reside?
Thanks in advance!
Hi,
I've tested the new RC1 version on the same code as before. The compiler sees the process the model further, but it stops after getting the following error:
[SimCodeC.tpl:2927:14-2927:14:writable] Error: Template error: Unknown external type OTHER
Error: Variable substanceName not found in scope ExternalMedia.Media.TestMedium.getMolarMass
Error: Variable libraryName not found in scope ExternalMedia.Media.TestMedium.getMolarMass
Error: Variable substanceName not found in scope ExternalMedia.Media.TestMedium.getMolarMass
Error: Variable libraryName not found in scope ExternalMedia.Media.TestMedium.getMolarMass
Error: Variable substanceName not found in scope ExternalMedia.Media.TestMedium.getCriticalTemperature
Error: Variable libraryName not found in scope ExternalMedia.Media.TestMedium.getCriticalTemperature
Error: Variable substanceName not found in scope ExternalMedia.Media.TestMedium.getCriticalTemperature
Error: Variable libraryName not found in scope ExternalMedia.Media.TestMedium.getCriticalTemperature
Error: Variable substanceName not found in scope ExternalMedia.Media.TestMedium.getCriticalPressure
Error: Variable libraryName not found in scope ExternalMedia.Media.TestMedium.getCriticalPressure
Error: Variable substanceName not found in scope ExternalMedia.Media.TestMedium.getCriticalPressure
Error: Variable libraryName not found in scope ExternalMedia.Media.TestMedium.getCriticalPressure
Error: Variable substanceName not found in scope ExternalMedia.Media.TestMedium.getCriticalMolarVolume
Error: Variable libraryName not found in scope ExternalMedia.Media.TestMedium.getCriticalMolarVolume
Error: Variable substanceName not found in scope ExternalMedia.Media.TestMedium.getCriticalMolarVolume
Error: Variable libraryName not found in scope ExternalMedia.Media.TestMedium.getCriticalMolarVolume
[SimCodeC.tpl:2927:14-2927:14:writable] Error: Template error: Unknown external type OTHER
In the generated code for ExternalMedia_Media_TestMedium_getMolarMass.h I recognize that the generated header-file are missing some arguments in the TwoPhaseMedium_getMolarMass_ function:
extern double TwoPhaseMedium_getMolarMass_(const char*,
#error "[SimCodeC.tpl:2927:14-2927:14] Unknown external type OTHER"
,
#error "[SimCodeC.tpl:2927:14-2927:14] Unknown external type OTHER"
);
#ifdef __cplusplus
extern "C" {
#endif
#include "externalmedialib.h"
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
}
#endif
#endif
Are these errors related to the omc compiler or is this something related to my model?
KR,
Geir Arne
Thanks for the quick answer. I've updated the example to take care of the SI stuff. However, as I understand it the above code will not work anyhow for the current version of OpenModelica. Will support for external declarations when doing class extent be available in OpenModelica in the near future?
Hi,
I've installed the externalmedia package on my computer https://www.modelica.org/libraries/ExternalMedia with the goal of using it from openmodelica. I know that this package works fine with dymola. I created a model which tests the package:
model Example
ExternalMedia.Media.TestMedium.ThermodynamicState state;
SI.Density d;
SI.SpecificEnthalpy h;
equation
state = TestMedium.setState_pT(1e5, 300);
d = TestMedium.density(state);
h = TestMedium.specificEnthalpy(state);
end Example;
However, when I try to compile the above model with: "omc +d=failtrace Example.mo ExternalMedia Modelica.Media" I see that the processor usage goes to 100% and the shell dumps out the following message:
ClassLoader.loadClassFromMp failed
ClassLoader.loadClassFromMp failed
Does someone have an idea what this means?
KR,
- Index
- » Users
- » geire
- » Profile