modelica-3rdparty / ExternalMedia

The ExternalMedia library provides a framework for interfacing external codes computing fluid properties to Modelica.Media-compatible component models.
53 stars 36 forks source link

v3.2.3 with CoolProp #24

Closed jowr closed 3 years ago

jowr commented 3 years ago

Dear all

Would you be interested in creating an intermediate branch that handles some of the issues we experienced earlier? We could make a minor release for v3.2.3 and then have a structured discussion for how to address v4.0.

I have now made a new version of the CMake scripts that uses CMake to pull the CoolProp sources, if enabled. There is no fixed connection between the ExternalMedia code and CoolProp anymore. This is a first step towards handling #8, but we are not ready to close it since we do not use the shared library, yet.

I also started to integrate GitHub actions as suggested by @beutlich - this could be the solution for #7.

I can make a pull request - but feel free to suggest other ways to address the roadmap for this project. Maybe we can start with creating GitHub draft releases and the tag new issues with the appropriate version numbers?

jowr commented 3 years ago

Hi again - I have now fixed most issues and I have a fully automated build and deploy setup. Please have a look at https://github.com/jowr/ExternalMedia/actions for details. I am also going to change the title and the initial post to reflect the latest changes.

@casella and @beutlich, could any of you test the libraries with OpenModelica? I do not seem to have any success even though I use the OMDev environment for compiling the static libraries.

You can grab a the build of this version https://github.com/jowr/ExternalMedia/commit/88eff7fa556868473f5e32d7da3700e56595f817 from here: https://ipudk-my.sharepoint.com/:u:/g/personal/jowr_ipu_dk/ERSQtkDKSQNFmYqRfCwMLfcBUt96k-BTaSDpzYxIzvZYMw?e=Rduoaw

slamer59 commented 3 years ago

Hello, can you point more precisely on the problem you face with testing with OpenModelica ?

I found this package which do similar constrcution with OpenModelica on Linux/Windows/MacOs.

https://github.com/dynawo/dynawo

jowr commented 3 years ago

Hi and thank you for getting back to me. My problem is that I can compile the library with OMDev on Windows, but when I open it in the OMEdit software, simulation fails for both 32bit and 64bit. Unfortunately, I have never used OpenModelica myself and i have a hard time debugging this. Here are the logs for 64bit:

C:/Program Files/OpenModelica1.16.0-64bit/share/omc/scripts/Compile.bat ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical gcc mingw64 parallel 8 0
PATH = "C:\PROGRA~1\OPENMO~1.0-6\tools\msys\mingw64\bin;C:\PROGRA~1\OPENMO~1.0-6\tools\msys\mingw64\bin\..\..\usr\bin;"
mingw32-make: Entering directory 'C:/Users/jowr.AD/AppData/Local/Temp/OPENMO~1/OMEdit/EXTERN~1.TES'
gcc  -Os -falign-functions -fno-ipa-pure-const -mstackrealign -msse2 -mfpmath=sse     "-IC:/Users/jowr.AD/Downloads/binaries/ExternalMedia 3.2.3/Resources/Include" -I"C:/Program Files/OpenModelica1.16.0-64bit/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical.c
gcc  -Os -falign-functions -fno-ipa-pure-const -mstackrealign -msse2 -mfpmath=sse     "-IC:/Users/jowr.AD/Downloads/binaries/ExternalMedia 3.2.3/Resources/Include" -I"C:/Program Files/OpenModelica1.16.0-64bit/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c
gcc  -Os -falign-functions -fno-ipa-pure-const -mstackrealign -msse2 -mfpmath=sse     "-IC:/Users/jowr.AD/Downloads/binaries/ExternalMedia 3.2.3/Resources/Include" -I"C:/Program Files/OpenModelica1.16.0-64bit/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_records.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_records.c
gcc  -Os -falign-functions -fno-ipa-pure-const -mstackrealign -msse2 -mfpmath=sse     "-IC:/Users/jowr.AD/Downloads/binaries/ExternalMedia 3.2.3/Resources/Include" -I"C:/Program Files/OpenModelica1.16.0-64bit/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_01exo.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_01exo.c
gcc  -Os -falign-functions -fno-ipa-pure-const -mstackrealign -msse2 -mfpmath=sse     "-IC:/Users/jowr.AD/Downloads/binaries/ExternalMedia 3.2.3/Resources/Include" -I"C:/Program Files/OpenModelica1.16.0-64bit/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_02nls.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_02nls.c
gcc  -Os -falign-functions -fno-ipa-pure-const -mstackrealign -msse2 -mfpmath=sse     "-IC:/Users/jowr.AD/Downloads/binaries/ExternalMedia 3.2.3/Resources/Include" -I"C:/Program Files/OpenModelica1.16.0-64bit/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_03lsy.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_03lsy.c
gcc  -Os -falign-functions -fno-ipa-pure-const -mstackrealign -msse2 -mfpmath=sse     "-IC:/Users/jowr.AD/Downloads/binaries/ExternalMedia 3.2.3/Resources/Include" -I"C:/Program Files/OpenModelica1.16.0-64bit/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_04set.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_04set.c
gcc  -Os -falign-functions -fno-ipa-pure-const -mstackrealign -msse2 -mfpmath=sse     "-IC:/Users/jowr.AD/Downloads/binaries/ExternalMedia 3.2.3/Resources/Include" -I"C:/Program Files/OpenModelica1.16.0-64bit/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_05evt.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_05evt.c
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c: In function 'omc_ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_Medium_setState__pT':
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:49:53: warning: passing argument 3 of 'TwoPhaseMedium_setState_pT_C_impl' from incompatible pointer type [-Wincompatible-pointer-types]
   TwoPhaseMedium_setState_pT_C_impl(_p_ext, _T_ext, &_state_ext, MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp1)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp2)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp3)));
                                                     ^
