Open bmazurie opened 3 months ago
I believe you maybe failed to recompile Coolprop? So after adding a custom fluid and modifying the json, you need to first recompile Coolprop (I used the python wrapper -> run setup.py file in the \wrappers\Python folder.) Then you need to recompile ExternalMedia, and tell it to use your modified, recompiled Coolprop.
(just like a high-level pointer, hope that helps)
Thank you for your answer.
Indeed CoolProp was the problem. In fact, when dev/incompressible_liquids/all_incompressibles.py
is ran to regenrate the JSON files with the fitted parameters, the json goes into ExternalMedia/build/CoolProp.sources/json
. But it should be in ExternalMedia/build/CoolProp.sources/dev/incompressible_liquids/json
(in my case) in order to be taken into account for the recompilation of CoolProp.
I had another issue regarding the definition of my medium in Modelica, I forget to add INCOMP::
in substanceNames = {"INCOMP::KOH"},
. Now it does find the medium when using ExternalMedia.
However I would like to point an issue that I have with ExternalMedia and a possible bug.
I start from the same example as before, I defined a medium with CoolProp where I defined data regarding density, cp, mu, k and saturation pressure at different temperature. In Modelica, I use:
package KOHCoolProp "CoolProp model of KOH"
extends ExternalMedia.Media.CoolPropMedium(
mediumName = "KOH",
substanceNames = {"INCOMP::KOH"},
ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph,
SpecificEnthalpy(start=2e5));
end KOHCoolProp;
And I use it in a model to find again those data:
replaceable package Medium_CoolProp_KOH =
Test_ExternalMedia_ThermoSysPro.Media.KOHCoolProp;
parameter Modelica.Units.SI.Temperature T=273.15+20;
parameter Modelica.Units.SI.Pressure P_atm=101325;
equation
h_KOH=Medium_CoolProp_KOH.specificEnthalpy_pT(P_atm,T);
d_KOH=Medium_CoolProp_KOH.density_ph(P_atm,h_KOH);
cp_KOH=Medium_CoolProp_KOH.specificHeatCapacityCp(Medium_CoolProp_KOH.setState_ph(p=P_atm, h=h_KOH, phase=0));
mu_KOH=Medium_CoolProp_KOH.dynamicViscosity(Medium_CoolProp_KOH.setState_ph(p=P_atm, h=h_KOH, phase=0));
k_KOH=Medium_CoolProp_KOH.thermalConductivity(Medium_CoolProp_KOH.setState_ph(p=P_atm, h=h_KOH, phase=0));
P_sat_KOH=Medium_CoolProp_KOH.saturationPressure(T);
It works fine, EXCEPT for the saturation pressure which gives what seems to be a default value:
As CoolProp has the Python wrapper, I used it to test my media:
PropsSI('D','T',293.15,'P',101325,'INCOMP::KOH'): 1293.591986384524
PropsSI('C','T',293.15,'P',101325,'INCOMP::KOH'): 2972.5632292009855
PropsSI('VISCOSITY','T',293.15,'P',101325,'INCOMP::KOH'): 0.0024487626442337763
PropsSI('CONDUCTIVITY','T',293.15,'P',101325,'INCOMP::KOH'): 0.5813769155106154
PropsSI('P','T',293.15,'Q',0,'INCOMP::KOH'): 1381.3038209276774
It can be seen that saturation pressure is well defined with Python (and it is the value I used in the data for the definition of the medium in CoolProp). Thus it seems to be a bug with ExternalMedia.
Any idea? Thank you in advance
According to CoolProp documentation, it is possible to add new fluids to CoolProp library. To do so, it should be
SolutionFLuids.py
to add tables for your new fluiddev/incompressible_liquids/all_incompressibles.py
to regenrate the JSON files with the fitted parametersI've added my data to
SolutionFLuids.py
, regenerate the JSON files (I can find the new JSON file KOH.json inExternalMedia/build/CoolProp.sources/json/
folder). To recompile, I usedcmake --build build --config Release --target install
mentioned in ExternalMedia documenation(which worked flawlessly for the first installation).However, when I define my medium in Modelica with:
and run a simple model such as (I defined my saturation pressure in the CoolProp's data):
It runs into translation errors both with OpenModelica 1.23.1 and Dymola23x. (Linux Scibian11 on both): OpenModelica errors: Dymola errors:
Thank you very much Baptiste