The docs could be more explicit on how to specify fluids in case of CoolProp internal mixtures
The fluid calls for Coolprop's fluid "APG" work only for tespy or for PropsSI.
using coolprop 7.1.0 and Tespy 0.9.7.post1
from CoolProp.CoolProp import PropsSI
from tespy.components import Sink, Source, HeatExchanger
from tespy.connections import Connection
from tespy.networks import Network
general setup
nw = Network(iterinfo=False)
nw.units.set_defaults(**{"pressure": "bar", "temperature": "degC", "enthalpy": "kJ/kg",
"volumetric_flow": "l/s", "mass_flow": "kg/s", "heat_transfer_coefficient": "W/K", "heat":"kW"})
hot_source = Source("hot_source")
hot_sink = Sink("hot_sink")
cold_source = Source("cold_source")
cold_sink = Sink("cold_sink")
he = HeatExchanger("heat exchanger")
c1 = Connection(hot_source, 'out1', he, 'in1')
c2 = Connection(he, 'out1', hot_sink, 'in1')
c3 = Connection(cold_source, 'out1', he, 'in2')
c4 = Connection(he, 'out2', cold_sink, 'in1')
nw.add_conns(c1, c2, c3, c4)
c1.set_attr(fluid={"Water": 1}, T=40, p=1, m=0.3)
c2.set_attr(T=30)
c3.set_attr(T=-10, p=1)
c4.set_attr(T=-5)
he.set_attr(dp1=0, dp2=0)
reproducing issue
works in coolprop only
h = PropsSI("H", "P",1*10**5,"T",-10+273.15,'INCOMP::APG-38%')
print(h)
#c3.set_attr(fluid={'INCOMP::APG-38%':1})
#nw.solve("design")
works in coolprop only
h = PropsSI("H", "P",1*10**5,"T",-10+273.15,'INCOMP::APG[0.38]')
print(h)
#c3.set_attr(fluid={'INCOMP::APG[0.38]':1})
#nw.solve("design")
works in Tespy only
#h = PropsSI("H", "P",1*10**5,"T",-10+273.15,{'INCOMP::APG[0.38]|volume':1})
#print(h)
c3.set_attr(fluid={'INCOMP::APG[0.38]|volume':1})
nw.solve("design")
Hi @25Nik,
this behavior is aktuall intended. The reason is, that tespy does not use the high-level interface of CoolProp (PropsSI) in the back-end but the low-level interface (AbstractState). That requires to specify the mass, molar or volumetric ratio of the binary mixture. With the |volume you tell the tespy fluid to use volumetric fraction. PropsSI does interpret that automatically, I did refrain from it because for other mixutres (REFPROP) you might leave the mixture specification to the user.
- high-level:
PropsSI(...), - low-level:
state = AbstractState(...), state.set_mass_fractions(...)
Best
Francesco
But I guess, the docs could be more explicit in this context, i.e. that you have to do it differently from the high-level API of CoolProp.
Hi @fwitte ,
I am using a script which calls multiple other scripts and passes the used media. As some scripts include PropsSI for data conversion and others contain tespy models, I am looking for a uniform method to set the media at one place. However, there is the following workaround if there is only one entry in the dictionary (at least for APG) in the main script which calls all others when the tespy form is set at first:
set tespy form
medium = {'INCOMP::APG[0.38]|volume':1}
get form needed for coolprop PropsSI input in additional variable
if type(medium) == dict: keys = list(medium.keys()) # get keys (=name of medium) if "|" in source_keys[0]: medium_source_coolprop = source_keys[0].split(sep="|")[0] # get only part left of '|' in key (=coolprop form) else: medium_source_coolprop = source_keys[0] # key already in matching form
From there on, both variables are passed and used in the needed inputs.
Any way to include something similar in tespy itself would be very helpful for my workflow. Maybe this is not an issue but rather an idea for future additions.
Best Nikolas