In file included from ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_includes.h:4:0,
                 from ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:7:
C:/Users/jowr.AD/Downloads/binaries/ExternalMedia 3.2.3/Resources/Include/externalmedialib.h:144:14: note: expected 'ExternalThermodynamicState * {aka struct <anonymous> *}' but argument is of type 'ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_Medium_ThermodynamicState * {aka struct <anonymous> *}'
  EXPORT void TwoPhaseMedium_setState_pT_C_impl(double p, double T, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
              ^
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c: In function 'omc_ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_Medium_setState__ph':
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:100:65: warning: passing argument 4 of 'TwoPhaseMedium_setState_ph_C_impl' from incompatible pointer type [-Wincompatible-pointer-types]
   TwoPhaseMedium_setState_ph_C_impl(_p_ext, _h_ext, _phase_ext, &_state_ext, MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp1)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp2)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp3)));
                                                                 ^
In file included from ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_includes.h:4:0,
                 from ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:7:
C:/Users/jowr.AD/Downloads/binaries/ExternalMedia 3.2.3/Resources/Include/externalmedialib.h:143:14: note: expected 'ExternalThermodynamicState * {aka struct <anonymous> *}' but argument is of type 'ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_Medium_ThermodynamicState * {aka struct <anonymous> *}'
  EXPORT void TwoPhaseMedium_setState_ph_C_impl(double p, double h, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
              ^
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c: In function 'omc_ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_completeState1_Medium_molarMass':
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:167:9: warning: implicit declaration of function 'ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_completeState1_Medium_FluidConstants_array_get' [-Wimplicit-function-declaration]
   _MM = ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_completeState1_Medium_FluidConstants_array_get(_completeState1._Medium._fluidConstants, 1, ((modelica_integer) 1))._molarMass;
         ^
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:167:112: error: '_completeState1' undeclared (first use in this function)
   _MM = ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_completeState1_Medium_FluidConstants_array_get(_completeState1._Medium._fluidConstants, 1, ((modelica_integer) 1))._molarMass;
                                                                                                                ^
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:167:112: note: each undeclared identifier is reported only once for each function it appears in
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c: In function 'omc_ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_completeState2_Medium_molarMass':
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:274:9: warning: implicit declaration of function 'ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_completeState2_Medium_FluidConstants_array_get' [-Wimplicit-function-declaration]
   _MM = ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_completeState2_Medium_FluidConstants_array_get(_completeState2._Medium._fluidConstants, 1, ((modelica_integer) 1))._molarMass;
         ^
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:274:112: error: '_completeState2' undeclared (first use in this function)
   _MM = ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_completeState2_Medium_FluidConstants_array_get(_completeState2._Medium._fluidConstants, 1, ((modelica_integer) 1))._molarMass;
                                                                                                                ^
<builtin>: recipe for target 'ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.o' failed
mingw32-make: *** [ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.o] Error 1
mingw32-make: *** Waiting for unfinished jobs....
mingw32-make: Leaving directory 'C:/Users/jowr.AD/AppData/Local/Temp/OPENMO~1/OMEdit/EXTERN~1.TES'
Compilation process failed. Exited with code 2.
slamer59 commented 3 years ago

Thanks for the log. I will share my findings (sorry if it is too obvisous): 2 errors with undeclared variable _completeState1 relates to this transformation https://github.com/modelica-3rdparty/ExternalMedia/blob/159518edd538b64e28cd70983a9cc47730323cc4/Modelica/ExternalMedia%203.2.1/Test.mo#L816 extends this package https://github.com/modelica-3rdparty/ExternalMedia/blob/159518edd538b64e28cd70983a9cc47730323cc4/Modelica/ExternalMedia%203.2.1/Examples.mo#L45

I don't understand why it doesnot find the variable.

slamer59 commented 3 years ago

Hello, I was able to reproduce the error inside OMEdit. In message I have this error too

[1] 10:26:15 Traduction Erreur
[C:/OM116/OM32bit/OMCompiler/Compiler/NFFrontEnd/NFEvalFunction.mo: 182:7-184:92]: Internal error NFEvalFunction.evaluateExternal failed on ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical.completeState1.Medium.getMolarMass, evaluation of userdefined external functions not yet implemented

[2] 10:26:15 Traduction Erreur
[C:/OM116/OM32bit/OMCompiler/Compiler/NFFrontEnd/NFEvalFunction.mo: 182:7-184:92]: Internal error NFEvalFunction.evaluateExternal failed on ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical.completeState2.Medium.getMolarMass, evaluation of userdefined external functions not yet implemented

[3] 10:26:15 Traduction Avertissement
[ExternalMedia.Common.CheckCoolPropOptions: 2:1-104:25]: Pure function ‘ExternalMedia.Common.CheckCoolPropOptions‘ contains a call to impure function ‘Modelica.Utilities.Streams.print‘.

I feel that library is not loaded. **Version Connected to OpenModelica v1.16.0 (32-bit) Connected to OMSimulator v2.1.0-dev-230-g10c82c8-mingw

Installation path C:/Users/xxxxxx/Documents/Developpements/Programs/OpenModelica-1.16.0-32bit

Copyright Open Source Modelica Consortium (OSMC). Distributed under OSMC-PL and GPL, see www.openmodelica.org.**

sgolle commented 3 years ago

After I compiled the development branch v.3.3.0-dev only with CoolProp on Linux, which was successful, I tried to test it in OpenModelica, but a couple of errors occured:

make -j8 -f ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical.makefile
clang  -Os -fPIC -falign-functions -mfpmath=sse -fno-dollars-in-identifiers     "-I/home/xxx/.openmodelica/libraries/ExternalMedia 3.2.1/Resources/Include" -I"/home/xxx/Programme/OpenModelica/build/bin/../include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical.c
clang  -Os -fPIC -falign-functions -mfpmath=sse -fno-dollars-in-identifiers     "-I/home/xxx/.openmodelica/libraries/ExternalMedia 3.2.1/Resources/Include" -I"/home/xxx/Programme/OpenModelica/build/bin/../include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c
clang  -Os -fPIC -falign-functions -mfpmath=sse -fno-dollars-in-identifiers     "-I/home/xxx/.openmodelica/libraries/ExternalMedia 3.2.1/Resources/Include" -I"/home/xxx/Programme/OpenModelica/build/bin/../include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_records.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_records.c
clang  -Os -fPIC -falign-functions -mfpmath=sse -fno-dollars-in-identifiers     "-I/home/xxx/.openmodelica/libraries/ExternalMedia 3.2.1/Resources/Include" -I"/home/xxx/Programme/OpenModelica/build/bin/../include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_01exo.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_01exo.c
clang  -Os -fPIC -falign-functions -mfpmath=sse -fno-dollars-in-identifiers     "-I/home/xxx/.openmodelica/libraries/ExternalMedia 3.2.1/Resources/Include" -I"/home/xxx/Programme/OpenModelica/build/bin/../include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_02nls.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_02nls.c
clang  -Os -fPIC -falign-functions -mfpmath=sse -fno-dollars-in-identifiers     "-I/home/xxx/.openmodelica/libraries/ExternalMedia 3.2.1/Resources/Include" -I"/home/xxx/Programme/OpenModelica/build/bin/../include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_03lsy.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_03lsy.c
clang  -Os -fPIC -falign-functions -mfpmath=sse -fno-dollars-in-identifiers     "-I/home/xxx/.openmodelica/libraries/ExternalMedia 3.2.1/Resources/Include" -I"/home/xxx/Programme/OpenModelica/build/bin/../include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_04set.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_04set.c
clang  -Os -fPIC -falign-functions -mfpmath=sse -fno-dollars-in-identifiers     "-I/home/xxx/.openmodelica/libraries/ExternalMedia 3.2.1/Resources/Include" -I"/home/xxx/Programme/OpenModelica/build/bin/../include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_05evt.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_05evt.c
clang  -Os -fPIC -falign-functions -mfpmath=sse -fno-dollars-in-identifiers     "-I/home/xxx/.openmodelica/libraries/ExternalMedia 3.2.1/Resources/Include" -I"/home/xxx/Programme/OpenModelica/build/bin/../include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_06inz.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_06inz.c
clang  -Os -fPIC -falign-functions -mfpmath=sse -fno-dollars-in-identifiers     "-I/home/xxx/.openmodelica/libraries/ExternalMedia 3.2.1/Resources/Include" -I"/home/xxx/Programme/OpenModelica/build/bin/../include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_07dly.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_07dly.c
clang  -Os -fPIC -falign-functions -mfpmath=sse -fno-dollars-in-identifiers     "-I/home/xxx/.openmodelica/libraries/ExternalMedia 3.2.1/Resources/Include" -I"/home/xxx/Programme/OpenModelica/build/bin/../include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_08bnd.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_08bnd.c
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:49:53: warning: incompatible pointer types passing 'ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_Medium_ThermodynamicState *' to parameter of type 'ExternalThermodynamicState *' [-Wincompatible-pointer-types]
  TwoPhaseMedium_setState_pT_C_impl(_p_ext, _T_ext, &_state_ext, MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp1)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp2)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp3)));
                                                    ^~~~~~~~~~~
