Problems with code generation - package constants in ExternalMedia
Original ticket https://trac.openmodelica.org/OpenModelica/ticket/2565
On Windows with OM 1.20 and current ExternalMedia master (f524f94), binaries from https://github.com/modelica-3rdparty/ExternalMedia/suites/9592856454/artifacts/457340537, I don't get suspicious/remarkable compilation times for ExternalMedia.Test.TestMedium.TestBasePropertiesExplicit or ExternalMedia.Test.TestMedium.TestConstants. Possibly this issue can be closed.
I still got the issue with undeclared variables in e.g. TestBasePropertiesDynamic, which I fixed in #9932.
The issue for me at least was that the frontend would try to evaluate e.g. Medium.fluidConstants.criticalPressure, but the external getCriticalPressure() function would fail with the error libraryName = FluidProp.RefProp is not supported by any external solver.
To deal with such situations we check the flat model for references to package constants and add declarations for them, but we failed to identify these constants as package constants due to some issue with redeclared packages. With my fix we now add declarations for the unevaluated constants to the flat model, so we no longer get errors for undefined variables when compiling the generated C-code.
However, the external media functions still fail for me and the simulation doesn't really work, but perhaps that's some issue with ExternalMedia?
I still got the issue with undeclared variables in e.g.
TestBasePropertiesDynamic, which I fixed in #9932.
Good, I think with this fix we can actually close this ticket.
The issue for me at least was that the frontend would try to evaluate e.g.
Medium.fluidConstants.criticalPressure, but the externalgetCriticalPressure()function would fail with the errorlibraryName = FluidProp.RefProp is not supported by any external solver.
This is because you need to install FluidProp (which is proprietary software) to get this medium model working.
To deal with such situations we check the flat model for references to package constants and add declarations for them, but we failed to identify these constants as package constants due to some issue with redeclared packages. With my fix we now add declarations for the unevaluated constants to the flat model, so we no longer get errors for undefined variables when compiling the generated C-code.
OK. In this case the compilation should fail in the NF with that error message you mentioned above. I assume this is now the case.
However, the external media functions still fail for me and the simulation doesn't really work, but perhaps that's some issue with ExternalMedia?
The problem is, you can't use the source code on GitHub, which lacks properly built binaries, but either used the GitHub CI artefacts, or eventually the official releases, which both contains the binaries in the proper places. I'll get there ASAP.