coolprop
coolprop copied to clipboard
Return values for undefined functions in Modelica wrapper
The solver classes in the ExternalMedia package contain function definitions that need to be overwritten by the actual solver implementation. Even though these functions might not be implement, they still return a value (often 0). This behaviour is confusing since the error message does not make it to the Modelica layer and a return value of zero is not very suspicious. An example can be found in basesolver.cpp in line 384. BaseSolver::isentropicEnthalpy is not implemented in coolpropsolver.cpp and returns 0.
What should we do about it? I recommend having an error message travelling all the way up to Modelica...
I think this is fixed now. Could one of you Windows-users please verify that things work as expected? I added a test to the Modelica package in CoolProp2Modelica,Test.TestMedium.TestIsentropicExpansion.
Please close the issue if it is resolved.
I don't know how to test this - Ill ask Sylvain or Adriano later on this week.
@squoilin can you please check this?
It does not seem to work in Windows. The function Medium.isentropicEnthalpy(p_out,state_in) crashes the console.
Hm, I cannot get it to work properly. We have two options:
- Abort model execution with an error message on Linux and without error message on Windows
- Return a value that is obviously wrong (-_HUGE) on both platforms. I think both options are better than the standard external media behaviour (return 0). Does anyone have strong feelings about this? I suggest to go for option 2 and put a note in the docs.
Well, I guess the best way would be to remove the functions from ExternalTwoPhaseMedium and add them to the FluidPropMedium interface. This allows us to avoid calls on the Modelica level. This could be improved a lot by properly designing the Modelica part. At the moment, it is very obvious that the Modelica standard interface was made with ExternalMedia in mind, which in turn focusses on FluidProp as property library... We should move this discussion to the ExternalMedia package.
I remove this from the 4.0 milestone since it should be solved elsewhere.
Added a message in https://github.com/thermocycle/CoolProp2Modelica-library/commit/6cf800ef42e2e405f9dc9b111173e3fd77981312