Comments (6)
The crash problem was due to
OpenModelica/OpenModelica#8738
which has been fixed but at the time of writing an OpenModelica build with the fix has not been released yet.
from externalmedia.
I would recommend that @casella, @albertoleva and @fedetft have a look at the branch v4-dev and provide some feedback here.
from externalmedia.
Tried building the v4-dev branch on Linux and testing with openmodelica, used these commands:
cmake -B build -S Projects -DCMAKE_BUILD_TYPE=Release
cmake -B build -S Projects -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --target install
no issues found in the building step.
Trying to run a model such as ExternalMedia.Test.CoolProp.CO2.TestStatesSatSubcritical however I still encountered two issues:
- openmodelica complains it can't find the library. It's the old issue that on linux the library should be in the Resources/library/linux64 and not in Resources/library/linux64/gcc94, which is where the install target puts the library. Incidentally, I noticed that the file libExternalMediaLib.so.4.0.0 (but NOT the libExternalMediaLib.so symbolic link) is also copied in the Resources/library directory, and I don't know why, but openmodelica does not look for the file there. By moving the content of the gcc94 directory one level above, openmodelica finds the library, but the following issue occurs
- OMEdit crashes when checking the model ExternalMedia.Test.CoolProp.CO2.TestStatesSatSubcritical, it appears that it tries to load the shared library to call the functions to initialize the package constants, but something goes wrong and it crashes
NOTE: to get the model to run I had to edit a few Modelica lines here and there, like "SI.IsothermalCompressibility > Modelica.SIunits.IsothermalCompressibility" probably because I'm using a different MSL than you,but I don't think this is the cause of the crash above.
from externalmedia.
We need to handle the error functions in ExternalMedia. This is potentially a problem in case of dynamic linking, because the ModelicaError, ModelicaWarning (and in fact all ModelicaUtilities) functions may not be available inside the library when compiled as a dll/so. This issue was actually discussed some years ago in ModelicaSpecification #2191, but then the discussion got nowhere, probably for lack of strong end-user motivation / available time.
@fedetftpolimi, who is a compiler and OS guru, figured out a very simple solution to that problem: you just need to export all the ModelicaUtilities symbols in the compiled simulation executable, and also in the Modelica compiler GUI, since ExternalMedia may be called at compile time as well, because of evaluation of package constants. This guarantees that the functions in the ExternalMedia dll can access them. This can be done both on Linux and Windows, and we know how to do that. However, this requires all tool vendors to agree to the principle and implement it in their tools, which is a bit of a lengthy process. In fact, Dymola does it on Linux, but apparently not on Windows, for some reason.
We will start that discussion in #2191, but for the time being we figured a relatively simple hack that should work in all cases and does not require to change the structure of all ExternalMedia functions to have them return an error code string in case of trouble.
The idea is that, at runtime, the first ExternalMedia function that is called is always a setState_XX function. There are only six of them. We just need to add a C wrapper function defined in the include annotation of the corresponding Modelica external functions, that passes to the actual library functions a pointer to ModelicaError. These C wrappers are statically compiled with the simulation code every time a model is generated, so they have access to that function and can pass the pointer further down the line. The first called setState_XX library function will then copy that pointer to a global static variable of the library, from which the errorMessage function will be able to retrieve it. In this way, all other external functions can be left unchanged, as they can safely call errorMessage, which will know what to do.
We'll implement the new errorMessage handling next week, with a bit of luck we should finally get ExternalMedia to run on OMC as well.
Since I'd like to have a MSL 3.2.3-compatible version that works in OMC to run legacy models using ExternalMedia, we have cherry-picked your changes regarding the shared library compilation, and then we'll release 3.3.2 and 4.0.0 based on that.
from externalmedia.
We are almost done with that, see the dynamiclib branch. Only a clean-up of the build scripts needs to be performed
from externalmedia.
Fix merged to master.
from externalmedia.
Related Issues (20)
- Incompressible package runs in OpenModelica but not Dymola
- Model fails to execute when using two different fluids
- Model fails to run when using Modelica.Fluid.Sensors.Temperature
- Call ExternalMedia from OMPython HOT 1
- External function could not be found in any of the given shared libraries HOT 1
- External functions in ExternalMedia should be explicitly declared as pure
- Use CoolProp 6.4.4 as soon as it is released, instead of nightly build HOT 1
- support for older gcc versions HOT 4
- Compilation errors in OpenModelica HOT 7
- Selection of different state variables (ph, pt, dT) for a CoolProp 2-phase medium HOT 1
- Cannot compute arbitrary partial derivatives with function `partialDeriv_state` HOT 2
- Wrong version of cmake required to compile the library HOT 1
- Restructuring of the repository HOT 4
- build error using cmake on windows HOT 1
- State functions do not seem to work properly HOT 6
- Compressible mixture support? HOT 2
- Custom fluid property support
- Incompressible CoolProp tests do not compile HOT 3
- Remove experiment annotation from partial models
- how to use fliudprop in external Media?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from externalmedia.