-
Notifications
You must be signed in to change notification settings - Fork 39
Description
Hi there,
I have created a Hydrogen model using ExternalMedia.Media.CoolPropMedium and I am using it as the medium in several components in my model.
I got the following error when I tried to simulate my model:
[1] 13:19:48 Translation Error
[ExternalMedia.Media.BaseClasses.ExternalTwoPhaseMedium: 235:25-257:18]: External function ‘TwoPhaseMedium_setState_pT_C_impl_wrap‘ could not be found in any of the given shared libraries:
C:/Programs/bin/ExternalMediaLib.dll
C:/Users/AliAbedi/AppData/Roaming/.openmodelica/libraries/ExternalMedia 4.0.0/Resources/Library/mingw64/ExternalMediaLib.dll
C:\Users\AliAbedi\AppData\Roaming\.openmodelica\libraries\ExternalMedia 4.0.0\Resources\Library\win64\ExternalMediaLib.dll
C:/Users/AliAbedi/AppData/Roaming/.openmodelica/libraries/ExternalMedia 4.0.0/Resources/Library/ExternalMediaLib.dll
C:/Programs/bin/libExternalMediaLib.dll
C:/Users/AliAbedi/AppData/Roaming/.openmodelica/libraries/ExternalMedia 4.0.0/Resources/Library/mingw64/libExternalMediaLib.dll
C:/Users/AliAbedi/AppData/Roaming/.openmodelica/libraries/ExternalMedia 4.0.0/Resources/Library/win64/libExternalMediaLib.dll
C:/Users/AliAbedi/AppData/Roaming/.openmodelica/libraries/ExternalMedia 4.0.0/Resources/Library/libExternalMediaLib.dll
C:/Programs/bin/ffi/ExternalMediaLib.dll
C:/Programs/bin/ffi/libExternalMediaLib.dll
[2] 13:19:48 Translation Error
[ExternalMedia.Media.BaseClasses.ExternalTwoPhaseMedium: 365:5-365:37]: [Failed to evaluate function: HRS_tst.volumeFlowRate.Medium.setState_pT.](omeditmessagesbrowser:///ExternalMedia.Media.BaseClasses.ExternalTwoPhaseMedium?lineNumber=365)
As the error message indicates, the external function ExternalMedia.Media.CoolPropMedium could not be found in any of the dynamic libraries provided with ExternalMedia. I have validated this claim by manually looking for such function in the .dll files above. No such function exists while TwoPhaseMedium_setState_pT_C_impl and TwoPhaseMedium_setState_pT_C_impl_err do exist.
I managed to temporarily solve the problem by changing the external function's name from TwoPhaseMedium_setState_pT_C_impl_wrap to TwoPhaseMedium_setState_pT_C_impl at line 243 of ExternalMedia.Media.BaseClasses.ExternalTwoPhaseMedium base class inside setState_pT function:
function setState_pT
"Return thermodynamic state record from p and T"
extends Modelica.Icons.Function;
input AbsolutePressure p "pressure";
input Temperature T "temperature";
input FixedPhase phase = 0
"2 for two-phase, 1 for one-phase, 0 if not known";
output ThermodynamicState state;
external "C" TwoPhaseMedium_setState_pT_C_impl(p, T, state, mediumName, libraryName, substanceName)
annotation(Library="ExternalMediaLib", IncludeDirectory="modelica://ExternalMedia/Resources/Include", LibraryDirectory="modelica://ExternalMedia/Resources/Library",
Include="
#ifndef SETSTATE_PT_DEFINED
#define SETSTATE_PT_DEFINED
#include \"externalmedialib.h\"
#include \"ModelicaUtilities.h\"
void TwoPhaseMedium_setState_pT_C_impl_wrap(double p, double T, void *state, const char *mediumName, const char *libraryName, const char *substanceName)
{
TwoPhaseMedium_setState_pT_C_impl_err(p, T, state, mediumName, libraryName, substanceName, ModelicaError, ModelicaWarning);
}
#endif // SETSTATE_PT_DEFINED
");
end setState_pT;It is strange that this error only occurs when Modelica.Fluid.Fittings.GenericResistances.VolumeFlowRate component is present in the model. So, I suspect that some part of the problem may be related to this component.