/home/xxx/.openmodelica/libraries/ExternalMedia 3.2.1/Resources/Include/externalmedialib.h:144:96: note: passing argument to parameter 'state' here
        EXPORT void TwoPhaseMedium_setState_pT_C_impl(double p, double T, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
                                                                                                      ^
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:100:65: warning: incompatible pointer types passing 'ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_Medium_ThermodynamicState *' to parameter of type 'ExternalThermodynamicState *' [-Wincompatible-pointer-types]
  TwoPhaseMedium_setState_ph_C_impl(_p_ext, _h_ext, _phase_ext, &_state_ext, MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp1)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp2)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp3)));
                                                                ^~~~~~~~~~~
/home/xxx/.openmodelica/libraries/ExternalMedia 3.2.1/Resources/Include/externalmedialib.h:143:107: note: passing argument to parameter 'state' here
        EXPORT void TwoPhaseMedium_setState_ph_C_impl(double p, double h, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
                                                                                                                 ^
clang  -Os -fPIC -falign-functions -mfpmath=sse -fno-dollars-in-identifiers     "-I/home/xxx/.openmodelica/libraries/ExternalMedia 3.2.1/Resources/Include" -I"/home/xxx/Programme/OpenModelica/build/bin/../include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_09alg.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_09alg.c
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:167:9: warning: implicit declaration of function 'ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_completeState1_Medium_FluidConstants_array_get' is invalid in C99 [-Wimplicit-function-declaration]
  _MM = ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_completeState1_Medium_FluidConstants_array_get(_completeState1._Medium._fluidConstants, 1, ((modelica_integer) 1))._molarMass;
        ^
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:167:112: error: use of undeclared identifier '_completeState1'
  _MM = ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_completeState1_Medium_FluidConstants_array_get(_completeState1._Medium._fluidConstants, 1, ((modelica_integer) 1))._molarMass;
                                                                                                               ^
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:274:9: warning: implicit declaration of function 'ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_completeState2_Medium_FluidConstants_array_get' is invalid in C99 [-Wimplicit-function-declaration]
  _MM = ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_completeState2_Medium_FluidConstants_array_get(_completeState2._Medium._fluidConstants, 1, ((modelica_integer) 1))._molarMass;
        ^
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:274:112: error: use of undeclared identifier '_completeState2'
  _MM = ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_completeState2_Medium_FluidConstants_array_get(_completeState2._Medium._fluidConstants, 1, ((modelica_integer) 1))._molarMass;
                                                                                                               ^
4 warnings and 2 errors generated.
make: *** [<builtin>: ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.o] Error 1
make: *** Waiting for unfinished jobs....
Compilation process failed. Exited with code 2.
jowr commented 3 years ago

This one still remains to be fixed, but we had a web meeting yesterday and agreed to prioritize OpenModelica compatibility. By the way, the test fluids seem to work which indicates that we are not too far from a working solution. Once #26 is merged, you can check the docs and see whether they need improvement with respect to OpenModelica.

dongkeun-oh commented 3 years ago

Hi, I recently joined in this interest, and I saw that the latest OpenModelica now works escaping from the long trouble with the fluidConstant array, which was the reason of compilation errors as @sgolle showed previously. As I mentioned https://trac.openmodelica.org/OpenModelica/ticket/6331, the critical spot was "initializing constants by means of external functions"; now, DLL call is employed to implement such a process seamlessly; see https://trac.openmodelica.org/OpenModelica/ticket/5240.

Then, I checked that all CoolProp tests in ExternalMedia.Test.CoolProp.CO2 are working based on an old version (4.2.6). So, now, I'm doing my best with the newest CoolProp (6.4.1), but a couple of issues are emerged, mainly, in runtime, in spite of the success of compilation in the both passes of making the library (libExternalMedia) and doing the simulations for test.

I just list up the remaining issues as the following;

  1. Some tests are hang, during the calculation of thermodynamic state; TestBasepropertiesImplicit is a typical one.

    • Calculations to update the thermodynamic states can be placed out of range, owing to the radical trials in the solving process of the simulation.
    • So, in case of such a "out of range", there should be a proper exception handling, not exiting the process. That means -DMODELICA_ERROR=0 can be the spot of trouble in such a case, and setting that variable as 1 seems to solve the symptom almost completely.
      • Even though the exception of 'ValueError' are handled, the other variables of state are recommended to be updated in consequence of (even) wrong result. So, I would suggest to do some minor modifications of the functions in coolpropsolver.cpp.
  2. REFPROP backend doesn't work.

    • According to the error message in the frontend (NF), some AbstractState functions like calc_first_saturation_deriv are missing. However, some guys like me look able to implement the missing parts, comparing with the old version (4.2.6), and I would try sooner or later.
  3. DLL (or shard object) is to be installed.

    • As I mentioned, it's owing to the NF calling DLL to initialize the constant (fluidConstant). I manually generate it, and copy it, which is a kind of brute-force manner. So, I ask to modify the building script to generate and to install the DLL in proper manner of naming and locating, with which I'm not familiar at all.

As a result, I managed to make it work, in spite of some brute-force modification, and I'm going to arrange my modification to show you as something applicable.

Your paying attention to what I did will be appreciated

casella commented 3 years ago

@jowr, the title of this issue is probably obsolete by now. Let's see how the version on the v.3.3.0 branch works now, and if we can get it to run in OpenModelica with help from dongkeun-oh, then we can merge it on master and release it for good.

jowr commented 3 years ago

Agreed - I can have a look at all these issues when I am back from Easter vacation...